File tree Expand file tree Collapse file tree
androidMain/kotlin/com/softartdev/kronos/sample
commonMain/kotlin/com/softartdev/kronos/sample Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,6 +4,11 @@ import ComposeApp
44
55@main
66struct iosApp : App {
7+
8+ init ( ) {
9+ MainKt . debugBuild ( )
10+ }
11+
712 var body : some Scene {
813 WindowGroup {
914 ContentView ( )
Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ import android.os.Bundle
77import androidx.activity.ComponentActivity
88import androidx.activity.compose.setContent
99import com.softartdev.kronos.NetworkClock
10+ import io.github.aakira.napier.DebugAntilog
11+ import io.github.aakira.napier.Napier
1012
1113class AndroidApp : Application () {
1214 companion object {
@@ -16,6 +18,7 @@ class AndroidApp : Application() {
1618 override fun onCreate () {
1719 super .onCreate()
1820 INSTANCE = this
21+ Napier .base(DebugAntilog ())
1922 NetworkClock .sync(applicationContext)
2023 }
2124}
Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ import androidx.compose.ui.Alignment
1010import androidx.compose.ui.Modifier
1111import com.softartdev.kronos.Greeting
1212import com.softartdev.kronos.NetworkClock
13+ import io.github.aakira.napier.Napier
14+ import kotlinx.datetime.Clock
1315
1416@Composable
1517internal fun App () = AppTheme {
@@ -21,7 +23,7 @@ internal fun App() = AppTheme {
2123 ) {
2224 Text (text = " Network time millis: $ntpTimeMs " )
2325 Button (
24- onClick = { ntpTimeMs = NetworkClock .getCurrentNtpTimeMs () }
26+ onClick = { ntpTimeMs = logNtpTimeMs () }
2527 ) {
2628 Text (text = " Refresh network time millis" )
2729 }
@@ -34,4 +36,14 @@ internal fun App() = AppTheme {
3436 }
3537}
3638
39+ private fun logNtpTimeMs (): Long? {
40+ val networkTimeMs = NetworkClock .getCurrentNtpTimeMs()
41+ Napier .d(tag = " ⌚️" , message = " Network time millis: $networkTimeMs " )
42+ val systemTimeMs = Clock .System .now().toEpochMilliseconds()
43+ Napier .d(tag = " ⌚️" , message = " System time millis: $systemTimeMs " )
44+ val diff = networkTimeMs?.minus(systemTimeMs)
45+ Napier .d(tag = " ⌚️" , message = " Diff: $diff " )
46+ return networkTimeMs
47+ }
48+
3749internal expect fun openUrl (url : String? )
Original file line number Diff line number Diff line change @@ -4,14 +4,19 @@ import androidx.compose.ui.window.application
44import androidx.compose.ui.window.rememberWindowState
55import com.softartdev.kronos.NetworkClock
66import com.softartdev.kronos.sample.App
7+ import io.github.aakira.napier.DebugAntilog
8+ import io.github.aakira.napier.Napier
79
8- fun main () = application {
10+ fun main () {
11+ Napier .base(DebugAntilog ())
912
1013 NetworkClock .sync()
1114
12- Window (
13- title = " Kronos Multiplatform" ,
14- state = rememberWindowState(width = 600 .dp, height = 400 .dp),
15- onCloseRequest = ::exitApplication,
16- ) { App () }
15+ application {
16+ Window (
17+ title = " Kronos Multiplatform" ,
18+ state = rememberWindowState(width = 600 .dp, height = 400 .dp),
19+ onCloseRequest = ::exitApplication,
20+ ) { App () }
21+ }
1722}
Original file line number Diff line number Diff line change 11import androidx.compose.ui.window.ComposeUIViewController
22import com.softartdev.kronos.sample.App
3+ import io.github.aakira.napier.DebugAntilog
4+ import io.github.aakira.napier.Napier
35import platform.UIKit.UIViewController
46
7+ fun debugBuild () {
8+ Napier .base(DebugAntilog ())
9+ }
10+
511fun MainViewController (): UIViewController {
612 return ComposeUIViewController { App () }
713}
You can’t perform that action at this time.
0 commit comments