Skip to content

Commit

Permalink
#17 in progress - theme refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
mjureczko committed Jun 5, 2024
1 parent f529697 commit a8e1179
Show file tree
Hide file tree
Showing 15 changed files with 40 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import pl.marianjureczko.poszukiwacz.shared.GoToGuide
import pl.marianjureczko.poszukiwacz.ui.components.AdvertBanner
import pl.marianjureczko.poszukiwacz.ui.components.TopBar
import pl.marianjureczko.poszukiwacz.ui.shareViewModelStoreOwner
import pl.marianjureczko.poszukiwacz.ui.theme.SecondaryBackground

@SuppressLint("UnusedMaterialScaffoldPaddingParameter")
@Composable
Expand Down Expand Up @@ -77,7 +76,7 @@ fun CommemorativeScreenBody(
localViewModel.setPhotoPath(
sharedState.treasuresProgress.commemorativePhotosByTreasuresDescriptionIds[localState.treasureDesId]!!
)
Column(Modifier.background(SecondaryBackground)) {
Column {
Spacer(
modifier = Modifier
.weight(0.01f)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package pl.marianjureczko.poszukiwacz.activity.main

import android.widget.Toast
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
Expand Down Expand Up @@ -35,17 +34,16 @@ import pl.marianjureczko.poszukiwacz.ui.components.EmbeddedButton
import pl.marianjureczko.poszukiwacz.ui.components.EnterTextDialog
import pl.marianjureczko.poszukiwacz.ui.components.LargeButton
import pl.marianjureczko.poszukiwacz.ui.components.YesNoDialog
import pl.marianjureczko.poszukiwacz.ui.theme.PrimaryBackground

@Composable
fun ClassicScreenBody(goToSearching: GoToSearching) {
val viewModel: ClassicMainViewModel = hiltViewModel()
val state = viewModel.state.value
Column(Modifier.background(PrimaryBackground)) {
Column(/*Modifier.background(PrimaryBackground)*/) {
LazyColumn(
contentPadding = PaddingValues(vertical = 8.dp, horizontal = 8.dp),
modifier = Modifier
.background(PrimaryBackground)
// .background(PrimaryBackground)
.weight(0.99f)
) {
items(state.routes) { route ->
Expand All @@ -55,7 +53,7 @@ fun ClassicScreenBody(goToSearching: GoToSearching) {
Spacer(
modifier = Modifier
.weight(0.01f)
.background(PrimaryBackground)
// .background(PrimaryBackground)
)
LargeButton(R.string.new_route_button) {
viewModel.openNewRouteDialog()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.MaterialTheme
import androidx.compose.material.OutlinedButton
Expand All @@ -22,6 +21,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
Expand All @@ -31,28 +31,28 @@ import pl.marianjureczko.poszukiwacz.R
import pl.marianjureczko.poszukiwacz.shared.GoToSearching
import pl.marianjureczko.poszukiwacz.ui.components.AdvertBanner
import pl.marianjureczko.poszukiwacz.ui.components.LargeButton
import pl.marianjureczko.poszukiwacz.ui.theme.PrimaryBackground
import pl.marianjureczko.poszukiwacz.ui.theme.Shapes

/** Kalinowice */
@Composable
fun CustomScreenBody(goToSearching: GoToSearching) {
val viewModel: CustomMainViewModel = hiltViewModel()
val state = viewModel.state.value
Column(Modifier.background(PrimaryBackground)) {
Column(Modifier.background(colorResource(R.color.colorBackgroundVariant))) {
Column(
modifier = Modifier
.padding(10.dp)
.background(PrimaryBackground)
.weight(0.89f)
) {
Text(
text = stringResource(R.string.custom_title),
style = MaterialTheme.typography.h3,
color = colorResource(R.color.colorPrimaryVariant),
textAlign = TextAlign.Center
)
Text(
text = state.messages[state.messageIndex].text,
style = MaterialTheme.typography.body1,
color = colorResource(R.color.colorPrimaryVariant),
textAlign = TextAlign.Justify
)
Row(
Expand Down Expand Up @@ -82,7 +82,6 @@ fun CustomScreenBody(goToSearching: GoToSearching) {
Spacer(
modifier = Modifier
.weight(0.01f)
.background(PrimaryBackground)
)
LargeButton(R.string.custom_lets_start) {
viewModel.restartMessages()
Expand All @@ -95,7 +94,7 @@ fun CustomScreenBody(goToSearching: GoToSearching) {
@Composable
private fun NextButton(viewModel: CustomMainViewModel) {
OutlinedButton(
shape = RoundedCornerShape(50),
shape = Shapes.small,
onClick = { viewModel.nextLeadMessage() },
colors = ButtonDefaults.buttonColors(
backgroundColor = Color.White,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import pl.marianjureczko.poszukiwacz.shared.GoToFacebook
import pl.marianjureczko.poszukiwacz.shared.GoToGuide
import pl.marianjureczko.poszukiwacz.ui.components.AdvertBanner
import pl.marianjureczko.poszukiwacz.ui.components.TopBar
import pl.marianjureczko.poszukiwacz.ui.theme.SecondaryBackground

@SuppressLint("UnusedMaterialScaffoldPaddingParameter")
@Composable
Expand All @@ -47,7 +46,7 @@ fun TipPhotoScreen(
fun TipPhotoScreenBody() {
val viewModel: TipPhotoViewModel = hiltViewModel()
val state = viewModel.state.value
Column(Modifier.background(SecondaryBackground)) {
Column {
Spacer(
modifier = Modifier
.weight(0.01f)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import pl.marianjureczko.poszukiwacz.ui.components.AdvertBanner
import pl.marianjureczko.poszukiwacz.ui.components.TopBar
import pl.marianjureczko.poszukiwacz.ui.shareViewModelStoreOwner
import pl.marianjureczko.poszukiwacz.ui.theme.FANCY_FONT
import pl.marianjureczko.poszukiwacz.ui.theme.SecondaryBackground

private const val SUBTITLES_MIME_TYPE = "application/x-subrip"

Expand All @@ -71,7 +70,7 @@ fun ResultScreenBody(viewModelStoreOwner: NavBackStackEntry) {
val localState: ResultState = localViewModel.state.value
val sharedViewModel: ResultSharedViewModel = getViewModel(viewModelStoreOwner)
sharedViewModel.resultPresented()
Column(Modifier.background(SecondaryBackground)) {
Column {
Spacer(
modifier = Modifier
.weight(0.01f)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material.CircularProgressIndicator
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Scaffold
import androidx.compose.material.ScaffoldState
import androidx.compose.material.Text
Expand All @@ -31,9 +32,7 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavController
import com.journeyapps.barcodescanner.ScanContract
Expand All @@ -59,7 +58,6 @@ import pl.marianjureczko.poszukiwacz.ui.Screen.dw
import pl.marianjureczko.poszukiwacz.ui.components.AdvertBanner
import pl.marianjureczko.poszukiwacz.ui.components.TopBar
import pl.marianjureczko.poszukiwacz.ui.isOnStack
import pl.marianjureczko.poszukiwacz.ui.theme.SecondaryBackground
import java.net.URLEncoder

@SuppressLint("UnusedMaterialScaffoldPaddingParameter")
Expand Down Expand Up @@ -127,7 +125,7 @@ private fun SearchingScreenBody(
scanOptions.setPrompt(prompt)
scanQrLauncher.launch(scanOptions)
}
Column(Modifier.background(SecondaryBackground)) {
Column {
Scores(isClassicMode, state.treasuresProgress.knowledge)
Compass(state.needleRotation)
Steps(state.stepsToTreasure)
Expand Down Expand Up @@ -243,9 +241,8 @@ fun Steps(stepsToTreasure: Int?) {
) {
if (stepsToTreasure != null) {
Text(
modifier = Modifier.padding(start = 50.dp),
fontSize = 56.sp,
fontWeight = FontWeight.Bold,
modifier = Modifier.padding(start = 40.dp),
style = MaterialTheme.typography.h2,
color = Color.Gray,
text = stepsToTreasure.toString()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import pl.marianjureczko.poszukiwacz.ui.components.TopBar
import pl.marianjureczko.poszukiwacz.ui.handlePermission
import pl.marianjureczko.poszukiwacz.ui.shareViewModelStoreOwner
import pl.marianjureczko.poszukiwacz.ui.theme.FANCY_FONT
import pl.marianjureczko.poszukiwacz.ui.theme.Shapes

@OptIn(ExperimentalPermissionsApi::class)
@SuppressLint("UnusedMaterialScaffoldPaddingParameter")
Expand Down Expand Up @@ -147,6 +148,7 @@ fun TreasureItem(
) {
Card(
elevation = 4.dp,
shape = Shapes.large,
modifier = Modifier
.padding(4.dp)
.clickable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import androidx.compose.foundation.border
import androidx.compose.material.AlertDialog
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.unit.dp
import pl.marianjureczko.poszukiwacz.App
import pl.marianjureczko.poszukiwacz.ui.theme.Primary
import pl.marianjureczko.poszukiwacz.R

@Composable
fun AbstractDialog(
Expand All @@ -21,7 +21,7 @@ fun AbstractDialog(
if (state) {
AlertDialog(
onDismissRequest = { hideIt() },
modifier = Modifier.border(width = 1.dp, color = Primary),
modifier = Modifier.border(width = 1.dp, color = colorResource(R.color.colorPrimary)),
title = { Text(text = App.getResources().getString(title)) },
text = text,
buttons = buttons
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package pl.marianjureczko.poszukiwacz.ui.components

import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.shape.CutCornerShape
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.OutlinedButton
import androidx.compose.material.Text
Expand All @@ -11,11 +10,12 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import pl.marianjureczko.poszukiwacz.ui.theme.Shapes

@Composable
fun LargeButton(title: Int, onClick: () -> Unit) {
OutlinedButton(
shape = CutCornerShape(percent = 25),
shape = Shapes.large,
modifier = Modifier.fillMaxWidth(),
colors = ButtonDefaults.buttonColors(
backgroundColor = Color.White,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,16 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import pl.marianjureczko.poszukiwacz.R
import pl.marianjureczko.poszukiwacz.ui.theme.Primary

@Composable
fun TopBar(navController: NavController, title:String, onClickOnGuide: () -> Unit, onClickOnFacebook: () -> Unit) {
val showMenu = remember { mutableStateOf(false) }
TopAppBar(
backgroundColor = Primary,
navigationIcon = {
if (navController.previousBackStackEntry != null) {
EmbeddedButton(
Expand Down Expand Up @@ -72,9 +71,8 @@ fun TopBar(navController: NavController, title:String, onClickOnGuide: () -> Uni
)
Text(
text = title,
//TODO t: save color in theme
color = Color.White,
style = MaterialTheme.typography.h6,
style = MaterialTheme.typography.h6.copy(fontFamily = FontFamily.Default),
textAlign = TextAlign.Center
)
}
Expand Down
11 changes: 0 additions & 11 deletions app/src/main/java/pl/marianjureczko/poszukiwacz/ui/theme/Color.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package pl.marianjureczko.poszukiwacz.ui.theme

import androidx.compose.foundation.shape.CutCornerShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Shapes
import androidx.compose.ui.unit.dp

val Shapes = Shapes(
small = RoundedCornerShape(4.dp),
medium = RoundedCornerShape(4.dp),
large = RoundedCornerShape(0.dp)
small = RoundedCornerShape(50),
medium = RoundedCornerShape(50),
large = RoundedCornerShape(35)
)
22 changes: 5 additions & 17 deletions app/src/main/java/pl/marianjureczko/poszukiwacz/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
@@ -1,33 +1,21 @@
package pl.marianjureczko.poszukiwacz.ui.theme

import androidx.compose.material.ButtonDefaults
import androidx.compose.material.MaterialTheme
import androidx.compose.material.lightColors
import androidx.compose.runtime.Composable
import androidx.compose.ui.res.colorResource
import pl.marianjureczko.poszukiwacz.R

@Composable
fun AppTheme(
content: @Composable() () -> Unit
) {
MaterialTheme(
colors = LightColorPalette,
colors = lightColors().copy(
primary = colorResource(R.color.colorPrimary)
),
typography = Typography,
shapes = Shapes,
content = content
)
}

private val LightColorPalette = lightColors(
primary = PrimaryBackground,
primaryVariant = Purple700,
secondary = Teal200,
background = PrimaryBackground

/* Other default colors to override
surface = Color.White,
onPrimary = Color.White,
onSecondary = Color.Black,
onBackground = Color.Black,
onSurface = Color.Black,
*/
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp
import pl.marianjureczko.poszukiwacz.R

val FANCY_FONT = FontFamily(Font(R.font.akaya_telivigala))

val Typography = Typography(
defaultFontFamily = FANCY_FONT,
body1 = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
Expand All @@ -18,15 +21,5 @@ val Typography = Typography(
fontFamily = FontFamily.Monospace,
fontWeight = FontWeight.W800,
fontSize = 18.sp,
color = PrimaryBackground
)
/* Other default text styles to override,
caption = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 12.sp
)
*/
)

val FANCY_FONT = FontFamily(Font(R.font.akaya_telivigala))
)
3 changes: 3 additions & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@
<color name="light_blue_900">#FF01579B</color>
<color name="light_blue_A200">#FF40C4FF</color>
<color name="light_blue_A400">#FF00B0FF</color>

<color name="colorPrimaryVariant">#FFFFFFFF</color>
<color name="colorBackgroundVariant">#FF00B0FF</color>
</resources>

0 comments on commit a8e1179

Please sign in to comment.