-
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
20 changed files
with
247 additions
and
287 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 |
---|---|---|
|
@@ -4,6 +4,12 @@ | |
|
||
### Changes | ||
|
||
# 1.0.2 | ||
|
||
### Changes | ||
|
||
- Updated AGP to 7.2.2 | ||
|
||
# 1.0.1 | ||
|
||
### Fixes | ||
|
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
13 changes: 12 additions & 1 deletion
13
demo/src/main/java/com/adamkobus/android/vm/demo/app/DemoApplication.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 |
---|---|---|
@@ -1,7 +1,18 @@ | ||
package com.adamkobus.android.vm.demo.app | ||
|
||
import android.app.Application | ||
import com.adamkobus.android.vm.demo.nav.ComposeNavigationConfigurator | ||
import dagger.hilt.android.HiltAndroidApp | ||
import javax.inject.Inject | ||
|
||
@HiltAndroidApp | ||
class DemoApplication : Application() | ||
class DemoApplication : Application() { | ||
|
||
@Inject | ||
lateinit var composeNavigationConfigStep: ComposeNavigationConfigurator | ||
|
||
override fun onCreate() { | ||
super.onCreate() | ||
composeNavigationConfigStep.configure() | ||
} | ||
} |
18 changes: 0 additions & 18 deletions
18
demo/src/main/java/com/adamkobus/android/vm/demo/di/DemoBinds.kt
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
demo/src/main/java/com/adamkobus/android/vm/demo/di/NavigationModule.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.adamkobus.android.vm.demo.di | ||
|
||
import com.adamkobus.android.vm.demo.nav.DemoNavActionVerifier | ||
import com.adamkobus.compose.navigation.ComposeNavigation | ||
import com.adamkobus.compose.navigation.NavActionVerifier | ||
import com.adamkobus.compose.navigation.NavigationConsumer | ||
import com.adamkobus.compose.navigation.NavigationStateSource | ||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import dagger.multibindings.IntoSet | ||
|
||
@Module(includes = [NavigationModuleBinds::class]) | ||
@InstallIn(SingletonComponent::class) | ||
object NavigationModule { | ||
|
||
@Provides | ||
fun providesNavigationConsumer(): NavigationConsumer { | ||
return ComposeNavigation.getNavigationConsumer() | ||
} | ||
|
||
@Provides | ||
fun provideNavigationStateSource(): NavigationStateSource = | ||
ComposeNavigation.getNavigationStateSource() | ||
} | ||
|
||
@InstallIn(SingletonComponent::class) | ||
@Module | ||
internal interface NavigationModuleBinds { | ||
|
||
@Binds | ||
@IntoSet | ||
fun bindDefaultNavActionVerifier(impl: DemoNavActionVerifier): NavActionVerifier | ||
} |
24 changes: 9 additions & 15 deletions
24
demo/src/main/java/com/adamkobus/android/vm/demo/nav/Actions.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 |
---|---|---|
@@ -1,24 +1,18 @@ | ||
package com.adamkobus.android.vm.demo.nav | ||
|
||
import com.adamkobus.compose.navigation.data.NavAction | ||
import com.adamkobus.compose.navigation.data.PopBackStackDestination | ||
import com.adamkobus.compose.navigation.action.NavAction | ||
import com.adamkobus.compose.navigation.action.NavActionWrapper | ||
|
||
sealed class FromHome(navAction: NavAction) : NavAction(navAction) { | ||
sealed class FromHome(navAction: NavAction) : NavActionWrapper(navAction) { | ||
|
||
object ToLogsList : FromHome(DemoGraph.Home to DemoGraph.LogsList) | ||
object ToLogsList : FromHome(DemoGraph.Home goTo DemoGraph.LogsList) | ||
} | ||
|
||
sealed class FromDemoDialog(navAction: NavAction) : NavAction(navAction) { | ||
object Dismiss : FromDemoDialog( | ||
NavAction( | ||
DemoGraph.DemoDialog, | ||
PopBackStackDestination, | ||
navigateWithController = { it.popBackStack() } | ||
) | ||
) | ||
sealed class FromDemoDialog(navAction: NavAction) : NavActionWrapper(navAction) { | ||
object Dismiss : FromDemoDialog(DemoGraph.DemoDialog.pop()) | ||
} | ||
|
||
sealed class FromLogs(navAction: NavAction) : NavAction(navAction) { | ||
class ToDemoDialog(logId: Int) : NavAction(DemoGraph.LogsList to DemoGraph.DemoDialog arg logId) | ||
object Back : NavAction(DemoGraph.LogsList, PopBackStackDestination, navigateWithController = { it.popBackStack() }) | ||
sealed class FromLogs(navAction: NavAction) : NavActionWrapper(navAction) { | ||
class ToDemoDialog(logId: Int) : FromLogs(DemoGraph.LogsList goTo DemoGraph.DemoDialog arg logId) | ||
object Back : FromLogs(DemoGraph.LogsList.pop()) | ||
} |
23 changes: 23 additions & 0 deletions
23
demo/src/main/java/com/adamkobus/android/vm/demo/nav/ComposeNavigationConfigurator.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.adamkobus.android.vm.demo.nav | ||
|
||
import android.util.Log | ||
import com.adamkobus.compose.navigation.BuildConfig | ||
import com.adamkobus.compose.navigation.ComposeNavigation | ||
import com.adamkobus.compose.navigation.NavActionVerifier | ||
import javax.inject.Inject | ||
|
||
class ComposeNavigationConfigurator @Inject constructor( | ||
private val navVerifiers: Set<@JvmSuppressWildcards NavActionVerifier>, | ||
) { | ||
|
||
fun configure() { | ||
val logLevel = if (BuildConfig.DEBUG) { | ||
Log.VERBOSE | ||
} else { | ||
Log.WARN | ||
} | ||
ComposeNavigation | ||
.addNavActionVerifiers(navVerifiers) | ||
.setLogLevel(logLevel) | ||
} | ||
} |
21 changes: 10 additions & 11 deletions
21
demo/src/main/java/com/adamkobus/android/vm/demo/nav/DemoGraph.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
15 changes: 11 additions & 4 deletions
15
demo/src/main/java/com/adamkobus/android/vm/demo/nav/DemoNavActionVerifier.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 |
---|---|---|
@@ -1,13 +1,20 @@ | ||
package com.adamkobus.android.vm.demo.nav | ||
|
||
import com.adamkobus.compose.navigation.NavActionVerifier | ||
import com.adamkobus.compose.navigation.data.INavDestination | ||
import com.adamkobus.compose.navigation.data.NavAction | ||
import com.adamkobus.compose.navigation.VerifyResult | ||
import com.adamkobus.compose.navigation.action.NavAction | ||
import com.adamkobus.compose.navigation.destination.GlobalGraph | ||
import com.adamkobus.compose.navigation.destination.NavState | ||
import javax.inject.Inject | ||
|
||
class DemoNavActionVerifier @Inject constructor() : NavActionVerifier { | ||
|
||
override fun isNavActionAllowed(currentDestination: INavDestination, action: NavAction): Boolean { | ||
return action.fromDestination == currentDestination | ||
override fun isNavActionAllowed(navState: NavState, action: NavAction): VerifyResult { | ||
if (action.fromDestination.graph == GlobalGraph) return VerifyResult.Allow | ||
return if (navState.isCurrent(action.fromDestination)) { | ||
VerifyResult.Allow | ||
} else { | ||
VerifyResult.Discard | ||
} | ||
} | ||
} |
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
Oops, something went wrong.