Нормальная модульная структура

This commit is contained in:
Roman Pytkov
2024-11-01 22:34:08 +03:00
parent b95666789c
commit 09210ff6f4
38 changed files with 381 additions and 49 deletions

View File

@@ -18,7 +18,8 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.github.nullptroma.wallenc.app.ui.theme.WallencTheme
import com.github.nullptroma.wallenc.presentation.screens.main.MainScreen
import com.github.nullptroma.wallenc.presentation.theme.WallencTheme
import com.yandex.authsdk.YandexAuthLoginOptions
import com.yandex.authsdk.YandexAuthOptions
import com.yandex.authsdk.YandexAuthResult
@@ -29,10 +30,10 @@ import dagger.hilt.android.AndroidEntryPoint
@AndroidEntryPoint
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
val sdk = YandexAuthSdk.create(YandexAuthOptions(applicationContext, true))
val launcher =
registerForActivityResult(sdk.contract) { result -> handleResult(result) }
@@ -41,9 +42,14 @@ class MainActivity : ComponentActivity() {
setContent {
WallencTheme {
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
Greeting(Modifier.padding(innerPadding)) {
launcher.launch(loginOptions)
}
// Greeting(Modifier.padding(innerPadding)) {
// launcher.launch(loginOptions)
// }
MainScreen(
Modifier.padding(
innerPadding
)
)
}
}
}
@@ -76,7 +82,7 @@ fun Greeting(modifier: Modifier = Modifier, onClick: () -> Unit) {
@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
WallencTheme {
com.github.nullptroma.wallenc.presentation.theme.WallencTheme {
Greeting(Modifier) {
}

View File

@@ -4,6 +4,4 @@ import android.app.Application
import dagger.hilt.android.HiltAndroidApp
@HiltAndroidApp
class WallencApplication : Application() {
}
class WallencApplication : Application()

View File

@@ -0,0 +1,21 @@
package com.github.nullptroma.wallenc.app.di.modules.domain
import com.github.nullptroma.wallenc.domain.models.IMetaInfo
import com.github.nullptroma.wallenc.domain.usecases.TestUseCase
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton
@Module
@InstallIn(SingletonComponent::class)
class UseCasesModule {
var count = 0
@Provides
@Singleton
fun provideTestUseCase(meta: IMetaInfo): TestUseCase {
return TestUseCase(meta, count++)
}
}

View File

@@ -1,27 +0,0 @@
package com.github.nullptroma.wallenc.app.ui.screens.main
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.imePadding
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.hilt.navigation.compose.hiltViewModel
@Composable
fun MainScreen(modifier: Modifier = Modifier, viewModel: MainViewModel = hiltViewModel()) {
val state = viewModel.stateFlow
Column(modifier = modifier.imePadding()) {
Text(text = state.value)
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.BottomCenter) {
TextField("", onValueChange = {
})
}
}
}

View File

@@ -1,3 +0,0 @@
package com.github.nullptroma.wallenc.app.ui.screens.main
data class MainScreenState(val value: String)

View File

@@ -1,11 +0,0 @@
package com.github.nullptroma.wallenc.app.ui.screens.main
import androidx.lifecycle.ViewModel
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
@HiltViewModel
class MainViewModel @Inject constructor(
): ViewModel() {
val stateFlow = MainScreenState("hello")
}

View File

@@ -1,11 +0,0 @@
package com.github.nullptroma.wallenc.app.ui.theme
import androidx.compose.ui.graphics.Color
val Purple80 = Color(0xFFD0BCFF)
val PurpleGrey80 = Color(0xFFCCC2DC)
val Pink80 = Color(0xFFEFB8C8)
val Purple40 = Color(0xFF6650a4)
val PurpleGrey40 = Color(0xFF625b71)
val Pink40 = Color(0xFF7D5260)

View File

@@ -1,57 +0,0 @@
package com.github.nullptroma.wallenc.app.ui.theme
import android.os.Build
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
private val DarkColorScheme = darkColorScheme(
primary = Purple80,
secondary = PurpleGrey80,
tertiary = Pink80
)
private val LightColorScheme = lightColorScheme(
primary = Purple40,
secondary = PurpleGrey40,
tertiary = Pink40
/* Other default colors to override
background = Color(0xFFFFFBFE),
surface = Color(0xFFFFFBFE),
onPrimary = Color.White,
onSecondary = Color.White,
onTertiary = Color.White,
onBackground = Color(0xFF1C1B1F),
onSurface = Color(0xFF1C1B1F),
*/
)
@Composable
fun WallencTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
// Dynamic color is available on Android 12+
dynamicColor: Boolean = true,
content: @Composable () -> Unit
) {
val colorScheme = when {
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
val context = LocalContext.current
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
}
darkTheme -> DarkColorScheme
else -> LightColorScheme
}
MaterialTheme(
colorScheme = colorScheme,
typography = Typography,
content = content
)
}

View File

@@ -1,34 +0,0 @@
package com.github.nullptroma.wallenc.app.ui.theme
import androidx.compose.material3.Typography
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp
// Set of Material typography styles to start with
val Typography = Typography(
bodyLarge = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 16.sp,
lineHeight = 24.sp,
letterSpacing = 0.5.sp
)
/* Other default text styles to override
titleLarge = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 22.sp,
lineHeight = 28.sp,
letterSpacing = 0.sp
),
labelSmall = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Medium,
fontSize = 11.sp,
lineHeight = 16.sp,
letterSpacing = 0.5.sp
)
*/
)