Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 0 additions & 2 deletions androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@ dependencies {
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.compose.foundation)
implementation(libs.androidx.compose.foundation.layout)
implementation(libs.androidx.compose.material)
implementation(libs.androidx.compose.runtime)
implementation(libs.androidx.compose.ui)
implementation(libs.androidx.compose.ui.tooling)
implementation(libs.androidx.compose.material3)
implementation(libs.accompanist.insets)
}
10 changes: 5 additions & 5 deletions androidApp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<application
android:name=".WordMasterApplication"
android:allowBackup="false"
android:supportsRtl="true"
android:usesCleartextTraffic="true"
android:theme="@style/AppTheme">
android:name=".WordMasterApplication"
android:allowBackup="false"
android:supportsRtl="true"
android:usesCleartextTraffic="true"
android:theme="@android:style/Theme.Material.Light.NoActionBar">
<activity android:name=".MainActivity"
android:exported="true"
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@ import android.annotation.SuppressLint
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Arrangement.Absolute.Center
import androidx.compose.material.*
import androidx.compose.material3.Button
import androidx.compose.material3.CenterAlignedTopAppBar
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.material3.TextFieldDefaults
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand All @@ -22,24 +31,19 @@ import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.core.view.WindowCompat.setDecorFitsSystemWindows
import com.google.accompanist.insets.ProvideWindowInsets
import com.google.accompanist.insets.statusBarsPadding
import dev.johnoreilly.wordmaster.shared.LetterStatus
import dev.johnoreilly.wordmaster.shared.WordMasterService
import dev.johnoreilly.wordmaster.androidApp.theme.WordMasterTheme


class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
enableEdgeToEdge()
super.onCreate(savedInstanceState)
setDecorFitsSystemWindows(window, false)

