Skip to content

Commit

Permalink
Merge pull request #17 from makeevrserg/develop
Browse files Browse the repository at this point in the history
Add towns preview
  • Loading branch information
makeevrserg authored Mar 9, 2024
2 parents 9c01d47 + c6b5024 commit 490bc9d
Show file tree
Hide file tree
Showing 64 changed files with 1,598 additions and 214 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,5 @@ modules/features/onboard/build
modules/features/ui/onboard/build
modules/features/ui/splash/build
modules/features/common/build
modules/features/ui/common/build
modules/features/ui/common/build
modules/features/towns/build
53 changes: 0 additions & 53 deletions LICENSE.md

This file was deleted.

7 changes: 2 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ org.gradle.parallel=true
kotlin.mpp.enableCInteropCommonization=true
org.jetbrains.compose.experimental.uikit.enabled=true
kotlin.native.binary.memoryModel=experimental
kotlin.native.enableDependencyPropagation=false
#kotlinOptions.useIR = true
kotlin.mpp.enableGranularSourceSetsMetadata=true
android.suppressUnsupportedCompileSdk=32
kotlin.mpp.androidSourceSetLayoutVersion=2
# Java
Expand All @@ -47,8 +44,8 @@ makeevrserg.android.sdk.target=34
# Project
makeevrserg.project.name=EmpireProjektMobile
makeevrserg.project.group=com.makeevrserg.empireprojekt.mobile
makeevrserg.project.version.string=0.2.4
makeevrserg.project.version.code=11
makeevrserg.project.version.string=0.3.0
makeevrserg.project.version.code=12
makeevrserg.project.description=EmpireProjekt mobile application
makeevrserg.project.developers=makeevrserg|Makeev Roman|makeevrserg@gmail.com
makeevrserg.project.url=https://empireprojekt.ru
Expand Down
16 changes: 11 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[versions]
# Kotlin
kotlin-version = "1.9.10"
kotlin-version = "1.9.22"
kotlin-dokka = "1.8.10"
kotlin-coroutines = "1.7.2"
kotlin-compilerExtensionVersion = "1.5.3"
kotlin-compilerExtensionVersion = "1.5.10"
kotlin-android-application = "8.0.1"
kotlin-serialization-json = "1.5.1"

# Androidx
androidx-lifecycle = "2.6.1"
androidx-lifecycle-ext = "2.2.0"
androidx-compose-bom = "2023.10.00"
androidx-compose-bom = "2024.02.02"
androidx-fragment = "1.6.1"
androidx-core = "1.10.1"
androidx-appcompat = "1.6.1"
Expand Down Expand Up @@ -50,12 +50,12 @@ ktor = "2.3.2-eap-692"
coil = "2.2.2"

# klibs
klibs-mikro = "1.0.0"
klibs-mikro = "1.5.0"
klibs-kstorage = "1.0.0"
klibs-kdi = "1.1.0"

# Compose
kotlin-compose = "1.5.3"
kotlin-compose = "1.6.0"

