Skip to content

Commit

Permalink
Merge pull request #5 from makeevrserg/develop
Browse files Browse the repository at this point in the history
App theme
  • Loading branch information
makeevrserg authored Aug 11, 2023
2 parents 3e88afc + dac08c1 commit 7b7c1e2
Show file tree
Hide file tree
Showing 23 changed files with 224 additions and 79 deletions.
2 changes: 0 additions & 2 deletions androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ dependencies {
implementation("androidx.compose.material:material")
implementation("androidx.compose.foundation:foundation")
implementation("androidx.compose.material:material")
// Accompanist
implementation(libs.google.accompanist.systemuicontroller)
// FireBase
implementation(platform(libs.google.firebase.bom))
implementation("com.google.firebase:firebase-auth-ktx")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.ModalBottomSheetLayout
import androidx.compose.runtime.getValue
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.core.view.WindowCompat
Expand Down Expand Up @@ -38,8 +39,8 @@ class MainActivity : ComponentActivity() {
val componentContext = defaultComponentContext()
val rootComponent = DefaultRootComponent(componentContext, rootModule, servicesModule)
val rootBottomSheetComponent = rootComponent.rootBottomSheetComponent

setContent {
TransparentBars()
val bottomSheetState = rememberSlotModalBottomSheetState(
rootBottomSheetComponent.childSlot,
onDismiss = rootBottomSheetComponent::dismissSlotChild
Expand All @@ -50,7 +51,7 @@ class MainActivity : ComponentActivity() {
}
}
}
ComposeApplication {
ComposeApplication(rootModule.themeSwitcher.value) {
ModalBottomSheetLayout(
sheetState = bottomSheetState.sheetState,
sheetContent = bottomSheetState.sheetContent.value,
Expand Down
9 changes: 5 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@ makeevrserg.java.source=11
makeevrserg.java.target=11
makeevrserg.java.ktarget=11
# Android
makeevrserg.android.sdk.compile=33
makeevrserg.android.sdk.compile=34
makeevrserg.android.sdk.min=21
makeevrserg.android.sdk.target=33
makeevrserg.android.sdk.target=34
# Project
makeevrserg.project.name=EmpireProjektMobile
makeevrserg.project.group=com.makeevrserg.empireprojekt.mobile
makeevrserg.project.version.string=0.0.2
makeevrserg.project.version.code=4
makeevrserg.project.version.string=0.0.3
makeevrserg.project.version.code=5
makeevrserg.project.description=EmpireProjekt mobile application
makeevrserg.project.developers=makeevrserg|Makeev Roman|[email protected]
makeevrserg.project.url=https://empireprojekt.ru
org.jetbrains.compose.ios.resources.sync=false
48 changes: 24 additions & 24 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,48 @@
# Kotlin
kotlin-version = "1.8.20"
kotlin-dokka = "1.8.10"
kotlin-coroutines = "1.6.4"
kotlin-coroutines = "1.7.2"
kotlin-compilerExtensionVersion = "1.4.5"
kotlin-android-application = "8.0.1"
kotlin-serialization-json = "1.5.0"
kotlin-serialization-json = "1.5.1"

# Androidx
androidx-lifecycle = "2.6.0"
androidx-lifecycle = "2.6.1"
androidx-lifecycle-ext = "2.2.0"
androidx-compose-bom = "2023.06.00"
androidx-fragment = "1.5.5"
androidx-core = "1.9.0"
androidx-fragment = "1.6.1"
androidx-core = "1.10.1"
androidx-appcompat = "1.6.1"
androidx-room = "2.5.1"
androidx-room = "2.5.2"
androidx-test-extJunit = "1.1.5"
androidx-navigation-compose = "2.5.3"
androidx-activity-compose = "1.6.1"
androidx-activity-ktx = "1.8.0-alpha02"
androidx-lifecycle-viewModelCompose = "2.6.0"
androidx-navigation-compose = "2.7.0"
androidx-activity-compose = "1.7.2"
androidx-activity-ktx = "1.8.0-alpha06"
androidx-lifecycle-viewModelCompose = "2.6.1"
androidx-constraintlayout-compose = "1.0.1"
androidx-constraintlayout-android = "2.1.4"
androidx-viewbinding = "7.4.2"
androidx-recyclerview = "1.3.0"
androidx-viewbinding = "8.1.0"
androidx-recyclerview = "1.3.1"
androidx-cicerone = "7.1"
leakcanary = "2.9.1"

# Google
google-coroutinesPlayServices = "1.6.4"
google-android-material = "1.8.0"
google-auth = "20.4.1"
google-ads = "21.5.0"
google-crashlytics = "2.9.0"
google-coroutinesPlayServices = "1.7.2"
google-android-material = "1.9.0"
google-auth = "20.6.0"
google-ads = "22.2.0"
google-crashlytics = "2.9.8"
google-services = "4.3.15"
google-accompanist = "0.31.0-alpha"
google-firebase-bom = "31.2.3"
google-firebase-bom = "32.2.2"

# Yandex
yandex-ads = "5.7.0"

# Testw
test-junit = "4.13.2"
tests-assertk = "0.25"
tests-turbine = "0.7.0"
tests-turbine = "1.0.0"

# Other
ktor = "2.3.2-eap-692"
Expand All @@ -58,16 +58,16 @@ klibs-kdi = "1.1.0"
kotlin-compose = "1.4.0"

# Moko
moko-mvvm = "0.15.0"
moko-resources = "0.22.3"
moko-network = "0.20.1"
moko-mvvm = "0.16.1"
moko-resources = "0.23.0"
moko-network = "0.21.0"

# Decompose
decompose = "2.0.0-beta-01"
decompose = "2.0.1"
essenty = "1.1.0"

# MVIKotlin
mvikotlin = "3.1.0"
mvikotlin = "3.2.1"

# lwjgl
lwjgl = "3.3.1"
Expand Down
16 changes: 15 additions & 1 deletion modules/features/root/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ plugins {
buildConfig {
className("BuildKonfig") // forces the class name. Defaults to 'BuildConfig'
packageName("${projectInfo.group}.shared") // forces the package. Defaults to '${project.group}'
buildConfigField("String", "VERSION_CODE", "\"${gradleProperty("project.version.code").integer}\"")
buildConfigField(
"String",
"VERSION_CODE",
"\"${gradleProperty("project.version.code").integer}\""
)
buildConfigField("String", "VERSION_NAME", "\"${projectInfo.versionString}\"")
}

Expand Down Expand Up @@ -89,11 +93,20 @@ kotlin {
implementation(libs.ktor.client.darwin)
}
}
val iosX64Main by getting {
resources.srcDirs("build/generated/moko/iosX64Main/src")
}
val iosArm64Main by getting {
resources.srcDirs("build/generated/moko/iosArm64Main/src")
}
}
}
android {
apply(plugin = "kotlin-parcelize")
namespace = "${projectInfo.group}.shared"
sourceSets {
getByName("main").java.srcDirs("build/generated/moko/androidMain/src")
}
}
dependencies {
// FireBase
Expand All @@ -102,6 +115,7 @@ dependencies {
implementation("com.google.firebase:firebase-common-ktx")
implementation("com.google.firebase:firebase-firestore-ktx")
implementation("com.google.firebase:firebase-messaging-ktx")
implementation(libs.klibs.kstorage)
implementation(libs.google.auth)
implementation(libs.kotlin.coroutines.playServices)
}
Expand Down
2 changes: 1 addition & 1 deletion modules/features/root/root.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = 'root'
spec.version = '0.0.2'
spec.version = '0.0.3'
spec.homepage = 'https://empireprojekt.ru'
spec.source = { :http=> ''}
spec.authors = ''
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.makeevrserg.empireprojekt.mobile.features.root.di.factories

import com.russhwolf.settings.Settings
import com.russhwolf.settings.SharedPreferencesSettings
import ru.astrainteractive.klibs.kdi.Factory
import ru.astrainteractive.klibs.mikro.platform.PlatformConfiguration

Expand All @@ -9,6 +10,6 @@ actual class SettingsFactory actual constructor(
private val configuration: PlatformConfiguration
) : Factory<Settings> {
override fun create(): Settings {
TODO()
return SharedPreferencesSettings.Factory(configuration.applicationContext).create("SETTINGS")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,19 @@ import com.makeevrserg.empireprojekt.mobile.features.root.di.impl.status.StatusM
import com.makeevrserg.empireprojekt.mobile.features.status.DefaultMinecraftStatusComponent
import com.makeevrserg.empireprojekt.mobile.features.status.StatusComponent
import com.makeevrserg.empireprojekt.mobile.features.status.UrlStatusComponent
import com.makeevrserg.empireprojekt.mobile.features.theme.ThemeSwitcher
import com.makeevrserg.empireprojekt.mobile.services.core.CoroutineFeature

class DefaultRootComponent(
componentContext: ComponentContext,
rootModule: RootModule,
servicesModule: ServicesModule
) : RootComponent, ComponentContext by componentContext {
override val rootBottomSheetComponent: RootBottomSheetComponent = DefaultRootBottomSheetComponent(
componentContext = childContext("RootBottomSheetComponent"),
servicesModule = servicesModule,
)
override val rootBottomSheetComponent: RootBottomSheetComponent =
DefaultRootBottomSheetComponent(
componentContext = childContext("RootBottomSheetComponent"),
servicesModule = servicesModule,
)
private val navigation = StackNavigation<RootComponent.Child>()

override val childStack: Value<ChildStack<*, Configuration>> = childStack(
Expand Down Expand Up @@ -98,6 +100,7 @@ class DefaultRootComponent(
}
)
Configuration.Status(
themeSwitcher = rootModule.themeSwitcher.value,
statusComponents = listOf(
esmpStatusComponent,
ainteractiveStatusComponent,
Expand Down Expand Up @@ -133,6 +136,9 @@ class DefaultRootComponent(
val splashComponent: SplashComponent
) : Configuration

class Status(val statusComponents: List<StatusComponent>) : Configuration
class Status(
val statusComponents: List<StatusComponent>,
val themeSwitcher: ThemeSwitcher
) : Configuration
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package com.makeevrserg.empireprojekt.mobile.features.root.di

import com.makeevrserg.empireprojekt.mobile.features.root.di.impl.root.RootModuleImpl
import com.makeevrserg.empireprojekt.mobile.features.theme.ThemeSwitcher
import com.russhwolf.settings.Settings
import kotlinx.coroutines.CoroutineScope
import ru.astrainteractive.klibs.kdi.ExperimentalKDIApi
import ru.astrainteractive.klibs.kdi.Module
import ru.astrainteractive.klibs.kdi.Single
import ru.astrainteractive.klibs.kdi.WiredModule
import ru.astrainteractive.klibs.mikro.core.dispatchers.KotlinDispatchers

@OptIn(ExperimentalKDIApi::class)
interface RootModule : WiredModule {
interface RootModule : Module {
val servicesModule: ServicesModule

val settings: Single<Settings>
val dispatchers: Single<KotlinDispatchers>
val mainScope: Single<CoroutineScope>
val themeSwitcher: Single<ThemeSwitcher>

companion object : RootModule by RootModuleImpl
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ package com.makeevrserg.empireprojekt.mobile.features.root.di
import com.makeevrserg.empireprojekt.mobile.services.core.LinkBrowser
import io.ktor.client.HttpClient
import kotlinx.serialization.json.Json
import ru.astrainteractive.klibs.kdi.ExperimentalKDIApi
import ru.astrainteractive.klibs.kdi.Lateinit
import ru.astrainteractive.klibs.kdi.Module
import ru.astrainteractive.klibs.kdi.Single
import ru.astrainteractive.klibs.kdi.WiredModule
import ru.astrainteractive.klibs.mikro.platform.PlatformConfiguration

@OptIn(ExperimentalKDIApi::class)
interface ServicesModule : WiredModule {
interface ServicesModule : Module {
val platformConfiguration: Lateinit<PlatformConfiguration>
val jsonConfiguration: Single<Json>
val httpClient: Single<HttpClient>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,32 @@ package com.makeevrserg.empireprojekt.mobile.features.root.di.impl.root

import com.makeevrserg.empireprojekt.mobile.features.root.di.RootModule
import com.makeevrserg.empireprojekt.mobile.features.root.di.factories.SettingsFactory
import com.makeevrserg.empireprojekt.mobile.features.theme.ThemeSwitcher
import com.makeevrserg.empireprojekt.mobile.features.theme.ThemeSwitcherComponent
import kotlinx.coroutines.MainScope
import ru.astrainteractive.klibs.kdi.ExperimentalKDIApi
import ru.astrainteractive.klibs.kdi.Single
import ru.astrainteractive.klibs.kdi.WiredModule
import ru.astrainteractive.klibs.kdi.getValue
import ru.astrainteractive.klibs.mikro.core.dispatchers.DefaultKotlinDispatchers
import ru.astrainteractive.klibs.mikro.core.dispatchers.KotlinDispatchers

@OptIn(ExperimentalKDIApi::class)
internal object RootModuleImpl : RootModule, WiredModule by WiredModule.Default() {
internal object RootModuleImpl : RootModule {
override val servicesModule by Single {
ServicesModuleImpl()
}

override val settings = Single {
val configuration by servicesModule.platformConfiguration
SettingsFactory(configuration).create()
}.remember()
}

override val dispatchers = Single<KotlinDispatchers> {
DefaultKotlinDispatchers
}.remember()
}

override val mainScope = Single {
MainScope()
}.remember()
}
override val themeSwitcher: Single<ThemeSwitcher> = Single {
ThemeSwitcherComponent(settings.value)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@ import io.ktor.client.HttpClient
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
import io.ktor.serialization.kotlinx.json.json
import kotlinx.serialization.json.Json
import ru.astrainteractive.klibs.kdi.ExperimentalKDIApi
import ru.astrainteractive.klibs.kdi.Lateinit
import ru.astrainteractive.klibs.kdi.Single
import ru.astrainteractive.klibs.kdi.WiredModule
import ru.astrainteractive.klibs.kdi.getValue
import ru.astrainteractive.klibs.mikro.platform.PlatformConfiguration

@OptIn(ExperimentalKDIApi::class)
internal class ServicesModuleImpl : ServicesModule, WiredModule by WiredModule.Default() {
internal class ServicesModuleImpl : ServicesModule {
override val platformConfiguration = Lateinit<PlatformConfiguration>()

override val jsonConfiguration = Single {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.makeevrserg.empireprojekt.mobile.features.theme

import kotlinx.coroutines.flow.StateFlow

interface ThemeSwitcher {
val theme: StateFlow<Theme>

enum class Theme {
DARK, LIGHT
}

fun selectDarkTheme()
fun selectLightTheme()
fun selectTheme(theme: Theme)
}
Loading

0 comments on commit 7b7c1e2

Please sign in to comment.