-
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
18 changed files
with
364 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Android Build | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
timeout-minutes: 60 | ||
|
||
steps: | ||
|
||
- name: Checkout branch | ||
uses: actions/checkout@v2 | ||
|
||
- name: set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
cache: gradle | ||
|
||
- name: set up LOCAL_PROPERTIES | ||
env: | ||
LOCAL_PROPERTIES: ${{ secrets.LOCAL_PROPERTIES }} | ||
run: echo "$LOCAL_PROPERTIES" > ./local.properties | ||
|
||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
- name: Build with Gradle | ||
run: ./gradlew build | ||
|
||
- name: Junit tests with Gradle | ||
run: ./gradlew testDebugUnitTest |
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
46 changes: 0 additions & 46 deletions
46
app/src/main/java/com/stslex/aproselection/MainActivity.kt
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
app/src/main/java/com/stslex/aproselection/SelectApplication.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,17 @@ | ||
package com.stslex.aproselection | ||
|
||
import android.app.Application | ||
import com.stslex.aproselection.feature.auth.di.FeatureAuthModule.featureAuthModule | ||
import org.koin.android.ext.koin.androidContext | ||
import org.koin.core.context.startKoin | ||
|
||
class SelectApplication : Application() { | ||
|
||
override fun onCreate() { | ||
super.onCreate() | ||
startKoin { | ||
androidContext(applicationContext) | ||
modules(featureAuthModule) | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
app/src/main/java/com/stslex/aproselection/navigation/NavigationHost.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,43 @@ | ||
package com.stslex.aproselection.navigation | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.navigation.NavHostController | ||
import androidx.navigation.compose.NavHost | ||
import com.stslex.aproselection.core.network.AppDestination | ||
import com.stslex.aproselection.core.network.NavigationScreen | ||
import com.stslex.aproselection.feature.auth.ui.navigation.authRouter | ||
|
||
@Composable | ||
fun NavigationHost( | ||
navController: NavHostController, | ||
modifier: Modifier = Modifier, | ||
startDestination: AppDestination = AppDestination.AUTH | ||
) { | ||
val navigator: (NavigationScreen) -> Unit = { screen -> | ||
when (screen) { | ||
is NavigationScreen.PopBackStack -> navController.popBackStack() | ||
else -> navController.navigateScreen(screen) | ||
} | ||
} | ||
NavHost( | ||
navController = navController, | ||
startDestination = startDestination.route | ||
) { | ||
authRouter(modifier, navigator) | ||
} | ||
} | ||
|
||
fun NavHostController.navigateScreen(screen: NavigationScreen) { | ||
navigate(screen.screenRoute) { | ||
if (screen.isSingleTop.not()) return@navigate | ||
graph.startDestinationRoute?.let { route -> | ||
popUpTo(route) { | ||
inclusive = true | ||
saveState = true | ||
} | ||
} | ||
launchSingleTop = true | ||
restoreState = false | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
app/src/main/java/com/stslex/aproselection/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,23 @@ | ||
package com.stslex.aproselection.ui | ||
|
||
import android.os.Bundle | ||
import androidx.activity.ComponentActivity | ||
import androidx.activity.compose.setContent | ||
import androidx.core.view.WindowCompat | ||
import com.stslex.aproselection.ui.components.InitialApp | ||
import com.stslex.aproselection.ui.theme.AppTheme | ||
|
||
class MainActivity : ComponentActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
WindowCompat.setDecorFitsSystemWindows(window, false) | ||
|
||
setContent { | ||
AppTheme { | ||
InitialApp() | ||
} | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
app/src/main/java/com/stslex/aproselection/ui/components/InitialApp.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,36 @@ | ||
package com.stslex.aproselection.ui.components | ||
|
||
import androidx.compose.foundation.isSystemInDarkTheme | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.DisposableEffect | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.navigation.compose.rememberNavController | ||
import com.google.accompanist.systemuicontroller.rememberSystemUiController | ||
import com.stslex.aproselection.navigation.NavigationHost | ||
import com.stslex.aproselection.ui.theme.AppTheme | ||
|
||
@Composable | ||
fun InitialApp() { | ||
val navController = rememberNavController() | ||
val systemUiController = rememberSystemUiController() | ||
val isDarkTheme = isSystemInDarkTheme() | ||
|
||
DisposableEffect(systemUiController, isDarkTheme) { | ||
systemUiController.setSystemBarsColor( | ||
color = Color.Transparent, | ||
darkIcons = isDarkTheme.not(), | ||
) | ||
onDispose {} | ||
} | ||
|
||
NavigationHost(navController = navController) | ||
} | ||
|
||
@Preview(showBackground = true) | ||
@Composable | ||
fun InitialAppPreview() { | ||
AppTheme { | ||
InitialApp() | ||
} | ||
} |
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
16 changes: 16 additions & 0 deletions
16
core/network/src/main/java/com/stslex/aproselection/core/network/AppArguments.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,16 @@ | ||
package com.stslex.aproselection.core.network | ||
|
||
sealed class AppArguments { | ||
|
||
abstract val arguments: List<String> | ||
|
||
open val argumentsForRoute: String | ||
get() = arguments.joinToString(separator = "/", prefix = "/") | ||
|
||
object Empty : AppArguments() { | ||
override val arguments: List<String> | ||
get() = emptyList() | ||
override val argumentsForRoute: String | ||
get() = String() | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
core/network/src/main/java/com/stslex/aproselection/core/network/AppDestination.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,28 @@ | ||
package com.stslex.aproselection.core.network | ||
|
||
enum class AppDestination( | ||
vararg val argsNames: String | ||
) { | ||
AUTH; | ||
|
||
val route: String | ||
get() = StringBuilder() | ||
.append(name, SEPARATOR_ROUTE, TAG_ROUTE) | ||
.toString() | ||
.lowercase() | ||
|
||
val navigationRoute: String | ||
get() = "$route${argsNames.argumentsRoute}" | ||
|
||
private val Array<out String>.argumentsRoute: String | ||
get() = if (isEmpty()) { | ||
String() | ||
} else { | ||
joinToString(separator = "}/{", prefix = "/{", postfix = "}") | ||
} | ||
|
||
companion object { | ||
private const val SEPARATOR_ROUTE = "_" | ||
private const val TAG_ROUTE = "route" | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
core/network/src/main/java/com/stslex/aproselection/core/network/NavExt.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,21 @@ | ||
package com.stslex.aproselection.core.network | ||
|
||
import androidx.navigation.NamedNavArgument | ||
import androidx.navigation.NavBackStackEntry | ||
import androidx.navigation.NavType | ||
import androidx.navigation.navArgument | ||
|
||
object NavExt { | ||
|
||
val AppDestination.composableArguments: List<NamedNavArgument> | ||
get() = argsNames.map { name -> | ||
navArgument(name) { NavType.StringType } | ||
} | ||
|
||
val AppDestination.parseArguments: NavBackStackEntry.() -> List<String> | ||
get() = { | ||
argsNames.map { name -> | ||
arguments?.getString(name).orEmpty() | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
core/network/src/main/java/com/stslex/aproselection/core/network/NavigationScreen.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,26 @@ | ||
package com.stslex.aproselection.core.network | ||
|
||
sealed class NavigationScreen { | ||
|
||
abstract val screen: AppDestination | ||
|
||
val screenRoute: String | ||
get() = "${screen.route}${appArgs.argumentsForRoute}" | ||
|
||
open val isSingleTop: Boolean | ||
get() = false | ||
|
||
open val appArgs: AppArguments | ||
get() = AppArguments.Empty | ||
|
||
object Auth : NavigationScreen() { | ||
|
||
override val screen: AppDestination = AppDestination.AUTH | ||
override val isSingleTop: Boolean = true | ||
} | ||
|
||
object PopBackStack : NavigationScreen() { | ||
override val screen: AppDestination = throw Exception("PopBackStack") | ||
override val appArgs: AppArguments = throw Exception("PopBackStack") | ||
} | ||
} |
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
12 changes: 12 additions & 0 deletions
12
feature/auth/src/main/java/com/stslex/aproselection/feature/auth/di/FeatureAuthModule.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,12 @@ | ||
package com.stslex.aproselection.feature.auth.di | ||
|
||
import com.stslex.aproselection.feature.auth.ui.AuthViewModel | ||
import org.koin.androidx.viewmodel.dsl.viewModelOf | ||
import org.koin.dsl.module | ||
|
||
object FeatureAuthModule { | ||
|
||
val featureAuthModule = module { | ||
viewModelOf(::AuthViewModel) | ||
} | ||
} |
Oops, something went wrong.