Skip to content

Commit

Permalink
style: apply spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
levinzonr committed May 7, 2024
1 parent da0430d commit e8b1177
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 43 deletions.
30 changes: 11 additions & 19 deletions demo/src/main/java/io/monstarlab/mosaic/HomeScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,60 +30,57 @@ import androidx.compose.ui.unit.dp
fun HomeScreen(
onSliderClick: () -> Unit,
onCarouselClick: () -> Unit,
modifier: Modifier = Modifier
modifier: Modifier = Modifier,
) = Scaffold(
modifier = modifier,
topBar = { TopAppBar(title = { Text(text = "Mosaic Demo") }) }
topBar = { TopAppBar(title = { Text(text = "Mosaic Demo") }) },
) {

Column(
verticalArrangement = Arrangement.spacedBy(32.dp),
modifier = Modifier
.padding(it)
.fillMaxSize()
.padding(16.dp)
.padding(16.dp),
) {
Image(
painter = painterResource(id = R.drawable.ic_mosaic_log),
contentDescription = "logo",
modifier = Modifier
.size(150.dp)
.align(Alignment.CenterHorizontally)
.align(Alignment.CenterHorizontally),
)

Text(
text = "Collection of Jetpack Compose UI components and utilities.",
modifier = Modifier.align(Alignment.CenterHorizontally),
textAlign = TextAlign.Center
textAlign = TextAlign.Center,
)

Column {
Row(
horizontalArrangement = Arrangement.spacedBy(16.dp),
modifier = Modifier
modifier = Modifier,
) {
DemoButton(
resource = R.drawable.ic_slider,
text = "Slider",
modifier = Modifier.weight(0.3f),
onClick = onSliderClick
onClick = onSliderClick,
)

DemoButton(
resource = R.drawable.ic_carousel,
text = "Carousel",
modifier = Modifier.weight(0.3f),
onClick = onCarouselClick
onClick = onCarouselClick,
)

Spacer(modifier = Modifier.weight(0.3f))
}
}

}
}


@Composable
private fun DemoButton(
resource: Int,
Expand All @@ -96,10 +93,9 @@ private fun DemoButton(
shape = RoundedCornerShape(16.dp),
shadowElevation = 16.dp,
tonalElevation = 2.dp,
onClick = onClick
onClick = onClick,
) {
Column(verticalArrangement = Arrangement.SpaceBetween) {

Spacer(modifier = Modifier)

Icon(
Expand All @@ -116,18 +112,14 @@ private fun DemoButton(
modifier = Modifier
.align(Alignment.CenterHorizontally)
.padding(bottom = 16.dp),
style = MaterialTheme.typography.titleMedium
style = MaterialTheme.typography.titleMedium,
)


}

}

}

@Preview
@Composable
private fun PreviewHomeScreen() {
HomeScreen({}, {})
}
}
6 changes: 3 additions & 3 deletions demo/src/main/java/io/monstarlab/mosaic/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ class MainActivity : ComponentActivity() {
val navController = rememberNavController()
NavHost(
navController = navController,
startDestination = Routes.Home.value
startDestination = Routes.Home.value,
) {
composable(Routes.Home.value) {
HomeScreen(
onSliderClick = {
navController.navigate(Routes.SliderDemo.value)
},
onCarouselClick = {

})
},
)
}

composable(Routes.SliderDemo.value) {
Expand Down
4 changes: 2 additions & 2 deletions demo/src/main/java/io/monstarlab/mosaic/Routes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package io.monstarlab.mosaic

enum class Routes(val value: String) {
Home("home"),
SliderDemo("slider-demo")
}
SliderDemo("slider-demo"),
}
26 changes: 10 additions & 16 deletions demo/src/main/java/io/monstarlab/mosaic/demos/SliderDemo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ fun SliderDemo() = Scaffold(
modifier = Modifier,
topBar = {
TopAppBar(
title = { Text(text = "Mosaic - Slider") }
title = { Text(text = "Mosaic - Slider") },
)
}
},
) {
Column(
modifier = Modifier
Expand Down Expand Up @@ -81,9 +81,8 @@ fun MosaicSliderDemo() {

Column(
verticalArrangement = Arrangement.Top,
modifier = Modifier
modifier = Modifier,
) {

MaterialSlider(
value = sliderValue,
onValueChange = { sliderValue = it },
Expand All @@ -92,7 +91,6 @@ fun MosaicSliderDemo() {
Text(text = "Material slider")
}


val modifier = if (isCustom) {
Modifier
.clip(RoundedCornerShape(16.dp))
Expand All @@ -112,9 +110,8 @@ fun MosaicSliderDemo() {

Column(
verticalArrangement = Arrangement.Top,
modifier = Modifier
modifier = Modifier,
) {

MosaicSlider(
value = sliderValue,
onValueChange = { sliderValue = it },
Expand Down Expand Up @@ -168,7 +165,6 @@ fun MosaicSliderDemo() {
},
)
Text(text = "Mosaic slider")

}

Text(
Expand All @@ -181,7 +177,7 @@ fun MosaicSliderDemo() {
Row(
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier
.fillMaxWidth()
.fillMaxWidth(),
) {
LabeledSwitch(
label = "Slider enabled",
Expand All @@ -193,7 +189,7 @@ fun MosaicSliderDemo() {
label = "Customise",
checked = isCustom,
onValueChange = { isCustom = it },
alignment = Alignment.End
alignment = Alignment.End,

)
}
Expand All @@ -202,9 +198,8 @@ fun MosaicSliderDemo() {
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier
.fillMaxWidth()
.align(Alignment.CenterHorizontally)
.align(Alignment.CenterHorizontally),
) {

LabeledSwitch(
label = "Use Non-Linear distribution",
checked = nonLinearDistribution,
Expand All @@ -215,10 +210,9 @@ fun MosaicSliderDemo() {
label = "Disable sub-range",
checked = disableSubRange,
onValueChange = { disableSubRange = it },
alignment = Alignment.End
alignment = Alignment.End,
)
}

}
}

Expand All @@ -234,10 +228,10 @@ private fun LabeledSwitch(
modifier = modifier,
horizontalAlignment = alignment,

) {
) {
Text(
text = label,
textAlign = TextAlign.Start
textAlign = TextAlign.Start,
)
Spacer(modifier = Modifier.height(3.dp))
Switch(
Expand Down
1 change: 0 additions & 1 deletion demo/src/main/java/io/monstarlab/mosaic/ui/theme/Color.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ val Pink80 = Color(0xFFEFB8C8)
val MonstarlabYellow = Color(0xFFFFFF00)
val DarkGrey = Color(0xFF343434)


val Purple40 = Color(0xFF6650a4)
val PurpleGrey40 = Color(0xFF625b71)
val Pink40 = Color(0xFF7D5260)
2 changes: 0 additions & 2 deletions demo/src/main/java/io/monstarlab/mosaic/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package io.monstarlab.mosaic.ui.theme
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color

Expand All @@ -15,7 +14,6 @@ private val DarkColorScheme = darkColorScheme(
surface = Color.Black,
)


@Composable
fun MosaicTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
Expand Down

0 comments on commit e8b1177

Please sign in to comment.