Sample application for https://github.com/cashapp/redwood
Login screen example:
@Composable
fun LoginScreen(navigator: Navigator) {
Box {
Column(
horizontalAlignment = CrossAxisAlignment.Center,
verticalAlignment = MainAxisAlignment.Center
) {
var login: String by remember { mutableStateOf("") }
var password: String by remember { mutableStateOf("") }
Image(
120,
120,
placeholder = MR.images.ava_preview,
layoutModifier = LayoutModifier.padding(Padding(bottom = 100)),
url = null
)
TextInput(login,
MR.strings.auth_login.desc(),
layoutModifier = LayoutModifier.padding(Padding(16)),
onChange = {
login = it
}
)
TextInput(
password,
MR.strings.auth_password.desc(),
layoutModifier = LayoutModifier.padding(Padding(horizontal = 16)),
onChange = {
password = it
},
inputType = InputType.Password
)
Button(
MR.strings.auth_button.desc(), buttonType = ButtonType.Primary,
enabled = login.isNotEmpty() && password.isNotEmpty(),
onClick = {
navigator.navigate("tabs")
}, layoutModifier = LayoutModifier.padding(Padding(start = 16, top = 100, end = 16))
)
}
}
}
Flat navigation example:
private fun secondTabNavigation() = navigation(startDestination = "start") {
registerScreen(
"start",
isToolbarVisible = true,
) { navigator, _, screenSettings ->
PostsList(screenSettings) { date, text ->
navigator.navigate("/details/${date}?description=${text}")
}
}
registerScreen(
"/details/{date}?description={description}",
isToolbarVisible = true
) { navController, args, screenSettings ->
DetailsScreen(
navController,
args["date"].orEmpty(),
args["description"].orEmpty(),
screenSettings
)
}
}
Tab navigation example:
private fun mainScreenNavigation(rootNavigator: Navigator): NavigationHost =
navigationTabs(startDestination = "line") {
registerNavigation(
uri = "line",
title = MR.strings.tab_list.desc(),
icon = MR.images.line,
childNavigation = {
secondTabNavigation()
}
)
registerScreen(
uri = "settings",
title = MR.strings.tab_settings.desc(),
icon = MR.images.settings,
screen = {
ProfileScreen(rootNavigator)
}
)
}
Open in Android Studio and just run androidApp
configuration.
- Run
pod install
iniosApp
directory - Open
iosApp/iosApp.xcworkspace
in Xcode - Run app
- At now redwood successfully compiles on iOS only with Release configuration. Debug compilation fails.
- Demo screen UI code in shared
- Android UI implemented with Jetpack Compose Material UI in androidApp
- iOS UI implemented with UIKit in iosApp