setContent {
WordMasterTheme {
ProvideWindowInsets {
MainLayout()
}
MainLayout()
}
}
}
Expand All @@ -50,14 +54,14 @@ class MainActivity : ComponentActivity() {
fun MainLayout() {
Scaffold(
topBar = { WordMasterTopAppBar("WordMaster KMP") }
) {
WordMasterView()
) { innerPadding ->
WordMasterView(Modifier.padding(innerPadding))
}
}


@Composable
fun WordMasterView() {
fun WordMasterView(padding: Modifier) {
val context = LocalContext.current

val wordMasterService = remember {
Expand All @@ -71,9 +75,9 @@ fun WordMasterView() {
val focusManager = LocalFocusManager.current
val focusRequester = remember { FocusRequester() }

Row(Modifier.fillMaxSize().padding(16.dp), horizontalArrangement = Center) {
Row(padding.fillMaxSize().padding(16.dp), horizontalArrangement = Center) {

Column {
Column(horizontalAlignment = Alignment.CenterHorizontally) {
for (guessAttempt in 0 until WordMasterService.MAX_NUMBER_OF_GUESSES) {
Row(horizontalArrangement = Arrangement.SpaceBetween) {
for (character in 0 until WordMasterService.NUMBER_LETTERS) {
Expand Down Expand Up @@ -101,12 +105,10 @@ fun WordMasterView() {
},
modifier = modifier,
textStyle = TextStyle(fontSize = 14.sp, textAlign = TextAlign.Center),
colors = TextFieldDefaults.textFieldColors(
textColor = mapLetterStatusToTextColor(boardStatus[guessAttempt][character]),
backgroundColor = mapLetterStatusToBackgroundColor(boardStatus[guessAttempt][character]),
unfocusedIndicatorColor = Color.Transparent,
focusedIndicatorColor = Color.Transparent
)
colors = TextFieldDefaults.colors(
unfocusedTextColor = mapLetterStatusToTextColor(boardStatus[guessAttempt][character]),
unfocusedContainerColor = mapLetterStatusToBackgroundColor(boardStatus[guessAttempt][character]),
),
)

DisposableEffect(Unit) {
Expand All @@ -118,7 +120,8 @@ fun WordMasterView() {
}
}

Row {
Spacer(Modifier.height(16.dp))
Row(horizontalArrangement = Arrangement.Center) {
Button(onClick = {
wordMasterService.checkGuess()
}) {
Expand Down Expand Up @@ -155,14 +158,10 @@ fun mapLetterStatusToTextColor(letterStatus: LetterStatus): Color {
}
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun WordMasterTopAppBar(title: String) {
Surface(color = MaterialTheme.colors.primary) {
TopAppBar(
title = { Text(title) },
backgroundColor = Color.Transparent,
elevation = 0.dp,
modifier = Modifier.statusBarsPadding()
)
}
CenterAlignedTopAppBar(
title = { Text(title) },
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ package dev.johnoreilly.wordmaster.androidApp.theme

import androidx.compose.ui.graphics.Color

val Purple200 = Color(0xFFBB86FC)
val Purple500 = Color(0xFF6200EE)
val Purple700 = Color(0xFF3700B3)
val Teal200 = Color(0xFF03DAC5)
val Purple80 = Color(0xFFD0BCFF)
val PurpleGrey80 = Color(0xFFCCC2DC)
val Pink80 = Color(0xFFEFB8C8)

val Purple40 = Color(0xFF6650a4)
val PurpleGrey40 = Color(0xFF625b71)
val Pink40 = Color(0xFF7D5260)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,47 +1,57 @@
package dev.johnoreilly.wordmaster.androidApp.theme

import android.os.Build
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.dynamicDarkColorScheme
import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext

private val DarkColorPalette = darkColors(
primary = Purple200,
primaryVariant = Purple700,
secondary = Teal200
private val DarkColorScheme = darkColorScheme(
primary = Purple80,
secondary = PurpleGrey80,
tertiary = Pink80
)

private val LightColorPalette = lightColors(
primary = Purple500,
primaryVariant = Purple700,
secondary = Teal200
private val LightColorScheme = lightColorScheme(
primary = Purple40,
secondary = PurpleGrey40,
tertiary = Pink40

/* Other default colors to override
background = Color.White,
surface = Color.White,
background = Color(0xFFFFFBFE),
surface = Color(0xFFFFFBFE),
onPrimary = Color.White,
onSecondary = Color.Black,
onBackground = Color.Black,
onSurface = Color.Black,
onSecondary = Color.White,
onTertiary = Color.White,
onBackground = Color(0xFF1C1B1F),
onSurface = Color(0xFF1C1B1F),
*/
)

@Composable
fun WordMasterTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
content: @Composable() () -> Unit
// Dynamic color is available on Android 12+
dynamicColor: Boolean = true,
content: @Composable () -> Unit
) {
val colors = if (darkTheme) {
DarkColorPalette
} else {
LightColorPalette
val colorScheme = when {
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
val context = LocalContext.current
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
}

darkTheme -> DarkColorScheme
else -> LightColorScheme
}

MaterialTheme(
colors = colors,
colorScheme = colorScheme,
typography = Typography,
shapes = Shapes,
content = content
)
}
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
package dev.johnoreilly.wordmaster.androidApp.theme

import androidx.compose.material.Typography
import androidx.compose.material3.Typography
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp

// Set of Material typography styles to start with
val Typography = Typography(
body1 = TextStyle(
bodyLarge = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 16.sp
fontSize = 16.sp,
)
/* Other default text styles to override
button = TextStyle(
titleLarge = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.W500,
fontSize = 14.sp
fontWeight = FontWeight.Normal,
fontSize = 22.sp,
lineHeight = 28.sp,
letterSpacing = 0.sp
),
caption = TextStyle(
labelSmall = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 12.sp
fontWeight = FontWeight.Medium,
fontSize = 11.sp,
lineHeight = 16.sp,
letterSpacing = 0.5.sp
)
*/
)
6 changes: 0 additions & 6 deletions androidApp/src/main/res/values/colors.xml

This file was deleted.

7 changes: 0 additions & 7 deletions androidApp/src/main/res/values/styles.xml

This file was deleted.

4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ ksp = "2.2.0-2.0.2"
kotlinx-coroutines = "1.10.2"


agp = "8.11.0"
agp = "8.11.1"
android-compileSdk = "36"
android-minSdk = "24"
android-targetSdk = "36"
androidx-activityCompose = "1.10.1"
androidxComposeBom = "2025.06.01"
androidxComposeBom = "2025.07.00"
compose-plugin = "1.8.2"
accompanist = "0.30.1"
kmp-nativecoroutines = "1.0.0-ALPHA-45"
Expand Down
Loading