Skip to content

Commit

Permalink
Updated the dividers and keys for lazy columns
Browse files Browse the repository at this point in the history
  • Loading branch information
nkuppan committed Feb 28, 2024
1 parent a55c1c9 commit 09d6b07
Show file tree
Hide file tree
Showing 15 changed files with 29 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowDownward
import androidx.compose.material.icons.filled.ArrowUpward
import androidx.compose.material3.Divider
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
Expand Down Expand Up @@ -129,7 +129,7 @@ fun AmountInfoWidget(
.fillMaxWidth(),
title = stringResource(id = R.string.income),
)
Divider()
HorizontalDivider()
ColorIconAmountView(
color = null,
icon = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ fun ColorSelectionScreen(onColorPicked: ((Int) -> Unit)? = null) {
.padding(start = 16.dp, end = 16.dp, bottom = 4.dp),
)
}
items(colors) { color ->
items(colors, key = { it }) { color ->
val parsedColor = color.toColorInt()
Box(
modifier = ColorIconSpecModifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fun IconSelectionScreen(
.padding(start = 16.dp, end = 16.dp, bottom = 4.dp),
)
}
items(icons) { icon ->
items(icons, key = { it }) { icon ->
Box(
modifier = ColorIconSpecModifier
.aspectRatio(1f)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ fun MonthPicker(
.fillMaxWidth(),
columns = GridCells.Adaptive(minSize = 96.dp),
) {
items(months) {
items(months, key = { it }) {
Box(
modifier = Modifier
.size(60.dp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ fun AccountSelectionScreen(
)
}
}
items(accounts) { account ->
items(accounts, key = { it.id }) { account ->
val isSelected = selectedAccount?.id == account.id
Box(
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import androidx.compose.material.icons.filled.AccountBalance
import androidx.compose.material.icons.filled.Done
import androidx.compose.material.icons.filled.EditCalendar
import androidx.compose.material.icons.filled.FilterList
import androidx.compose.material3.Divider
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.FloatingActionButton
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.ModalBottomSheet
Expand Down Expand Up @@ -290,9 +290,7 @@ fun BudgetCreateScreen(
label = R.string.budget_amount,
)

Divider(
modifier = Modifier.padding(top = 16.dp),
)
HorizontalDivider(modifier = Modifier.padding(top = 16.dp))

SelectedItemView(
modifier = Modifier
Expand All @@ -318,7 +316,7 @@ fun BudgetCreateScreen(
selectedCount = categoriesCount.asString(context),
)

Divider()
HorizontalDivider()

Spacer(
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ private fun BudgetDetailContent(
val transactions = budget?.transactions
if (transactions?.isNotEmpty() == true) {
LazyColumn(modifier = Modifier.padding(top = 16.dp)) {
items(transactions) { item ->
items(transactions, key = { it.id }) { item ->
TransactionItem(
modifier = Modifier
.fillMaxWidth()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ private fun CategoryListScreenContentView(
},
text = {
Text(
text = stringResource(id = items.labelResourceID),
text = stringResource(id = items.labelResourceID).uppercase(),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
Expand Down Expand Up @@ -167,7 +167,7 @@ private fun CategoryListScreenContent(
val items = categoryUiState.data

LazyColumn {
items(items) { category ->
items(items, key = { it.id }) { category ->
CategoryItem(
name = category.name,
icon = category.storedIcon.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fun CategorySelectionScreen(
Row(
modifier = Modifier
.fillMaxWidth()
.padding(start = 16.dp, end = 16.dp, bottom = 4.dp),
.padding(16.dp),
) {
SelectionTitle(
title = stringResource(id = R.string.select_category),
Expand All @@ -57,7 +57,7 @@ fun CategorySelectionScreen(
)
}
}
items(categories) { category ->
items(categories, key = { it.id }) { category ->
val isSelected = selectedCategory?.id == category.id
Box(
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.Divider
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -95,7 +95,7 @@ fun MultipleCategoriesSelectionScreen(
.padding(start = 16.dp, end = 16.dp, bottom = 4.dp),
)
}
items(categories) { category ->
items(categories, key = { it.id }) { category ->
val isSelected = selectedCategories.fastAny { it.id == category.id }
CategoryCheckedItem(
modifier = Modifier
Expand All @@ -114,7 +114,7 @@ fun MultipleCategoriesSelectionScreen(
}
item {
Column {
Divider(modifier = Modifier.padding(top = 8.dp))
HorizontalDivider(modifier = Modifier.padding(top = 8.dp))
Row(
modifier = Modifier
.padding(start = 16.dp, end = 16.dp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,10 @@ private fun CategoryTransactionListScreenContent(
)
}
} else {
items(uiState.data.categoryTransactions) { categoryTransaction ->
items(
uiState.data.categoryTransactions,
key = { it.category.id }
) { categoryTransaction ->
CategoryTransactionItem(
modifier = Modifier
.clickable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private fun DashboardScreenContent(
contentPadding = PaddingValues(horizontal = 16.dp),
horizontalArrangement = Arrangement.spacedBy(16.dp),
) {
items(accounts) {
items(accounts, key = { it.id }) {
DashBoardAccountItem(
modifier = Modifier
.wrapContentWidth()
Expand Down Expand Up @@ -187,7 +187,7 @@ private fun DashboardScreenContent(
contentPadding = PaddingValues(horizontal = 16.dp),
horizontalArrangement = Arrangement.spacedBy(16.dp),
) {
items(budgets) { budget ->
items(budgets, key = { it.id }) { budget ->
DashBoardBudgetItem(
modifier = Modifier
.clickable {
Expand Down Expand Up @@ -225,7 +225,7 @@ private fun DashboardScreenContent(
)
}
if (transactions.isNotEmpty()) {
items(transactions) { transaction ->
items(transactions, key = { it.id }) { transaction ->
TransactionItem(
modifier = Modifier
.fillMaxWidth()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material3.Divider
import androidx.compose.material3.FloatingActionButton
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
Expand Down Expand Up @@ -173,7 +173,7 @@ fun TransactionGroupItem(
)
}
if (isLastItem.not()) {
Divider(modifier = Modifier.padding(top = 8.dp, bottom = 8.dp))
HorizontalDivider(modifier = Modifier.padding(top = 8.dp, bottom = 8.dp))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.naveenapps.expensemanager.feature.transaction.numberpad

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand All @@ -10,30 +9,26 @@ import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Backspace
import androidx.compose.material3.DividerDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.VerticalDivider
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.window.Dialog
Expand Down Expand Up @@ -301,24 +296,6 @@ private fun NumberPadScreenView(
}
}

@Composable
fun VerticalDivider(
modifier: Modifier = Modifier,
thickness: Dp = DividerDefaults.Thickness,
color: Color = DividerDefaults.color,
) {
val targetThickness = if (thickness == Dp.Hairline) {
(1f / LocalDensity.current.density).dp
} else {
thickness
}
Box(
modifier
.width(targetThickness)
.background(color = color),
)
}

@Composable
fun RowScope.NumberPadActionText(
text: String,
Expand Down
5 changes: 2 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,15 @@ opencsv = "4.6"
review = "2.0.1"
googleOssPlugin = "0.10.6"
spotless = "6.23.0"
hilt = "2.48.1"
hilt = "2.49"
hiltExt = "1.2.0"
jacoco = "0.8.8"
junit4 = "4.13.2"
kotlin = "1.9.21"
kotlinKsp = "1.8.10-1.0.9"
kotlinxCoroutines = "1.7.3"
kotlinxDatetime = "0.4.1"
kotlinxSerializationJson = "1.6.0"
ksp = "1.9.10-1.0.13"
ksp = "1.9.21-1.0.16"
lint = "31.2.2"
okhttp = "4.12.0"
protobuf = "3.24.4"
Expand Down

0 comments on commit 09d6b07

Please sign in to comment.