forked from Kaaveh/ComposeNews
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
100 changed files
with
1,893 additions
and
832 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
plugins { | ||
id("composenews.android.application") | ||
id("composenews.android.application.compose") | ||
id("composenews.android.hilt") | ||
} | ||
|
||
android { | ||
namespace = libs.versions.projectApplicationId.get() | ||
defaultConfig { | ||
applicationId = libs.versions.projectApplicationId.get() | ||
versionCode = libs.versions.projectVersionCode.get().toInt() | ||
versionName = libs.versions.projectVersionName.get() | ||
minSdk = libs.versions.projectMinSdkVersionWear.get().toInt() | ||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
vectorDrawables { | ||
useSupportLibrary = true | ||
} | ||
} | ||
buildTypes { | ||
getByName("debug") { | ||
isMinifyEnabled = false | ||
isShrinkResources = false | ||
applicationIdSuffix = ".debug" | ||
versionNameSuffix = "-debug" | ||
} | ||
getByName("release") { | ||
isMinifyEnabled = true | ||
isShrinkResources = true | ||
proguardFiles( | ||
getDefaultProguardFile("proguard-android-optimize.txt"), | ||
"proguard-rules.pro", | ||
) | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
projects.apply { | ||
implementation(appWatch.navigation) | ||
implementation(library.designsystem) | ||
implementation(core.base) | ||
implementation(core.uimarket) | ||
} | ||
libs.apply { | ||
implementation(androidx.ktx) | ||
implementation(hilt.work) | ||
implementation(lifecycle.runtime.ktx) | ||
implementation(hilt.navigation.compose) | ||
implementation(work.runtime.ktx) | ||
implementation(compose.activity) | ||
implementation(compose.ui.preview.wear) | ||
implementation(compose.foundation.wear) | ||
implementation(compose.horologist.layout) | ||
androidTestImplementation(platform(compose.bom)) | ||
androidTestImplementation(compose.ui.test.junit4) | ||
debugImplementation(compose.ui.tooling) | ||
debugImplementation(compose.ui.test.manifest) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<lint> | ||
<!-- Ignore the IconLocation for the Tile preview images --> | ||
<issue id="IconLocation"> | ||
<ignore path="res/drawable/tile_preview.png" /> | ||
<ignore path="res/drawable-round/tile_preview.png" /> | ||
</issue> | ||
</lint> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile | ||
-dontwarn reactor.blockhound.integration.BlockHoundIntegration |
31 changes: 31 additions & 0 deletions
31
app-watch/app/src/androidTest/java/ir/composenews/ui/MainActivityTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package ir.composenews.ui | ||
|
||
import androidx.compose.ui.test.junit4.createAndroidComposeRule | ||
import androidx.compose.ui.test.onAllNodesWithText | ||
import androidx.compose.ui.test.onNodeWithContentDescription | ||
import androidx.compose.ui.test.onNodeWithText | ||
import androidx.compose.ui.test.onParent | ||
import androidx.compose.ui.test.performClick | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
class MainActivityTest { | ||
|
||
@get:Rule | ||
val composeTestRule = createAndroidComposeRule<MainActivity>() | ||
|
||
@Test | ||
fun marketListScreen_DisplayedCorrectly() { | ||
|
||
composeTestRule.waitUntil(timeoutMillis = 5_000) { | ||
composeTestRule.onAllNodesWithText("BNB").fetchSemanticsNodes().isNotEmpty() || | ||
composeTestRule.onAllNodesWithText("BTC").fetchSemanticsNodes().isNotEmpty() | ||
} | ||
|
||
composeTestRule.onNodeWithText("BNB").assertExists() | ||
composeTestRule.onNodeWithText("Bitcoin").assertExists().onParent().performClick() | ||
composeTestRule.onNodeWithContentDescription("Loading. PLease wait").assertExists() | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<uses-permission android:name="android.permission.WAKE_LOCK" /> | ||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> | ||
|
||
<uses-feature android:name="android.hardware.type.watch" /> | ||
|
||
<application | ||
android:name=".ComposeNewsWearApplication" | ||
android:allowBackup="true" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
android:theme="@android:style/Theme.DeviceDefault"> | ||
<uses-library | ||
android:name="com.google.android.wearable" | ||
android:required="true" /> | ||
|
||
<!-- | ||
Set to true if your app is Standalone, that is, it does not require the handheld | ||
app to run. | ||
--> | ||
<meta-data | ||
android:name="com.google.android.wearable.standalone" | ||
android:value="true" /> | ||
|
||
|
||
<activity | ||
android:name=".ui.MainActivity" | ||
android:exported="true" | ||
android:taskAffinity=""> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
</application> | ||
|
||
</manifest> |
7 changes: 7 additions & 0 deletions
7
app-watch/app/src/main/java/ir/composenews/ComposeNewsWearApplication.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package ir.composenews | ||
|
||
import android.app.Application | ||
import dagger.hilt.android.HiltAndroidApp | ||
|
||
@HiltAndroidApp | ||
class ComposeNewsWearApplication : Application() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
app-watch/app/src/main/java/ir/composenews/navigation/ComposeNewsWearNavHost.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package ir.composenews.navigation | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.navigation.NavHostController | ||
import androidx.wear.compose.navigation.SwipeDismissableNavHost | ||
import ir.composenews.appwatch.navigation.MainContract | ||
import ir.composenews.appwatch.navigation.graph.Destinations | ||
import ir.composenews.appwatch.navigation.graph.wearMarketDetail | ||
import ir.composenews.appwatch.navigation.graph.wearMarketList | ||
import ir.composenews.uimarket.model.MarketModel | ||
|
||
@Composable | ||
fun ComposeNewsWearNavHost( | ||
navController: NavHostController, | ||
modifier: Modifier, | ||
onMarketSelected: ((MarketModel) -> Unit)? = null, | ||
uiState: MainContract.State | ||
) { | ||
SwipeDismissableNavHost( | ||
navController = navController, | ||
startDestination = Destinations.MarketListScreen.route, | ||
modifier = modifier, | ||
) { | ||
wearMarketList( | ||
showFavorite = false, | ||
onMarketSelected = onMarketSelected, | ||
) | ||
wearMarketDetail(uiState) | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
app-watch/app/src/main/java/ir/composenews/ui/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package ir.composenews.ui | ||
|
||
import android.os.Bundle | ||
import androidx.activity.ComponentActivity | ||
import androidx.activity.compose.setContent | ||
import androidx.activity.viewModels | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.collectAsState | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.wear.compose.material.TimeText | ||
import androidx.wear.compose.navigation.rememberSwipeDismissableNavController | ||
import androidx.wear.tooling.preview.devices.WearDevices | ||
import com.google.android.horologist.compose.layout.AppScaffold | ||
import com.google.android.horologist.compose.layout.ScreenScaffold | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import ir.composenews.MainViewModel | ||
import ir.composenews.appwatch.navigation.graph.Destinations | ||
import ir.composenews.appwatch.navigation.MainContract | ||
import ir.composenews.designsystem.theme.ComposeNewsTheme | ||
import ir.composenews.navigation.ComposeNewsWearNavHost | ||
|
||
@AndroidEntryPoint | ||
class MainActivity : ComponentActivity() { | ||
|
||
private val mainViewModel: MainViewModel by viewModels() | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContent { | ||
WearApp() | ||
} | ||
} | ||
|
||
@Composable | ||
fun WearApp() { | ||
val navController = rememberSwipeDismissableNavController() | ||
val state = mainViewModel.state.collectAsState() | ||
ComposeNewsTheme { | ||
AppScaffold { | ||
ScreenScaffold(timeText = { TimeText() }) { | ||
ComposeNewsWearNavHost( | ||
navController = navController, | ||
onMarketSelected = { | ||
mainViewModel.event(MainContract.Event.SetMarket(it)) | ||
navController.navigate(Destinations.MarketDetailScreen().route) | ||
}, | ||
uiState = state.value, | ||
modifier = Modifier | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Preview(device = WearDevices.LARGE_ROUND, showSystemUi = true) | ||
@Composable | ||
fun DefaultPreview() { | ||
WearApp() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<resources> | ||
<string name="app_name">Compose News</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
Oops, something went wrong.