# Moko
moko-mvvm = "0.16.1"
Expand Down Expand Up @@ -90,8 +90,10 @@ dokka = "1.8.10"
# klibs
klibs-mikro-core = { module = "ru.astrainteractive.klibs:mikro-core", version.ref = "klibs-mikro" }
klibs-mikro-platform = { module = "ru.astrainteractive.klibs:mikro-platform", version.ref = "klibs-mikro" }
klibs-mikro-extensions = { module = "ru.astrainteractive.klibs:mikro-extensions", version.ref = "klibs-mikro" }
klibs-kstorage = { module = "ru.astrainteractive.klibs:kstorage", version.ref = "klibs-kstorage" }
klibs-kdi = { module = "ru.astrainteractive.klibs:kdi", version.ref = "klibs-kdi" }
klibs-paging = { module = "ru.astrainteractive.klibs:paging", version.strictly = "2.0.0" }
# dokka
dokka-android = { module = "org.jetbrains.dokka:android-documentation-plugin", version.ref = "dokka" }
dokka-gradle-plugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka" }
Expand Down Expand Up @@ -129,6 +131,7 @@ decompose-android = { module = "com.arkivanov.decompose:extensions-android", ver
essenty = { module = "com.arkivanov.essenty:lifecycle", version.ref = "essenty" }
# Kotlin
kotlin-gradlePlugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin-version" }
kotlin-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.strictly = "0.4.0" }
kotlin-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlin-coroutines" }
kotlin-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlin-coroutines" }
kotlin-coroutines-javafx = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-javafx", version.ref = "kotlin-coroutines" }
Expand Down Expand Up @@ -205,6 +208,9 @@ moko-resources-compose = { module = "dev.icerock.moko:resources-compose", versio
# Other
coil = { module = "io.coil-kt:coil-compose", version.ref = "coil" }

# Compose ext
composeext-shimmer = { module = "com.valentinilk.shimmer:compose-shimmer", version.strictly = "1.2.0" }

# Okio
okio = { module = "com.squareup.okio:okio", version.strictly = "3.3.0" }

Expand Down
2 changes: 1 addition & 1 deletion modules/features/rating/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ kotlin {
// Moko
implementation(libs.moko.resources.core)
// Paging
implementation("ru.astrainteractive.klibs:paging:1.0.0")
implementation(libs.klibs.paging)
// Coroutines
implementation(libs.kotlin.coroutines.core)
// MVIKotlin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,18 @@ class DefaultRatingUserComponent(
)

private fun collectPagingState() = coroutineFeature.launch {
repository.pagingStateFlow.collectLatest {
repository.state.collectLatest {
model.update { model ->
model.copy(
isLastPage = it.isLastPage,
isLoading = it.isLoading,
isFailure = it.isFailure
isFailure = it.isFailure,
items = it.items
)
}
}
}

private fun collectListStateFlow() = coroutineFeature.launch {
repository.listStateFlow.collectLatest {
model.update { model ->
model.copy(items = it)
}
}
}

override fun reset() {
coroutineFeature.launch {
repository.reset()
Expand All @@ -56,7 +49,6 @@ class DefaultRatingUserComponent(
}

override fun loadNextPage() {
println("LoadingNextPage")
coroutineFeature.launch {
repository.loadNextPage()
}
Expand All @@ -65,6 +57,5 @@ class DefaultRatingUserComponent(
init {
repository.updateRequest(model.value.request)
collectPagingState()
collectListStateFlow()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ package com.makeevrserg.empireprojekt.mobile.features.rating.user.data
import kotlinx.coroutines.flow.StateFlow
import ru.astrainteractive.empireapi.models.rating.RatingModel
import ru.astrainteractive.empireapi.models.rating.UserRatingsRequest
import ru.astrainteractive.klibs.paging.context.IntPageContext
import ru.astrainteractive.klibs.paging.state.PagingState

interface RatingUserRepository {

val pagingStateFlow: StateFlow<PagingState<Int>>

val listStateFlow: StateFlow<List<RatingModel>>
val state: StateFlow<PagingState<RatingModel, IntPageContext>>

suspend fun reset()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ package com.makeevrserg.empireprojekt.mobile.features.rating.user.data

import com.makeevrserg.empireprojekt.mobile.api.empireapi.RatingApi
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.withContext
import ru.astrainteractive.empireapi.models.rating.RatingModel
import ru.astrainteractive.empireapi.models.rating.UserRatingsRequest
import ru.astrainteractive.klibs.mikro.core.dispatchers.KotlinDispatchers
import ru.astrainteractive.klibs.paging.IntPagerCollector
import ru.astrainteractive.klibs.paging.context.IntPageContext
import ru.astrainteractive.klibs.paging.data.LambdaPagedListDataSource
import ru.astrainteractive.klibs.paging.state.PagingState

class RatingUserRepositoryImpl(
private val ratingApi: RatingApi,
Expand All @@ -19,13 +22,11 @@ class RatingUserRepositoryImpl(
private val pagingCollector = IntPagerCollector(
initialPage = 0,
pager = LambdaPagedListDataSource {
loadPage(it.pageDescriptor)
loadPage(it.pageContext.page)
}
)

override val pagingStateFlow = pagingCollector.pagingStateFlow

override val listStateFlow = pagingCollector.listStateFlow
override val state: StateFlow<PagingState<RatingModel, IntPageContext>> = pagingCollector.state

private suspend fun loadPage(page: Int): Result<List<RatingModel>> {
return runCatching {
Expand All @@ -44,8 +45,6 @@ class RatingUserRepositoryImpl(
}

override suspend fun loadNextPage() {
println("LoadingNextPage in repository")
println(pagingCollector.pagingStateFlow.value)
pagingCollector.loadNextPage()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package com.makeevrserg.empireprojekt.mobile.features.rating.users.data
import kotlinx.coroutines.flow.StateFlow
import ru.astrainteractive.empireapi.models.rating.RatingListRequest
import ru.astrainteractive.empireapi.models.rating.RatingUserModel
import ru.astrainteractive.klibs.paging.context.IntPageContext
import ru.astrainteractive.klibs.paging.state.PagingState

interface RatingUsersRepository {
fun updateRequest(request: RatingListRequest)
suspend fun loadNextPage()
suspend fun reset()
val pagingStateFlow: StateFlow<PagingState<Int>>
val listStateFlow: StateFlow<List<RatingUserModel>>
val state: StateFlow<PagingState<RatingUserModel, IntPageContext>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ package com.makeevrserg.empireprojekt.mobile.features.rating.users.data

import com.makeevrserg.empireprojekt.mobile.api.empireapi.RatingApi
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.withContext
import ru.astrainteractive.empireapi.models.rating.RatingListRequest
import ru.astrainteractive.empireapi.models.rating.RatingUserModel
import ru.astrainteractive.klibs.mikro.core.dispatchers.KotlinDispatchers
import ru.astrainteractive.klibs.paging.IntPagerCollector
import ru.astrainteractive.klibs.paging.context.IntPageContext
import ru.astrainteractive.klibs.paging.data.LambdaPagedListDataSource
import ru.astrainteractive.klibs.paging.state.PagingState

class RatingUsersRepositoryImpl(
private val ratingApi: RatingApi,
Expand All @@ -19,13 +22,11 @@ class RatingUsersRepositoryImpl(
private val pagingCollector = IntPagerCollector(
initialPage = 0,
pager = LambdaPagedListDataSource {
loadPage(it.pageDescriptor)
loadPage(it.pageContext.page)
}
)

override val pagingStateFlow = pagingCollector.pagingStateFlow

override val listStateFlow = pagingCollector.listStateFlow
override val state: StateFlow<PagingState<RatingUserModel, IntPageContext>> = pagingCollector.state

private suspend fun loadPage(page: Int): Result<List<RatingUserModel>> {
return runCatching {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ internal class RatingUsersBootstrapper(

override fun invoke() {
collectPagingState()
collectListStateFlow()
updateRequestModel()
}

Expand All @@ -22,14 +21,9 @@ internal class RatingUsersBootstrapper(
}

private fun collectPagingState() = scope.launch {
ratingUsersRepository.pagingStateFlow.collectLatest {
ratingUsersRepository.state.collectLatest {
Action.PagingStateChanged(it).run(::dispatch)
}
}

private fun collectListStateFlow() = scope.launch {
ratingUsersRepository.listStateFlow.collectLatest {
Action.ListChanged(it).run(::dispatch)
Action.ListChanged(it.items).run(::dispatch)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.makeevrserg.empireprojekt.mobile.features.rating.users.store.RatingUs
import com.makeevrserg.empireprojekt.mobile.features.rating.users.store.RatingUsersStore.State
import ru.astrainteractive.empireapi.models.rating.RatingListRequest
import ru.astrainteractive.empireapi.models.rating.RatingUserModel
import ru.astrainteractive.klibs.paging.context.IntPageContext
import ru.astrainteractive.klibs.paging.state.PagingState

interface RatingUsersStore : Store<Intent, State, Label> {
Expand All @@ -24,14 +25,14 @@ interface RatingUsersStore : Store<Intent, State, Label> {

sealed interface Message {
class ListChanged(val list: List<RatingUserModel>) : Message
class PagingStateChanged(val pagingState: PagingState<Int>) : Message
class PagingStateChanged(val pagingState: PagingState<RatingUserModel, IntPageContext>) : Message
}

object Label

sealed interface Action {
class ListChanged(val list: List<RatingUserModel>) : Action
class PagingStateChanged(val pagingState: PagingState<Int>) : Action
class PagingStateChanged(val pagingState: PagingState<RatingUserModel, IntPageContext>) : Action
data object UpdateRequestModel : Action
}
}
1 change: 1 addition & 0 deletions modules/features/root/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ kotlin {
api(projects.modules.features.rating)
api(projects.modules.features.theme)
api(projects.modules.features.status)
api(projects.modules.features.towns)
}
}
val androidMain by getting {
Expand Down
13 changes: 12 additions & 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.2.2'
spec.version = '0.3.0'
spec.homepage = 'https://empireprojekt.ru'
spec.source = { :http=> ''}
spec.authors = ''
Expand All @@ -11,6 +11,17 @@ Pod::Spec.new do |spec|
spec.ios.deployment_target = '16.0'


if !Dir.exist?('build/cocoapods/framework/Root.framework') || Dir.empty?('build/cocoapods/framework/Root.framework')
raise "
Kotlin framework 'Root' doesn't exist yet, so a proper Xcode project can't be generated.
'pod install' should be executed after running ':generateDummyFramework' Gradle task:
./gradlew :modules:features:root:generateDummyFramework
Alternatively, proper pod installation is performed during Gradle sync in the IDE (if Podfile location is set)"
end

spec.pod_target_xcconfig = {
'KOTLIN_PROJECT_PATH' => ':modules:features:root',
'PRODUCT_MODULE_NAME' => 'Root',
Expand Down
Loading

0 comments on commit 490bc9d

Please sign in to comment.