Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Removed m2 dependency
This completely removes the Material2 dependency. The last pieces that
were using it were the local overrides of alpha values, which are now
set manually at that site based on the design.
  • Loading branch information
IanGClifton committed Aug 19, 2022
commit 0360ddcaa0c26cc513da7dabd5f709a559ed0e58
1 change: 0 additions & 1 deletion Jetsurvey/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ dependencies {
implementation Libs.AndroidX.Activity.activityCompose

implementation Libs.AndroidX.Compose.layout
implementation Libs.AndroidX.Compose.material
implementation Libs.AndroidX.Compose.material3
implementation Libs.AndroidX.Compose.materialIconsExtended
implementation Libs.AndroidX.Compose.toolingPreview
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ fun ErrorSnackbar(
TextButton(onClick = onDismiss) {
Text(
text = stringResource(id = R.string.dismiss),
//color = MaterialTheme.colorScheme.snackbarAction
color = MaterialTheme.colorScheme.inversePrimary
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.ContentAlpha
import androidx.compose.material.LocalContentAlpha
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ChevronLeft
import androidx.compose.material.icons.filled.Visibility
Expand All @@ -44,9 +42,9 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.SmallTopAppBar
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
Expand Down Expand Up @@ -136,12 +134,11 @@ fun Email(
emailState.text = it
},
label = {
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
Text(
text = stringResource(id = R.string.email),
style = MaterialTheme.typography.bodyMedium
)
}
Text(
text = stringResource(id = R.string.email),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.6f)
)
},
modifier = Modifier
.fillMaxWidth()
Expand Down Expand Up @@ -193,12 +190,11 @@ fun Password(
},
textStyle = MaterialTheme.typography.bodyMedium,
label = {
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
Text(
text = label,
style = MaterialTheme.typography.bodyMedium
)
}
Text(
text = label,
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.6f)
)
},
trailingIcon = {
if (showPassword.value) {
Expand Down Expand Up @@ -261,13 +257,12 @@ fun OrSignInAsGuest(
modifier = modifier,
horizontalAlignment = Alignment.CenterHorizontally
) {
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
Text(
text = stringResource(id = R.string.or),
style = MaterialTheme.typography.titleSmall,
modifier = Modifier.paddingFromBaseline(top = 25.dp)
)
}
Text(
text = stringResource(id = R.string.or),
style = MaterialTheme.typography.titleSmall,
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.6f),
modifier = Modifier.paddingFromBaseline(top = 25.dp)
)
OutlinedButton(
onClick = onSignedInAsGuest,
modifier = Modifier
Expand All @@ -283,9 +278,11 @@ fun OrSignInAsGuest(
@Composable
fun SignInSignUpScreenPreview() {
JetsurveyTheme {
SignInSignUpScreen(
onSignedInAsGuest = {},
content = {}
)
Surface {
SignInSignUpScreen(
onSignedInAsGuest = {},
content = {}
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,12 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.material.ContentAlpha
import androidx.compose.material.LocalContentAlpha
import androidx.compose.material3.Button
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
Expand Down Expand Up @@ -106,12 +103,11 @@ fun SignUpContent(
)

Spacer(modifier = Modifier.height(16.dp))
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
Text(
text = stringResource(id = R.string.terms_and_conditions),
style = MaterialTheme.typography.bodySmall
)
}
Text(
text = stringResource(id = R.string.terms_and_conditions),
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.6f)
)

Spacer(modifier = Modifier.height(16.dp))
Button(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,11 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.ContentAlpha
import androidx.compose.material.LocalContentAlpha
import androidx.compose.material3.Button
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
Expand All @@ -51,6 +48,7 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.example.compose.jetsurvey.R
import com.example.compose.jetsurvey.theme.JetsurveyTheme
import com.example.compose.jetsurvey.theme.surfaceIsLight
import com.example.compose.jetsurvey.util.supportWideScreen

sealed class WelcomeEvent {
Expand Down Expand Up @@ -122,9 +120,7 @@ private fun Branding(modifier: Modifier = Modifier) {
@Composable
private fun Logo(
modifier: Modifier = Modifier,
// TODO: figure out theme
lightTheme: Boolean = true
//lightTheme: Boolean = MaterialTheme.colors.isLight
lightTheme: Boolean = surfaceIsLight()
) {
val assetId = if (lightTheme) {
R.drawable.ic_logo_light
Expand All @@ -148,14 +144,13 @@ private fun SignInCreateAccount(
mutableStateOf(EmailState())
}
Column(modifier = modifier, horizontalAlignment = Alignment.CenterHorizontally) {
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
Text(
text = stringResource(id = R.string.sign_in_create_account),
style = MaterialTheme.typography.titleSmall,
textAlign = TextAlign.Center,
modifier = Modifier.padding(top = 64.dp, bottom = 12.dp)
)
}
Text(
text = stringResource(id = R.string.sign_in_create_account),
style = MaterialTheme.typography.titleSmall,
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.6f),
textAlign = TextAlign.Center,
modifier = Modifier.padding(top = 64.dp, bottom = 12.dp)
)
val onSubmit = {
if (emailState.isValid) {
onEvent(WelcomeEvent.SignInSignUp(emailState.text))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.selection.selectable
import androidx.compose.material.ContentAlpha
import androidx.compose.material.LocalContentAlpha
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.AddAPhoto
import androidx.compose.material.icons.filled.ArrowDropDown
Expand All @@ -55,7 +53,6 @@ import androidx.compose.material3.Slider
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand All @@ -64,7 +61,6 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
Expand All @@ -75,6 +71,7 @@ import coil.compose.AsyncImage
import coil.request.ImageRequest
import com.example.compose.jetsurvey.R
import com.example.compose.jetsurvey.theme.JetsurveyTheme
import com.example.compose.jetsurvey.theme.surfaceIsLight
import com.google.accompanist.permissions.ExperimentalPermissionsApi
import com.google.accompanist.permissions.MultiplePermissionsState
import com.google.accompanist.permissions.rememberMultiplePermissionsState
Expand Down Expand Up @@ -166,15 +163,14 @@ private fun QuestionContent(
QuestionTitle(question.questionText)
Spacer(modifier = Modifier.height(24.dp))
if (question.description != null) {
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
Text(
text = stringResource(id = question.description),
style = MaterialTheme.typography.bodySmall,
modifier = Modifier
.fillParentMaxWidth()
.padding(bottom = 18.dp, start = 8.dp, end = 8.dp)
)
}
Text(
text = stringResource(id = question.description),
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.6f),
style = MaterialTheme.typography.bodySmall,
modifier = Modifier
.fillParentMaxWidth()
.padding(bottom = 18.dp, start = 8.dp, end = 8.dp)
)
}
when (question.answer) {
is PossibleAnswer.SingleChoice -> SingleChoiceQuestion(
Expand Down Expand Up @@ -237,15 +233,11 @@ private fun QuestionContent(

@Composable
private fun QuestionTitle(@StringRes title: Int) {
// TODO figure out dark/light
val backgroundColor = Color.Red
/*
val backgroundColor = if (MaterialTheme.colors.isLight) {
val backgroundColor = if (surfaceIsLight()) {
MaterialTheme.colorScheme.onSurface.copy(alpha = 0.04f)
} else {
MaterialTheme.colorScheme.onSurface.copy(alpha = 0.06f)
}
*/
Row(
modifier = Modifier
.fillMaxWidth()
Expand Down Expand Up @@ -681,9 +673,8 @@ private fun DateQuestion(
Button(
onClick = { onAction(questionId, SurveyActionType.PICK_DATE) },
colors = ButtonDefaults.buttonColors(
// TODO verify this color
containerColor = MaterialTheme.colorScheme.onPrimary,
contentColor = MaterialTheme.colorScheme.onSecondary
containerColor = MaterialTheme.colorScheme.surface,
contentColor = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.87f),
),
shape = MaterialTheme.shapes.small,
modifier = modifier
Expand Down Expand Up @@ -711,9 +702,7 @@ private fun DateQuestion(
@Composable
private fun PhotoDefaultImage(
modifier: Modifier = Modifier,
// TODO figure out light/dark
//lightTheme: Boolean = MaterialTheme.colors.isLight
lightTheme: Boolean = true
lightTheme: Boolean = surfaceIsLight()
) {
val assetId = if (lightTheme) {
R.drawable.ic_selfie_light
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.ContentAlpha
import androidx.compose.material.LocalContentAlpha
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Close
import androidx.compose.material3.Button
Expand All @@ -49,7 +47,6 @@ import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
Expand Down Expand Up @@ -241,19 +238,18 @@ private fun SurveyTopAppBar(
.align(Alignment.Center)
)

CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
IconButton(
onClick = onBackPressed,
modifier = Modifier
.padding(horizontal = 20.dp, vertical = 20.dp)
.fillMaxWidth()
) {
Icon(
Icons.Filled.Close,
contentDescription = stringResource(id = R.string.close),
modifier = Modifier.align(Alignment.CenterEnd)
)
}
IconButton(
onClick = onBackPressed,
modifier = Modifier
.padding(horizontal = 20.dp, vertical = 20.dp)
.fillMaxWidth()
) {
Icon(
Icons.Filled.Close,
contentDescription = stringResource(id = R.string.close),
modifier = Modifier.align(Alignment.CenterEnd),
tint = MaterialTheme.colorScheme.onSurface.copy(0.6f)
)
}
}
val animatedProgress by animateFloatAsState(
Expand All @@ -265,9 +261,7 @@ private fun SurveyTopAppBar(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 20.dp),
// TODO set background properly
//trackColor =
//backgroundColor = MaterialTheme.colors.progressIndicatorBackground
trackColor = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.12f),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.example.compose.jetsurvey.theme

import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -92,21 +93,23 @@ fun JetsurveyTheme(
DarkColors
}

androidx.compose.material3.MaterialTheme(
MaterialTheme(
colorScheme = colors,
shapes = Shapes,
typography = Typography,
content = content,
)
}

// TODO Delete old theme
/*
val Colors.snackbarAction: Color
@Composable
get() = if (isLight) Purple300 else Purple700

val Colors.progressIndicatorBackground: Color
@Composable
get() = if (isLight) Color.Black.copy(alpha = 0.12f) else Color.White.copy(alpha = 0.24f)
*/
@Composable
fun surfaceIsLight(): Boolean {
return when (val surface = MaterialTheme.colorScheme.surface) {
LightColors.surface -> true
DarkColors.surface -> false
else -> {
// If surface is ever set to some other color, it was manually overridden locally and
// the calling site should determine the light/dark value itself
throw java.lang.IllegalStateException("Surface does not match known value: $surface")
}
}
}
Loading