-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate device screen to decompose (without deeplink) (#750)
**Background** Right now we have outdated navigation with google **Changes** Migrate options screen to decompose **Test plan** Try all screens in device tab
- Loading branch information
Showing
48 changed files
with
534 additions
and
447 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
2 changes: 2 additions & 0 deletions
2
components/deeplink/api/src/main/java/com/flipperdevices/deeplink/model/Deeplink.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
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
...fo/api/src/main/java/com/flipperdevices/info/api/screen/DeviceScreenDecomposeComponent.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.flipperdevices.info.api.screen | ||
|
||
import com.arkivanov.decompose.ComponentContext | ||
import com.flipperdevices.ui.decompose.DecomposeComponent | ||
|
||
interface DeviceScreenDecomposeComponent : DecomposeComponent { | ||
fun interface Factory { | ||
operator fun invoke( | ||
componentContext: ComponentContext, | ||
): DeviceScreenDecomposeComponent | ||
} | ||
} |
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
76 changes: 76 additions & 0 deletions
76
...impl/src/main/java/com/flipperdevices/info/impl/api/DeviceScreenDecomposeComponentImpl.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,76 @@ | ||
package com.flipperdevices.info.impl.api | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import com.arkivanov.decompose.ComponentContext | ||
import com.arkivanov.decompose.extensions.compose.stack.Children | ||
import com.arkivanov.decompose.extensions.compose.subscribeAsState | ||
import com.arkivanov.decompose.router.stack.ChildStack | ||
import com.arkivanov.decompose.router.stack.StackNavigation | ||
import com.arkivanov.decompose.router.stack.childStack | ||
import com.arkivanov.decompose.router.stack.pop | ||
import com.arkivanov.decompose.value.Value | ||
import com.flipperdevices.core.di.AppGraph | ||
import com.flipperdevices.info.api.screen.DeviceScreenDecomposeComponent | ||
import com.flipperdevices.info.impl.model.DeviceScreenNavigationConfig | ||
import com.flipperdevices.settings.api.SettingsDecomposeComponent | ||
import com.flipperdevices.ui.decompose.DecomposeComponent | ||
import com.squareup.anvil.annotations.ContributesBinding | ||
import dagger.assisted.Assisted | ||
import dagger.assisted.AssistedFactory | ||
import dagger.assisted.AssistedInject | ||
|
||
class DeviceScreenDecomposeComponentImpl @AssistedInject constructor( | ||
@Assisted componentContext: ComponentContext, | ||
private val settingsFactory: SettingsDecomposeComponent.Factory, | ||
private val updateFactory: UpdateScreenDecomposeComponent.Factory, | ||
private val fullInfoDecomposeComponentFactory: FullInfoDecomposeComponent.Factory | ||
) : DeviceScreenDecomposeComponent, ComponentContext by componentContext { | ||
private val navigation = StackNavigation<DeviceScreenNavigationConfig>() | ||
|
||
val stack: Value<ChildStack<DeviceScreenNavigationConfig, DecomposeComponent>> = childStack( | ||
source = navigation, | ||
serializer = DeviceScreenNavigationConfig.serializer(), | ||
initialConfiguration = DeviceScreenNavigationConfig.Update(), | ||
handleBackButton = true, | ||
childFactory = ::child, | ||
) | ||
|
||
private fun child( | ||
config: DeviceScreenNavigationConfig, | ||
componentContext: ComponentContext | ||
): DecomposeComponent = when (config) { | ||
is DeviceScreenNavigationConfig.Update -> updateFactory( | ||
componentContext, | ||
config.deeplink, | ||
navigation | ||
) | ||
|
||
DeviceScreenNavigationConfig.FullInfo -> fullInfoDecomposeComponentFactory( | ||
componentContext = componentContext, | ||
onBack = navigation::pop | ||
) | ||
|
||
DeviceScreenNavigationConfig.Options -> settingsFactory(componentContext) | ||
} | ||
|
||
@Composable | ||
@Suppress("NonSkippableComposable") | ||
override fun Render() { | ||
val childStack by stack.subscribeAsState() | ||
|
||
Children( | ||
stack = childStack, | ||
) { | ||
it.instance.Render() | ||
} | ||
} | ||
|
||
@AssistedFactory | ||
@ContributesBinding(AppGraph::class, DeviceScreenDecomposeComponent.Factory::class) | ||
interface Factory : DeviceScreenDecomposeComponent.Factory { | ||
override operator fun invoke( | ||
componentContext: ComponentContext, | ||
): DeviceScreenDecomposeComponentImpl | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
...ts/info/impl/src/main/java/com/flipperdevices/info/impl/api/FullInfoDecomposeComponent.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,53 @@ | ||
package com.flipperdevices.info.impl.api | ||
|
||
import androidx.compose.runtime.Composable | ||
import com.arkivanov.decompose.ComponentContext | ||
import com.flipperdevices.core.ui.ktx.viewModelWithFactory | ||
import com.flipperdevices.info.impl.compose.screens.ComposableFullDeviceInfoScreen | ||
import com.flipperdevices.info.impl.viewmodel.DeviceStatusViewModel | ||
import com.flipperdevices.info.impl.viewmodel.deviceinfo.BasicInfoViewModel | ||
import com.flipperdevices.info.impl.viewmodel.deviceinfo.FullInfoViewModel | ||
import com.flipperdevices.info.impl.viewmodel.deviceinfo.ShareFullInfoFileViewModel | ||
import com.flipperdevices.ui.decompose.DecomposeComponent | ||
import com.flipperdevices.ui.decompose.DecomposeOnBackParameter | ||
import dagger.assisted.Assisted | ||
import dagger.assisted.AssistedFactory | ||
import dagger.assisted.AssistedInject | ||
import javax.inject.Provider | ||
|
||
class FullInfoDecomposeComponent @AssistedInject constructor( | ||
@Assisted componentContext: ComponentContext, | ||
@Assisted private val onBack: DecomposeOnBackParameter, | ||
private val shareFullInfoViewModelProvider: Provider<ShareFullInfoFileViewModel>, | ||
private val basicInfoViewModelProvider: Provider<BasicInfoViewModel>, | ||
private val fullInfoViewModelProvider: Provider<FullInfoViewModel>, | ||
private val deviceStatusViewModelProvider: Provider<DeviceStatusViewModel> | ||
) : DecomposeComponent, ComponentContext by componentContext { | ||
@Composable | ||
@Suppress("NonSkippableComposable") | ||
override fun Render() { | ||
ComposableFullDeviceInfoScreen( | ||
onBack = onBack::invoke, | ||
shareViewModel = viewModelWithFactory(key = null) { | ||
shareFullInfoViewModelProvider.get() | ||
}, | ||
basicInfoViewModel = viewModelWithFactory(key = null) { | ||
basicInfoViewModelProvider.get() | ||
}, | ||
fullInfoViewModel = viewModelWithFactory(key = null) { | ||
fullInfoViewModelProvider.get() | ||
}, | ||
deviceStatusViewModel = viewModelWithFactory(key = null) { | ||
deviceStatusViewModelProvider.get() | ||
} | ||
) | ||
} | ||
|
||
@AssistedFactory | ||
fun interface Factory { | ||
operator fun invoke( | ||
componentContext: ComponentContext, | ||
onBack: DecomposeOnBackParameter | ||
): FullInfoDecomposeComponent | ||
} | ||
} |
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
79 changes: 20 additions & 59 deletions
79
components/info/impl/src/main/java/com/flipperdevices/info/impl/api/InfoFeatureEntryImpl.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
Oops, something went wrong.