update kotlin version. use material3 color scheme.

This commit is contained in:
Satindar Dhillon
2022-08-17 20:08:01 -07:00
parent a99aafe6d8
commit da45bcdd2c
6 changed files with 137 additions and 39 deletions

View File

@ -39,7 +39,7 @@ android {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion compose_version
kotlinCompilerExtensionVersion = '1.2.0-alpha08'
}
packagingOptions {
resources {
@ -117,6 +117,9 @@ dependencies {
kapt 'com.google.dagger:hilt-compiler:2.42'
implementation 'com.apollographql.apollo3:apollo-runtime:3.5.0'
implementation 'androidx.compose.material3:material3:1.0.0-alpha16'
implementation 'androidx.compose.material3:material3-window-size-class:1.0.0-alpha16'
}
apollo {

View File

@ -12,7 +12,8 @@ import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.*
//import androidx.compose.material.*
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment
@ -40,7 +41,7 @@ class MainActivity : ComponentActivity() {
setContent {
OmnivoreTheme {
// A surface container using the 'background' color from the theme
Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colors.background) {
Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background) {
PrimaryView(viewModel)
}
}
@ -74,7 +75,7 @@ fun LoggedInView(viewModel: LoginViewModel) {
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier
.background(MaterialTheme.colors.background)
.background(MaterialTheme.colorScheme.background)
.fillMaxSize()
) {
Text("You have a valid auth token. Nice. Go save something in Chrome!")
@ -100,7 +101,7 @@ fun LoginView(viewModel: LoginViewModel) {
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier
.background(MaterialTheme.colors.background)
.background(MaterialTheme.colorScheme.background)
.fillMaxSize()
.clickable { focusManager.clearFocus() }
) {
@ -135,6 +136,7 @@ fun LoginView(viewModel: LoginViewModel) {
}
}
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun LoginFields(
email: String,

View File

@ -12,8 +12,6 @@ import androidx.compose.material.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier

View File

@ -1,8 +1,62 @@
package app.omnivore.omnivore.ui.theme
import androidx.compose.ui.graphics.Color
val Purple200 = Color(0xFFBB86FC)
val Purple500 = Color(0xFF6200EE)
val Purple700 = Color(0xFF3700B3)
val Teal200 = Color(0xFF03DAC5)
val md_theme_light_primary = Color(0xFF745B00)
val md_theme_light_onPrimary = Color(0xFFFFFFFF)
val md_theme_light_primaryContainer = Color(0xFFFFE08C)
val md_theme_light_onPrimaryContainer = Color(0xFF241A00)
val md_theme_light_secondary = Color(0xFF6D5E00)
val md_theme_light_onSecondary = Color(0xFFFFFFFF)
val md_theme_light_secondaryContainer = Color(0xFFFCE365)
val md_theme_light_onSecondaryContainer = Color(0xFF211B00)
val md_theme_light_tertiary = Color(0xFF4B670A)
val md_theme_light_onTertiary = Color(0xFFFFFFFF)
val md_theme_light_tertiaryContainer = Color(0xFFCBEF86)
val md_theme_light_onTertiaryContainer = Color(0xFF141F00)
val md_theme_light_error = Color(0xFFBA1A1A)
val md_theme_light_errorContainer = Color(0xFFFFDAD6)
val md_theme_light_onError = Color(0xFFFFFFFF)
val md_theme_light_onErrorContainer = Color(0xFF410002)
val md_theme_light_background = Color(0xFFF7FFED)
val md_theme_light_onBackground = Color(0xFF032100)
val md_theme_light_surface = Color(0xFFF7FFED)
val md_theme_light_onSurface = Color(0xFF032100)
val md_theme_light_surfaceVariant = Color(0xFFEBE1CF)
val md_theme_light_onSurfaceVariant = Color(0xFF4C4639)
val md_theme_light_outline = Color(0xFF7E7667)
val md_theme_light_inverseOnSurface = Color(0xFFCBFFB5)
val md_theme_light_inverseSurface = Color(0xFF083900)
val md_theme_light_inversePrimary = Color(0xFFEFC125)
val md_theme_light_shadow = Color(0xFF000000)
val md_theme_light_surfaceTint = Color(0xFF745B00)
val md_theme_dark_primary = Color(0xFFEFC125)
val md_theme_dark_onPrimary = Color(0xFF3D2F00)
val md_theme_dark_primaryContainer = Color(0xFF584400)
val md_theme_dark_onPrimaryContainer = Color(0xFFFFE08C)
val md_theme_dark_secondary = Color(0xFFDEC64C)
val md_theme_dark_onSecondary = Color(0xFF393000)
val md_theme_dark_secondaryContainer = Color(0xFF524600)
val md_theme_dark_onSecondaryContainer = Color(0xFFFCE365)
val md_theme_dark_tertiary = Color(0xFFB0D36D)
val md_theme_dark_onTertiary = Color(0xFF243600)
val md_theme_dark_tertiaryContainer = Color(0xFF364E00)
val md_theme_dark_onTertiaryContainer = Color(0xFFCBEF86)
val md_theme_dark_error = Color(0xFFFFB4AB)
val md_theme_dark_errorContainer = Color(0xFF93000A)
val md_theme_dark_onError = Color(0xFF690005)
val md_theme_dark_onErrorContainer = Color(0xFFFFDAD6)
val md_theme_dark_background = Color(0xFF032100)
val md_theme_dark_onBackground = Color(0xFFB4F39B)
val md_theme_dark_surface = Color(0xFF032100)
val md_theme_dark_onSurface = Color(0xFFB4F39B)
val md_theme_dark_surfaceVariant = Color(0xFF4C4639)
val md_theme_dark_onSurfaceVariant = Color(0xFFCFC5B4)
val md_theme_dark_outline = Color(0xFF989080)
val md_theme_dark_inverseOnSurface = Color(0xFF032100)
val md_theme_dark_inverseSurface = Color(0xFFB4F39B)
val md_theme_dark_inversePrimary = Color(0xFF745B00)
val md_theme_dark_shadow = Color(0xFF000000)
val md_theme_dark_surfaceTint = Color(0xFFEFC125)
val seed = Color(0xFFE2B513)

View File

@ -1,44 +1,84 @@
package app.omnivore.omnivore.ui.theme
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material.MaterialTheme
import androidx.compose.material.darkColors
import androidx.compose.material.lightColors
import androidx.compose.runtime.Composable
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.material3.darkColorScheme
private val DarkColorPalette = darkColors(
primary = Purple200,
primaryVariant = Purple700,
secondary = Teal200
private val LightColors = lightColorScheme(
primary = md_theme_light_primary,
onPrimary = md_theme_light_onPrimary,
primaryContainer = md_theme_light_primaryContainer,
onPrimaryContainer = md_theme_light_onPrimaryContainer,
secondary = md_theme_light_secondary,
onSecondary = md_theme_light_onSecondary,
secondaryContainer = md_theme_light_secondaryContainer,
onSecondaryContainer = md_theme_light_onSecondaryContainer,
tertiary = md_theme_light_tertiary,
onTertiary = md_theme_light_onTertiary,
tertiaryContainer = md_theme_light_tertiaryContainer,
onTertiaryContainer = md_theme_light_onTertiaryContainer,
error = md_theme_light_error,
errorContainer = md_theme_light_errorContainer,
onError = md_theme_light_onError,
onErrorContainer = md_theme_light_onErrorContainer,
background = md_theme_light_background,
onBackground = md_theme_light_onBackground,
surface = md_theme_light_surface,
onSurface = md_theme_light_onSurface,
surfaceVariant = md_theme_light_surfaceVariant,
onSurfaceVariant = md_theme_light_onSurfaceVariant,
outline = md_theme_light_outline,
inverseOnSurface = md_theme_light_inverseOnSurface,
inverseSurface = md_theme_light_inverseSurface,
inversePrimary = md_theme_light_inversePrimary,
surfaceTint = md_theme_light_surfaceTint,
)
private val LightColorPalette = lightColors(
primary = Purple500,
primaryVariant = Purple700,
secondary = Teal200
/* Other default colors to override
background = Color.White,
surface = Color.White,
onPrimary = Color.White,
onSecondary = Color.Black,
onBackground = Color.Black,
onSurface = Color.Black,
*/
private val DarkColors = darkColorScheme(
primary = md_theme_dark_primary,
onPrimary = md_theme_dark_onPrimary,
primaryContainer = md_theme_dark_primaryContainer,
onPrimaryContainer = md_theme_dark_onPrimaryContainer,
secondary = md_theme_dark_secondary,
onSecondary = md_theme_dark_onSecondary,
secondaryContainer = md_theme_dark_secondaryContainer,
onSecondaryContainer = md_theme_dark_onSecondaryContainer,
tertiary = md_theme_dark_tertiary,
onTertiary = md_theme_dark_onTertiary,
tertiaryContainer = md_theme_dark_tertiaryContainer,
onTertiaryContainer = md_theme_dark_onTertiaryContainer,
error = md_theme_dark_error,
errorContainer = md_theme_dark_errorContainer,
onError = md_theme_dark_onError,
onErrorContainer = md_theme_dark_onErrorContainer,
background = md_theme_dark_background,
onBackground = md_theme_dark_onBackground,
surface = md_theme_dark_surface,
onSurface = md_theme_dark_onSurface,
surfaceVariant = md_theme_dark_surfaceVariant,
onSurfaceVariant = md_theme_dark_onSurfaceVariant,
outline = md_theme_dark_outline,
inverseOnSurface = md_theme_dark_inverseOnSurface,
inverseSurface = md_theme_dark_inverseSurface,
inversePrimary = md_theme_dark_inversePrimary,
surfaceTint = md_theme_dark_surfaceTint,
)
@Composable
fun OmnivoreTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) {
val colors = if (darkTheme) {
DarkColorPalette
val colorScheme = if (darkTheme) {
DarkColors
} else {
LightColorPalette
LightColors
}
MaterialTheme(
colors = colors,
typography = Typography,
shapes = Shapes,
colorScheme = colorScheme,
// typography = Typography,
// shapes = Shapes,
content = content
)
}

View File

@ -1,7 +1,8 @@
buildscript {
ext {
compose_version = '1.1.0-beta01'
compose_version = '1.3.0-alpha03'
lifecycle_version = '2.5.1'
kotlin_version = '1.6.20'
}
dependencies {
@ -13,7 +14,7 @@ buildscript {
plugins {
id 'com.android.application' version '7.2.2' apply false
id 'com.android.library' version '7.2.2' apply false
id 'org.jetbrains.kotlin.android' version '1.5.31' apply false
id 'org.jetbrains.kotlin.android' version '1.6.20' apply false
// id 'com.android.application' version '7.2.2' apply false
// id 'com.android.library' version '7.2.2' apply false
// id 'org.jetbrains.kotlin.android' version '1.7.20-Beta' apply false