From f6888eeb1852dc4037cbbd1c2276ccca32fe7c6c Mon Sep 17 00:00:00 2001 From: Nymos Date: Tue, 18 Feb 2025 18:10:41 +0300 Subject: [PATCH] Integrate hilt --- presentation/build.gradle.kts | 4 +-- presentation/src/main/AndroidManifest.xml | 2 +- .../java/com/nto/presentation/MainActivity.kt | 30 ++++--------------- .../main/java/com/nto/presentation/di/App.kt | 7 +++++ .../nto/presentation/{ui => }/theme/Color.kt | 2 +- .../nto/presentation/{ui => }/theme/Theme.kt | 3 +- .../nto/presentation/{ui => }/theme/Type.kt | 2 +- 7 files changed, 18 insertions(+), 32 deletions(-) create mode 100644 presentation/src/main/java/com/nto/presentation/di/App.kt rename presentation/src/main/java/com/nto/presentation/{ui => }/theme/Color.kt (86%) rename presentation/src/main/java/com/nto/presentation/{ui => }/theme/Theme.kt (96%) rename presentation/src/main/java/com/nto/presentation/{ui => }/theme/Type.kt (96%) diff --git a/presentation/build.gradle.kts b/presentation/build.gradle.kts index 83b5f0e..40c7d65 100644 --- a/presentation/build.gradle.kts +++ b/presentation/build.gradle.kts @@ -8,12 +8,12 @@ plugins { android { namespace = "com.nto.presentation" - compileSdk = 34 + compileSdk = 35 defaultConfig { applicationId = "com.nto.presentation" minSdk = 28 - targetSdk = 34 + targetSdk = 35 versionCode = 1 versionName = "1.0" diff --git a/presentation/src/main/AndroidManifest.xml b/presentation/src/main/AndroidManifest.xml index 174b703..df16903 100644 --- a/presentation/src/main/AndroidManifest.xml +++ b/presentation/src/main/AndroidManifest.xml @@ -7,11 +7,11 @@ android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" + android:name=".di.App" android:theme="@style/Theme.Onomatopoeiafront"> diff --git a/presentation/src/main/java/com/nto/presentation/MainActivity.kt b/presentation/src/main/java/com/nto/presentation/MainActivity.kt index 2867186..aa9d469 100644 --- a/presentation/src/main/java/com/nto/presentation/MainActivity.kt +++ b/presentation/src/main/java/com/nto/presentation/MainActivity.kt @@ -5,14 +5,13 @@ 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 com.nto.presentation.ui.theme.OnomatopoeiafrontTheme +import com.nto.presentation.theme.OnomatopoeiafrontTheme +import dagger.hilt.android.AndroidEntryPoint + +@AndroidEntryPoint class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -20,28 +19,9 @@ class MainActivity : ComponentActivity() { setContent { OnomatopoeiafrontTheme { Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding -> - Greeting( - name = "Android", - modifier = Modifier.padding(innerPadding) - ) + } } } } } - -@Composable -fun Greeting(name: String, modifier: Modifier = Modifier) { - Text( - text = "Hello $name!", - modifier = modifier - ) -} - -@Preview(showBackground = true) -@Composable -fun GreetingPreview() { - OnomatopoeiafrontTheme { - Greeting("Android") - } -} \ No newline at end of file diff --git a/presentation/src/main/java/com/nto/presentation/di/App.kt b/presentation/src/main/java/com/nto/presentation/di/App.kt new file mode 100644 index 0000000..e238686 --- /dev/null +++ b/presentation/src/main/java/com/nto/presentation/di/App.kt @@ -0,0 +1,7 @@ +package com.nto.presentation.di + +import android.app.Application +import dagger.hilt.android.HiltAndroidApp + +@HiltAndroidApp +class App: Application() \ No newline at end of file diff --git a/presentation/src/main/java/com/nto/presentation/ui/theme/Color.kt b/presentation/src/main/java/com/nto/presentation/theme/Color.kt similarity index 86% rename from presentation/src/main/java/com/nto/presentation/ui/theme/Color.kt rename to presentation/src/main/java/com/nto/presentation/theme/Color.kt index 7bbee5e..e6a8074 100644 --- a/presentation/src/main/java/com/nto/presentation/ui/theme/Color.kt +++ b/presentation/src/main/java/com/nto/presentation/theme/Color.kt @@ -1,4 +1,4 @@ -package com.nto.presentation.ui.theme +package com.nto.presentation.theme import androidx.compose.ui.graphics.Color diff --git a/presentation/src/main/java/com/nto/presentation/ui/theme/Theme.kt b/presentation/src/main/java/com/nto/presentation/theme/Theme.kt similarity index 96% rename from presentation/src/main/java/com/nto/presentation/ui/theme/Theme.kt rename to presentation/src/main/java/com/nto/presentation/theme/Theme.kt index 2471759..91e489a 100644 --- a/presentation/src/main/java/com/nto/presentation/ui/theme/Theme.kt +++ b/presentation/src/main/java/com/nto/presentation/theme/Theme.kt @@ -1,6 +1,5 @@ -package com.nto.presentation.ui.theme +package com.nto.presentation.theme -import android.app.Activity import android.os.Build import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.material3.MaterialTheme diff --git a/presentation/src/main/java/com/nto/presentation/ui/theme/Type.kt b/presentation/src/main/java/com/nto/presentation/theme/Type.kt similarity index 96% rename from presentation/src/main/java/com/nto/presentation/ui/theme/Type.kt rename to presentation/src/main/java/com/nto/presentation/theme/Type.kt index c1255ab..21cfb3c 100644 --- a/presentation/src/main/java/com/nto/presentation/ui/theme/Type.kt +++ b/presentation/src/main/java/com/nto/presentation/theme/Type.kt @@ -1,4 +1,4 @@ -package com.nto.presentation.ui.theme +package com.nto.presentation.theme import androidx.compose.material3.Typography import androidx.compose.ui.text.TextStyle