Skip to content

Commit 4faf148

Browse files
authored
Merge pull request #17 from joreilly/update_dependencies
dependency updates + android style updates
2 parents 1b88df9 + c87262a commit 4faf148

File tree

10 files changed

+87
-97
lines changed

10 files changed

+87
-97
lines changed

androidApp/build.gradle.kts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,8 @@ dependencies {
4545
implementation(platform(libs.androidx.compose.bom))
4646
implementation(libs.androidx.compose.foundation)
4747
implementation(libs.androidx.compose.foundation.layout)
48-
implementation(libs.androidx.compose.material)
4948
implementation(libs.androidx.compose.runtime)
5049
implementation(libs.androidx.compose.ui)
5150
implementation(libs.androidx.compose.ui.tooling)
5251
implementation(libs.androidx.compose.material3)
53-
implementation(libs.accompanist.insets)
5452
}

androidApp/src/main/AndroidManifest.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
77

88
<application
9-
android:name=".WordMasterApplication"
10-
android:allowBackup="false"
11-
android:supportsRtl="true"
12-
android:usesCleartextTraffic="true"
13-
android:theme="@style/AppTheme">
9+
android:name=".WordMasterApplication"
10+
android:allowBackup="false"
11+
android:supportsRtl="true"
12+
android:usesCleartextTraffic="true"
13+
android:theme="@android:style/Theme.Material.Light.NoActionBar">
1414
<activity android:name=".MainActivity"
1515
android:exported="true"
1616
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden">

androidApp/src/main/java/dev/johnoreilly/wordmaster/androidApp/MainActivity.kt

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,20 @@ import android.annotation.SuppressLint
44
import android.os.Bundle
55
import androidx.activity.ComponentActivity
66
import androidx.activity.compose.setContent
7+
import androidx.activity.enableEdgeToEdge
78
import androidx.compose.foundation.background
89
import androidx.compose.foundation.border
910
import androidx.compose.foundation.layout.*
11+
import androidx.compose.foundation.layout.Arrangement
1012
import androidx.compose.foundation.layout.Arrangement.Absolute.Center
11-
import androidx.compose.material.*
13+
import androidx.compose.material3.Button
14+
import androidx.compose.material3.CenterAlignedTopAppBar
15+
import androidx.compose.material3.ExperimentalMaterial3Api
16+
import androidx.compose.material3.Scaffold
17+
import androidx.compose.material3.Text
18+
import androidx.compose.material3.TextField
19+
import androidx.compose.material3.TextFieldDefaults
20+
import androidx.compose.material3.TopAppBar
1221
import androidx.compose.runtime.*
1322
import androidx.compose.ui.Alignment
1423
import androidx.compose.ui.Modifier
@@ -22,24 +31,19 @@ import androidx.compose.ui.text.TextStyle
2231
import androidx.compose.ui.text.style.TextAlign
2332
import androidx.compose.ui.unit.dp
2433
import androidx.compose.ui.unit.sp
25-
import androidx.core.view.WindowCompat.setDecorFitsSystemWindows
26-
import com.google.accompanist.insets.ProvideWindowInsets
27-
import com.google.accompanist.insets.statusBarsPadding
2834
import dev.johnoreilly.wordmaster.shared.LetterStatus
2935
import dev.johnoreilly.wordmaster.shared.WordMasterService
3036
import dev.johnoreilly.wordmaster.androidApp.theme.WordMasterTheme
3137

3238

