Skip to content

Commit

Permalink
Merge pull request #33 from avidraghav/feature/splash_screen
Browse files Browse the repository at this point in the history
Implement Splash Screen
  • Loading branch information
avidraghav authored Nov 17, 2023
2 parents 592ddc1 + 87387cc commit 0d3dc49
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 176 deletions.
4 changes: 4 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ dependencies {
// Navigation with Hilt and Compose
implementation(libs.hilt.navigation)

// Splash Screen
implementation(libs.splashscreen.core)

// Test Dependencies
testImplementation(libs.test.junit)
androidTestImplementation(libs.androidx.test.extensions)
androidTestImplementation(libs.androidx.expresso.core)
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.SpaceDawn"
android:theme="@style/Theme.SpaceDawn.Splash"
tools:targetApi="31">
<activity
android:name=".ui.MainActivity"
android:exported="true"
android:theme="@style/Theme.SpaceDawn">
android:theme="@style/Theme.SpaceDawn.Splash">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
6 changes: 4 additions & 2 deletions app/src/main/java/com/raghav/spacedawnv2/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import androidx.compose.animation.AnimatedContentTransitionScope
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.NavigationBar
Expand All @@ -29,6 +28,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.navigation.NavDestination
import androidx.navigation.NavDestination.Companion.hierarchy
import androidx.navigation.NavHostController
Expand All @@ -52,6 +52,7 @@ import kotlinx.coroutines.launch
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
installSplashScreen()
setContent {
SpaceDawnTheme {
// A surface container using the 'background' color from the theme
Expand All @@ -66,7 +67,6 @@ class MainActivity : ComponentActivity() {
}
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SpaceDawnApp(modifier: Modifier = Modifier) {
val navController = rememberNavController()
Expand All @@ -86,6 +86,7 @@ fun SpaceDawnApp(modifier: Modifier = Modifier) {
startDestination = LaunchesScreen.route,
modifier = Modifier.padding(innerPadding)
) {
// Launches Screen
composable(
LaunchesScreen.route,
enterTransition = {
Expand Down Expand Up @@ -128,6 +129,7 @@ fun SpaceDawnApp(modifier: Modifier = Modifier) {
}
)
}
// Reminders Screen
composable(
RemindersScreen.route,
enterTransition = {
Expand Down
170 changes: 0 additions & 170 deletions app/src/main/res/drawable/ic_launcher_background.xml

This file was deleted.

8 changes: 8 additions & 0 deletions app/src/main/res/values-v31/themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.SpaceDawn.Splash" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/white</item>
<item name="postSplashScreenTheme">@style/Theme.SpaceDawn</item>
<item name="android:windowSplashScreenAnimatedIcon">@drawable/ic_launcher_foreground</item>
</style>
</resources>
6 changes: 5 additions & 1 deletion app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="Theme.SpaceDawn" parent="android:Theme.Material.Light.NoActionBar" />
<style name="Theme.SpaceDawn.Splash" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/white</item>
<item name="postSplashScreenTheme">@style/Theme.SpaceDawn</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_launcher_foreground</item>
</style>
</resources>
8 changes: 7 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ coil = "2.4.0"
# WorkManager
workmanager = "2.8.1"

# Splash Screen
splashscreen_core = "1.0.1"

# Quality
ktlint = "11.5.0"

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

# Splash Screen
splashscreen_core = { module = "androidx.core:core-splashscreen", version.ref = "splashscreen_core" }

# General dependencies
kotlin_immutable_collections = { module = "org.jetbrains.kotlinx:kotlinx-collections-immutable", version = "0.3.5" }
androidx_annotations = { module = "androidx.annotation:annotation", version = "1.6.0" }
Expand All @@ -124,7 +130,7 @@ kotlin_android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin_jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" }
kotlin_kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" }
hilt= { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" }
android_library = { id = "com.android.library", version.ref = "android_gradle_plugin" }
Expand Down

0 comments on commit 0d3dc49

Please sign in to comment.