Skip to content

Commit

Permalink
Merge pull request #40 from NielsLee/dev
Browse files Browse the repository at this point in the history
Publish v2.1
  • Loading branch information
NielsLee authored Sep 17, 2024
2 parents f19b6c7 + fd51d71 commit f187af1
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 48 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ android {
applicationId "lying.fengfeng.foodrecords"
minSdk 26
targetSdk 34
versionCode 12
versionName "2.0"
versionCode 13
versionName "2.1"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.lazy.staggeredgrid.LazyHorizontalStaggeredGrid
import androidx.compose.foundation.lazy.staggeredgrid.StaggeredGridCells
import androidx.compose.foundation.lazy.staggeredgrid.rememberLazyStaggeredGridState
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
Expand Down Expand Up @@ -65,6 +66,7 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand All @@ -89,12 +91,11 @@ import lying.fengfeng.foodrecords.MainActivity
import lying.fengfeng.foodrecords.R
import lying.fengfeng.foodrecords.entities.FoodTypeInfo
import lying.fengfeng.foodrecords.entities.ShelfLifeInfo
import lying.fengfeng.foodrecords.repository.AppRepo
import lying.fengfeng.foodrecords.ui.FoodRecordsAppViewModel
import lying.fengfeng.foodrecords.ui.LocalActivityContext
import lying.fengfeng.foodrecords.ui.theme.ThemeOptions
import java.util.Locale

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SettingsScreen(
snackBarHostState: SnackbarHostState
Expand All @@ -117,6 +118,17 @@ fun SettingsScreen(
val titleFontSize = 18.sp
val titlePadding = PaddingValues(start = 8.dp)

val dateFormatList = listOf(
"yy-MM-dd",
"dd-MM-yy",
"MM-dd-yy",
"yyyy-MM-dd",
"dd-MM-yyyy",
"MM-dd-yyyy"
)

val dateFormatGridState = rememberLazyStaggeredGridState()

var foodTypeOptionExpanded by remember { mutableStateOf(false) }
var shelfOptionExpanded by remember { mutableStateOf(false) }
var dateFormatOptionExpanded by remember { mutableStateOf(false) }
Expand Down Expand Up @@ -415,62 +427,36 @@ fun SettingsScreen(
LazyHorizontalStaggeredGrid(
rows = StaggeredGridCells.Fixed(1),
modifier = Modifier.heightIn(max = 48.dp),
contentPadding = PaddingValues(horizontal = 8.dp)
contentPadding = PaddingValues(horizontal = 8.dp),
state = dateFormatGridState
) {
item {
Row(
verticalAlignment = Alignment.CenterVertically
) {
Checkbox(
checked = currentDateFormat == "yy-MM-dd",
onCheckedChange = {
currentDateFormat = "yy-MM-dd"
appViewModel.updateDateFormat(currentDateFormat)
}
)
Text(
text = "YY-MM-DD",
style = MaterialTheme.typography.bodyLarge,
modifier = Modifier.padding(8.dp)
)
}
}

item {
items(
count = dateFormatList.size,
key = { index -> dateFormatList[index] }
) { index ->
Row(
verticalAlignment = Alignment.CenterVertically
) {
Checkbox(
checked = currentDateFormat == "dd-MM-yy",
checked = currentDateFormat == dateFormatList[index],
onCheckedChange = {
currentDateFormat = "dd-MM-yy"
currentDateFormat = dateFormatList[index]
appViewModel.updateDateFormat(currentDateFormat)
}
)
Text(
text = "DD-MM-YY",
text = dateFormatList[index].uppercase(Locale.getDefault()),
style = MaterialTheme.typography.bodyLarge,
modifier = Modifier.padding(8.dp)
)
}
}
}

item {
Row(
verticalAlignment = Alignment.CenterVertically
) {
Checkbox(
checked = currentDateFormat == "MM-dd-yy",
onCheckedChange = {
currentDateFormat = "MM-dd-yy"
appViewModel.updateDateFormat(currentDateFormat)
}
)
Text(
text = "MM-DD-YY",
style = MaterialTheme.typography.bodyLarge,
modifier = Modifier.padding(8.dp)
)
LaunchedEffect(key1 = Unit) {
dateFormatList.forEachIndexed { index, dateFormat ->
if (currentDateFormat == dateFormat) {
dateFormatGridState.animateScrollToItem(index)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<string name="title_shelf_life">Durée de conservation</string>
<string name="title_name">Nom</string>
<string name="expired">Expiré</string>
<string name="valid_in">Valide dans</string>
<string name="valid_in">Valide</string>
<string name="delete_record">Supprimer</string>
<string name="ok">OK</string>
<string name="cancel">Annuler</string>
Expand Down Expand Up @@ -51,7 +51,7 @@
<string name="supplement">Compléter</string>
<string name="theme_option">Paramètres du thème</string>
<string name="edit">Réviser</string>
<string name="amount">quantité</string>
<string name="amount">Qté</string>
<string name="use_new_ui">Utiliser la nouvelle UI</string>
<string name="badge_new">nouveau</string>
</resources>
4 changes: 2 additions & 2 deletions app/src/main/res/values-pt-rBR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<string name="title_shelf_life">Validade</string>
<string name="title_name">Nome</string>
<string name="expired">Expirado</string>
<string name="valid_in">Válido até</string>
<string name="valid_in">Válido</string>
<string name="delete_record">Excluir</string>
<string name="ok">Confirmar</string>
<string name="cancel">Cancelar</string>
Expand Down Expand Up @@ -52,7 +52,7 @@
<string name="supplement">Suplementar</string>
<string name="theme_option">Configurações de tema</string>
<string name="edit">Rever</string>
<string name="amount">quantidade</string>
<string name="amount">Qtd.</string>
<string name="use_new_ui">Usar nova interface</string>
<string name="badge_new">novo</string>
</resources>
2 changes: 2 additions & 0 deletions metadata/en-US/changelogs/13.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix some UI layout issue
Add some new date format
2 changes: 2 additions & 0 deletions metadata/fr/changelogs/13.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Correction de certains problèmes de mise en page de l'interface utilisateur
Ajout d'un nouveau format de date
2 changes: 2 additions & 0 deletions metadata/pt-BR/changelogs/13.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Corrigir alguns problemas de layout da IU
Adicionar um novo formato de data
2 changes: 2 additions & 0 deletions metadata/zh-CN/changelogs/13.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
修复一些 UI 布局问题
添加一些新的日期格式
2 changes: 2 additions & 0 deletions metadata/zh-HK/changelogs/13.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
修復一些 UI 佈局問題
新增一些新的日期格式
2 changes: 2 additions & 0 deletions metadata/zh-TW/changelogs/13.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
修復一些 UI 佈局問題
新增一些新的日期格式

0 comments on commit f187af1

Please sign in to comment.