Skip to content

Commit 1740c87

Browse files
authored
Merge pull request #10 from blocoio/splash-screen
Implement splash screen with light and dark mode
2 parents b9acbf9 + 9bcfcc6 commit 1740c87

6 files changed

Lines changed: 21 additions & 3 deletions

File tree

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
android:icon="@mipmap/ic_launcher"
1717
android:label="@string/app_name"
1818
android:supportsRtl="true"
19-
android:theme="@style/Theme.Snowflake">
19+
android:theme="@style/Theme.Snowflake.Splash">
2020
<activity
2121
android:name=".ui.MainActivity"
2222
android:exported="true"

app/src/main/java/io/bloco/snowflake/ui/MainActivity.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import androidx.compose.runtime.remember
2525
import androidx.compose.ui.Modifier
2626
import androidx.compose.ui.platform.LocalLayoutDirection
2727
import androidx.core.net.toUri
28+
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
2829
import androidx.lifecycle.compose.collectAsStateWithLifecycle
2930
import androidx.lifecycle.viewmodel.compose.viewModel
3031
import androidx.navigation.compose.rememberNavController
@@ -36,6 +37,7 @@ class MainActivity : ComponentActivity() {
3637
private val dependencies by lazy { (applicationContext as App).dependencies }
3738

3839
override fun onCreate(savedInstanceState: Bundle?) {
40+
installSplashScreen()
3941
super.onCreate(savedInstanceState)
4042
enableEdgeToEdge()
4143

app/src/main/java/io/bloco/snowflake/ui/home/HomeScreen.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,9 @@ private fun Stats(
232232
} else {
233233
stringResource(R.string.snowflake_looking_to_help)
234234
}
235-
} else null,
235+
} else {
236+
null
237+
},
236238
)
237239
StatsCell(
238240
title = stringResource(R.string.snowflake_stats_connections),
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<style name="Theme.Snowflake.Splash" parent="Theme.SplashScreen.IconBackground">
4+
<item name="windowSplashScreenBackground">#FF000000</item>
5+
<item name="postSplashScreenTheme">@style/Theme.Snowflake</item>
6+
</style>
7+
<style name="Theme.Snowflake" parent="android:Theme.Material.NoActionBar" />
8+
</resources>

app/src/main/res/values/themes.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
3+
<style name="Theme.Snowflake.Splash" parent="Theme.SplashScreen.IconBackground">
4+
<item name="windowSplashScreenBackground">#FFF5EDDD</item>
5+
<item name="postSplashScreenTheme">@style/Theme.Snowflake</item>
6+
</style>
37
<style name="Theme.Snowflake" parent="android:Theme.Material.Light.NoActionBar" />
4-
</resources>
8+
</resources>

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ androidx-compose-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-
3636
androidx-compose-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
3737
androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3" }
3838
androidx-compose-material3-adaptive = { group = "androidx.compose.material3.adaptive", name = "adaptive" }
39+
androidx-splash = { group = "androidx.core", name = "core-splashscreen", version = "1.2.0" }
3940
androidx-lifecycle-process = { group = "androidx.lifecycle", name = "lifecycle-process", version.ref = "lifecycleProcess" }
4041
androidx-navigation = { group = "androidx.navigation", name = "navigation-compose", version = "2.9.8" }
4142
androidx-work = { group = "androidx.work", name = "work-runtime-ktx", version = "2.11.2" }
@@ -71,6 +72,7 @@ androidx = [
7172
"androidx-compose-ui-test-junit4",
7273
"androidx-compose-material3",
7374
"androidx-compose-material3-adaptive",
75+
"androidx-splash",
7476
"androidx-lifecycle-process",
7577
"androidx-navigation",
7678
"androidx-work",

0 commit comments

Comments
 (0)