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

Bump androidx.compose:compose-bom from 2023.10.01 to 2024.02.00 #88

Merged
merged 9 commits into from
Feb 17, 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
10 changes: 3 additions & 7 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ android {
defaultConfig {
applicationId = "be.chvp.nanoledger"
minSdk = 26
targetSdk = 33
targetSdk = 34
versionCode = 10700
versionName = "0.1.6"

Expand All @@ -40,19 +40,16 @@ android {
jvmTarget = "17"
freeCompilerArgs +=
arrayOf(
"-opt-in=androidx.compose.material.ExperimentalMaterialApi",
"-opt-in=androidx.compose.material3.ExperimentalMaterial3Api",
)
}
lint {
quiet = true
disable.addAll(
arrayOf(
"OldTargetApi",
"NewerVersionAvailable",
"IntentWithNullActionLaunch",
"GradleDependency",
"ComposableLambdaParameterNaming",
"ObsoleteLintCustomCheck",
),
)
checkAllWarnings = true
Expand All @@ -66,7 +63,7 @@ android {
viewBinding = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.8"
kotlinCompilerExtensionVersion = "1.5.9"
}
packaging {
resources {
Expand All @@ -87,7 +84,6 @@ dependencies {
implementation(libs.activity.compose)
implementation(libs.activity.ktx)
implementation(platform(libs.compose.bom))
implementation(libs.compose.material)
implementation(libs.compose.material.icons.extended)
implementation(libs.compose.material3)
implementation(libs.compose.runtime)
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/be/chvp/nanoledger/ui/add/AddActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.filled.Done
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.CircularProgressIndicator
Expand Down Expand Up @@ -262,7 +262,7 @@ fun Bar() {
}
}) {
Icon(
Icons.Default.ArrowBack,
Icons.AutoMirrored.Default.ArrowBack,
contentDescription = stringResource(R.string.back),
)
}
Expand Down
30 changes: 24 additions & 6 deletions app/src/main/java/be/chvp/nanoledger/ui/main/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.Settings
import androidx.compose.material.pullrefresh.PullRefreshIndicator
import androidx.compose.material.pullrefresh.pullRefresh
import androidx.compose.material.pullrefresh.rememberPullRefreshState
import androidx.compose.material3.Card
import androidx.compose.material3.FloatingActionButton
import androidx.compose.material3.Icon
Expand All @@ -32,13 +29,16 @@ import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.pulltorefresh.PullToRefreshContainer
import androidx.compose.material3.pulltorefresh.rememberPullToRefreshState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontFamily
Expand Down Expand Up @@ -155,8 +155,26 @@ fun MainContent(
val context = LocalContext.current
val transactions by mainViewModel.transactions.observeAsState()
val isRefreshing by mainViewModel.isRefreshing.observeAsState()
val state = rememberPullRefreshState(isRefreshing ?: false, { mainViewModel.refresh() })
Box(modifier = Modifier.pullRefresh(state).padding(contentPadding)) {
val state = rememberPullToRefreshState()
if (state.isRefreshing && !(isRefreshing ?: false)) {
LaunchedEffect(true) {
state.endRefresh()
}
} else if (!state.isRefreshing && (isRefreshing ?: false)) {
LaunchedEffect(true) {
state.startRefresh()
}
}
if (state.isRefreshing) {
LaunchedEffect(true) {
mainViewModel.refresh()
// Due to the way compositing works, we cancel the refresh in the
// first if (even if the first if is moved below this one, and then
// we have no way to undo the cancel).
state.startRefresh()
}
}
Box(modifier = Modifier.nestedScroll(state.nestedScrollConnection).padding(contentPadding)) {
if ((transactions?.size ?: 0) > 0 || (isRefreshing ?: true)) {
LazyColumn(modifier = Modifier.fillMaxSize()) {
items(transactions?.size ?: 0) {
Expand Down Expand Up @@ -241,7 +259,7 @@ fun MainContent(
}
}
}
PullRefreshIndicator(isRefreshing ?: false, state, Modifier.align(Alignment.TopCenter))
PullToRefreshContainer(state = state, modifier = Modifier.align(Alignment.TopCenter))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,15 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.ContentAlpha
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Divider
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.ExposedDropdownMenuBox
import androidx.compose.material3.ExposedDropdownMenuDefaults
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Scaffold
Expand All @@ -42,6 +40,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import be.chvp.nanoledger.R
import be.chvp.nanoledger.ui.theme.NanoLedgerTheme
Expand Down Expand Up @@ -90,7 +89,7 @@ class PreferencesActivity() : ComponentActivity() {
) {
openFile.launch(arrayOf("*/*"))
}
Divider()
HorizontalDivider()
val defaultCurrency by preferencesViewModel.defaultCurrency.observeAsState()
var newDefaultCurrency by remember { mutableStateOf(defaultCurrency ?: "") }
var defaultCurrencyOpen by remember { mutableStateOf(false) }
Expand All @@ -109,7 +108,7 @@ class PreferencesActivity() : ComponentActivity() {
) {
OutlinedTextField(newDefaultCurrency, { newDefaultCurrency = it })
}
Divider()
HorizontalDivider()
val defaultStatus by preferencesViewModel.defaultStatus.observeAsState()
var expandedStatus by rememberSaveable { mutableStateOf(false) }
ExposedDropdownMenuBox(
Expand Down Expand Up @@ -142,7 +141,7 @@ class PreferencesActivity() : ComponentActivity() {
}
}
}
Divider()
HorizontalDivider()
val currencyBeforeAmount by
preferencesViewModel.currencyBeforeAmount.observeAsState()
var expandedCurrency by rememberSaveable { mutableStateOf(false) }
Expand Down Expand Up @@ -209,7 +208,7 @@ fun Setting(
subtext,
modifier = Modifier.padding(bottom = 8.dp, start = 8.dp),
style = MaterialTheme.typography.bodyMedium,
color = LocalContentColor.current.copy(alpha = ContentAlpha.medium),
fontWeight = FontWeight.Normal,
)
}
}
Expand All @@ -222,7 +221,7 @@ fun Bar() {
navigationIcon = {
IconButton(onClick = { (context as Activity).finish() }) {
Icon(
Icons.Default.ArrowBack,
Icons.AutoMirrored.Default.ArrowBack,
contentDescription = stringResource(R.string.back),
)
}
Expand Down
3 changes: 1 addition & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ androidx-test-ext-junit = "1.1.5"
espresso-core = "3.5.1"
lifecycle = "2.7.0"
activity = "1.8.2"
compose-bom = "2023.10.01"
compose-bom = "2024.02.00"
material = "1.11.0"

[libraries]
activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activity" }
activity-ktx = { group = "androidx.activity", name = "activity-ktx", version.ref = "activity" }
androidx-test-ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "androidx-test-ext-junit" }
compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "compose-bom" }
compose-material = { group = "androidx.compose.material", name = "material" }
compose-material-icons-extended = { group = "androidx.compose.material", name = "material-icons-extended" }
compose-material3 = { group = "androidx.compose.material3", name = "material3" }
compose-runtime = { group = "androidx.compose.runtime", name = "runtime-livedata" }
Expand Down
Loading