This file contains 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
suspend fun <T : Any> executeApi(call: suspend () -> Response<T>): DataResult<T, DataError.Network> { | |
return try { | |
val response = call.invoke() | |
val body = response.body() | |
val errorBody = response.errorBody() | |
if (response.isSuccessful && body != null) { | |
DataResult.Success(body) | |
} else if (errorBody != null) { | |
val gson = Gson() | |
val errorResponse = gson.fromJson(String(errorBody.bytes()), ErrorResponse::class.java) |
This file contains 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.bouncingClickable( | |
enabled: Boolean = true, | |
onLongClick: () -> Unit = {}, | |
onClick: () -> Unit = {}, | |
) = composed { | |
val interactionSource = remember { MutableInteractionSource() } | |
val isPressed by interactionSource.collectIsPressedAsState() | |
val haptic = LocalHapticFeedback.current | |
val animationTransition = updateTransition(isPressed, label = "BouncingClickableTransition") |
This file contains 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
//Utils - Declaration | |
object PromptUtils { | |
fun alertDialog(context: Context, @StyleRes style: Int, dialogBuilder: AlertDialog.Builder.() -> Unit): Dialog { | |
val builder = AlertDialog.Builder(context, style).also { | |
it.setCancelable(false) | |
it.dialogBuilder() | |
} | |
return builder.create() | |
} |
This file contains 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
// App Level build.gradle File | |
plugins { | |
id("com.android.application") | |
id("org.jetbrains.kotlin.android") | |
id("kotlin-kapt") | |
id("dagger.hilt.android.plugin") | |
id("androidx.navigation.safeargs.kotlin") | |
id("com.google.devtools.ksp") | |
} |