redwood-sample

Sample application for https://github.com/cashapp/redwood

android-app

ios-app

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)
            }
        )
    }

Run

Android

Open in Android Studio and just run androidApp configuration.

iOS

  1. Run pod install in iosApp directory
  2. Open iosApp/iosApp.xcworkspace in Xcode
  3. Run app

Notes

  1. At now redwood successfully compiles on iOS only with Release configuration. Debug compilation fails.
  2. Demo screen UI code in shared
  3. Android UI implemented with Jetpack Compose Material UI in androidApp
  4. iOS UI implemented with UIKit in iosApp