Skip to content

Commit 107388f

Browse files
refactor: auth module with loading animation (#2957)
1 parent 3d9ad2c commit 107388f

File tree

28 files changed

+408
-271
lines changed

28 files changed

+408
-271
lines changed

cmp-android/dependencies/demoDebugRuntimeClasspath.txt

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ com.russhwolf:multiplatform-settings-serialization:1.2.0
186186
com.russhwolf:multiplatform-settings:1.2.0
187187
com.squareup.okhttp3:okhttp-sse:4.12.0
188188
com.squareup.okhttp3:okhttp:4.12.0
189-
com.squareup.okio:okio-jvm:3.11.0
190-
com.squareup.okio:okio:3.11.0
189+
com.squareup.okio:okio-jvm:3.15.0
190+
com.squareup.okio:okio:3.15.0
191191
de.jensklingenberg.ktorfit:ktorfit-annotations-android-debug:2.2.0
192192
de.jensklingenberg.ktorfit:ktorfit-annotations:2.2.0
193193
de.jensklingenberg.ktorfit:ktorfit-lib-android-debug:2.2.0
@@ -211,6 +211,14 @@ io.coil-kt.coil3:coil-network-ktor3:3.0.4
211211
io.coil-kt.coil3:coil-svg-android:3.0.4
212212
io.coil-kt.coil3:coil-svg:3.0.4
213213
io.coil-kt.coil3:coil:3.2.0
214+
io.github.alexzhirkevich:compottie-core-android:2.0.0-rc05
215+
io.github.alexzhirkevich:compottie-core:2.0.0-rc05
216+
io.github.alexzhirkevich:compottie-lite-android:2.0.0-rc05
217+
io.github.alexzhirkevich:compottie-lite:2.0.0-rc05
218+
io.github.alexzhirkevich:compottie-resources-android:2.0.0-rc05
219+
io.github.alexzhirkevich:compottie-resources:2.0.0-rc05
220+
io.github.alexzhirkevich:keight-core-android:0.0.02
221+
io.github.alexzhirkevich:keight-core:0.0.02
214222
io.github.alexzhirkevich:qrose-android:1.0.1
215223
io.github.alexzhirkevich:qrose-core-android:1.0.1
216224
io.github.alexzhirkevich:qrose-core:1.0.1
@@ -333,15 +341,17 @@ org.jetbrains.kotlin:kotlin-reflect:2.1.0
333341
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.23
334342
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.20
335343
org.jetbrains.kotlin:kotlin-stdlib:2.1.21
344+
org.jetbrains.kotlinx:atomicfu-jvm:0.23.2
345+
org.jetbrains.kotlinx:atomicfu:0.23.2
336346
org.jetbrains.kotlinx:kotlinx-collections-immutable-jvm:0.3.8
337347
org.jetbrains.kotlinx:kotlinx-collections-immutable:0.3.8
338348
org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2
339349
org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.10.2
340350
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.10.2
341351
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2
342352
org.jetbrains.kotlinx:kotlinx-coroutines-slf4j:1.10.2
343-
org.jetbrains.kotlinx:kotlinx-datetime-jvm:0.6.2
344-
org.jetbrains.kotlinx:kotlinx-datetime:0.6.2
353+
org.jetbrains.kotlinx:kotlinx-datetime-jvm:0.7.1-0.6.x-compat
354+
org.jetbrains.kotlinx:kotlinx-datetime:0.7.1-0.6.x-compat
345355
org.jetbrains.kotlinx:kotlinx-io-bytestring-jvm:0.7.0
346356
org.jetbrains.kotlinx:kotlinx-io-bytestring:0.7.0
347357
org.jetbrains.kotlinx:kotlinx-io-core-jvm:0.7.0

cmp-android/dependencies/demoReleaseRuntimeClasspath.txt

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ com.russhwolf:multiplatform-settings-serialization:1.2.0
186186
com.russhwolf:multiplatform-settings:1.2.0
187187
com.squareup.okhttp3:okhttp-sse:4.12.0
188188
com.squareup.okhttp3:okhttp:4.12.0
189-
com.squareup.okio:okio-jvm:3.11.0
190-
com.squareup.okio:okio:3.11.0
189+
com.squareup.okio:okio-jvm:3.15.0
190+
com.squareup.okio:okio:3.15.0
191191
de.jensklingenberg.ktorfit:ktorfit-annotations-android:2.2.0
192192
de.jensklingenberg.ktorfit:ktorfit-annotations:2.2.0
193193
de.jensklingenberg.ktorfit:ktorfit-lib-android:2.2.0
@@ -211,6 +211,14 @@ io.coil-kt.coil3:coil-network-ktor3:3.0.4
211211
io.coil-kt.coil3:coil-svg-android:3.0.4
212212
io.coil-kt.coil3:coil-svg:3.0.4
213213
io.coil-kt.coil3:coil:3.2.0
214+
io.github.alexzhirkevich:compottie-core-android:2.0.0-rc05
215+
io.github.alexzhirkevich:compottie-core:2.0.0-rc05
216+
io.github.alexzhirkevich:compottie-lite-android:2.0.0-rc05
217+
io.github.alexzhirkevich:compottie-lite:2.0.0-rc05
218+
io.github.alexzhirkevich:compottie-resources-android:2.0.0-rc05
219+
io.github.alexzhirkevich:compottie-resources:2.0.0-rc05
220+
io.github.alexzhirkevich:keight-core-android:0.0.02
221+
io.github.alexzhirkevich:keight-core:0.0.02
214222
io.github.alexzhirkevich:qrose-android:1.0.1
215223
io.github.alexzhirkevich:qrose-core-android:1.0.1
216224
io.github.alexzhirkevich:qrose-core:1.0.1
@@ -330,15 +338,17 @@ org.jetbrains.kotlin:kotlin-reflect:2.1.0
330338
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.23
331339
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.20
332340
org.jetbrains.kotlin:kotlin-stdlib:2.1.21
341+
org.jetbrains.kotlinx:atomicfu-jvm:0.23.2
342+
org.jetbrains.kotlinx:atomicfu:0.23.2
333343
org.jetbrains.kotlinx:kotlinx-collections-immutable-jvm:0.3.8
334344
org.jetbrains.kotlinx:kotlinx-collections-immutable:0.3.8
335345
org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2
336346
org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.10.2
337347
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.10.2
338348
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2
339349
org.jetbrains.kotlinx:kotlinx-coroutines-slf4j:1.10.2
340-
org.jetbrains.kotlinx:kotlinx-datetime-jvm:0.6.2
341-
org.jetbrains.kotlinx:kotlinx-datetime:0.6.2
350+
org.jetbrains.kotlinx:kotlinx-datetime-jvm:0.7.1-0.6.x-compat
351+
org.jetbrains.kotlinx:kotlinx-datetime:0.7.1-0.6.x-compat
342352
org.jetbrains.kotlinx:kotlinx-io-bytestring-jvm:0.7.0
343353
org.jetbrains.kotlinx:kotlinx-io-bytestring:0.7.0
344354
org.jetbrains.kotlinx:kotlinx-io-core-jvm:0.7.0

cmp-android/dependencies/prodDebugRuntimeClasspath.txt

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ com.russhwolf:multiplatform-settings-serialization:1.2.0
186186
com.russhwolf:multiplatform-settings:1.2.0
187187
com.squareup.okhttp3:okhttp-sse:4.12.0
188188
com.squareup.okhttp3:okhttp:4.12.0
189-
com.squareup.okio:okio-jvm:3.11.0
190-
com.squareup.okio:okio:3.11.0
189+
com.squareup.okio:okio-jvm:3.15.0
190+
com.squareup.okio:okio:3.15.0
191191
de.jensklingenberg.ktorfit:ktorfit-annotations-android-debug:2.2.0
192192
de.jensklingenberg.ktorfit:ktorfit-annotations:2.2.0
193193
de.jensklingenberg.ktorfit:ktorfit-lib-android-debug:2.2.0
@@ -211,6 +211,14 @@ io.coil-kt.coil3:coil-network-ktor3:3.0.4
211211
io.coil-kt.coil3:coil-svg-android:3.0.4
212212
io.coil-kt.coil3:coil-svg:3.0.4
213213
io.coil-kt.coil3:coil:3.2.0
214+
io.github.alexzhirkevich:compottie-core-android:2.0.0-rc05
215+
io.github.alexzhirkevich:compottie-core:2.0.0-rc05
216+
io.github.alexzhirkevich:compottie-lite-android:2.0.0-rc05
217+
io.github.alexzhirkevich:compottie-lite:2.0.0-rc05
218+
io.github.alexzhirkevich:compottie-resources-android:2.0.0-rc05
219+
io.github.alexzhirkevich:compottie-resources:2.0.0-rc05
220+
io.github.alexzhirkevich:keight-core-android:0.0.02
221+
io.github.alexzhirkevich:keight-core:0.0.02
214222
io.github.alexzhirkevich:qrose-android:1.0.1
215223
io.github.alexzhirkevich:qrose-core-android:1.0.1
216224
io.github.alexzhirkevich:qrose-core:1.0.1
@@ -333,15 +341,17 @@ org.jetbrains.kotlin:kotlin-reflect:2.1.0
333341
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.23
334342
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.20
335343
org.jetbrains.kotlin:kotlin-stdlib:2.1.21
344+
org.jetbrains.kotlinx:atomicfu-jvm:0.23.2
345+
org.jetbrains.kotlinx:atomicfu:0.23.2
336346
org.jetbrains.kotlinx:kotlinx-collections-immutable-jvm:0.3.8
337347
org.jetbrains.kotlinx:kotlinx-collections-immutable:0.3.8
338348
org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2
339349
org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.10.2
340350
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.10.2
341351
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2
342352
org.jetbrains.kotlinx:kotlinx-coroutines-slf4j:1.10.2
343-
org.jetbrains.kotlinx:kotlinx-datetime-jvm:0.6.2
344-
org.jetbrains.kotlinx:kotlinx-datetime:0.6.2
353+
org.jetbrains.kotlinx:kotlinx-datetime-jvm:0.7.1-0.6.x-compat
354+
org.jetbrains.kotlinx:kotlinx-datetime:0.7.1-0.6.x-compat
345355
org.jetbrains.kotlinx:kotlinx-io-bytestring-jvm:0.7.0
346356
org.jetbrains.kotlinx:kotlinx-io-bytestring:0.7.0
347357
org.jetbrains.kotlinx:kotlinx-io-core-jvm:0.7.0

cmp-android/dependencies/prodReleaseRuntimeClasspath.txt

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ com.russhwolf:multiplatform-settings-serialization:1.2.0
186186
com.russhwolf:multiplatform-settings:1.2.0
187187
com.squareup.okhttp3:okhttp-sse:4.12.0
188188
com.squareup.okhttp3:okhttp:4.12.0
189-
com.squareup.okio:okio-jvm:3.11.0
190-
com.squareup.okio:okio:3.11.0
189+
com.squareup.okio:okio-jvm:3.15.0
190+
com.squareup.okio:okio:3.15.0
191191
de.jensklingenberg.ktorfit:ktorfit-annotations-android:2.2.0
192192
de.jensklingenberg.ktorfit:ktorfit-annotations:2.2.0
193193
de.jensklingenberg.ktorfit:ktorfit-lib-android:2.2.0
@@ -211,6 +211,14 @@ io.coil-kt.coil3:coil-network-ktor3:3.0.4
211211
io.coil-kt.coil3:coil-svg-android:3.0.4
212212
io.coil-kt.coil3:coil-svg:3.0.4
213213
io.coil-kt.coil3:coil:3.2.0
214+
io.github.alexzhirkevich:compottie-core-android:2.0.0-rc05
215+
io.github.alexzhirkevich:compottie-core:2.0.0-rc05
216+
io.github.alexzhirkevich:compottie-lite-android:2.0.0-rc05
217+
io.github.alexzhirkevich:compottie-lite:2.0.0-rc05
218+
io.github.alexzhirkevich:compottie-resources-android:2.0.0-rc05
219+
io.github.alexzhirkevich:compottie-resources:2.0.0-rc05
220+
io.github.alexzhirkevich:keight-core-android:0.0.02
221+
io.github.alexzhirkevich:keight-core:0.0.02
214222
io.github.alexzhirkevich:qrose-android:1.0.1
215223
io.github.alexzhirkevich:qrose-core-android:1.0.1
216224
io.github.alexzhirkevich:qrose-core:1.0.1
@@ -330,15 +338,17 @@ org.jetbrains.kotlin:kotlin-reflect:2.1.0
330338
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.23
331339
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.20
332340
org.jetbrains.kotlin:kotlin-stdlib:2.1.21
341+
org.jetbrains.kotlinx:atomicfu-jvm:0.23.2
342+
org.jetbrains.kotlinx:atomicfu:0.23.2
333343
org.jetbrains.kotlinx:kotlinx-collections-immutable-jvm:0.3.8
334344
org.jetbrains.kotlinx:kotlinx-collections-immutable:0.3.8
335345
org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2
336346
org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.10.2
337347
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.10.2
338348
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2
339349
org.jetbrains.kotlinx:kotlinx-coroutines-slf4j:1.10.2
340-
org.jetbrains.kotlinx:kotlinx-datetime-jvm:0.6.2
341-
org.jetbrains.kotlinx:kotlinx-datetime:0.6.2
350+
org.jetbrains.kotlinx:kotlinx-datetime-jvm:0.7.1-0.6.x-compat
351+
org.jetbrains.kotlinx:kotlinx-datetime:0.7.1-0.6.x-compat
342352
org.jetbrains.kotlinx:kotlinx-io-bytestring-jvm:0.7.0
343353
org.jetbrains.kotlinx:kotlinx-io-bytestring:0.7.0
344354
org.jetbrains.kotlinx:kotlinx-io-core-jvm:0.7.0

core/common/src/commonMain/kotlin/org/mifos/mobile/core/common/DateHelper.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import kotlinx.datetime.isoDayNumber
2525
import kotlinx.datetime.minus
2626
import kotlinx.datetime.toLocalDateTime
2727
import kotlin.time.Duration.Companion.days
28+
import kotlin.time.ExperimentalTime
2829

2930
@Suppress("TooManyFunctions")
3031
@OptIn(FormatStringsInDatetimeFormats::class)
@@ -162,6 +163,7 @@ object DateHelper {
162163

163164
private val monthNumberToAbbreviation = monthMap.entries.associate { (k, v) -> v to k }
164165

166+
@OptIn(ExperimentalTime::class)
165167
fun getDateAsLongFromList(integersOfDate: List<Int>?): Long? {
166168
if (integersOfDate == null) return null
167169
val dateStr = getDateAsString(integersOfDate)

core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/UserAuthRepositoryImp.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ class UserAuthRepositoryImp(
7373
DataState.Error(Exception("Invalid Credentials"), null)
7474
}
7575
}
76-
} catch (e: Exception) {
77-
DataState.Error(e, null)
76+
} catch (e: ClientRequestException) {
77+
val errorMessage = extractErrorMessage(e.response)
78+
DataState.Error(Exception(errorMessage), null)
7879
}
7980
}
8081

