From 77b3bb81308b9cee3cde75b02d4342e2f2ecf7ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9luchu?= Date: Fri, 14 Jun 2024 09:47:18 +0200 Subject: [PATCH] Refactor clock methods --- .../jchucomponents/ui/extensions/time/Time.kt | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/jchucomponents-ui/src/main/kotlin/com/jeluchu/jchucomponents/ui/extensions/time/Time.kt b/jchucomponents-ui/src/main/kotlin/com/jeluchu/jchucomponents/ui/extensions/time/Time.kt index 726420a2..e4a7f156 100644 --- a/jchucomponents-ui/src/main/kotlin/com/jeluchu/jchucomponents/ui/extensions/time/Time.kt +++ b/jchucomponents-ui/src/main/kotlin/com/jeluchu/jchucomponents/ui/extensions/time/Time.kt @@ -26,8 +26,35 @@ import java.util.Calendar */ @Composable -fun minutesLeft(): String { +fun clock(): String { + var time by rememberMutableStateOf(currentTime()) + + LaunchedEffect(0) { + while (true) { + time = currentTime() + delay(1000) + } + } + + return "${time.hours}:${time.minutes}" +} +@Composable +fun clockTime(): Time { + var time by rememberMutableStateOf(currentTime()) + + LaunchedEffect(0) { + while (true) { + time = currentTime() + delay(1000) + } + } + + return time +} + +@Composable +fun clockWithZoneDay(): String { var time by rememberMutableStateOf(currentTime()) LaunchedEffect(0) {