This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies { | |
// coreLibraryDesugaring(libs.desugar.jdk.libs) | |
// timber as logging | |
implementation(libs.logging.timber) | |
// common android+compose dependencies | |
implementation(libs.bundles.common) | |
implementation(platform(libs.androidx.compose.bom)) | |
// using material3 | |
implementation(libs.androidx.material3) | |
implementation(libs.material.icons.extended) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[versions] | |
agp = "8.7.1" | |
authsdk = "3.1.0" | |
composecalendar = "1.1.0" | |
desugar_jdk_libs = "2.1.2" | |
firebaseBom = "33.1.2" | |
glance = "1.1.0" | |
hiltCompiler = "1.2.0" | |
kotlin = "2.0.0" | |
coreKtx = "1.13.1" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun Modifier.shimmerBackground(shape: Shape = RectangleShape): Modifier = composed { | |
val transition = rememberInfiniteTransition() | |
val translateAnimation by transition.animateFloat( | |
initialValue = 0f, | |
targetValue = 400f, | |
animationSpec = infiniteRepeatable( | |
tween(durationMillis = 1500, easing = LinearOutSlowInEasing), | |
RepeatMode.Restart | |
), | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val result: Flow<Result> = flow { | |
val data = someSuspendingFunction() | |
emit(data) | |
}.stateIn( | |
scope = viewModelScope, | |
started = SharingStarted.WhileSubscribed(5000L), | |
initialValue = Result.Loading | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import lifecycle:lifecycle-runtime-ktx:2.4.0 | |
viewLifecycleOwner.lifecycleScope.launch { | |
viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) { | |
viewModel.result.collect { data -> | |
displayResult(data) | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.3.1" | |
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3" | |
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.3" | |
import androidx.lifecycle.coroutineScope | |
import androidx.lifecycle.findViewTreeLifecycleOwner | |
import kotlinx.coroutines.CoroutineDispatcher | |
import kotlinx.coroutines.Dispatchers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@SuppressLint("ApplySharedPref") | |
fun String.save(applicationContext: Context, value: Map<String, Any>, clear: Boolean = false, now: Boolean = false) { | |
val sp = applicationContext.getSharedPreferences(this, Context.MODE_PRIVATE).edit() | |
if (clear) | |
sp.clear() | |
value.keys.forEach { key -> | |
val v = value[key] | |
if (v != null) { | |
when (v) { | |
is String -> sp.putString(key, v) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
compileOptions { | |
sourceCompatibility JavaVersion.VERSION_1_8 | |
targetCompatibility JavaVersion.VERSION_1_8 | |
} | |
kotlinOptions { | |
jvmTarget = '1.8' | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
implementation 'com.jakewharton.timber:timber:4.7.1' | |
private fun initTimber() { | |
if (BuildConfig.DEBUG) { | |
Timber.plant(DebugTree()) | |
} else { | |
Fabric.with(this, Crashlytics()) | |
} | |
} |