Changed Theme / Deprecated Preferences. Use DataStore instead.

This commit is contained in:
tom5079
2021-12-17 11:56:34 +09:00
parent ef0f71310b
commit 62d0de3ef6
5 changed files with 30 additions and 8 deletions

View File

@@ -111,10 +111,13 @@ dependencies {
kapt("androidx.room:room-compiler:2.3.0")
implementation("androidx.room:room-ktx:2.3.0")
implementation("androidx.datastore:datastore:1.0.0")
implementation("androidx.datastore:datastore-preferences:1.0.0")
implementation("org.kodein.di:kodein-di-framework-compose:7.9.0")
implementation("com.google.android.material:material:1.4.0")
0
implementation(platform("com.google.firebase:firebase-bom:28.3.0"))
implementation("com.google.firebase:firebase-analytics-ktx")
implementation("com.google.firebase:firebase-crashlytics")

View File

@@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Card
import androidx.compose.material.LinearProgressIndicator
import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
@@ -20,7 +21,7 @@ fun ProgressCard(progress: Float? = null, content: @Composable () -> Unit) {
elevation = 4.dp
) {
Column {
progress?.run { LinearProgressIndicator(progress = progress, modifier = Modifier.fillMaxWidth()) }
progress?.run { LinearProgressIndicator(progress = progress, modifier = Modifier.fillMaxWidth(), color = MaterialTheme.colors.secondary) }
content()
}
}

View File

@@ -23,9 +23,19 @@ import androidx.compose.material.MaterialTheme
import androidx.compose.material.darkColors
import androidx.compose.material.lightColors
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
private val DarkColorPalette = darkColors()
private val LightColorPalette = lightColors()
private val DarkColorPalette = darkColors(
secondary = Pink600,
onSecondary = Color.White
)
private val LightColorPalette = lightColors(
primary = LightBlue300,
primaryVariant = LightBlue700,
secondary = Pink600,
onPrimary = Color.White,
onSecondary = Color.White
)
@Composable
fun PupilTheme(

View File

@@ -18,10 +18,15 @@
package xyz.quaver.pupil.ui.viewmodel
import android.annotation.SuppressLint
import android.app.Application
import androidx.compose.runtime.*
import androidx.lifecycle.*
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations
import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.*
import org.kodein.di.DIAware
import org.kodein.di.android.x.closestDI
@@ -29,7 +34,9 @@ import org.kodein.di.direct
import org.kodein.di.instance
import org.kodein.log.LoggerFactory
import org.kodein.log.newLogger
import xyz.quaver.pupil.sources.*
import xyz.quaver.pupil.sources.History
import xyz.quaver.pupil.sources.ItemInfo
import xyz.quaver.pupil.sources.Source
import xyz.quaver.pupil.util.Preferences
import xyz.quaver.pupil.util.source
import kotlin.math.ceil

View File

@@ -23,6 +23,7 @@ import kotlin.reflect.KClass
lateinit var preferences: SharedPreferences
@Deprecated("Use DataStore")
object Preferences: SharedPreferences by preferences {
val defMap = mapOf(