3339
class MainActivity : ComponentActivity() {
3440
override fun onCreate(savedInstanceState: Bundle?) {
41+
enableEdgeToEdge()
3542
super.onCreate(savedInstanceState)
36-
setDecorFitsSystemWindows(window, false)
3743

3844
setContent {
3945
WordMasterTheme {
40-
ProvideWindowInsets {
41-
MainLayout()
42-
}
46+
MainLayout()
4347
}
4448
}
4549
}
@@ -50,14 +54,14 @@ class MainActivity : ComponentActivity() {
5054
fun MainLayout() {
5155
Scaffold(
5256
topBar = { WordMasterTopAppBar("WordMaster KMP") }
53-
) {
54-
WordMasterView()
57+
) { innerPadding ->
58+
WordMasterView(Modifier.padding(innerPadding))
5559
}
5660
}
5761

5862

5963
@Composable
60-
fun WordMasterView() {
64+
fun WordMasterView(padding: Modifier) {
6165
val context = LocalContext.current
6266

6367
val wordMasterService = remember {
@@ -71,9 +75,9 @@ fun WordMasterView() {
7175
val focusManager = LocalFocusManager.current
7276
val focusRequester = remember { FocusRequester() }
7377

74-
Row(Modifier.fillMaxSize().padding(16.dp), horizontalArrangement = Center) {
78+
Row(padding.fillMaxSize().padding(16.dp), horizontalArrangement = Center) {
7579

76-
Column {
80+
Column(horizontalAlignment = Alignment.CenterHorizontally) {
7781
for (guessAttempt in 0 until WordMasterService.MAX_NUMBER_OF_GUESSES) {
7882
Row(horizontalArrangement = Arrangement.SpaceBetween) {
7983
for (character in 0 until WordMasterService.NUMBER_LETTERS) {
@@ -101,12 +105,10 @@ fun WordMasterView() {
101105
},
102106
modifier = modifier,
103107
textStyle = TextStyle(fontSize = 14.sp, textAlign = TextAlign.Center),
104-
colors = TextFieldDefaults.textFieldColors(
105-
textColor = mapLetterStatusToTextColor(boardStatus[guessAttempt][character]),
106-
backgroundColor = mapLetterStatusToBackgroundColor(boardStatus[guessAttempt][character]),
107-
unfocusedIndicatorColor = Color.Transparent,
108-
focusedIndicatorColor = Color.Transparent
109-
)
108+
colors = TextFieldDefaults.colors(
109+
unfocusedTextColor = mapLetterStatusToTextColor(boardStatus[guessAttempt][character]),
110+
unfocusedContainerColor = mapLetterStatusToBackgroundColor(boardStatus[guessAttempt][character]),
111+
),
110112
)
111113

112114
DisposableEffect(Unit) {
@@ -118,7 +120,8 @@ fun WordMasterView() {
118120
}
119121
}
120122

121-
Row {
123+
Spacer(Modifier.height(16.dp))
124+
Row(horizontalArrangement = Arrangement.Center) {
122125
Button(onClick = {
123126
wordMasterService.checkGuess()
124127
}) {
@@ -155,14 +158,10 @@ fun mapLetterStatusToTextColor(letterStatus: LetterStatus): Color {
155158
}
156159
}
157160

161+
@OptIn(ExperimentalMaterial3Api::class)
158162
@Composable
159163
private fun WordMasterTopAppBar(title: String) {
160-
Surface(color = MaterialTheme.colors.primary) {
161-
TopAppBar(
162-
title = { Text(title) },
163-
backgroundColor = Color.Transparent,
164-
elevation = 0.dp,
165-
modifier = Modifier.statusBarsPadding()
166-
)
167-
}
164+
CenterAlignedTopAppBar(
165+
title = { Text(title) },
166+
)
168167
}

androidApp/src/main/java/dev/johnoreilly/wordmaster/androidApp/theme/Color.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ package dev.johnoreilly.wordmaster.androidApp.theme
22

33
import androidx.compose.ui.graphics.Color
44

5-
val Purple200 = Color(0xFFBB86FC)
6-
val Purple500 = Color(0xFF6200EE)
7-
val Purple700 = Color(0xFF3700B3)
8-
val Teal200 = Color(0xFF03DAC5)
5+
val Purple80 = Color(0xFFD0BCFF)
6+
val PurpleGrey80 = Color(0xFFCCC2DC)
7+
val Pink80 = Color(0xFFEFB8C8)
8+
9+
val Purple40 = Color(0xFF6650a4)
10+
val PurpleGrey40 = Color(0xFF625b71)
11+
val Pink40 = Color(0xFF7D5260)

androidApp/src/main/java/dev/johnoreilly/wordmaster/androidApp/theme/Shape.kt

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,57 @@
11
package dev.johnoreilly.wordmaster.androidApp.theme
22

3+
import android.os.Build
34
import androidx.compose.foundation.isSystemInDarkTheme
4-
import androidx.compose.material.MaterialTheme
5-
import androidx.compose.material.darkColors
6-
import androidx.compose.material.lightColors
5+
import androidx.compose.material3.MaterialTheme
6+
import androidx.compose.material3.darkColorScheme
7+
import androidx.compose.material3.dynamicDarkColorScheme
8+
import androidx.compose.material3.dynamicLightColorScheme
9+
import androidx.compose.material3.lightColorScheme
710
import androidx.compose.runtime.Composable
11+
import androidx.compose.ui.platform.LocalContext
812

9-
private val DarkColorPalette = darkColors(
10-
primary = Purple200,
11-
primaryVariant = Purple700,
12-
secondary = Teal200
13+
private val DarkColorScheme = darkColorScheme(
14+
primary = Purple80,
15+
secondary = PurpleGrey80,
16+
tertiary = Pink80
1317
)
1418

15-
private val LightColorPalette = lightColors(
16-
primary = Purple500,
17-
primaryVariant = Purple700,
18-
secondary = Teal200
19+
private val LightColorScheme = lightColorScheme(
20+
primary = Purple40,
21+
secondary = PurpleGrey40,
22+
tertiary = Pink40
1923

2024
/* Other default colors to override
21-
background = Color.White,
22-
surface = Color.White,
25+
background = Color(0xFFFFFBFE),
26+
surface = Color(0xFFFFFBFE),
2327
onPrimary = Color.White,
24-
onSecondary = Color.Black,
25-
onBackground = Color.Black,
26-
onSurface = Color.Black,
28+
onSecondary = Color.White,
29+
onTertiary = Color.White,
30+
onBackground = Color(0xFF1C1B1F),
31+
onSurface = Color(0xFF1C1B1F),
2732
*/
2833
)
2934

3035
@Composable
3136
fun WordMasterTheme(
3237
darkTheme: Boolean = isSystemInDarkTheme(),
33-
content: @Composable() () -> Unit
38+
// Dynamic color is available on Android 12+
39+
dynamicColor: Boolean = true,
40+
content: @Composable () -> Unit
3441
) {
35-
val colors = if (darkTheme) {
36-
DarkColorPalette
37-
} else {
38-
LightColorPalette
42+
val colorScheme = when {
43+
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
44+
val context = LocalContext.current
45+
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
46+
}
47+
48+
darkTheme -> DarkColorScheme
49+
else -> LightColorScheme
3950
}
4051

4152
MaterialTheme(
42-
colors = colors,
53+
colorScheme = colorScheme,
4354
typography = Typography,
44-
shapes = Shapes,
4555
content = content
4656
)
4757
}
Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,32 @@
11
package dev.johnoreilly.wordmaster.androidApp.theme
22

3-
import androidx.compose.material.Typography
3+
import androidx.compose.material3.Typography
44
import androidx.compose.ui.text.TextStyle
55
import androidx.compose.ui.text.font.FontFamily
66
import androidx.compose.ui.text.font.FontWeight
77
import androidx.compose.ui.unit.sp
88

99
// Set of Material typography styles to start with
1010
val Typography = Typography(
11-
body1 = TextStyle(
11+
bodyLarge = TextStyle(
1212
fontFamily = FontFamily.Default,
1313
fontWeight = FontWeight.Normal,
14-
fontSize = 16.sp
14+
fontSize = 16.sp,
1515
)
1616
/* Other default text styles to override
17-
button = TextStyle(
17+
titleLarge = TextStyle(
1818
fontFamily = FontFamily.Default,
19-
fontWeight = FontWeight.W500,
20-
fontSize = 14.sp
19+
fontWeight = FontWeight.Normal,
20+
fontSize = 22.sp,
21+
lineHeight = 28.sp,
22+
letterSpacing = 0.sp
2123
),
22-
caption = TextStyle(
24+
labelSmall = TextStyle(
2325
fontFamily = FontFamily.Default,
24-
fontWeight = FontWeight.Normal,
25-
fontSize = 12.sp
26+
fontWeight = FontWeight.Medium,
27+
fontSize = 11.sp,
28+
lineHeight = 16.sp,
29+
letterSpacing = 0.5.sp
2630
)
2731
*/
2832
)

androidApp/src/main/res/values/colors.xml

Lines changed: 0 additions & 6 deletions
This file was deleted.

androidApp/src/main/res/values/styles.xml

Lines changed: 0 additions & 7 deletions
This file was deleted.

gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ ksp = "2.2.0-2.0.2"
44
kotlinx-coroutines = "1.10.2"
55

66

7-
agp = "8.11.0"
7+
agp = "8.11.1"
88
android-compileSdk = "36"
99
android-minSdk = "24"
1010
android-targetSdk = "36"
1111
androidx-activityCompose = "1.10.1"
12-
androidxComposeBom = "2025.06.01"
12+
androidxComposeBom = "2025.07.00"
1313
compose-plugin = "1.8.2"
1414
accompanist = "0.30.1"
1515
kmp-nativecoroutines = "1.0.0-ALPHA-45"

0 commit comments

Comments
 (0)