-
Notifications
You must be signed in to change notification settings - Fork 0
#14 UI enhancement #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,6 @@ fun AppRoot() { | |
| backStack.add(AddTimerScreen) | ||
| }) | ||
| } | ||
| addTimerScreen() | ||
| addTimerScreen(backStack) | ||
| }) | ||
| } | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| package me.rezapour.designsystem.components.button | ||
|
|
||
| import androidx.compose.foundation.background | ||
| import androidx.compose.foundation.layout.size | ||
| import androidx.compose.foundation.shape.RoundedCornerShape | ||
| import androidx.compose.material3.Icon | ||
| import androidx.compose.material3.IconButton | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.draw.clip | ||
| import androidx.compose.ui.res.painterResource | ||
| import androidx.compose.ui.unit.dp | ||
| import me.rezapour.designsystem.theme.IniTheme | ||
| import me.rezapour.designsystem.util.IniPreview | ||
| import me.rezapour.designsystem.R as res | ||
|
|
||
|
|
||
| @Composable | ||
| fun IniButtonPicker( | ||
| modifier: Modifier = Modifier, | ||
| increaseMode: Boolean = true, | ||
| onClick: () -> Unit | ||
| ) { | ||
|
|
||
| IconButton( | ||
| modifier = modifier | ||
| .size(54.dp) | ||
| .clip(RoundedCornerShape(IniTheme.appShapes.medium)) | ||
| .background( | ||
| color = IniTheme.colors.primaryContainer, | ||
| ), | ||
| onClick = onClick | ||
| ) { | ||
| Icon( | ||
| painter = if (increaseMode) | ||
| painterResource(res.drawable.ic_plus) | ||
| else | ||
| painterResource(res.drawable.ic_minus), | ||
| contentDescription = null, | ||
| tint = IniTheme.colors.primary, | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| @IniPreview | ||
| @Composable | ||
| fun IniButtonPreview() { | ||
| IniTheme() { | ||
| IniButtonPicker(increaseMode = true) { | ||
|
|
||
| } | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,42 +1,93 @@ | ||
| package me.rezapour.designsystem.theme | ||
|
|
||
| import android.os.Build | ||
| import androidx.compose.foundation.isSystemInDarkTheme | ||
| import androidx.compose.material3.ColorScheme | ||
| import androidx.compose.material3.MaterialTheme | ||
| import androidx.compose.material3.Shapes | ||
| import androidx.compose.material3.Typography | ||
| import androidx.compose.material3.darkColorScheme | ||
| import androidx.compose.material3.dynamicDarkColorScheme | ||
| import androidx.compose.material3.dynamicLightColorScheme | ||
| import androidx.compose.material3.lightColorScheme | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.runtime.CompositionLocalProvider | ||
| import androidx.compose.runtime.ReadOnlyComposable | ||
| import androidx.compose.ui.graphics.Color | ||
| import androidx.compose.ui.platform.LocalContext | ||
|
|
||
| private val DarkColorScheme = darkColorScheme( | ||
| primary = Purple80, | ||
| secondary = PurpleGrey80, | ||
| tertiary = Pink80 | ||
| primary = GreenPrimary, | ||
| onPrimary = OnLight, | ||
| primaryContainer = GreenContainerDark, | ||
| onPrimaryContainer = GreenContainerLight, | ||
|
|
||
| secondary = OrangeSecondary, | ||
| onSecondary = OnLight, | ||
| secondaryContainer = OrangeContainerDark, | ||
| onSecondaryContainer = Color(0xFFFFDCC2), | ||
|
|
||
| tertiary = SkyTertiary, | ||
| onTertiary = OnLight, | ||
| tertiaryContainer = SkyContainerDark, | ||
| onTertiaryContainer = Color(0xFFBFE9FF), | ||
|
|
||
| background = BackgroundDark, | ||
| onBackground = OnDark, | ||
|
|
||
| surface = SurfaceDark, | ||
| onSurface = OnDark, | ||
|
|
||
| surfaceVariant = SurfaceVariantDark, | ||
| onSurfaceVariant = MutedDark, | ||
|
|
||
| outline = OutlineDark, | ||
| outlineVariant = OutlineVariantDark, | ||
|
|
||
| error = ErrorDark, | ||
| onError = OnErrorDark, | ||
| errorContainer = ErrorContainerDark, | ||
| onErrorContainer = Color(0xFFFFDAD6), | ||
| ) | ||
|
|
||
| private val LightColorScheme = lightColorScheme( | ||
| primary = Purple40, | ||
| secondary = PurpleGrey40, | ||
| tertiary = Pink40 | ||
|
|
||
| /* Other default colors to override | ||
| background = Color(0xFFFFFBFE), | ||
| surface = Color(0xFFFFFBFE), | ||
| primary = GreenPrimaryDark, | ||
| onPrimary = Color.White, | ||
| primaryContainer = GreenContainerLight, | ||
| onPrimaryContainer = Color(0xFF052E16), | ||
|
|
||
| secondary = OrangeSecondaryDark, | ||
| onSecondary = Color.White, | ||
| secondaryContainer = OrangeContainerLight, | ||
| onSecondaryContainer = Color(0xFF431407), | ||
|
|
||
| tertiary = SkyTertiaryDark, | ||
| onTertiary = Color.White, | ||
| onBackground = Color(0xFF1C1B1F), | ||
| onSurface = Color(0xFF1C1B1F), | ||
| */ | ||
| tertiaryContainer = SkyContainerLight, | ||
| onTertiaryContainer = Color(0xFF082F49), | ||
|
|
||
| background = BackgroundLight, | ||
| onBackground = OnLight, | ||
|
|
||
| surface = SurfaceLight, | ||
| onSurface = OnLight, | ||
|
|
||
| surfaceVariant = SurfaceVariantLight, | ||
| onSurfaceVariant = MutedLight, | ||
|
|
||
| outline = OutlineLight, | ||
| outlineVariant = OutlineVariantLight, | ||
|
|
||
| error = ErrorLight, | ||
| onError = OnErrorLight, | ||
| errorContainer = ErrorContainerLight, | ||
| onErrorContainer = Color(0xFF410E0B), | ||
| ) | ||
|
|
||
| @Composable | ||
| fun IntervalTimerTheme( | ||
| darkTheme: Boolean = isSystemInDarkTheme(), | ||
| fun IniTheme( | ||
| darkTheme: Boolean = true, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Useful? React with 👍 / 👎.
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will fix it latter |
||
| // Dynamic color is available on Android 12+ | ||
| dynamicColor: Boolean = true, | ||
| dynamicColor: Boolean = false, | ||
| content: @Composable () -> Unit | ||
| ) { | ||
| val colorScheme = when { | ||
|
|
@@ -49,9 +100,38 @@ fun IntervalTimerTheme( | |
| else -> LightColorScheme | ||
| } | ||
|
|
||
| MaterialTheme( | ||
| colorScheme = colorScheme, | ||
| typography = Typography, | ||
| content = content | ||
| ) | ||
| } | ||
| val spacing = Spacing() | ||
| val appShapes = AppShapes() | ||
| val sizes = Sizes() | ||
|
|
||
| CompositionLocalProvider( | ||
| LocalSpacing provides spacing, | ||
| LocalShapes provides appShapes, | ||
| LocalSizes provides sizes | ||
| ) { | ||
| MaterialTheme( | ||
| colorScheme = colorScheme, | ||
| typography = Typography, | ||
| content = content | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| object IniTheme { | ||
| val spacing: Spacing | ||
| @Composable @ReadOnlyComposable get() = LocalSpacing.current | ||
| val sizes: Sizes | ||
| @Composable @ReadOnlyComposable get() = LocalSizes.current | ||
|
|
||
| val appShapes: AppShapes | ||
| @Composable @ReadOnlyComposable get() = LocalShapes.current | ||
|
|
||
| val colors: ColorScheme | ||
| @Composable @ReadOnlyComposable get() = MaterialTheme.colorScheme | ||
|
|
||
| val typography: Typography | ||
| @Composable @ReadOnlyComposable get() = MaterialTheme.typography | ||
|
|
||
| val shapes: Shapes | ||
| @Composable @ReadOnlyComposable get() = MaterialTheme.shapes | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| package me.rezapour.designsystem.theme | ||
|
|
||
| import androidx.compose.runtime.Immutable | ||
| import androidx.compose.runtime.staticCompositionLocalOf | ||
| import androidx.compose.ui.unit.Dp | ||
| import androidx.compose.ui.unit.dp | ||
|
|
||
| val LocalSpacing = staticCompositionLocalOf { Spacing() } | ||
| val LocalShapes = staticCompositionLocalOf { AppShapes() } | ||
| val LocalSizes = staticCompositionLocalOf { Sizes() } | ||
|
|
||
| @Immutable | ||
| data class Spacing( | ||
| val xs: Dp = 4.dp, | ||
| val s: Dp = 8.dp, | ||
| val m: Dp = 16.dp, | ||
| val l: Dp = 24.dp, | ||
| val xl: Dp = 32.dp | ||
| ) | ||
|
|
||
| @Immutable | ||
| data class AppShapes( | ||
| val extraLarge: Dp = 24.dp, | ||
| val large: Dp = 16.dp, | ||
| val medium: Dp = 12.dp, | ||
| val circle: Float = 0.5f // 50% | ||
| ) | ||
|
|
||
| @Immutable | ||
| data class Sizes( | ||
| val touchTarget: Dp = 48.dp, | ||
| val primaryFab: Dp = 80.dp, | ||
| val secondaryFab: Dp = 64.dp | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IniButtonPickerrenders anIconButtonwhose icon hascontentDescription = null, which produces unlabeled controls for screen-reader users. This component is used for primary interactive actions (including icon-only entry and +/- controls), so assistive-tech users cannot reliably understand what each button does.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will fix it later