Skip to content

Commit

Permalink
Merge pull request #1 from CarbideCowboy/navigation
Browse files Browse the repository at this point in the history
Added nav routes - z0bot
  • Loading branch information
z0bot authored Apr 26, 2024
2 parents 757a478 + fc7758f commit 20ae798
Show file tree
Hide file tree
Showing 6 changed files with 170 additions and 65 deletions.
Original file line number Diff line number Diff line change
@@ -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")
}
Original file line number Diff line number Diff line change
@@ -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),
) {}
}
}
Original file line number Diff line number Diff line change
@@ -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,
) { }
}
Original file line number Diff line number Diff line change
@@ -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()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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()
}
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -60,6 +60,7 @@ fun SupraTextureListItem(
)
}
Text(
modifier = Modifier.padding(start = 8.dp),
text = title
)
}
Expand Down

0 comments on commit 20ae798

Please sign in to comment.