Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI state #4

Merged
merged 4 commits into from
Jun 2, 2024
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
3 changes: 2 additions & 1 deletion .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
val versionMajor = 1
val versionMinor = 0
val versionPatch = 2
val versionPatch = 4

plugins {
alias(libs.plugins.android.application)
Expand Down
18 changes: 0 additions & 18 deletions app/src/debug/res/values/strings.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ import com.example.pos_moneylist.ui.home.HomeScreen
import com.example.pos_moneylist.ui.home.productArea.ProductAreaViewModel
import com.example.pos_moneylist.ui.home.receiptArea.ReceiptAreaViewModel
import com.example.pos_moneylist.ui.productListsScreen.DestinationSettings
import com.example.pos_moneylist.ui.productListsScreen.ProductListScreen
import com.example.pos_moneylist.ui.productListsScreen.ProductListsScreenViewModel
import com.example.pos_moneylist.ui.productListsScreen.SettingsScreen
import kotlinx.coroutines.launch

@Composable
Expand Down Expand Up @@ -85,8 +85,7 @@ fun MoneyListNavHost(
icon = Icons.Outlined.Home,
iconSelected = Icons.Filled.Home
), DrawerItem(
id = "settings",
name = stringResource(R.string.title_Lists_screen),
id = "settings", name = stringResource(R.string.title_lists_screen),
icon = Icons.AutoMirrored.Outlined.List,
iconSelected = Icons.AutoMirrored.Filled.List
), DrawerItem(
Expand Down Expand Up @@ -135,14 +134,13 @@ fun MoneyListNavHost(

composable(route = DestinationAbout.route) {
AboutScreen(
aboutScreenViewModel = aboutScreenViewModel, innerPadding = innerPadding
viewModel = aboutScreenViewModel, innerPadding = innerPadding
)
}

composable(route = DestinationSettings.route) {
SettingsScreen(
productListsScreenViewModel = productListsScreenViewModel,
innerPadding = innerPadding
ProductListScreen(
viewModel = productListsScreenViewModel, padding = innerPadding
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ object DestinationAbout : NavigationDestination {

@Composable
fun AboutScreen(
aboutScreenViewModel: AboutScreenViewModel,
viewModel: AboutScreenViewModel,
innerPadding: PaddingValues,
) {

val context: Context = LocalContext.current

val license by remember { aboutScreenViewModel.license }
aboutScreenViewModel.loadLicenses(context)
val license by remember { viewModel.license }
viewModel.loadLicenses(context)

val appVersion: String = aboutScreenViewModel.getAppVersion(context)
val appVersion: String = viewModel.getAppVersion(context)

Column(
horizontalAlignment = Alignment.CenterHorizontally,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ class AboutScreenViewModel : ViewModel() {
viewModelScope.launch(Dispatchers.IO) {
try {
val bufferedReader = context.assets.open("licenses/PaperDB").bufferedReader()
val name = bufferedReader.readLine()
val link = bufferedReader.readLine()
val text = bufferedReader.readText()
val name = bufferedReader.readLine() // First line of the license is the name
val link = bufferedReader.readLine() // Seconed line of the license is the link
val text = bufferedReader.readText() // The rest of the license is the text
bufferedReader.close()
launch(Dispatchers.Main) {
license.value = license.value.copy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fun HomeScreen(
Modifier.weight(0.6f)
) {
ProductArea(
productAreaViewModel = productAreaViewModel,
viewModel = productAreaViewModel,
onProductButtonClicked = { saleItem ->
receiptAreaViewModel.addSaleItem(
saleItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ import com.example.pos_moneylist.data.saleItemList.SaleItem
@Composable
fun ProductArea(
modifier: Modifier = Modifier,
productAreaViewModel: ProductAreaViewModel,
viewModel: ProductAreaViewModel,
gridColumns: Int = 2,
onProductButtonClicked: (SaleItem) -> Unit,
) {

val productLists = remember { productAreaViewModel.productLists }
val productLists = remember { viewModel.productLists }
var selectedListIndex by remember { mutableIntStateOf(0) }

productAreaViewModel.sortLists()
viewModel.sortLists()

var showProductList: Boolean by remember { mutableStateOf(false) }
showProductList = productLists.isNotEmpty()
Expand All @@ -93,7 +93,7 @@ fun ProductArea(
key = { index: Int, item: ProductList -> item.name + index.toString() }) { index, list ->
OutlinedButton(
onClick = {
selectedListIndex = productAreaViewModel.getListIndex(list.name)
selectedListIndex = viewModel.getListIndex(list.name)
},
border = if (selectedListIndex == index) BorderStroke(
width = 3.dp, color = Color.Black
Expand Down
Loading