Skip to content

Instantly share code, notes, and snippets.

Avatar

Gabriel Peal gpeal

View GitHub Profile
View GuidedWorkoutFragment.kt
class GuidedWorkoutFragment : TonalFragment(R.layout.guided_workout_fragment) {
override val daggerComponent: GuidedWorkoutMergeComponent by fragmentComponent { scope, app ->
app.bindings<GuidedWorkoutMergeComponent.Parent>().guidedWorkoutComponentBuilder()
.coroutineScope(WorkoutCoroutineScope(scope))
.args(arg)
.build()
}
}
View ContributesApiCodeGenerator.kt
package com.tonal.trainer.anvilcompilers
import com.google.auto.service.AutoService
import com.squareup.anvil.annotations.ContributesTo
import com.squareup.anvil.compiler.api.AnvilContext
import com.squareup.anvil.compiler.api.CodeGenerator
import com.squareup.anvil.compiler.api.GeneratedFile
import com.squareup.anvil.compiler.api.createGeneratedFile
import com.squareup.anvil.compiler.internal.asClassName
import com.squareup.anvil.compiler.internal.buildFile
@gpeal
gpeal / Simple.kt
Created Mar 5, 2022
Anvil Simple Use Case
View Simple.kt
@Singleton
class LocationProvider @Inject constructor() {
suspend fun currentLocation(): Pair<Float, Float> = 123.456f to 789.012f
}
class WeatherApi @Inject constructor() {
suspend fun getWeather(latLng: Pair<Float, Float>): Float = 72f
}
class WeatherUseCase @Inject constructor(
private val locationProvider: LocationProvider,
private val weatherApi: WeatherApi,
View WorkoutDetailsFragment.kt
import com.sun.tools.javac.resources.CompilerProperties
import javax.swing.text.View
data class WorkoutDetailsState(
val workout: Async<Workout> = Uninitialized,
) : MavericksState {
}
class WorkoutDetailsViewModel @Inject constructor(
@Assisted initialState: WorkoutState,
View build.gradle
implementation "com.airbnb.android:lottie-compose:4.0.0"
View animatable.kt
val anim = rememberLottieAnimatable()
LaunchedEffect(composition) {
anim.animate(
composition,
iterations = LottieConstants.IterateForever,
)
}
View lottie.kt
val composition by rememberLottieComposition(LottieCompositionSpec.RawRes(R.raw.heart))
val progress by animateLottieCompositionAsState(
composition,
iterations = LottieConstants.IterateForever,
)
LottieAnimation(
composition,
progress,
)
View LottieAnimation.kt
LottieAnimation(
composition,
progress,
)
View animateLottieCompositionAsState.kt
val progress by animateLottieCompositionAsState(
composition,
iterations = LottieConstants.IterateForever,
)
View composition.kt
val composition by rememberLottieComposition(LottieCompositionSpec.RawRes(R.raw.heart))