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
@Composable | |
fun FluidMeshGradient( | |
modifier: Modifier = Modifier | |
) { | |
val infiniteTransition = rememberInfiniteTransition(label = "gradient") | |
// Angle animations for smoother movement | |
val angle1 = infiniteTransition.animateFloat( | |
initialValue = 0f, |
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
@Composable | |
fun CardGradient(modifier: Modifier = Modifier) { | |
Card( | |
modifier = Modifier.padding(16.dp).fillMaxWidth().aspectRatio(600 / 400f) | |
.clip(RoundedCornerShape(16.dp)) | |
) { | |
Gradient() | |
} | |
} |
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
@Composable | |
fun AgeCalculator() { | |
var startDate by remember { mutableStateOf(LocalDate.now()) } | |
var endDate by remember { mutableStateOf(LocalDate.now()) } | |
var showDialogStartDate by remember { mutableStateOf(false) } | |
var showDialogEndDate by remember { mutableStateOf(false) } | |
Column( | |
modifier = Modifier.fillMaxSize(), | |
verticalArrangement = Arrangement.Center, |
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
@Composable | |
fun BouncingBall() { | |
val scope = rememberCoroutineScope() | |
val animatable = remember { Animatable(0f) } | |
var targetHeight by remember { mutableStateOf(1f) } | |
LaunchedEffect(key1 = true) { | |
scope.launch { | |
while (targetHeight > 0.01f) { // the animation will stop when the height is less than 1% of maxHeight |
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
@HiltViewModel | |
class MusicDetailViewModel @Inject constructor( | |
private val savedStateHandle: SavedStateHandle, private val repository: MusicRepository | |
) : ViewModel() { | |
val state: StateFlow<MusicDetailScreenState> | |
init { | |
val musicDetails = savedStateHandle.getStateFlow<Long>(MUSIC_ID, -1).filter { it != -1L } | |
.flatMapLatest { getMusicDetails(it) } |
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
class MusicDetailViewModelTest { | |
private lateinit var SUT: MusicDetailViewModel | |
private val repository: MusicRepository = mockk() | |
private val savedInstanceStateHandle: SavedStateHandle = SavedStateHandle() | |
@Before | |
fun setUp() { | |
Dispatchers.setMain(Dispatchers.Unconfined) |
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
@HiltViewModel | |
class MusicDetailViewModel @Inject constructor( | |
private val savedStateHandle: SavedStateHandle, private val repository: MusicRepository, | |
) : ViewModel() { | |
val state: StateFlow<MusicDetailScreenState> | |
init { | |
val musicDetails = savedStateHandle.getStateFlow<Long>(MUSIC_ID, -1).filter { it != -1L } | |
.flatMapLatest { getMusicDetails(it) } |
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
class MusicDetailViewModelTest { | |
lateinit var SUT: MusicDetailViewModel | |
@MockK | |
val repo = mockk<MusicRepository>() | |
@MockK | |
val savedInstanceStateHandle = mockk<SavedStateHandle>(relaxed = true) |