[#116] Migrate to Material 3

This commit is contained in:
Carter Jernigan 2022-02-21 09:33:40 -05:00 committed by Carter Jernigan
parent 8efa866a3d
commit 6be2590ad8
23 changed files with 270 additions and 189 deletions

View File

@ -74,6 +74,7 @@ ANDROIDX_ACTIVITY_VERSION=1.4.0
ANDROIDX_ANNOTATION_VERSION=1.3.0
ANDROIDX_APPCOMPAT_VERSION=1.3.1
ANDROIDX_COMPOSE_COMPILER_VERSION=1.1.0
ANDROIDX_COMPOSE_MATERIAL3_VERSION=1.0.0-alpha05
ANDROIDX_COMPOSE_VERSION=1.1.0
ANDROIDX_CORE_VERSION=1.7.0
ANDROIDX_ESPRESSO_VERSION=3.4.0
@ -88,7 +89,6 @@ ANDROIDX_TEST_RUNNER_VERSION=1.5.0-alpha01
ANDROIDX_UI_AUTOMATOR_VERSION=2.2.0-alpha1
ANDROIDX_WORK_MANAGER_VERSION=2.7.1
CORE_LIBRARY_DESUGARING_VERSION=1.1.5
GOOGLE_MATERIAL_VERSION=1.4.0
JACOCO_VERSION=0.8.7
KOTLIN_VERSION=1.6.10
KOTLINX_COROUTINES_VERSION=1.6.0

View File

@ -1,3 +1,4 @@
enableFeaturePreview("VERSION_CATALOGS")
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
pluginManagement {
@ -87,6 +88,7 @@ dependencyResolutionManagement {
val androidxAnnotationVersion = extra["ANDROIDX_ANNOTATION_VERSION"].toString()
val androidxAppcompatVersion = extra["ANDROIDX_APPCOMPAT_VERSION"].toString()
val androidxComposeCompilerVersion = extra["ANDROIDX_COMPOSE_COMPILER_VERSION"].toString()
val androidxComposeMaterial3Version = extra["ANDROIDX_COMPOSE_MATERIAL3_VERSION"].toString()
val androidxComposeVersion = extra["ANDROIDX_COMPOSE_VERSION"].toString()
val androidxCoreVersion = extra["ANDROIDX_CORE_VERSION"].toString()
val androidxEspressoVersion = extra["ANDROIDX_ESPRESSO_VERSION"].toString()
@ -101,7 +103,6 @@ dependencyResolutionManagement {
val androidxUiAutomatorVersion = extra["ANDROIDX_UI_AUTOMATOR_VERSION"].toString()
val androidxWorkManagerVersion = extra["ANDROIDX_WORK_MANAGER_VERSION"].toString()
val coreLibraryDesugaringVersion = extra["CORE_LIBRARY_DESUGARING_VERSION"].toString()
val googleMaterialVersion = extra["GOOGLE_MATERIAL_VERSION"].toString()
val jacocoVersion = extra["JACOCO_VERSION"].toString()
val javaVersion = extra["ANDROID_JVM_TARGET"].toString()
val kotlinVersion = extra["KOTLIN_VERSION"].toString()
@ -115,48 +116,48 @@ dependencyResolutionManagement {
version("java", javaVersion)
// Aliases
library("androidx-activity", "androidx.activity:activity-ktx:$androidxActivityVersion")
library("androidx-activity-compose", "androidx.activity:activity-compose:$androidxActivityVersion")
library("androidx-annotation", "androidx.annotation:annotation:$androidxAnnotationVersion")
library("androidx-appcompat", "androidx.appcompat:appcompat:$androidxAppcompatVersion")
library("androidx-compose-foundation", "androidx.compose.foundation:foundation:$androidxComposeVersion")
library("androidx-compose-material", "androidx.compose.material:material:$androidxComposeVersion")
library("androidx-compose-material-icons-core", "androidx.compose.material:material-icons-core:$androidxComposeVersion")
library("androidx-compose-material-icons-extended", "androidx.compose.material:material-icons-extended:$androidxComposeVersion")
library("androidx-compose-tooling", "androidx.compose.ui:ui-tooling:$androidxComposeVersion")
library("androidx-compose-ui", "androidx.compose.ui:ui:$androidxComposeVersion")
library("androidx-compose-compiler", "androidx.compose.compiler:compiler:$androidxComposeCompilerVersion")
library("androidx-core", "androidx.core:core-ktx:$androidxCoreVersion")
library("androidx-lifecycle-livedata", "androidx.lifecycle:lifecycle-livedata-ktx:$androidxLifecycleVersion")
library("androidx-navigation-compose", "androidx.navigation:navigation-compose:$androidxNavigationComposeVersion")
library("androidx-security-crypto", "androidx.security:security-crypto-ktx:$androidxSecurityCryptoVersion")
library("androidx-splash", "androidx.core:core-splashscreen:$androidxSplashScreenVersion")
library("androidx-viewmodel-compose", "androidx.lifecycle:lifecycle-viewmodel-compose:$androidxLifecycleVersion")
library("androidx-workmanager", "androidx.work:work-runtime-ktx:$androidxWorkManagerVersion")
library("desugaring", "com.android.tools:desugar_jdk_libs:$coreLibraryDesugaringVersion")
library("google-material", "com.google.android.material:material:$googleMaterialVersion")
library("kotlin-stdlib", "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion")
library("kotlin-reflect", "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
library("kotlin-test", "org.jetbrains.kotlin:kotlin-test:$kotlinVersion")
library("kotlinx-coroutines-android", "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinxCoroutinesVersion")
library("kotlinx-coroutines-core", "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinxCoroutinesVersion")
library("zcash-sdk", "cash.z.ecc.android:zcash-android-sdk:$zcashSdkVersion")
library("zcash-bip39", "cash.z.ecc.android:kotlin-bip39:$zcashBip39Version")
library("zcash-walletplgns", "cash.z.ecc.android:zcash-android-wallet-plugins:$zcashBip39Version")
library("zxing", "com.google.zxing:core:$zxingVersion")
alias("androidx-activity").to("androidx.activity:activity-ktx:$androidxActivityVersion")
alias("androidx-activity-compose").to("androidx.activity:activity-compose:$androidxActivityVersion")
alias("androidx-annotation").to("androidx.annotation:annotation:$androidxAnnotationVersion")
alias("androidx-appcompat").to("androidx.appcompat:appcompat:$androidxAppcompatVersion")
alias("androidx-compose-foundation").to("androidx.compose.foundation:foundation:$androidxComposeVersion")
alias("androidx-compose-material").to("androidx.compose.material:material:$androidxComposeVersion")
alias("androidx-compose-material3").to("androidx.compose.material3:material3:$androidxComposeMaterial3Version")
alias("androidx-compose-material-icons-core").to("androidx.compose.material:material-icons-core:$androidxComposeVersion")
alias("androidx-compose-material-icons-extended").to("androidx.compose.material:material-icons-extended:$androidxComposeVersion")
alias("androidx-compose-tooling").to("androidx.compose.ui:ui-tooling:$androidxComposeVersion")
alias("androidx-compose-ui").to("androidx.compose.ui:ui:$androidxComposeVersion")
alias("androidx-compose-compiler").to("androidx.compose.compiler:compiler:$androidxComposeCompilerVersion")
alias("androidx-core").to("androidx.core:core-ktx:$androidxCoreVersion")
alias("androidx-lifecycle-livedata").to("androidx.lifecycle:lifecycle-livedata-ktx:$androidxLifecycleVersion")
alias("androidx-navigation-compose").to("androidx.navigation:navigation-compose:$androidxNavigationComposeVersion")
alias("androidx-security-crypto").to("androidx.security:security-crypto-ktx:$androidxSecurityCryptoVersion")
alias("androidx-splash").to("androidx.core:core-splashscreen:$androidxSplashScreenVersion")
alias("androidx-viewmodel-compose").to("androidx.lifecycle:lifecycle-viewmodel-compose:$androidxLifecycleVersion")
alias("androidx-workmanager").to("androidx.work:work-runtime-ktx:$androidxWorkManagerVersion")
alias("desugaring").to("com.android.tools:desugar_jdk_libs:$coreLibraryDesugaringVersion")
alias("kotlin-stdlib").to("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion")
alias("kotlin-reflect").to("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
alias("kotlin-test").to("org.jetbrains.kotlin:kotlin-test:$kotlinVersion")
alias("kotlinx-coroutines-android").to("org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinxCoroutinesVersion")
alias("kotlinx-coroutines-core").to("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinxCoroutinesVersion")
alias("zcash-sdk").to("cash.z.ecc.android:zcash-android-sdk:$zcashSdkVersion")
alias("zcash-bip39").to("cash.z.ecc.android:kotlin-bip39:$zcashBip39Version")
alias("zcash-walletplgns").to("cash.z.ecc.android:zcash-android-wallet-plugins:$zcashBip39Version")
alias("zxing").to("com.google.zxing:core:$zxingVersion")
// Test libraries
library("androidx-compose-test-junit", "androidx.compose.ui:ui-test-junit4:$androidxComposeVersion")
library("androidx-compose-test-manifest", "androidx.compose.ui:ui-test-manifest:$androidxComposeVersion")
alias("androidx-compose-test-junit").to("androidx.compose.ui:ui-test-junit4:$androidxComposeVersion")
alias("androidx-compose-test-manifest").to("androidx.compose.ui:ui-test-manifest:$androidxComposeVersion")
// Cannot use espresso-contrib, because it causes a build failure
//alias("androidx-espresso-contrib", "androidx.test.espresso:espresso-contrib:$androidxEspressoVersion")
library("androidx-espresso-core", "androidx.test.espresso:espresso-core:$androidxEspressoVersion")
library("androidx-espresso-intents", "androidx.test.espresso:espresso-intents:$androidxEspressoVersion")
library("androidx-test-core", "androidx.test:core:$androidxTestCoreVersion")
library("androidx-test-junit", "androidx.test.ext:junit:$androidxTestJunitVersion")
library("androidx-test-orchestrator", "androidx.test:orchestrator:$androidxTestOrchestratorVersion")
library("androidx-test-runner", "androidx.test:runner:$androidxTestRunnerVersion")
library("androidx-uiAutomator", "androidx.test.uiautomator:uiautomator-v18:$androidxUiAutomatorVersion")
library("kotlinx-coroutines-test", "org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlinxCoroutinesVersion")
//alias("androidx-espresso-contrib").to("androidx.test.espresso:espresso-contrib:$androidxEspressoVersion")
alias("androidx-espresso-core").to("androidx.test.espresso:espresso-core:$androidxEspressoVersion")
alias("androidx-espresso-intents").to("androidx.test.espresso:espresso-intents:$androidxEspressoVersion")
alias("androidx-test-core").to("androidx.test:core:$androidxTestCoreVersion")
alias("androidx-test-junit").to("androidx.test.ext:junit:$androidxTestJunitVersion")
alias("androidx-test-orchestrator").to("androidx.test:orchestrator:$androidxTestOrchestratorVersion")
alias("androidx-test-runner").to("androidx.test:runner:$androidxTestRunnerVersion")
alias("androidx-uiAutomator").to("androidx.test.uiautomator:uiautomator-v18:$androidxUiAutomatorVersion")
alias("kotlinx-coroutines-test").to("org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlinxCoroutinesVersion")
// Bundles
bundle(
@ -166,6 +167,7 @@ dependencyResolutionManagement {
"androidx-compose-compiler",
"androidx-compose-foundation",
"androidx-compose-material",
"androidx-compose-material3",
"androidx-compose-material-icons-core",
"androidx-compose-material-icons-extended",
"androidx-compose-tooling",

View File

@ -44,13 +44,13 @@ android {
dependencies {
implementation(libs.androidx.activity)
implementation(libs.androidx.appcompat)
implementation(libs.androidx.annotation)
implementation(libs.androidx.core)
implementation(libs.androidx.lifecycle.livedata)
implementation(libs.androidx.splash)
implementation(libs.androidx.workmanager)
implementation(libs.bundles.androidx.compose)
implementation(libs.google.material)
implementation(libs.kotlin.stdlib)
implementation(libs.kotlinx.coroutines.android)
implementation(libs.kotlinx.coroutines.core)

View File

@ -6,7 +6,8 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material.Card
import androidx.compose.material3.Card
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.ui.Modifier
@ -99,6 +100,7 @@ private fun EducationOverview(onNext: () -> Unit) {
}
}
@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun EducationRecoveryPhrase(onNext: () -> Unit) {
Column {

View File

@ -1,19 +1,21 @@
package cash.z.ecc.ui.screen.backup.view
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.DropdownMenu
import androidx.compose.material.DropdownMenuItem
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowDropDown
import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@ -33,7 +35,7 @@ import cash.z.ecc.ui.theme.ZcashTheme
* @param choices Item choices to display in the open drop down menu. Positional index is important.
* @param onChoiceSelected Callback with the positional index of the item the user selected from [choices].
*/
@OptIn(ExperimentalMaterialApi::class)
@Composable
fun ChipDropDown(
chipIndex: Index,
@ -45,11 +47,17 @@ fun ChipDropDown(
var expanded by remember { mutableStateOf(false) }
Surface(
modifier = modifier.then(Modifier.padding(4.dp)),
shape = MaterialTheme.shapes.medium,
color = MaterialTheme.colors.secondary,
elevation = 8.dp,
onClick = { expanded = !expanded }
modifier = modifier.then(
Modifier
.padding(4.dp)
.clickable { expanded = !expanded }
),
shape = RoundedCornerShape(8.dp),
color = MaterialTheme.colorScheme.secondary,
contentColor = MaterialTheme.colorScheme.secondary,
tonalElevation = 8.dp,
shadowElevation = 8.dp,
interactionSource = MutableInteractionSource(),
) {
Row(modifier = Modifier.padding(8.dp)) {
Text(
@ -77,12 +85,15 @@ fun ChipDropDown(
modifier = dropdownModifier
) {
choices.forEachIndexed { index, label ->
DropdownMenuItem(onClick = {
expanded = false
onChoiceSelected(Index(index))
}) {
Text(text = label)
}
DropdownMenuItem(
text = {
Text(text = label)
},
onClick = {
expanded = false
onChoiceSelected(Index(index))
}
)
}
}
}

View File

@ -3,11 +3,11 @@ package cash.z.ecc.ui.screen.common
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Button
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.ButtonDefaults.buttonColors
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.ButtonDefaults.buttonColors
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
@ -44,9 +44,13 @@ fun PrimaryButton(
.padding(horizontal = 16.dp, vertical = 8.dp)
),
enabled = enabled,
colors = buttonColors(backgroundColor = MaterialTheme.colors.primary)
colors = buttonColors(containerColor = MaterialTheme.colorScheme.primary)
) {
Text(style = MaterialTheme.typography.button, text = text, color = MaterialTheme.colors.onPrimary)
Text(
style = MaterialTheme.typography.labelLarge,
text = text,
color = MaterialTheme.colorScheme.onPrimary
)
}
}
@ -63,9 +67,13 @@ fun SecondaryButton(
.fillMaxWidth()
.padding(horizontal = 16.dp, vertical = 8.dp)
),
colors = buttonColors(backgroundColor = MaterialTheme.colors.secondary)
colors = buttonColors(containerColor = MaterialTheme.colorScheme.secondary)
) {
Text(style = MaterialTheme.typography.button, text = text, color = MaterialTheme.colors.onSecondary)
Text(
style = MaterialTheme.typography.labelLarge,
text = text,
color = MaterialTheme.colorScheme.onSecondary
)
}
}
@ -81,9 +89,9 @@ fun NavigationButton(
Modifier
.padding(horizontal = 16.dp, vertical = 8.dp)
),
colors = buttonColors(backgroundColor = MaterialTheme.colors.secondary)
colors = buttonColors(containerColor = MaterialTheme.colorScheme.secondary)
) {
Text(style = MaterialTheme.typography.button, text = text, color = MaterialTheme.colors.onSecondary)
Text(style = MaterialTheme.typography.labelLarge, text = text, color = MaterialTheme.colorScheme.onSecondary)
}
}
@ -100,10 +108,14 @@ fun TertiaryButton(
.fillMaxWidth()
.padding(horizontal = 16.dp, vertical = 8.dp)
),
elevation = ButtonDefaults.elevation(0.dp, 0.dp, 0.dp),
colors = buttonColors(backgroundColor = ZcashTheme.colors.tertiary)
elevation = ButtonDefaults.buttonElevation(0.dp, 0.dp, 0.dp),
colors = buttonColors(containerColor = ZcashTheme.colors.tertiary)
) {
Text(style = MaterialTheme.typography.button, text = text, color = ZcashTheme.colors.onTertiary)
Text(
style = MaterialTheme.typography.labelLarge,
text = text,
color = ZcashTheme.colors.onTertiary
)
}
}
@ -120,8 +132,12 @@ fun DangerousButton(
.fillMaxWidth()
.padding(horizontal = 16.dp, vertical = 8.dp)
),
colors = buttonColors(backgroundColor = ZcashTheme.colors.dangerous)
colors = buttonColors(containerColor = ZcashTheme.colors.dangerous)
) {
Text(style = MaterialTheme.typography.button, text = text, color = ZcashTheme.colors.onDangerous)
Text(
style = MaterialTheme.typography.labelLarge,
text = text,
color = ZcashTheme.colors.onDangerous
)
}
}

View File

@ -3,9 +3,10 @@ package cash.z.ecc.ui.screen.common
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.padding
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
@ -30,9 +31,9 @@ fun Chip(
) {
Surface(
modifier = modifier.then(Modifier.padding(4.dp)),
shape = MaterialTheme.shapes.medium,
color = MaterialTheme.colors.secondary,
elevation = 8.dp,
shape = RoundedCornerShape(8.dp),
color = MaterialTheme.colorScheme.secondary,
shadowElevation = 8.dp,
) {
Row(
modifier = Modifier
@ -46,8 +47,8 @@ fun Chip(
Spacer(modifier = Modifier.padding(horizontal = 2.dp, vertical = 0.dp))
Text(
text = text,
style = MaterialTheme.typography.body1,
color = MaterialTheme.colors.onSecondary,
style = MaterialTheme.typography.bodyLarge,
color = MaterialTheme.colorScheme.onSecondary,
modifier = Modifier.testTag(CommonTag.CHIP)
)
}

View File

@ -1,7 +1,7 @@
package cash.z.ecc.ui.screen.common
import androidx.compose.foundation.background
import androidx.compose.material.Surface
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color

View File

@ -1,6 +1,6 @@
package cash.z.ecc.ui.screen.common
import androidx.compose.material.LinearProgressIndicator
import androidx.compose.material3.LinearProgressIndicator
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import cash.z.ecc.ui.screen.onboarding.model.Progress

View File

@ -1,7 +1,7 @@
package cash.z.ecc.ui.screen.common
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import cash.z.ecc.ui.theme.ZcashTheme
@ -13,7 +13,7 @@ fun Header(
) {
Text(
text = text,
style = MaterialTheme.typography.h1,
style = MaterialTheme.typography.headlineLarge,
color = ZcashTheme.colors.onBackgroundHeader,
modifier = modifier
)
@ -26,8 +26,8 @@ fun Body(
) {
Text(
text = text,
style = MaterialTheme.typography.body1,
color = MaterialTheme.colors.onBackground,
style = MaterialTheme.typography.bodyLarge,
color = MaterialTheme.colorScheme.onBackground,
modifier = modifier
)
}
@ -40,7 +40,7 @@ fun ListItem(
Text(
text = text,
style = ZcashTheme.typography.listItem,
color = MaterialTheme.colors.onBackground,
color = MaterialTheme.colorScheme.onBackground,
modifier = modifier
)
}
@ -53,7 +53,7 @@ fun ListHeader(
Text(
text = text,
style = ZcashTheme.typography.listItem,
color = MaterialTheme.colors.onBackground,
color = MaterialTheme.colorScheme.onBackground,
modifier = modifier
)
}

View File

@ -0,0 +1,59 @@
package cash.z.ecc.ui.screen.common
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.LocalTextStyle
import androidx.compose.material.TextFieldColors
import androidx.compose.material.TextFieldDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.input.VisualTransformation
// Material3 does not have its own TextField component yet, so proxy the one from Material 2
@Suppress("LongParameterList")
@Composable
fun TextField(
value: String,
onValueChange: (String) -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
readOnly: Boolean = false,
textStyle: TextStyle = LocalTextStyle.current,
label: @Composable (() -> Unit)? = null,
placeholder: @Composable (() -> Unit)? = null,
leadingIcon: @Composable (() -> Unit)? = null,
trailingIcon: @Composable (() -> Unit)? = null,
isError: Boolean = false,
visualTransformation: VisualTransformation = VisualTransformation.None,
keyboardOptions: KeyboardOptions = KeyboardOptions.Default,
keyboardActions: KeyboardActions = KeyboardActions(),
singleLine: Boolean = false,
maxLines: Int = Int.MAX_VALUE,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
colors: TextFieldColors = TextFieldDefaults.textFieldColors()
) {
androidx.compose.material.TextField(
value,
onValueChange,
modifier,
enabled,
readOnly,
textStyle,
label,
placeholder,
leadingIcon,
trailingIcon,
isError,
visualTransformation,
keyboardOptions,
keyboardActions,
singleLine,
maxLines,
interactionSource,
colors = colors
)
}

View File

@ -6,16 +6,16 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.Scaffold
import androidx.compose.material.Text
import androidx.compose.material.TopAppBar
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Person
import androidx.compose.material.icons.filled.QrCodeScanner
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SmallTopAppBar
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment.Companion.CenterVertically
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
@ -51,6 +51,7 @@ fun ComposablePreview() {
}
}
@OptIn(ExperimentalMaterial3Api::class)
@Suppress("LongParameterList")
@Composable
fun Home(
@ -77,14 +78,7 @@ fun Home(
@Composable
private fun HomeTopAppBar() {
TopAppBar {
Row(
verticalAlignment = CenterVertically,
modifier = Modifier.fillMaxWidth()
) {
Text(text = stringResource(id = R.string.app_name))
}
}
SmallTopAppBar(title = { Text(text = stringResource(id = R.string.app_name)) })
}
@Suppress("LongParameterList")

View File

@ -12,12 +12,12 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.Text
import androidx.compose.material.TopAppBar
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.SmallTopAppBar
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.ui.Modifier
@ -79,7 +79,7 @@ fun Onboarding(
private fun OnboardingTopAppBar(onboardingState: OnboardingState) {
val currentStage = onboardingState.current.collectAsState().value
TopAppBar(
SmallTopAppBar(
title = { Text(text = stringResource(id = R.string.app_name)) },
navigationIcon =
if (IS_NAVIGATION_IN_APP_BAR && currentStage.hasPrevious()) {
@ -92,7 +92,7 @@ private fun OnboardingTopAppBar(onboardingState: OnboardingState) {
}
}
} else {
null
{ Unit }
},
actions = {
if (IS_NAVIGATION_IN_APP_BAR && currentStage.hasNext()) {

View File

@ -4,14 +4,14 @@ import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Divider
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material.TopAppBar
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material3.Divider
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.SmallTopAppBar
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@ -78,7 +78,7 @@ fun Profile(
@Composable
private fun ProfileTopAppBar(onBack: () -> Unit) {
TopAppBar(
SmallTopAppBar(
title = {
Text(
text = stringResource(id = R.string.profile_title)
@ -91,7 +91,7 @@ private fun ProfileTopAppBar(onBack: () -> Unit) {
Icon(
imageVector = Icons.Filled.ArrowBack,
contentDescription = stringResource(R.string.profile_back_content_description),
tint = MaterialTheme.colors.secondary
tint = MaterialTheme.colorScheme.secondary
)
}
}
@ -116,8 +116,8 @@ private fun ProfileContents(
// TODO [#163]: Ellipsize center of the string
Text(
text = walletAddress.address,
style = MaterialTheme.typography.body1,
color = MaterialTheme.colors.onBackground,
style = MaterialTheme.typography.headlineLarge,
color = MaterialTheme.colorScheme.onBackground,
modifier = Modifier.align(Alignment.CenterHorizontally),
overflow = TextOverflow.Ellipsis
)

View File

@ -5,14 +5,14 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.Scaffold
import androidx.compose.material.Text
import androidx.compose.material.TextField
import androidx.compose.material.TopAppBar
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SmallTopAppBar
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@ -33,6 +33,7 @@ import cash.z.ecc.sdk.model.fromZecString
import cash.z.ecc.ui.R
import cash.z.ecc.ui.screen.common.GradientSurface
import cash.z.ecc.ui.screen.common.PrimaryButton
import cash.z.ecc.ui.screen.common.TextField
import cash.z.ecc.ui.theme.MINIMAL_WEIGHT
import cash.z.ecc.ui.theme.ZcashTheme
import kotlinx.coroutines.runBlocking
@ -53,6 +54,7 @@ fun PreviewRequest() {
/**
* @param myAddress The address that ZEC should be sent to.
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun Request(
myAddress: WalletAddress.Unified,
@ -71,7 +73,7 @@ fun Request(
@Composable
private fun RequestTopAppBar(onBack: () -> Unit) {
TopAppBar(
SmallTopAppBar(
title = { Text(text = stringResource(id = R.string.request_title)) },
navigationIcon = {
IconButton(

View File

@ -16,15 +16,15 @@ import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Button
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.Scaffold
import androidx.compose.material.Text
import androidx.compose.material.TextField
import androidx.compose.material.TopAppBar
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material3.Button
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SmallTopAppBar
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.collectAsState
@ -55,6 +55,7 @@ import cash.z.ecc.ui.screen.common.GradientSurface
import cash.z.ecc.ui.screen.common.Header
import cash.z.ecc.ui.screen.common.NavigationButton
import cash.z.ecc.ui.screen.common.PrimaryButton
import cash.z.ecc.ui.screen.common.TextField
import cash.z.ecc.ui.screen.onboarding.model.Index
import cash.z.ecc.ui.screen.restore.RestoreTag
import cash.z.ecc.ui.screen.restore.model.ParseResult
@ -98,6 +99,7 @@ fun PreviewRestoreComplete() {
}
}
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun RestoreWallet(
completeWordList: Set<String>,
@ -121,7 +123,7 @@ fun RestoreWallet(
@Composable
private fun RestoreTopAppBar(onBack: () -> Unit, onClear: () -> Unit) {
TopAppBar(
SmallTopAppBar(
title = { Text(text = stringResource(id = R.string.restore_header)) },
navigationIcon = {
IconButton(

View File

@ -3,13 +3,14 @@ package cash.z.ecc.ui.screen.seed.view
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.Scaffold
import androidx.compose.material.Text
import androidx.compose.material.TopAppBar
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SmallTopAppBar
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
@ -42,6 +43,7 @@ fun PreviewSeed() {
* Note we have some things to determine regarding locking of the secrets for persistableWallet
* (e.g. seed phrase and spending keys) which should require additional authorization to view.
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun Seed(
persistableWallet: PersistableWallet,
@ -57,7 +59,7 @@ fun Seed(
@Composable
private fun SeedTopAppBar(onBack: () -> Unit) {
TopAppBar(
SmallTopAppBar(
title = { Text(text = stringResource(id = R.string.seed_title)) },
navigationIcon = {
IconButton(

View File

@ -1,13 +1,14 @@
package cash.z.ecc.ui.screen.settings.view
import androidx.compose.foundation.layout.Column
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.Scaffold
import androidx.compose.material.Text
import androidx.compose.material.TopAppBar
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SmallTopAppBar
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
@ -33,6 +34,7 @@ fun PreviewSettings() {
}
}
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun Settings(
onBack: () -> Unit,
@ -53,7 +55,7 @@ fun Settings(
@Composable
private fun SettingsTopAppBar(onBack: () -> Unit) {
TopAppBar(
SmallTopAppBar(
title = { Text(text = stringResource(id = R.string.settings_header)) },
navigationIcon = {
IconButton(

View File

@ -15,15 +15,15 @@ import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.width
import androidx.compose.material.Divider
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material.TopAppBar
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.filled.ArrowDropDownCircle
import androidx.compose.material3.Divider
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.SmallTopAppBar
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@ -71,7 +71,7 @@ fun WalletAddresses(walletAddresses: WalletAddresses, onBack: () -> Unit) {
@Composable
private fun WalletDetailTopAppBar(onBack: () -> Unit) {
TopAppBar(
SmallTopAppBar(
title = {
Text(
text = stringResource(id = R.string.wallet_address_title)
@ -84,7 +84,7 @@ private fun WalletDetailTopAppBar(onBack: () -> Unit) {
Icon(
imageVector = Icons.Filled.ArrowBack,
contentDescription = stringResource(R.string.wallet_address_back_content_description),
tint = MaterialTheme.colors.secondary
tint = MaterialTheme.colorScheme.secondary
)
}
}
@ -251,6 +251,6 @@ private fun ExpandableArrow(isExpanded: Boolean) {
} else {
Modifier.rotate(NINETY_DEGREES)
},
tint = MaterialTheme.colors.onBackground
tint = MaterialTheme.colorScheme.onBackground
)
}

View File

@ -1,11 +0,0 @@
package cash.z.ecc.ui.theme
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Shapes
import androidx.compose.ui.unit.dp
val Shapes = Shapes(
small = RoundedCornerShape(4.dp),
medium = RoundedCornerShape(4.dp),
large = RoundedCornerShape(0.dp)
)

View File

@ -1,9 +1,9 @@
package cash.z.ecc.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.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.Immutable
@ -11,7 +11,7 @@ import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
private val DarkColorPalette = darkColors(
private val DarkColorPalette = darkColorScheme(
primary = Dark.primaryButton,
secondary = Dark.secondaryButton,
onPrimary = Dark.textPrimaryButton,
@ -22,7 +22,7 @@ private val DarkColorPalette = darkColors(
onBackground = Dark.textBodyOnBackground,
)
private val LightColorPalette = lightColors(
private val LightColorPalette = lightColorScheme(
primary = Light.primaryButton,
secondary = Light.secondaryButton,
onPrimary = Light.textPrimaryButton,
@ -58,7 +58,7 @@ data class ExtendedColors(
@Composable
fun surfaceGradient() = Brush.verticalGradient(
colors = listOf(
MaterialTheme.colors.surface,
MaterialTheme.colorScheme.surface,
ZcashTheme.colors.surfaceEnd
)
)
@ -151,9 +151,8 @@ fun ZcashTheme(
CompositionLocalProvider(LocalExtendedColors provides extendedColors) {
MaterialTheme(
colors = baseColors,
colorScheme = baseColors,
typography = Typography,
shapes = Shapes,
content = content
)
}

View File

@ -1,6 +1,6 @@
package cash.z.ecc.ui.theme
import androidx.compose.material.Typography
import androidx.compose.material3.Typography
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.text.TextStyle
@ -19,22 +19,22 @@ private val Rubik = FontFamily(
@OptIn(ExperimentalUnitApi::class)
val Typography = Typography(
h1 = TextStyle(
headlineLarge = TextStyle(
fontFamily = Rubik,
fontWeight = FontWeight.W600,
fontSize = 30.sp,
),
body1 = TextStyle(
bodyLarge = TextStyle(
fontFamily = Rubik,
fontWeight = FontWeight.Normal,
fontSize = 16.sp
),
caption = TextStyle(
bodySmall = TextStyle(
fontFamily = Rubik,
fontWeight = FontWeight.Medium,
fontSize = 16.sp
),
button = TextStyle(
labelLarge = TextStyle(
fontFamily = Rubik,
fontWeight = FontWeight.Normal,
fontSize = 16.sp
@ -49,12 +49,12 @@ data class ExtendedTypography(
val LocalExtendedTypography = staticCompositionLocalOf {
ExtendedTypography(
chipIndex = Typography.body1.copy(
chipIndex = Typography.bodyLarge.copy(
fontSize = 10.sp,
baselineShift = BaselineShift.Superscript,
fontWeight = FontWeight.Bold
),
listItem = Typography.body1.copy(
listItem = Typography.bodyLarge.copy(
fontSize = 24.sp
)
)

View File

@ -3,6 +3,6 @@
<style name="Theme.App.Starting" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/splash_screen_background</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_launcher_adaptive_foreground</item>
<item name="postSplashScreenTheme">@style/Theme.MaterialComponents.DayNight</item>
<item name="postSplashScreenTheme">@style/Theme.AppCompat.DayNight</item>
</style>
</resources>