Skip to content

Commit 0b62c88

Browse files
Merge pull request #28 from CodandoTV/feature/composeBase
[Issue-27] - Compose basics
2 parents 1797a44 + 58feac8 commit 0b62c88

File tree

9 files changed

+86
-13
lines changed

9 files changed

+86
-13
lines changed

app/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@file:Suppress("UnstableApiUsage")
12
android {
23
namespace = "${Config.packageName}app"
34

app/src/main/java/com/codandotv/streamplayerapp/MainActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ class MainActivity : ComponentActivity() {
1313
SplashScreen()
1414
}
1515
}
16-
}
16+
}

core-shared-ui/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ android {
1313
}
1414

1515
dependencies {
16+
implementation(platform(Dependencies.Compose.composeBomVersion))
17+
Dependencies.Compose.list.forEach { implementation(it) }
1618
Dependencies.Kotlin.list.forEach { implementation(it) }
1719
Dependencies.Support.list.forEach { implementation(it) }
1820
Dependencies.UnitTest.list.forEach { testImplementation(it) }
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.codandotv.streamplayerapp.core_shared_ui.resources
2+
3+
import androidx.compose.material3.darkColorScheme
4+
import androidx.compose.material3.lightColorScheme
5+
import androidx.compose.ui.graphics.Color
6+
7+
object Colors {
8+
9+
val LightColors = lightColorScheme(
10+
primary = Color(0xFF000000),
11+
)
12+
13+
val DarkColors = darkColorScheme(
14+
primary = Color(0xFF000000),
15+
)
16+
17+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.codandotv.streamplayerapp.core_shared_ui.theme
2+
3+
import android.content.res.Configuration
4+
import androidx.compose.material3.Surface
5+
import androidx.compose.runtime.Composable
6+
import androidx.compose.ui.tooling.preview.Preview
7+
8+
@Preview(
9+
name = "dark mode",
10+
group = "themes",
11+
uiMode = Configuration.UI_MODE_NIGHT_YES
12+
)
13+
@Preview(
14+
name = "light mode",
15+
group = "themes",
16+
uiMode = Configuration.UI_MODE_NIGHT_NO
17+
)
18+
annotation class ThemePreviews
19+
20+
@Composable
21+
fun ThemePreview(
22+
content: @Composable () -> Unit
23+
) {
24+
StreamPlayerTheme {
25+
Surface { content() }
26+
}
27+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.codandotv.streamplayerapp.core_shared_ui.theme
2+
3+
import androidx.compose.foundation.isSystemInDarkTheme
4+
import androidx.compose.material3.MaterialTheme
5+
import androidx.compose.runtime.Composable
6+
import com.codandotv.streamplayerapp.core_shared_ui.resources.Colors
7+
8+
@Composable
9+
fun StreamPlayerTheme(
10+
isDarkTheme: Boolean = isSystemInDarkTheme(),
11+
content: @Composable () -> Unit
12+
) {
13+
14+
MaterialTheme(
15+
colorScheme = getColorScheme(isDarkTheme),
16+
content = content
17+
)
18+
}
19+
20+
private fun getColorScheme(isDarkTheme: Boolean) =
21+
if (isDarkTheme) {
22+
Colors.LightColors
23+
} else {
24+
Colors.DarkColors
25+
}
26+
27+
28+

core-shared-ui/src/main/res/values-night/themes.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
1414
<!-- Customize your theme here. -->
1515
</style>
16-
</resources>
16+
</resources>

feature-list-streams/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ android {
1212

1313
dependencies {
1414
implementation(project(Dependencies.Module.core_networking))
15+
implementation(project(Dependencies.Module.core_shared_ui))
1516
implementation(Dependencies.Koin.koin)
1617
Dependencies.Retrofit.list.forEach { implementation(it) }
1718
Dependencies.Kotlin.list.forEach { implementation(it) }

feature-list-streams/src/main/java/com/codandotv/streamplayerapp/feature_list_streams/presentation/screens/ListStreamsScreen.kt

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,16 @@ package com.codandotv.streamplayerapp.feature_list_streams.presentation.screens
22

33
import androidx.compose.foundation.background
44
import androidx.compose.foundation.layout.Column
5-
import androidx.compose.foundation.layout.Row
65
import androidx.compose.foundation.layout.Spacer
76
import androidx.compose.foundation.layout.fillMaxSize
8-
import androidx.compose.foundation.layout.fillMaxWidth
97
import androidx.compose.foundation.layout.height
108
import androidx.compose.foundation.layout.padding
11-
import androidx.compose.foundation.layout.size
12-
import androidx.compose.foundation.lazy.LazyRow
13-
import androidx.compose.material3.Text
9+
import androidx.compose.material3.MaterialTheme
1410
import androidx.compose.runtime.Composable
1511
import androidx.compose.ui.Modifier
16-
import androidx.compose.ui.graphics.Color
17-
import androidx.compose.ui.tooling.preview.Preview
1812
import androidx.compose.ui.unit.dp
19-
import com.codandotv.streamplayerapp.feature_list_streams.presentation.widgets.StreamsCard
13+
import com.codandotv.streamplayerapp.core_shared_ui.theme.ThemePreview
14+
import com.codandotv.streamplayerapp.core_shared_ui.theme.ThemePreviews
2015
import com.codandotv.streamplayerapp.feature_list_streams.presentation.widgets.StreamsCardContent
2116
import com.codandotv.streamplayerapp.feature_list_streams.presentation.widgets.StreamsCarousel
2217

@@ -69,7 +64,7 @@ val streamsCategoryY = listOf(
6964
fun ListStreamsScreen() {
7065
Column(
7166
modifier = Modifier
72-
.background(Color.Black)
67+
.background(MaterialTheme.colorScheme.primary)
7368
.fillMaxSize()
7469
) {
7570
StreamsCarousel(
@@ -89,7 +84,9 @@ fun ListStreamsScreen() {
8984
}
9085

9186
@Composable
92-
@Preview
87+
@ThemePreviews
9388
fun ListStreamsScreenPreview() {
94-
ListStreamsScreen()
89+
ThemePreview {
90+
ListStreamsScreen()
91+
}
9592
}

0 commit comments

Comments
 (0)