Comments (4)
Hey @tethridge , I'm trying the same right now. This is my approach, but even thoughh currentContent2
changes, the navigator does not redraw.
class MainScreen : Screen {
override val key: ScreenKey = uniqueScreenKey
@Composable
override fun Content() {
val screenModel = getScreenModel<MainScreenModel>()
val userRepository = koinInject<UserRepository>()
var currentContent by remember { mutableStateOf<Screen>(SplashScreen()) }
LaunchedEffect(true) {
userRepository.isLoggedIn.collect { value ->
when (value) {
true -> {
currentContent = HomeScreen().also { println("set to Home") }
}
false -> {
currentContent = LoginScreen().also { println("set to Login") }
}
}
}
}
Navigator(currentContent)
}
}
Maybe we find a solution together?
from voyager.
// This sort of works, but I'd like to have transitions.
@Composable
fun App() {
MyAppTheme {
Navigator(MainScreen()) { navigator ->
val rootScreenModel = navigator.getNavigatorScreenModel<RootScreenModel>()
val state by rootScreenModel.state.collectAsState()
when (state) {
is RootScreenModel.State.Authenticated -> {
println("Authenticated")
}
is RootScreenModel.State.Unauthenticated -> {
println("Unauthenticated: pushing login screen")
navigator.push(StartLoginScreen())
}
}
CurrentScreen()
// Adding transitions causes issues with reloading of content
//SlideTransition(navigator)
}
}
}
from voyager.
I understand. Works for me too without transitions. I'll try around with transitions and let you know if I find sth!
from voyager.
I would encourage to go on Discussions, issues are more focus on bugs and feature request.
from voyager.
Related Issues (20)
- Voyager Screen with a `ViewModel` does not have its `SavedStateHandle` saved on process death HOT 1
- Custom back handling depending on the currentScreen HOT 2
- Integration with KMMViewModel
- Nesting Navigators prevents WindowInsets from being updated upon device rotation on iOS HOT 1
- Parcelable encountered IOException writing serializable object HOT 6
- Configuration changes not handled - Tab Options
- Screen State not getting retained HOT 2
- Update compose version to 1.6.1 HOT 2
- Cant pass a lambda to a Screen HOT 2
- Saveable state exception on transition HOT 1
- ViewModel not found in hilt graph. Please, check if you have a Multibinding HOT 1
- Deeplink in IOS HOT 1
- State Preservation Issue with Nested Navigators in Voyager HOT 5
- how can I change BottomSheetNavigator background in Screen? HOT 1
- Navigation from ScreeModel HOT 2
- [Bug][Deeplink] Navigator stack doesn't change after screens list changes
- How to set the actionbar functionalities using the TabNavigation?
- TabDisposable with nested/parent navigation loses Screen state
- Recomposition issue when using nested Navigators and MaterialKolor HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from voyager.