Skip to content

Commit

Permalink
style: Apply code inspection suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Lastaapps committed Jan 22, 2024
1 parent 20e0489 commit a11160b
Show file tree
Hide file tree
Showing 28 changed files with 92 additions and 174 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023, Petr Laštovička as Lasta apps, All rights reserved
* Copyright 2024, Petr Laštovička as Lasta apps, All rights reserved
*
* This file is part of Menza.
*
Expand Down Expand Up @@ -144,12 +144,12 @@ internal class TodayDishSubsystemRepoImpl(
.toImmutableList()
}

mapped.collectLatest {
mapped.collectLatest { categories ->
log.i {
val dishCount = it.sumOf { it.dishList.size }
"Collected ${it.size} categories and $dishCount dishes"
val dishCount = categories.sumOf { it.dishList.size }
"Collected ${categories.size} categories and $dishCount dishes"
}
send(it)
send(categories)
}
}
}.onStart {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023, Petr Laštovička as Lasta apps, All rights reserved
* Copyright 2024, Petr Laštovička as Lasta apps, All rights reserved
*
* This file is part of Menza.
*
Expand Down Expand Up @@ -28,7 +28,7 @@ internal suspend fun HttpClient.getFun(
func: Func,
subsystemId: Int? = null,
secondId: Int? = null,
) = get() {
) = get {
parameter("Funkce", func.funName)
subsystemId?.let {
parameter("Podsystem", it)
Expand Down
3 changes: 0 additions & 3 deletions api/agata/src/commonMain/sqldelight/agata/Address.sq
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import cz.lastaapps.api.core.domain.model.LatLong;


CREATE TABLE AddressEntity(
id INTEGER NOT NULL,
subsystemId INTEGER NOT NULL,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023, Petr Laštovička as Lasta apps, All rights reserved
* Copyright 2024, Petr Laštovička as Lasta apps, All rights reserved
*
* This file is part of Menza.
*
Expand All @@ -22,6 +22,7 @@ package cz.lastaapps.api.agata.test
import arrow.core.Either.Right
import cz.lastaapps.menza.api.agata.api.CafeteriaApiImpl
import cz.lastaapps.menza.api.agata.data.createAgataClient
import cz.lastaapps.menza.api.agata.data.model.AgataBEConfig
import cz.lastaapps.menza.api.agata.data.model.dto.DishTypeDto
import cz.lastaapps.menza.api.agata.data.model.dto.ServingPlaceDto
import cz.lastaapps.menza.api.agata.data.model.dto.SubsystemDto
Expand All @@ -35,11 +36,12 @@ class CafeteriaTest : StringSpec(
{

fun client() = createAgataClient(
HttpClient() {
HttpClient {
install(Logging) {
level = BODY
}
},
AgataBEConfig.prod,
)

fun api() = CafeteriaApiImpl(client())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023, Petr Laštovička as Lasta apps, All rights reserved
* Copyright 2024, Petr Laštovička as Lasta apps, All rights reserved
*
* This file is part of Menza.
*
Expand Down Expand Up @@ -40,7 +40,7 @@ class DishApiTest : StringSpec(
{

fun client() = createAgataClient(
HttpClient() {
HttpClient {
install(Logging) {
level = BODY
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023, Petr Laštovička as Lasta apps, All rights reserved
* Copyright 2024, Petr Laštovička as Lasta apps, All rights reserved
*
* This file is part of Menza.
*
Expand Down Expand Up @@ -39,7 +39,7 @@ class SubsystemApiTest : StringSpec(
{

fun client() = createAgataClient(
HttpClient() {
HttpClient {
install(Logging) {
level = BODY
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023, Petr Laštovička as Lasta apps, All rights reserved
* Copyright 2024, Petr Laštovička as Lasta apps, All rights reserved
*
* This file is part of Menza.
*
Expand All @@ -25,7 +25,6 @@ import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.DrawerState
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Scaffold
import androidx.compose.material3.windowsizeclass.WindowWidthSizeClass
import androidx.compose.runtime.Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,4 @@ internal data class AgataWalletState(
val isLoading: Boolean = false,
val isWarning: Boolean = false,
val balance: Option<UserBalance?> = None,
) : VMState {
}
) : VMState
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ private fun LicenseContent(
)
},
detailNode = {
Crossfade(state.selectedLibrary) { lib ->
Crossfade(
state.selectedLibrary,
label = "library_detail",
) { lib ->
if (lib != null) {
LibraryDetail(library = lib)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import androidx.compose.foundation.lazy.items
import androidx.compose.material3.Button
import androidx.compose.material3.Card
import androidx.compose.material3.ElevatedCard
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
Expand Down Expand Up @@ -105,7 +104,7 @@ internal fun CrashesList(
private fun NoContent() {
Text(
stringResource(R.string.crash_none_title),
style = MaterialTheme.typography.headlineMedium
style = MaterialTheme.typography.headlineMedium,
)
Text(stringResource(R.string.crash_none_subtitle))
Text(stringResource(R.string.crash_none_subsubtitle))
Expand All @@ -114,11 +113,11 @@ private fun NoContent() {
@Composable
private fun Content(
crashes: ImmutableList<Pair<Long, Crash>>,
onItemSelected: (Pair<Long, Crash>) -> Unit
onItemSelected: (Pair<Long, Crash>) -> Unit,
) {
Text(
stringResource(R.string.crash_title),
style = MaterialTheme.typography.headlineMedium
style = MaterialTheme.typography.headlineMedium,
)
Text(stringResource(R.string.crash_subtitle))

Expand All @@ -133,49 +132,49 @@ private fun Content(
}
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun CrashItem(crash: Crash, onClick: () -> Unit) {
ElevatedCard(onClick = onClick) {
Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(4.dp)) {
with(crash) {
Text(
crash.message ?: stringResource(R.string.crash_message_unknown),
style = MaterialTheme.typography.titleLarge,
)
Column {
Text(
message ?: stringResource(R.string.crash_message_unknown),
style = MaterialTheme.typography.titleLarge,
stringResource(
R.string.crash_date_title,
crash.date.format(
DateTimeFormatter.ISO_LOCAL_DATE_TIME,
),
),
)
Text(
stringResource(
R.string.crash_severity_title,
when (crash.severity) {
ErrorSeverity.CRASH -> stringResource(R.string.crash_severity_crash)
ErrorSeverity.HANDLED -> stringResource(R.string.crash_severity_internal)
},
),
)
Text(
stringResource(
R.string.crash_status_title,
when (crash.reported) {
ReportState.UNREPORTED -> stringResource(R.string.crash_status_unreported)
ReportState.DISMISSED -> stringResource(R.string.crash_status_dismissed)
ReportState.REPORTED -> stringResource(R.string.crash_status_reported)
},
),
)
}
Card {
Text(
crash.trace,
style = MaterialTheme.typography.bodySmall,
modifier = Modifier.padding(8.dp),
)
Column {
Text(
stringResource(
R.string.crash_date_title, crash.date.format(
DateTimeFormatter.ISO_LOCAL_DATE_TIME
)
)
)
Text(
stringResource(
R.string.crash_severity_title, when (crash.severity) {
ErrorSeverity.CRASH -> stringResource(R.string.crash_severity_crash)
ErrorSeverity.HANDLED -> stringResource(R.string.crash_severity_internal)
}
)
)
Text(
stringResource(
R.string.crash_status_title, when (crash.reported) {
ReportState.UNREPORTED -> stringResource(R.string.crash_status_unreported)
ReportState.DISMISSED -> stringResource(R.string.crash_status_dismissed)
ReportState.REPORTED -> stringResource(R.string.crash_status_reported)
}
)
)
}
Card {
Text(
crash.trace,
style = MaterialTheme.typography.bodySmall,
modifier = Modifier.padding(8.dp)
)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023, Petr Laštovička as Lasta apps, All rights reserved
* Copyright 2024, Petr Laštovička as Lasta apps, All rights reserved
*
* This file is part of Menza.
*
Expand All @@ -19,7 +19,6 @@

package cz.lastaapps.menza.features.panels.crashreport.ui

import androidx.lifecycle.viewModelScope
import app.cash.sqldelight.coroutines.asFlow
import app.cash.sqldelight.coroutines.mapToList
import app.cash.sqldelight.coroutines.mapToOne
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

package cz.lastaapps.menza.features.panels.whatsnew.ui.vm

import GetAppVersionUC
import cz.lastaapps.core.data.DeviceLocalesProvider
import cz.lastaapps.core.domain.usecase.GetAppVersionUC
import cz.lastaapps.core.ui.vm.Appearing
import cz.lastaapps.core.ui.vm.StateViewModel
import cz.lastaapps.core.ui.vm.VMContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import androidx.compose.material3.Slider
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.mutableFloatStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
Expand All @@ -52,7 +52,7 @@ internal fun ImageSizeSetting(
onProgressChanged: (Float) -> Unit,
modifier: Modifier = Modifier,
) {
var uiProgress by remember(progress) { mutableStateOf(progress) }
var uiProgress by remember(progress) { mutableFloatStateOf(progress) }

Column(modifier = modifier) {
Row(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
Expand Down Expand Up @@ -114,7 +114,7 @@ private object AppThemeItem {
@Composable
private fun ThemeItemPreview() {
Column(verticalArrangement = Arrangement.spacedBy(Padding.Medium)) {
var selected by remember { mutableStateOf(1) }
var selected by remember { mutableIntStateOf(1) }
AppThemeType.entries.forEachIndexed { index, theme ->
AppThemeItem(theme, DarkMode.Light, selected != index, { selected = index })
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Brightness3
import androidx.compose.material.icons.filled.BrightnessMedium
import androidx.compose.material.icons.filled.WbSunny
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
Expand Down Expand Up @@ -114,7 +113,6 @@ internal fun DarkThemeChooser(
}
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun DarkThemeItem(
item: DarkThemeItem,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ private fun DownloadContent(
Crossfade(
targetState = state.isLoading to state.isReady,
modifier = Modifier.fillMaxWidth(),
label = "download_state",
) { (isLoading, isReady) ->
when {
isLoading && isReady -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023, Petr Laštovička as Lasta apps, All rights reserved
* Copyright 2024, Petr Laštovička as Lasta apps, All rights reserved
*
* This file is part of Menza.
*
Expand All @@ -21,12 +21,10 @@ package cz.lastaapps.menza.ui.components

import androidx.compose.material3.Badge
import androidx.compose.material3.BadgedBox
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.vector.ImageVector

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun BadgeIcon(icon: ImageVector, showBadge: Boolean) {
if (showBadge)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023, Petr Laštovička as Lasta apps, All rights reserved
* Copyright 2024, Petr Laštovička as Lasta apps, All rights reserved
*
* This file is part of Menza.
*
Expand All @@ -26,7 +26,6 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Checkbox
import androidx.compose.material3.CheckboxColors
import androidx.compose.material3.CheckboxDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
Expand Down
Loading

0 comments on commit a11160b

Please sign in to comment.