Skip to content

Commit 0d3dc49

Browse files
authored
Merge pull request #33 from avidraghav/feature/splash_screen
Implement Splash Screen
2 parents 592ddc1 + 87387cc commit 0d3dc49

File tree

7 files changed

+30
-176
lines changed

7 files changed

+30
-176
lines changed

app/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ dependencies {
107107
// Navigation with Hilt and Compose
108108
implementation(libs.hilt.navigation)
109109

110+
// Splash Screen
111+
implementation(libs.splashscreen.core)
112+
113+
// Test Dependencies
110114
testImplementation(libs.test.junit)
111115
androidTestImplementation(libs.androidx.test.extensions)
112116
androidTestImplementation(libs.androidx.expresso.core)

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
android:label="@string/app_name"
1717
android:roundIcon="@mipmap/ic_launcher_round"
1818
android:supportsRtl="true"
19-
android:theme="@style/Theme.SpaceDawn"
19+
android:theme="@style/Theme.SpaceDawn.Splash"
2020
tools:targetApi="31">
2121
<activity
2222
android:name=".ui.MainActivity"
2323
android:exported="true"
24-
android:theme="@style/Theme.SpaceDawn">
24+
android:theme="@style/Theme.SpaceDawn.Splash">
2525
<intent-filter>
2626
<action android:name="android.intent.action.MAIN" />
2727

app/src/main/java/com/raghav/spacedawnv2/ui/MainActivity.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import androidx.compose.animation.AnimatedContentTransitionScope
88
import androidx.compose.foundation.layout.RowScope
99
import androidx.compose.foundation.layout.fillMaxSize
1010
import androidx.compose.foundation.layout.padding
11-
import androidx.compose.material3.ExperimentalMaterial3Api
1211
import androidx.compose.material3.Icon
1312
import androidx.compose.material3.MaterialTheme
1413
import androidx.compose.material3.NavigationBar
@@ -29,6 +28,7 @@ import androidx.compose.ui.Modifier
2928
import androidx.compose.ui.platform.LocalContext
3029
import androidx.compose.ui.res.stringResource
3130
import androidx.compose.ui.tooling.preview.Preview
31+
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
3232
import androidx.navigation.NavDestination
3333
import androidx.navigation.NavDestination.Companion.hierarchy
3434
import androidx.navigation.NavHostController
@@ -52,6 +52,7 @@ import kotlinx.coroutines.launch
5252
class MainActivity : ComponentActivity() {
5353
override fun onCreate(savedInstanceState: Bundle?) {
5454
super.onCreate(savedInstanceState)
55+
installSplashScreen()
5556
setContent {
5657
SpaceDawnTheme {
5758
// A surface container using the 'background' color from the theme
@@ -66,7 +67,6 @@ class MainActivity : ComponentActivity() {
6667
}
6768
}
6869

69-
@OptIn(ExperimentalMaterial3Api::class)
7070
@Composable
7171
fun SpaceDawnApp(modifier: Modifier = Modifier) {
7272
val navController = rememberNavController()
@@ -86,6 +86,7 @@ fun SpaceDawnApp(modifier: Modifier = Modifier) {
8686
startDestination = LaunchesScreen.route,
8787
modifier = Modifier.padding(innerPadding)
8888
) {
89+
// Launches Screen
8990
composable(
9091
LaunchesScreen.route,
9192
enterTransition = {
@@ -128,6 +129,7 @@ fun SpaceDawnApp(modifier: Modifier = Modifier) {
128129
}
129130
)
130131
}
132+
// Reminders Screen
131133
composable(
132134
RemindersScreen.route,
133135
enterTransition = {

app/src/main/res/drawable/ic_launcher_background.xml

Lines changed: 0 additions & 170 deletions
This file was deleted.
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.SpaceDawn.Splash" parent="Theme.SplashScreen">
4+
<item name="windowSplashScreenBackground">@color/white</item>
5+
<item name="postSplashScreenTheme">@style/Theme.SpaceDawn</item>
6+
<item name="android:windowSplashScreenAnimatedIcon">@drawable/ic_launcher_foreground</item>
7+
</style>
8+
</resources>

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
3-
43
<style name="Theme.SpaceDawn" parent="android:Theme.Material.Light.NoActionBar" />
4+
<style name="Theme.SpaceDawn.Splash" parent="Theme.SplashScreen">
5+
<item name="windowSplashScreenBackground">@color/white</item>
6+
<item name="postSplashScreenTheme">@style/Theme.SpaceDawn</item>
7+
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_launcher_foreground</item>
8+
</style>
59
</resources>

gradle/libs.versions.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ coil = "2.4.0"
4141
# WorkManager
4242
workmanager = "2.8.1"
4343

44+
# Splash Screen
45+
splashscreen_core = "1.0.1"
46+
4447
# Quality
4548
ktlint = "11.5.0"
4649

@@ -100,6 +103,9 @@ coil = { module = "io.coil-kt:coil-compose", version.ref = "coil" }
100103
# WorkManager
101104
workmanager = { module = "androidx.work:work-runtime-ktx", version.ref = "workmanager" }
102105

106+
# Splash Screen
107+
splashscreen_core = { module = "androidx.core:core-splashscreen", version.ref = "splashscreen_core" }
108+
103109
# General dependencies
104110
kotlin_immutable_collections = { module = "org.jetbrains.kotlinx:kotlinx-collections-immutable", version = "0.3.5" }
105111
androidx_annotations = { module = "androidx.annotation:annotation", version = "1.6.0" }
@@ -124,7 +130,7 @@ kotlin_android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
124130
kotlin_jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
125131
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" }
126132
kotlin_kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" }
127-
hilt= { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
133+
hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
128134
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
129135
kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" }
130136
android_library = { id = "com.android.library", version.ref = "android_gradle_plugin" }

0 commit comments

Comments
 (0)