-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a red blinking dot for ongoing sessions and scroll to next session
- Loading branch information
Showing
5 changed files
with
109 additions
and
5 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
wearApp/src/main/java/fr/paug/androidmakers/wear/ui/common/PulsatingRedDot.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package fr.paug.androidmakers.wear.ui.common | ||
|
||
import androidx.compose.animation.core.RepeatMode | ||
import androidx.compose.animation.core.animateFloat | ||
import androidx.compose.animation.core.infiniteRepeatable | ||
import androidx.compose.animation.core.rememberInfiniteTransition | ||
import androidx.compose.animation.core.tween | ||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.shape.CircleShape | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.alpha | ||
import androidx.compose.ui.unit.dp | ||
import fr.paug.androidmakers.wear.ui.theme.amRed | ||
|
||
@Composable | ||
fun Pulsating(content: @Composable () -> Unit) { | ||
val infiniteTransition = rememberInfiniteTransition(label = "pulse") | ||
|
||
val scale by infiniteTransition.animateFloat( | ||
label = "pulse", | ||
initialValue = 1f, | ||
targetValue = 0f, | ||
animationSpec = infiniteRepeatable( | ||
animation = tween(500), | ||
repeatMode = RepeatMode.Reverse | ||
) | ||
) | ||
|
||
Box(modifier = Modifier.alpha(scale)) { | ||
content() | ||
} | ||
} | ||
|
||
@Composable | ||
fun PulsatingRedDot() { | ||
Pulsating { | ||
Box( | ||
modifier = Modifier | ||
.size(8.dp) | ||
.background(color = amRed, shape = CircleShape) | ||
) | ||
} | ||
} |
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
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
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
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