feat: add splash screen, structure for navigation and DI with hilt
This commit is contained in:
parent
a7c87fd9d3
commit
21f2338101
11 changed files with 111 additions and 38 deletions
|
@ -1,17 +1,23 @@
|
|||
import com.android.sdklib.AndroidVersion.ApiBaseExtension.BAKLAVA
|
||||
import com.android.sdklib.AndroidVersion.ApiBaseExtension.VANILLA_ICE_CREAM
|
||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.android.application)
|
||||
alias(libs.plugins.kotlin.android)
|
||||
alias(libs.plugins.kotlin.compose)
|
||||
alias(libs.plugins.hilt.android)
|
||||
alias(libs.plugins.ksp)
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "xyz.leomurca.csgomatches"
|
||||
compileSdk = 35
|
||||
compileSdk = VANILLA_ICE_CREAM.api
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "xyz.leomurca.csgomatches"
|
||||
minSdk = 26
|
||||
targetSdk = 35
|
||||
targetSdk = BAKLAVA.api
|
||||
versionCode = 1
|
||||
versionName = "1.0"
|
||||
|
||||
|
@ -31,8 +37,11 @@ android {
|
|||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = "11"
|
||||
|
||||
kotlin {
|
||||
compilerOptions {
|
||||
jvmTarget = JvmTarget.JVM_11
|
||||
}
|
||||
}
|
||||
buildFeatures {
|
||||
compose = true
|
||||
|
@ -49,6 +58,10 @@ dependencies {
|
|||
implementation(libs.androidx.ui.graphics)
|
||||
implementation(libs.androidx.ui.tooling.preview)
|
||||
implementation(libs.androidx.material3)
|
||||
implementation(libs.hilt.android)
|
||||
implementation(libs.androidx.navigation.compose)
|
||||
implementation(libs.androidx.core.splashscreen)
|
||||
ksp(libs.hilt.android.compiler)
|
||||
testImplementation(libs.junit)
|
||||
androidTestImplementation(libs.androidx.junit)
|
||||
androidTestImplementation(libs.androidx.espresso.core)
|
||||
|
|
|
@ -11,11 +11,11 @@
|
|||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.CSGOMatches"
|
||||
android:name=".CSGOApplication"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/Theme.CSGOMatches">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
package xyz.leomurca.csgomatches
|
||||
|
||||
import android.app.Application
|
||||
import dagger.hilt.android.HiltAndroidApp
|
||||
|
||||
@HiltAndroidApp
|
||||
class CSGOApplication: Application()
|
|
@ -4,44 +4,23 @@ import android.os.Bundle
|
|||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import xyz.leomurca.csgomatches.navigation.RootNavHost
|
||||
import xyz.leomurca.csgomatches.ui.theme.CSGOMatchesTheme
|
||||
|
||||
@AndroidEntryPoint
|
||||
class MainActivity : ComponentActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
installSplashScreen()
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
enableEdgeToEdge()
|
||||
setContent {
|
||||
CSGOMatchesTheme {
|
||||
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
|
||||
Greeting(
|
||||
name = "Android",
|
||||
modifier = Modifier.padding(innerPadding)
|
||||
)
|
||||
}
|
||||
RootNavHost()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun Greeting(name: String, modifier: Modifier = Modifier) {
|
||||
Text(
|
||||
text = "Hello $name!",
|
||||
modifier = modifier
|
||||
)
|
||||
}
|
||||
|
||||
@Preview(showBackground = true)
|
||||
@Composable
|
||||
fun GreetingPreview() {
|
||||
CSGOMatchesTheme {
|
||||
Greeting("Android")
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package xyz.leomurca.csgomatches.navigation
|
||||
|
||||
import androidx.navigation.NavGraphBuilder
|
||||
import androidx.navigation.compose.composable
|
||||
import xyz.leomurca.csgomatches.ui.main.MainScreen
|
||||
|
||||
const val MAIN_ROUTE = "main"
|
||||
|
||||
fun NavGraphBuilder.mainScreen() {
|
||||
composable(MAIN_ROUTE) {
|
||||
MainScreen()
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package xyz.leomurca.csgomatches.navigation
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.navigation.compose.NavHost
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
|
||||
@Composable
|
||||
fun RootNavHost() {
|
||||
val navController = rememberNavController()
|
||||
NavHost(
|
||||
navController = navController,
|
||||
startDestination = MAIN_ROUTE
|
||||
) {
|
||||
mainScreen()
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package xyz.leomurca.csgomatches.ui.main
|
||||
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.sp
|
||||
|
||||
@Composable
|
||||
fun MainScreen() {
|
||||
Box(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Text("Main Screen", fontSize = 24.sp)
|
||||
}
|
||||
}
|
9
app/src/main/res/values-v31/themes.xml
Normal file
9
app/src/main/res/values-v31/themes.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<style name="Theme.CSGOMatches" parent="android:Theme.Material.Light.NoActionBar">
|
||||
<item name="android:windowSplashScreenBackground">#161621</item>
|
||||
<item name="android:windowSplashScreenAnimatedIcon">@drawable/ic_launcher_foreground</item>
|
||||
<item name="android:windowSplashScreenIconBackgroundColor">#272639</item>
|
||||
</style>
|
||||
</resources>
|
|
@ -1,5 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<style name="Theme.CSGOMatches" parent="android:Theme.Material.Light.NoActionBar" />
|
||||
<style name="Theme.CSGOMatches" parent="android:Theme.Material.Light.NoActionBar">
|
||||
<item name="android:windowBackground">@color/ic_launcher_background</item>
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
<item name="android:windowFullscreen">true</item>
|
||||
</style>
|
||||
</resources>
|
|
@ -3,4 +3,6 @@ plugins {
|
|||
alias(libs.plugins.android.application) apply false
|
||||
alias(libs.plugins.kotlin.android) apply false
|
||||
alias(libs.plugins.kotlin.compose) apply false
|
||||
alias(libs.plugins.hilt.android) apply false
|
||||
alias(libs.plugins.ksp) apply false
|
||||
}
|
|
@ -1,13 +1,17 @@
|
|||
[versions]
|
||||
agp = "8.10.0"
|
||||
kotlin = "2.0.21"
|
||||
agp = "8.10.1"
|
||||
kotlin = "2.2.0"
|
||||
coreKtx = "1.16.0"
|
||||
junit = "4.13.2"
|
||||
junitVersion = "1.2.1"
|
||||
espressoCore = "3.6.1"
|
||||
lifecycleRuntimeKtx = "2.9.2"
|
||||
activityCompose = "1.10.1"
|
||||
composeBom = "2024.09.00"
|
||||
composeBom = "2025.07.00"
|
||||
hilt = "2.56.2"
|
||||
ksp = "2.2.0-2.0.2"
|
||||
navigation = "2.9.2"
|
||||
splashScreen = "1.0.1"
|
||||
|
||||
[libraries]
|
||||
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
||||
|
@ -24,9 +28,16 @@ androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-toolin
|
|||
androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
|
||||
androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
|
||||
androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
|
||||
hilt-android = { group = "com.google.dagger", name="hilt-android", version.ref = "hilt" }
|
||||
hilt-android-compiler = { group = "com.google.dagger", name = "hilt-android-compiler", version.ref = "hilt" }
|
||||
androidx-navigation-compose = { group = "androidx.navigation", name = "navigation-compose", version.ref = "navigation" }
|
||||
androidx-core-splashscreen = { group = "androidx.core", name = "core-splashscreen", version.ref = "splashScreen" }
|
||||
|
||||
[plugins]
|
||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
||||
kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
|
||||
hilt-android = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
|
||||
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue