Skip to content

Commit 6bea2f8

Browse files
authored
Merge pull request #28 from joreilly/theme_updates
compuse ui style updates
2 parents 4215185 + 7444c58 commit 6bea2f8

File tree

10 files changed

+191
-75
lines changed

10 files changed

+191
-75
lines changed

android-app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ android {
5252
}
5353

5454
create("release") {
55-
storeFile = file("/Users/joreilly/dev/keystore/galwaybus_android.jks")
55+
storeFile = file("/Users/johnoreilly/dev/keystore/galwaybus_android.jks")
5656
keyAlias = keystoreProperties["keyAlias"] as String?
5757
keyPassword = keystoreProperties["keyPassword"] as String?
5858
storePassword = keystoreProperties["storePassword"] as String?

android-app/src/main/java/dev/johnoreilly/galwaybus/MainActivity.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ import androidx.navigation.NavHostController
5454
import androidx.navigation.compose.*
5555
import com.surrus.galwaybus.common.model.Location
5656
import dev.johnoreilly.galwaybus.ui.screens.*
57+
import dev.johnoreilly.galwaybus.ui.theme.GalwayBusBackground
5758
import dev.johnoreilly.galwaybus.ui.theme.GalwayBusTheme
59+
import dev.johnoreilly.galwaybus.ui.theme.LocalBackgroundTheme
5860
import dev.johnoreilly.galwaybus.ui.theme.maroon500
5961
import dev.johnoreilly.galwaybus.ui.utils.*
6062
import dev.johnoreilly.galwaybus.ui.viewmodel.GalwayBusViewModel
@@ -74,10 +76,7 @@ class MainActivity : ComponentActivity() {
7476

7577
setContent {
7678
GalwayBusTheme {
77-
Surface(
78-
modifier = Modifier.fillMaxSize(),
79-
color = MaterialTheme.colorScheme.background
80-
) {
79+
GalwayBusBackground {
8180
val fusedLocationWrapper = fusedLocationWrapper()
8281
val fineLocation = checkSelfPermissionState(
8382
this,
@@ -183,7 +182,10 @@ fun MainLayout(windowSizeClass: WindowSizeClass,
183182
@Composable
184183
private fun GalwayBusBottomNavigation(navController: NavHostController, items: List<Screens>) {
185184

186-
NavigationBar {
185+
NavigationBar(
186+
contentColor = MaterialTheme.colorScheme.onSurfaceVariant,
187+
tonalElevation = 0.dp,
188+
) {
187189
val navBackStackEntry by navController.currentBackStackEntryAsState()
188190
val currentRoute = navBackStackEntry?.destination?.route
189191

android-app/src/main/java/dev/johnoreilly/galwaybus/ui/screens/BikeShareScreen.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,7 @@ import androidx.compose.foundation.layout.size
1313
import androidx.compose.foundation.layout.width
1414
import androidx.compose.foundation.lazy.LazyColumn
1515
import androidx.compose.foundation.lazy.items
16-
import androidx.compose.material3.CenterAlignedTopAppBar
17-
import androidx.compose.material3.ExperimentalMaterial3Api
18-
import androidx.compose.material3.MaterialTheme
19-
import androidx.compose.material3.ProvideTextStyle
20-
import androidx.compose.material3.Scaffold
21-
import androidx.compose.material3.Text
16+
import androidx.compose.material3.*
2217
import androidx.compose.runtime.Composable
2318
import androidx.compose.runtime.LaunchedEffect
2419
import androidx.compose.runtime.collectAsState
@@ -55,7 +50,10 @@ fun BikeShareScreen(viewModel: GalwayBusViewModel) {
5550
Scaffold(
5651
topBar = {
5752
CenterAlignedTopAppBar(
58-
title = { Text("Galway Bike Share") }
53+
title = { Text("Galway Bike Share") },
54+
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(
55+
containerColor = Color.Transparent
56+
)
5957
)
6058
},
6159
containerColor = Color.Transparent,

android-app/src/main/java/dev/johnoreilly/galwaybus/ui/screens/FavoritesScreen.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ fun FavoritesScreen(viewModel: GalwayBusViewModel, navController: NavHostControl
4141
Scaffold(
4242
topBar = {
4343
CenterAlignedTopAppBar(
44-
title = { androidx.compose.material3.Text("Galway Bus - Favourites") }
44+
title = { androidx.compose.material3.Text("Galway Bus - Favourites") },
45+
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(
46+
containerColor = Color.Transparent
47+
)
4548
)
4649
},
4750
containerColor = Color.Transparent,

android-app/src/main/java/dev/johnoreilly/galwaybus/ui/screens/NearbyBusStopsScreen.kt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ fun NearestBusStopsScreen(viewModel: GalwayBusViewModel, navController: NavHostC
6262
Scaffold(
6363
topBar = {
6464
CenterAlignedTopAppBar(
65-
title = { Text(text = stringResource(id = R.string.app_name)) },
65+
title = {
66+
Text(text = stringResource(id = R.string.app_name))
67+
},
6668
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(
6769
containerColor = Color.Transparent
6870
),
@@ -93,7 +95,7 @@ fun NearestBusStopsScreen(viewModel: GalwayBusViewModel, navController: NavHostC
9395

9496

9597
Box(modifier = Modifier.weight(0.6f)) {
96-
when (val uiState = busStopState.value) {
98+
when (uiState) {
9799
is UiState.Success -> {
98100
BusStopListView(viewModel, uiState.data, favorites) {
99101

@@ -116,7 +118,9 @@ fun NearestBusStopsScreen(viewModel: GalwayBusViewModel, navController: NavHostC
116118
}
117119
is UiState.Loading -> {
118120
Box(
119-
modifier = Modifier.fillMaxSize().wrapContentSize(Alignment.Center)
121+
modifier = Modifier
122+
.fillMaxSize()
123+
.wrapContentSize(Alignment.Center)
120124
) {
121125
CircularProgressIndicator()
122126
}
@@ -131,6 +135,7 @@ fun NearestBusStopsScreen(viewModel: GalwayBusViewModel, navController: NavHostC
131135
}
132136
}
133137
}
138+
134139
}
135140
}
136141
}
@@ -145,7 +150,9 @@ fun DeparturesSheetContent(viewModel: GalwayBusViewModel, departureSelected: (de
145150
Column(Modifier.defaultMinSize(minHeight = 200.dp)) {
146151

147152
Text(text = busStop?.longName ?: "", style = typography.headlineSmall,
148-
modifier = Modifier.padding(16.dp).fillMaxWidth(),
153+
modifier = Modifier
154+
.padding(16.dp)
155+
.fillMaxWidth(),
149156
textAlign = TextAlign.Center
150157
)
151158

@@ -188,6 +195,7 @@ fun BusStopView(stop: BusStop, stopSelected : (stop : BusStop) -> Unit, isFavori
188195

189196
if (supportingText.isNotEmpty()) {
190197
ListItem(
198+
colors = ListItemDefaults.colors(containerColor = Color.Transparent),
191199
modifier = Modifier.clickable(onClick = { stopSelected(stop) }),
192200
headlineText = { Text(headlineText, fontWeight = FontWeight.Bold) },
193201
supportingText = { Text(supportingText) },
@@ -197,6 +205,7 @@ fun BusStopView(stop: BusStop, stopSelected : (stop : BusStop) -> Unit, isFavori
197205
)
198206
} else {
199207
ListItem(
208+
colors = ListItemDefaults.colors(containerColor = Color.Transparent),
200209
modifier = Modifier.clickable(onClick = { stopSelected(stop) }),
201210
headlineText = { Text(headlineText) },
202211
trailingContent = {
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package dev.johnoreilly.galwaybus.ui.theme
2+
3+
import androidx.compose.foundation.layout.Box
4+
import androidx.compose.foundation.layout.fillMaxSize
5+
import androidx.compose.material3.LocalAbsoluteTonalElevation
6+
import androidx.compose.material3.Surface
7+
import androidx.compose.runtime.Composable
8+
import androidx.compose.runtime.CompositionLocalProvider
9+
import androidx.compose.runtime.Immutable
10+
import androidx.compose.runtime.staticCompositionLocalOf
11+
import androidx.compose.ui.Modifier
12+
import androidx.compose.ui.graphics.Color
13+
import androidx.compose.ui.unit.Dp
14+
import androidx.compose.ui.unit.dp
15+
16+
/**
17+
* A class to model background color and tonal elevation values
18+
*/
19+
@Immutable
20+
data class BackgroundTheme(
21+
val color: Color = Color.Unspecified,
22+
val tonalElevation: Dp = Dp.Unspecified
23+
)
24+
25+
/**
26+
* A composition local for [BackgroundTheme].
27+
*/
28+
val LocalBackgroundTheme = staticCompositionLocalOf { BackgroundTheme() }
29+
30+
31+
32+
/**
33+
* The main background for the app.
34+
* Uses [LocalBackgroundTheme] to set the color and tonal elevation of a [Box].
35+
*
36+
* @param modifier Modifier to be applied to the background.
37+
* @param content The background content.
38+
*/
39+
@Composable
40+
fun GalwayBusBackground(
41+
modifier: Modifier = Modifier,
42+
content: @Composable () -> Unit
43+
) {
44+
val color = LocalBackgroundTheme.current.color
45+
val tonalElevation = LocalBackgroundTheme.current.tonalElevation
46+
Surface(
47+
color = if (color == Color.Unspecified) Color.Transparent else color,
48+
tonalElevation = if (tonalElevation == Dp.Unspecified) 0.dp else tonalElevation,
49+
modifier = modifier.fillMaxSize(),
50+
) {
51+
CompositionLocalProvider(LocalAbsoluteTonalElevation provides 0.dp) {
52+
content()
53+
}
54+
}
55+
}
56+

android-app/src/main/java/dev/johnoreilly/galwaybus/ui/theme/Color.kt

Lines changed: 47 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,67 +8,71 @@ val maroon500 = Color(0xFF800000)
88
val maroon700 = Color(0xFF4f0000)
99
val teal200 = Color(0xFF03DAC5)
1010

11-
12-
val md_theme_light_primary = Color(0xFFB22B1D)
11+
val md_theme_light_primary = Color(0xFF4f0000)
1312
val md_theme_light_onPrimary = Color(0xFFFFFFFF)
14-
val md_theme_light_primaryContainer = Color(0xFFFFDAD4)
15-
val md_theme_light_onPrimaryContainer = Color(0xFF410000)
16-
val md_theme_light_secondary = Color(0xFF775651)
13+
val md_theme_light_primaryContainer = Color(0xFFFFDADA)
14+
val md_theme_light_onPrimaryContainer = Color(0xFF40000B)
15+
val md_theme_light_secondary = Color(0xFF765657)
1716
val md_theme_light_onSecondary = Color(0xFFFFFFFF)
18-
val md_theme_light_secondaryContainer = Color(0xFFFFDAD4)
19-
val md_theme_light_onSecondaryContainer = Color(0xFF2C1512)
20-
val md_theme_light_tertiary = Color(0xFF705C2E)
17+
val md_theme_light_secondaryContainer = Color(0xFFFFDADA)
18+
val md_theme_light_onSecondaryContainer = Color(0xFF2C1516)
19+
val md_theme_light_tertiary = Color(0xFF755A2F)
2120
val md_theme_light_onTertiary = Color(0xFFFFFFFF)
22-
val md_theme_light_tertiaryContainer = Color(0xFFFBDFA6)
23-
val md_theme_light_onTertiaryContainer = Color(0xFF251A00)
21+
val md_theme_light_tertiaryContainer = Color(0xFFFFDDB0)
22+
val md_theme_light_onTertiaryContainer = Color(0xFF281800)
2423
val md_theme_light_error = Color(0xFFBA1A1A)
2524
val md_theme_light_errorContainer = Color(0xFFFFDAD6)
2625
val md_theme_light_onError = Color(0xFFFFFFFF)
2726
val md_theme_light_onErrorContainer = Color(0xFF410002)
2827
val md_theme_light_background = Color(0xFFFFFBFF)
29-
val md_theme_light_onBackground = Color(0xFF201A19)
28+
val md_theme_light_onBackground = Color(0xFF201A1A)
3029
val md_theme_light_surface = Color(0xFFFFFBFF)
31-
val md_theme_light_onSurface = Color(0xFF201A19)
32-
val md_theme_light_surfaceVariant = Color(0xFFF5DDDA)
33-
val md_theme_light_onSurfaceVariant = Color(0xFF534341)
34-
val md_theme_light_outline = Color(0xFF857370)
35-
val md_theme_light_inverseOnSurface = Color(0xFFFBEEEC)
36-
val md_theme_light_inverseSurface = Color(0xFF362F2E)
37-
val md_theme_light_inversePrimary = Color(0xFFFFB4A8)
30+
val md_theme_light_onSurface = Color(0xFF201A1A)
31+
val md_theme_light_surfaceVariant = Color(0xFFF4DDDD)
32+
val md_theme_light_onSurfaceVariant = Color(0xFF524343)
33+
val md_theme_light_outline = Color(0xFF857373)
34+
val md_theme_light_inverseOnSurface = Color(0xFFFBEEED)
35+
val md_theme_light_inverseSurface = Color(0xFF362F2F)
36+
val md_theme_light_inversePrimary = Color(0xFFFFB3B4)
3837
val md_theme_light_shadow = Color(0xFF000000)
39-
val md_theme_light_surfaceTint = Color(0xFFB22B1D)
38+
val md_theme_light_surfaceTint = Color(0xFF9F3E45)
39+
val md_theme_light_outlineVariant = Color(0xFFD7C1C1)
40+
val md_theme_light_scrim = Color(0xFF000000)
4041

41-
val md_theme_dark_primary = Color(0xFFFFB4A8)
42-
val md_theme_dark_onPrimary = Color(0xFF690000)
43-
val md_theme_dark_primaryContainer = Color(0xFF8F0F07)
44-
val md_theme_dark_onPrimaryContainer = Color(0xFFFFDAD4)
45-
val md_theme_dark_secondary = Color(0xFFE7BDB6)
46-
val md_theme_dark_onSecondary = Color(0xFF442925)
47-
val md_theme_dark_secondaryContainer = Color(0xFF5D3F3B)
48-
val md_theme_dark_onSecondaryContainer = Color(0xFFFFDAD4)
49-
val md_theme_dark_tertiary = Color(0xFFDEC48C)
50-
val md_theme_dark_onTertiary = Color(0xFF3E2E04)
51-
val md_theme_dark_tertiaryContainer = Color(0xFF564419)
52-
val md_theme_dark_onTertiaryContainer = Color(0xFFFBDFA6)
42+
val md_theme_dark_primary = Color(0xFFFFB3B4)
43+
val md_theme_dark_onPrimary = Color(0xFF61101B)
44+
val md_theme_dark_primaryContainer = Color(0xFF802730)
45+
val md_theme_dark_onPrimaryContainer = Color(0xFFFFDADA)
46+
val md_theme_dark_secondary = Color(0xFFE6BDBD)
47+
val md_theme_dark_onSecondary = Color(0xFF44292A)
48+
val md_theme_dark_secondaryContainer = Color(0xFF5D3F40)
49+
val md_theme_dark_onSecondaryContainer = Color(0xFFFFDADA)
50+
val md_theme_dark_tertiary = Color(0xFFE6C18D)
51+
val md_theme_dark_onTertiary = Color(0xFF422C05)
52+
val md_theme_dark_tertiaryContainer = Color(0xFF5B421A)
53+
val md_theme_dark_onTertiaryContainer = Color(0xFFFFDDB0)
5354
val md_theme_dark_error = Color(0xFFFFB4AB)
5455
val md_theme_dark_errorContainer = Color(0xFF93000A)
5556
val md_theme_dark_onError = Color(0xFF690005)
5657
val md_theme_dark_onErrorContainer = Color(0xFFFFDAD6)
57-
val md_theme_dark_background = Color(0xFF201A19)
58-
val md_theme_dark_onBackground = Color(0xFFEDE0DD)
59-
val md_theme_dark_surface = Color(0xFF201A19)
60-
val md_theme_dark_onSurface = Color(0xFFEDE0DD)
61-
val md_theme_dark_surfaceVariant = Color(0xFF534341)
62-
val md_theme_dark_onSurfaceVariant = Color(0xFFD8C2BE)
63-
val md_theme_dark_outline = Color(0xFFA08C89)
64-
val md_theme_dark_inverseOnSurface = Color(0xFF201A19)
65-
val md_theme_dark_inverseSurface = Color(0xFFEDE0DD)
66-
val md_theme_dark_inversePrimary = Color(0xFFB22B1D)
58+
val md_theme_dark_background = Color(0xFF201A1A)
59+
val md_theme_dark_onBackground = Color(0xFFECE0DF)
60+
val md_theme_dark_surface = Color(0xFF201A1A)
61+
val md_theme_dark_onSurface = Color(0xFFECE0DF)
62+
val md_theme_dark_surfaceVariant = Color(0xFF524343)
63+
val md_theme_dark_onSurfaceVariant = Color(0xFFD7C1C1)
64+
val md_theme_dark_outline = Color(0xFF9F8C8C)
65+
val md_theme_dark_inverseOnSurface = Color(0xFF201A1A)
66+
val md_theme_dark_inverseSurface = Color(0xFFECE0DF)
67+
val md_theme_dark_inversePrimary = Color(0xFF9F3E45)
6768
val md_theme_dark_shadow = Color(0xFF000000)
68-
val md_theme_dark_surfaceTint = Color(0xFFFFB4A8)
69+
val md_theme_dark_surfaceTint = Color(0xFFFFB3B4)
70+
val md_theme_dark_outlineVariant = Color(0xFF524343)
71+
val md_theme_dark_scrim = Color(0xFF000000)
72+
6973

74+
val seed = Color(0xFF6750A4)
7075

71-
val seed = Color(0xFF800000)
7276

7377

7478

0 commit comments

Comments
 (0)