Skip to content

Commit 393862c

Browse files
authored
feat(Demo): Update demo application
1 parent ec914e2 commit 393862c

File tree

140 files changed

+521
-16711
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+521
-16711
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</p>
77

88
<p align="center" style="font-size: 15px;">
9-
<strong>Mosaic</strong> is acollection of Jetpack Compose UI components and utilities. It is designed to accelerate the development process by providing a rich set of tools and components that are ready to use out of the box. These components are highly customizable ensuring to fit in your use case.
9+
<strong>Mosaic</strong> is a collection of Jetpack Compose UI components and utilities. It is designed to accelerate the development process by providing a rich set of tools and components that are ready to use out of the box. These components are highly customizable ensuring to fit in your use case.
1010
</p>
1111

1212

@@ -15,6 +15,7 @@
1515
### 🎛️ [Mosaic Slider](./slider/)
1616
Mosaic Slider is a highly customizable slider component that allows precise customization of values distribution and disabled ranges. Its API is similar to Material sliders, making it easy to integrate into existing projects.
1717

18+
![Disabled range](./docs/assets/example_disabled_range.gif)
1819

1920

2021
## Contributing

demo/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ dependencies {
4848
implementation(libs.androidx.lifecycle.runtime.ktx)
4949
implementation(libs.androidx.activity.compose)
5050
implementation(platform(libs.compose.bom))
51+
implementation(libs.androidx.navigation.compose)
5152
implementation(libs.compose.material3)
5253
testImplementation(libs.junit)
5354
androidTestImplementation(libs.androidx.junit)
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
package io.monstarlab.mosaic
2+
3+
import androidx.compose.foundation.Image
4+
import androidx.compose.foundation.layout.Arrangement
5+
import androidx.compose.foundation.layout.Column
6+
import androidx.compose.foundation.layout.Row
7+
import androidx.compose.foundation.layout.Spacer
8+
import androidx.compose.foundation.layout.aspectRatio
9+
import androidx.compose.foundation.layout.fillMaxSize
10+
import androidx.compose.foundation.layout.padding
11+
import androidx.compose.foundation.layout.size
12+
import androidx.compose.foundation.shape.RoundedCornerShape
13+
import androidx.compose.material3.ExperimentalMaterial3Api
14+
import androidx.compose.material3.Icon
15+
import androidx.compose.material3.MaterialTheme
16+
import androidx.compose.material3.Scaffold
17+
import androidx.compose.material3.Surface
18+
import androidx.compose.material3.Text
19+
import androidx.compose.material3.TopAppBar
20+
import androidx.compose.runtime.Composable
21+
import androidx.compose.ui.Alignment
22+
import androidx.compose.ui.Modifier
23+
import androidx.compose.ui.res.painterResource
24+
import androidx.compose.ui.text.style.TextAlign
25+
import androidx.compose.ui.tooling.preview.Preview
26+
import androidx.compose.ui.unit.dp
27+
28+
@OptIn(ExperimentalMaterial3Api::class)
29+
@Composable
30+
fun HomeScreen(
31+
onSliderClick: () -> Unit,
32+
onCarouselClick: () -> Unit,
33+
modifier: Modifier = Modifier,
34+
) = Scaffold(
35+
modifier = modifier,
36+
topBar = { TopAppBar(title = { Text(text = "Mosaic Demo") }) },
37+
) {
38+
Column(
39+
verticalArrangement = Arrangement.spacedBy(32.dp),
40+
modifier = Modifier
41+
.padding(it)
42+
.fillMaxSize()
43+
.padding(16.dp),
44+
) {
45+
Image(
46+
painter = painterResource(id = R.drawable.ic_mosaic_log),
47+
contentDescription = "logo",
48+
modifier = Modifier
49+
.size(150.dp)
50+
.align(Alignment.CenterHorizontally),
51+
)
52+
53+
Text(
54+
text = "Collection of Jetpack Compose UI components and utilities.",
55+
modifier = Modifier.align(Alignment.CenterHorizontally),
56+
textAlign = TextAlign.Center,
57+
)
58+
59+
Column {
60+
Row(
61+
horizontalArrangement = Arrangement.spacedBy(16.dp),
62+
modifier = Modifier,
63+
) {
64+
DemoButton(
65+
resource = R.drawable.ic_slider,
66+
text = "Slider",
67+
modifier = Modifier.weight(0.3f),
68+
onClick = onSliderClick,
69+
)
70+
71+
DemoButton(
72+
resource = R.drawable.ic_carousel,
73+
text = "Carousel",
74+
modifier = Modifier.weight(0.3f),
75+
onClick = onCarouselClick,
76+
)
77+
78+
Spacer(modifier = Modifier.weight(0.3f))
79+
}
80+
}
81+
}
82+
}
83+
84+
@Composable
85+
private fun DemoButton(
86+
resource: Int,
87+
text: String,
88+
onClick: () -> Unit,
89+
modifier: Modifier = Modifier,
90+
) {
91+
Surface(
92+
modifier = modifier.aspectRatio(1f),
93+
shape = RoundedCornerShape(16.dp),
94+
shadowElevation = 16.dp,
95+
tonalElevation = 2.dp,
96+
onClick = onClick,
97+
) {
98+
Column(verticalArrangement = Arrangement.SpaceBetween) {
99+
Spacer(modifier = Modifier)
100+
101+
Icon(
102+
painter = painterResource(id = resource),
103+
contentDescription = text,
104+
tint = MaterialTheme.colorScheme.primary,
105+
modifier = Modifier
106+
.size(60.dp)
107+
.align(Alignment.CenterHorizontally),
108+
)
109+
110+
Text(
111+
text = text,
112+
modifier = Modifier
113+
.align(Alignment.CenterHorizontally)
114+
.padding(bottom = 16.dp),
115+
style = MaterialTheme.typography.titleMedium,
116+
)
117+
}
118+
}
119+
}
120+
121+
@Preview
122+
@Composable
123+
private fun PreviewHomeScreen() {
124+
HomeScreen({}, {})
125+
}

demo/src/main/java/io/monstarlab/mosaic/MainActivity.kt

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import androidx.compose.material3.Text
88
import androidx.compose.runtime.Composable
99
import androidx.compose.ui.Modifier
1010
import androidx.compose.ui.tooling.preview.Preview
11-
import io.monstarlab.mosaic.features.SliderDemo
11+
import androidx.navigation.compose.NavHost
12+
import androidx.navigation.compose.composable
13+
import androidx.navigation.compose.rememberNavController
14+
import io.monstarlab.mosaic.demos.SliderDemo
1215
import io.monstarlab.mosaic.ui.theme.MosaicTheme
1316

1417
class MainActivity : ComponentActivity() {
@@ -17,7 +20,25 @@ class MainActivity : ComponentActivity() {
1720
enableEdgeToEdge()
1821
setContent {
1922
MosaicTheme {
20-
SliderDemo()
23+
val navController = rememberNavController()
24+
NavHost(
25+
navController = navController,
26+
startDestination = Routes.Home.value,
27+
) {
28+
composable(Routes.Home.value) {
29+
HomeScreen(
30+
onSliderClick = {
31+
navController.navigate(Routes.SliderDemo.value)
32+
},
33+
onCarouselClick = {
34+
},
35+
)
36+
}
37+
38+
composable(Routes.SliderDemo.value) {
39+
SliderDemo()
40+
}
41+
}
2142
}
2243
}
2344
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package io.monstarlab.mosaic
2+
3+
enum class Routes(val value: String) {
4+
Home("home"),
5+
SliderDemo("slider-demo"),
6+
}

0 commit comments

Comments
 (0)