From fc7758f9d8713468ea33d267007d20ad53114471 Mon Sep 17 00:00:00 2001 From: CarbideCowboy Date: Wed, 24 Apr 2024 17:47:10 -0700 Subject: [PATCH] Added nav routes - z0bot --- .../supraexample/domain/models/NavRoutes.kt | 7 ++ .../supraexample/presentation/ButtonScreen.kt | 49 ++++++++++ .../supraexample/presentation/CardScreen.kt | 23 +++++ .../supraexample/presentation/HomeScreen.kt | 63 +++++++++++++ .../supraexample/presentation/MainActivity.kt | 90 ++++++------------- .../list_items/SupraTextureListItem.kt | 3 +- 6 files changed, 170 insertions(+), 65 deletions(-) create mode 100644 app/src/main/java/com/carbidecowboy/supraexample/domain/models/NavRoutes.kt create mode 100644 app/src/main/java/com/carbidecowboy/supraexample/presentation/ButtonScreen.kt create mode 100644 app/src/main/java/com/carbidecowboy/supraexample/presentation/CardScreen.kt create mode 100644 app/src/main/java/com/carbidecowboy/supraexample/presentation/HomeScreen.kt diff --git a/app/src/main/java/com/carbidecowboy/supraexample/domain/models/NavRoutes.kt b/app/src/main/java/com/carbidecowboy/supraexample/domain/models/NavRoutes.kt new file mode 100644 index 0000000..8392727 --- /dev/null +++ b/app/src/main/java/com/carbidecowboy/supraexample/domain/models/NavRoutes.kt @@ -0,0 +1,7 @@ +package com.carbidecowboy.supraexample.domain.models + +sealed class NavRoutes(val route: String) { + data object CardScreen: NavRoutes("card_screen") + data object HomeScreen: NavRoutes("home_screen") + data object ButtonScreen: NavRoutes("button_screen") +} \ No newline at end of file diff --git a/app/src/main/java/com/carbidecowboy/supraexample/presentation/ButtonScreen.kt b/app/src/main/java/com/carbidecowboy/supraexample/presentation/ButtonScreen.kt new file mode 100644 index 0000000..c4dbcd8 --- /dev/null +++ b/app/src/main/java/com/carbidecowboy/supraexample/presentation/ButtonScreen.kt @@ -0,0 +1,49 @@ +package com.carbidecowboy.supraexample.presentation + +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.unit.dp +import com.carbidecowboy.supra.presentation.buttons.SupraHardwareButton + +@Composable +fun ButtonScreen() { + //Example Hardware Buttons + Row ( + modifier = Modifier + .fillMaxSize() + .padding(16.dp), + Arrangement.SpaceBetween + ) { + SupraHardwareButton( + modifier = Modifier + .size(100.dp), + buttonText = "GB", + backgroundColor = Color(0xFFE9D30E), + ) {} + SupraHardwareButton( + modifier = Modifier + .size(64.dp), + outerCornerRadius = 4.dp, + innerCornerRadius = 4.dp , + buttonText = "Text", + backgroundColor = Color(0xFF04B4BA), + ) {} + SupraHardwareButton( + modifier = Modifier + .height(70.dp) + .width(150.dp), + outerCornerRadius = 16.dp, + innerCornerRadius = 8.dp , + buttonText = "Text", + backgroundColor = Color(0xFFD8D4CF), + ) {} + } +} \ No newline at end of file diff --git a/app/src/main/java/com/carbidecowboy/supraexample/presentation/CardScreen.kt b/app/src/main/java/com/carbidecowboy/supraexample/presentation/CardScreen.kt new file mode 100644 index 0000000..f4a92e2 --- /dev/null +++ b/app/src/main/java/com/carbidecowboy/supraexample/presentation/CardScreen.kt @@ -0,0 +1,23 @@ +package com.carbidecowboy.supraexample.presentation + +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.unit.dp +import com.carbidecowboy.supra.presentation.cards.SupraTextureCard +import com.carbidecowboy.supra.presentation.cards.TextureType + +@Composable +fun CardScreen() { + SupraTextureCard( + modifier = Modifier + .fillMaxWidth() + .height(160.dp) + .padding(16.dp), + textureType = TextureType.TOPOGRAPHIC, + backgroundColor = Color.Yellow, + ) { } +} \ No newline at end of file diff --git a/app/src/main/java/com/carbidecowboy/supraexample/presentation/HomeScreen.kt b/app/src/main/java/com/carbidecowboy/supraexample/presentation/HomeScreen.kt new file mode 100644 index 0000000..cc4d2fa --- /dev/null +++ b/app/src/main/java/com/carbidecowboy/supraexample/presentation/HomeScreen.kt @@ -0,0 +1,63 @@ +package com.carbidecowboy.supraexample.presentation + +import android.widget.Toast +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.ChevronRight +import androidx.compose.material.icons.filled.Person +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.unit.dp +import com.carbidecowboy.supra.presentation.buttons.SupraHardwareButton +import com.carbidecowboy.supra.presentation.cards.SupraTextureCard +import com.carbidecowboy.supra.presentation.cards.TextureType +import com.carbidecowboy.supra.presentation.list_items.SupraTextureListItem + +@Composable +fun HomeScreen( + onCardsClicked: () -> Unit, + onButtonsClicked: () -> Unit +) { + LazyColumn( + modifier = Modifier + .padding(16.dp) + .fillMaxSize(), + verticalArrangement = Arrangement.spacedBy(4.dp) + ) { + //Example Texture List Item + item { + SupraTextureListItem( + modifier = Modifier + .height(60.dp), + title = "Cards", + rightIconImageVector = Icons.Default.ChevronRight, + textureType = TextureType.TOPOGRAPHIC, + backgroundColor = Color.Gray + ) { + onCardsClicked() + } + } + item { + SupraTextureListItem( + modifier = Modifier + .height(60.dp), + title = "Buttons", + rightIconImageVector = Icons.Default.ChevronRight, + textureType = TextureType.TOPOGRAPHIC, + backgroundColor = Color.Gray + ) { + onButtonsClicked() + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/carbidecowboy/supraexample/presentation/MainActivity.kt b/app/src/main/java/com/carbidecowboy/supraexample/presentation/MainActivity.kt index ea5e1ec..737f1af 100644 --- a/app/src/main/java/com/carbidecowboy/supraexample/presentation/MainActivity.kt +++ b/app/src/main/java/com/carbidecowboy/supraexample/presentation/MainActivity.kt @@ -27,12 +27,16 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import androidx.navigation.compose.NavHost +import androidx.navigation.compose.composable +import androidx.navigation.compose.rememberNavController import com.carbidecowboy.supra.presentation.buttons.SupraHardwareButton import com.carbidecowboy.supra.presentation.cards.SupraTextureCard import com.carbidecowboy.supra.presentation.cards.TextureType import com.carbidecowboy.supra.presentation.list_items.SupraTextureListItem import com.carbidecowboy.supra.presentation.scaffolds.SupraGyroScaffold import com.carbidecowboy.supra.presentation.scaffolds.SupraScaffold +import com.carbidecowboy.supraexample.domain.models.NavRoutes import com.carbidecowboy.supraexample.presentation.theme.SupraExampleTheme import dagger.hilt.android.AndroidEntryPoint @@ -42,75 +46,33 @@ class MainActivity : ComponentActivity() { super.onCreate(savedInstanceState) setContent { SupraExampleTheme { - SupraScaffold( borderColor = Color.LightGray, backgroundColor = Color.DarkGray ) { - LazyColumn( - modifier = Modifier - .padding(16.dp) - .fillMaxSize(), - verticalArrangement = Arrangement.spacedBy(4.dp) - ) { - //Example Texture Card - item { - SupraTextureCard( - modifier = Modifier - .fillMaxWidth() - .height(160.dp), - textureType = TextureType.TOPOGRAPHIC, - backgroundColor = Color.Yellow, - ) { - - } - } + SupraScaffold(borderColor = Color.LightGray, backgroundColor = Color.DarkGray) { - //Example Texture List Item - item { - SupraTextureListItem( - modifier = Modifier - .height(60.dp), - title = "Big Poopies", - leftIconImageVector = Icons.Default.Person, - rightIconImageVector = Icons.Default.ChevronRight, - textureType = TextureType.TOPOGRAPHIC, - backgroundColor = Color.Gray - ) { - Toast.makeText(this@MainActivity, "Big Poopies", Toast.LENGTH_SHORT).show() - } - } + val navController = rememberNavController() - //Example Hardware Buttons - item{ - Row ( - modifier = Modifier.fillMaxSize(), - Arrangement.SpaceBetween - ) { - SupraHardwareButton( - modifier = Modifier - .size(100.dp), - buttonText = "GB", - backgroundColor = Color(0xFFE9D30E), - ) {} - SupraHardwareButton( - modifier = Modifier - .size(64.dp), - outerCornerRadius = 4.dp, - innerCornerRadius = 4.dp , - buttonText = "Text", - backgroundColor = Color(0xFF04B4BA), - ) {} - SupraHardwareButton( - modifier = Modifier - .height(70.dp) - .width(150.dp), - outerCornerRadius = 16.dp, - innerCornerRadius = 8.dp , - buttonText = "Text", - backgroundColor = Color(0xFFD8D4CF), - ) {} + NavHost( + navController = navController, + startDestination = NavRoutes.HomeScreen.route + ) { + composable(NavRoutes.HomeScreen.route) { + HomeScreen( + onCardsClicked = { + navController.navigate(NavRoutes.CardScreen.route) + }, + onButtonsClicked = { + navController.navigate((NavRoutes.ButtonScreen.route)) } - } + ) + } + composable(NavRoutes.CardScreen.route) { + CardScreen() + } + composable(NavRoutes.ButtonScreen.route) { + ButtonScreen() } } } } } - } \ No newline at end of file + } +} \ No newline at end of file diff --git a/supra/src/main/java/com/carbidecowboy/supra/presentation/list_items/SupraTextureListItem.kt b/supra/src/main/java/com/carbidecowboy/supra/presentation/list_items/SupraTextureListItem.kt index 45ff277..6293927 100644 --- a/supra/src/main/java/com/carbidecowboy/supra/presentation/list_items/SupraTextureListItem.kt +++ b/supra/src/main/java/com/carbidecowboy/supra/presentation/list_items/SupraTextureListItem.kt @@ -47,7 +47,7 @@ fun SupraTextureListItem( ) { leftIconId?.let { iconId -> Icon( - modifier = Modifier.padding(horizontal = 8.dp), + modifier = Modifier.padding(start = 8.dp), painter = painterResource(id = iconId), contentDescription = "left icon" ) @@ -60,6 +60,7 @@ fun SupraTextureListItem( ) } Text( + modifier = Modifier.padding(start = 8.dp), text = title ) }