henrikhorbovyi
06/06/2020, 6:52 AM@Model
object AppNavigator {
var currentScreen: Screen = Screen.Home()
}
/**
* Temporary solution pending navigation support.
*/
fun navigateTo(destination: Screen) {
AppNavigator.currentScreen = destination
}
But now I'm using dev12, and we know that @Model
is deprecated. How do you guys would fix it?
I've tryied:
object AppNavigator {
var currentScreen: MutableState<Screen> = state { Screen.Home() }
}
But it does not work, states must be called inside composablesKazemihabib1996
06/06/2020, 7:10 AMvar currentScreen by mutableStateOf(Screen.Home())
import androidx.compose.getValue
import androidx.compose.setValue
Val Salamakha
06/06/2020, 8:57 AMKazemihabib1996
06/06/2020, 9:05 AMVal Salamakha
06/06/2020, 9:05 AMKazemihabib1996
06/06/2020, 9:06 AMVal Salamakha
06/06/2020, 9:07 AMimport androidx.compose.getValue
import androidx.compose.setValue
The abovementioned is not active and they are shown as unused .Kazemihabib1996
06/06/2020, 9:12 AMVal Salamakha
06/06/2020, 9:22 AMvar currentScreen by mutableStateOf( Screen.Home )
Anyway thanks to @Kazemihabib1996import androidx.compose.getValue
import androidx.compose.setValueobject ... object JetnewsStatus {
var currentScreen by mutableStateOf( Screen.Home as Screen )
val favorites by mutableStateOf(ModelList<String>())
val selectedTopics by mutableStateOf(ModelList<String>())
}
other code without changes.Adam Powell
06/06/2020, 1:44 PMnickbutcher
06/06/2020, 1:49 PMdev12
on the develop
branch. We still need to merge this back
https://github.com/android/compose-samples/blob/develop/JetNews/app/src/main/java/com/example/jetnews/ui/Status.kt#L33henrikhorbovyi
06/06/2020, 6:05 PM<T>
... mutableStateOf<Screen>(...)
@Model
😄nickbutcher
06/07/2020, 2:15 PMdevelop
branch more prominent as it's the most useful.