Storing BookNest's Settings

BookNest's About tab now has a theme choice (system, light or dark) and a dynamic-color switch. A SettingsViewModel exposes the settings as a StateFlow that starts at null ("not read yet"), and MainActivity draws nothing until the real value arrives, so a dark-theme user never sees a light flash:

MainActivity.kt: the theme follows the stored setting (excerpt)Kotlin
      val settingsVm: SettingsViewModel = hiltViewModel()
      val settings = settingsVm.settings.collectAsStateWithLifecycle().value
        ?: return@setContent                             // wait for the stored theme
      ...
      BookNestTheme(darkTheme = dark, dynamicColor = dynamic || settings.dynamicColor) {

Tapping Dark logged two emissions, one per collector (the activity's ViewModel and the About screen's), and the whole app switched at once because both read the same file; a cold start afterwards logged the same line:

Output of 150
D/BookNestStore: settings: Settings(theme=DARK, dynamicColor=false)
D/BookNestStore: settings: Settings(theme=DARK, dynamicColor=false)
Reading notes in Room after the version 2 migration, and the theme setting stored in DataStore
Reading notes in Room 234 after the version 2 migration, and the theme setting stored in DataStore 234

The file itself, files/datastore/settings.preferences_pb, was 17 bytes: the protobuf encoding of one key, theme, and its value, DARK. Keep DataStore for small data like this; anything that grows, needs queries or relates records belongs in Room.