core/ui/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ kotlin{
4444
implementation(libs.jb.composeNavigation)
4545
implementation(libs.filekit.compose)
4646
implementation(libs.filekit.core)
47+
implementation(libs.compottie.resources)
48+
implementation(libs.compottie.lite)
4749
}
4850
}
4951
}

core/ui/src/commonMain/composeResources/files/loading_animation.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

core/ui/src/commonMain/kotlin/org/mifos/mobile/core/ui/component/MifosProgressIndicator.kt

Lines changed: 59 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,53 +9,95 @@
99
*/
1010
package org.mifos.mobile.core.ui.component
1111

12+
import androidx.compose.foundation.Image
1213
import androidx.compose.foundation.background
1314
import androidx.compose.foundation.clickable
1415
import androidx.compose.foundation.interaction.MutableInteractionSource
15-
import androidx.compose.foundation.layout.Arrangement
16-
import androidx.compose.foundation.layout.Column
16+
import androidx.compose.foundation.layout.Box
1717
import androidx.compose.foundation.layout.fillMaxSize
18-
import androidx.compose.foundation.layout.padding
19-
import androidx.compose.material3.CircularProgressIndicator
2018
import androidx.compose.material3.MaterialTheme
2119
import androidx.compose.runtime.Composable
20+
import androidx.compose.runtime.getValue
2221
import androidx.compose.runtime.remember
2322
import androidx.compose.ui.Alignment
2423
import androidx.compose.ui.Modifier
25-
import org.mifos.mobile.core.designsystem.theme.DesignToken
26-
import org.mifos.mobile.core.ui.utils.DevicePreview
24+
import io.github.alexzhirkevich.compottie.LottieCompositionSpec
25+
import io.github.alexzhirkevich.compottie.animateLottieCompositionAsState
26+
import io.github.alexzhirkevich.compottie.rememberLottieComposition
27+
import io.github.alexzhirkevich.compottie.rememberLottiePainter
28+
import mifos_mobile.core.ui.generated.resources.Res
29+
import org.jetbrains.compose.ui.tooling.preview.Preview
30+
import org.mifos.mobile.core.designsystem.theme.MifosMobileTheme
31+
import org.mifos.mobile.core.ui.utils.LottieConstants
2732

