Move time tracking into a CompositionLocal (#493)

## Description
Creates a `CompositionLocal` which tracks the current time in a single
place and is usable anywhere in the app.

Can be used such as:
```kotlin
val now = LocalClock.current.now
val details = remember(item, now) {
  // Create detail strings based the item and current time
  // This will be recomposed/updated whenever the time changes
}
```

### Related issues
Related to #475
This commit is contained in:
Ray 2025-12-17 13:25:36 -05:00 committed by GitHub
parent 2908f539e2
commit 7581b05b97
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 54 additions and 24 deletions

View file

@ -47,6 +47,7 @@ import com.github.damontecres.wholphin.ui.launchIO
import com.github.damontecres.wholphin.ui.nav.ApplicationContent
import com.github.damontecres.wholphin.ui.nav.Destination
import com.github.damontecres.wholphin.ui.theme.WholphinTheme
import com.github.damontecres.wholphin.ui.util.ProvideLocalClock
import com.github.damontecres.wholphin.util.DebugLogTree
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.Dispatchers
@ -222,13 +223,15 @@ class MainActivity : AppCompatActivity() {
)
}
}
ApplicationContent(
user = current?.user,
server = current?.server,
navigationManager = navigationManager,
preferences = preferences,
modifier = Modifier.fillMaxSize(),
)
ProvideLocalClock {
ApplicationContent(
user = current?.user,
server = current?.server,
navigationManager = navigationManager,
preferences = preferences,
modifier = Modifier.fillMaxSize(),
)
}
}
}
}