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
| animationSpec = spring( | |
| dampingRatio = Spring.DampingRatioMediumBouncy, | |
| stiffness = Spring.StiffnessMediumLow, | |
| visibilityThreshold = 0.001f, | |
| ), |
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
| @Preview(showBackground = true, name = "Animation") | |
| @Composable | |
| private fun BouncingProgressAnimationPreview() { | |
| var progress by remember { mutableIntStateOf(0) } | |
| LaunchedEffect(Unit) { | |
| while (true) { | |
| progress = 0 | |
| delay(600) | |
| progress = 60 |
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
| private class ProgressPreviewProvider : PreviewParameterProvider<Float> { | |
| override val values = (0..100 step 10).map { it / 100f }.asSequence() | |
| } | |
| @Preview(showBackground = true, uiMode = UI_MODE_NIGHT_NO, name = "Light") | |
| @Preview(showBackground = true, uiMode = UI_MODE_NIGHT_YES, name = "Dark") | |
| @Composable | |
| private fun BouncingProgressPreview( | |
| @PreviewParameter(ProgressPreviewProvider::class) progress: Float, | |
| ) { |
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
| Box( | |
| modifier = modifier | |
| .fillMaxWidth() | |
| .height(height) | |
| .clip(RoundedCornerShape(50)) | |
| .background(trackColor) | |
| ) { | |
| Box( | |
| modifier = Modifier | |
| .fillMaxWidth(animatedProgress) |
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 android.content.res.Configuration.UI_MODE_NIGHT_NO | |
| import android.content.res.Configuration.UI_MODE_NIGHT_YES | |
| import androidx.compose.animation.core.Spring | |
| import androidx.compose.animation.core.animateFloatAsState | |
| import androidx.compose.animation.core.spring | |
| import androidx.compose.foundation.background | |
| import androidx.compose.foundation.layout.Box | |
| import androidx.compose.foundation.layout.fillMaxHeight | |
| import androidx.compose.foundation.layout.fillMaxWidth | |
| import androidx.compose.foundation.layout.height |
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 androidx.compose.foundation.background | |
| import androidx.compose.foundation.layout.Arrangement | |
| import androidx.compose.foundation.layout.Box | |
| import androidx.compose.foundation.layout.Column | |
| import androidx.compose.foundation.layout.fillMaxSize | |
| import androidx.compose.foundation.layout.fillMaxWidth | |
| import androidx.compose.foundation.layout.height | |
| import androidx.compose.foundation.layout.padding | |
| import androidx.compose.foundation.shape.RoundedCornerShape | |
| import androidx.compose.material3.Text |
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 io.ktor.client.plugins.api.ClientPlugin | |
| import io.ktor.client.plugins.api.createClientPlugin | |
| class AuthenticationPlugin(private val settingsRepository: SettingsRepository) { | |
| fun createPlugin(): ClientPlugin<Unit> { | |
| val token = settingsRepository.getToken() | |
| return createClientPlugin(PLUGIN_NAME) { | |
| onRequest { request, _ -> |
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
| abstract class BaseFlowUseCase<out Type, in Params> { | |
| abstract suspend fun execute(param: Params): Flow<Type> | |
| } | |
| override suspend fun getNumberInvites(): Flow<Int> { | |
| return local.getNumberInvites() | |
| } | |
| override suspend fun getNumberInvites(): Flow<Int> { |
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
| class GoalDataSource(private val getReactGoalsUseCase: GetReactGoalsUseCase) : | |
| PositionalDataSource<Goal>() { | |
| override fun loadRange(params: LoadRangeParams, callback: LoadRangeCallback<Goal>) { | |
| CoroutineScope(Dispatchers.Main).launch { | |
| getReactGoalsUseCase.invoke(this, GetReactGoalsUseCase.Param(params.startPosition)) { | |
| it.either({}, { goals: List<Goal> -> | |
| callback.onResult(goals) | |
| }) | |
| } |
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
| abstract class BaseUseCase<in Param, out Type> where Type : Any { | |
| abstract suspend fun run(param: Param): Either<Failure, Type> | |
| open val dispatcher: CoroutineDispatcher = Dispatchers.Main | |
| open operator fun invoke( | |
| scope: CoroutineScope, | |
| param: Param, | |
| result: (Either<Failure, Type>) -> Unit = {} |
NewerOlder