28-
@DevicePreview
2933
@Composable
3034
fun MifosProgressIndicator(
3135
modifier: Modifier = Modifier.fillMaxSize(),
3236
) {
33-
Column(
37+
val composition by rememberLottieComposition {
38+
LottieCompositionSpec.JsonString(
39+
Res.readBytes(LottieConstants.LOADING_ANIMATION).decodeToString(),
40+
)
41+
}
42+
val progress by animateLottieCompositionAsState(composition)
43+
44+
Box(
3445
modifier = modifier,
35-
verticalArrangement = Arrangement.Center,
36-
horizontalAlignment = Alignment.CenterHorizontally,
46+
contentAlignment = Alignment.Center,
3747
) {
38-
CircularProgressIndicator()
48+
Image(
49+
painter = rememberLottiePainter(
50+
composition = composition,
51+
progress = { progress },
52+
),
53+
contentDescription = "Lottie animation",
54+
)
3955
}
4056
}
4157

42-
@DevicePreview
4358
@Composable
4459
fun MifosProgressIndicatorOverlay(
4560
modifier: Modifier = Modifier.fillMaxSize(),
4661
) {
47-
Column(
62+
val composition by rememberLottieComposition {
63+
LottieCompositionSpec.JsonString(
64+
Res.readBytes("files/loading_animation.json").decodeToString(),
65+
)
66+
}
67+
val progress by animateLottieCompositionAsState(composition)
68+
69+
Box(
4870
modifier = modifier
49-
.padding(DesignToken.padding.large)
5071
.background(MaterialTheme.colorScheme.background.copy(alpha = 0.7f))
5172
.clickable(
5273
enabled = false,
5374
indication = null,
5475
interactionSource = remember { MutableInteractionSource() },
5576
) { },
56-
verticalArrangement = Arrangement.Center,
57-
horizontalAlignment = Alignment.CenterHorizontally,
77+
contentAlignment = Alignment.Center,
5878
) {
59-
CircularProgressIndicator()
79+
Image(
80+
painter = rememberLottiePainter(
81+
composition = composition,
82+
progress = { progress },
83+
),
84+
contentDescription = "Loading animation",
85+
)
86+
}
87+
}
88+
89+
@Preview
90+
@Composable
91+
private fun Loading_Preview() {
92+
MifosMobileTheme {
93+
MifosProgressIndicator()
94+
}
95+
}
96+
97+
@Preview
98+
@Composable
99+
private fun Overlay_Loading_Preview() {
100+
MifosMobileTheme {
101+
MifosProgressIndicatorOverlay()
60102
}
61103
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright 2025 Mifos Initiative
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*
8+
* See https://github.com/openMF/mobile-mobile/blob/master/LICENSE.md
9+
*/
10+
package org.mifos.mobile.core.ui.utils
11+
12+
object LottieConstants {
13+
const val LOADING_ANIMATION = "files/loading_animation.json"
14+
}

0 commit comments

Comments
 (0)