Modern Apps git

← Modern-Apps.git

photos: use button groups and expressive loading indicators

Commit
dde9c4bb04ad5dabc0c753f3404cd2a959b9a6d5
Author
vayun-mathur <[email protected]>
When
2026-08-21 18:49 UTC (3 months ago)
Parents
dc3377a

Diff

photos/src/main/java/com/vayunmathur/photos/MainActivity.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/MainActivity.kt b/photos/src/main/java/com/vayunmathur/photos/MainActivity.ktindex 6b2fbd1505..417c32e9c3 100644--- a/photos/src/main/java/com/vayunmathur/photos/MainActivity.kt+++ b/photos/src/main/java/com/vayunmathur/photos/MainActivity.kt@@ -21,7 +21,7 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding import com.vayunmathur.library.util.AppMessages import com.vayunmathur.library.ui.Button-import com.vayunmathur.library.ui.CircularProgressIndicator+import com.vayunmathur.library.ui.LoadingIndicator import com.vayunmathur.library.ui.IconGroup import com.vayunmathur.library.ui.IconLock import com.vayunmathur.library.ui.IconMap@@ -320,7 +320,7 @@ private fun SecureFolderEntry(             )         }         Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {-            CircularProgressIndicator()+            LoadingIndicator()         }     } else {         SecureFolderPage(backStack, vaultPassword!!, secureFolderViewModel)
photos/src/main/java/com/vayunmathur/photos/ui/AdvancedPanels.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/AdvancedPanels.kt b/photos/src/main/java/com/vayunmathur/photos/ui/AdvancedPanels.ktindex b903dc6686..653f9b7e21 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/AdvancedPanels.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/AdvancedPanels.kt@@ -12,7 +12,7 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.RoundedCornerShape-import com.vayunmathur.library.ui.FilterChip+import com.vayunmathur.library.ui.ButtonGroup import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.Slider import com.vayunmathur.library.ui.Surface@@ -94,12 +94,9 @@ fun LevelsPanel(levels: LevelsAdjustment, onChange: (LevelsAdjustment) -> Unit) @Composable fun ColorBalancePanel(balance: ColorBalanceAdjustment, onChange: (ColorBalanceAdjustment) -> Unit) = PanelColumn {     var range by remember { mutableStateOf(0) } // 0 shadows, 1 mid, 2 high-    Row(-        modifier = Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()).padding(horizontal = 8.dp),-        horizontalArrangement = Arrangement.spacedBy(6.dp),-    ) {+    ButtonGroup(Modifier.fillMaxWidth().padding(horizontal = 8.dp)) {         listOf("Shadows", "Midtones", "Highlights").forEachIndexed { i, label ->-            FilterChip(selected = range == i, onClick = { range = i }, label = { Text(label, fontSize = 12.sp) })+            toggleableItem(checked = range == i, label = label, onCheckedChange = { range = i })         }     }     val rc = when (range) { 0 -> balance.shadowsRedCyan; 1 -> balance.midRedCyan; else -> balance.highRedCyan }@@ -220,11 +217,8 @@ fun FiltersPanel(onAddFx: (com.vayunmathur.photos.data.LayerAdjustment) -> Unit)     var radius by remember { mutableFloatStateOf(2f) }     var angle by remember { mutableFloatStateOf(0f) }     val tools = listOf("Sharpen", "Gaussian", "Motion", "Radial", "Spin", "Noise", "Find Edges", "Emboss")-    Row(-        modifier = Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()).padding(horizontal = 8.dp),-        horizontalArrangement = Arrangement.spacedBy(6.dp),-    ) {-        tools.forEach { t -> FilterChip(selected = tool == t, onClick = { tool = t }, label = { Text(t, fontSize = 12.sp) }) }+    ButtonGroup(Modifier.fillMaxWidth().padding(horizontal = 8.dp)) {+        tools.forEach { t -> toggleableItem(checked = tool == t, label = t, onCheckedChange = { tool = t }) }     }     when (tool) {         "Sharpen" -> {@@ -287,15 +281,12 @@ fun PhotoFilterPanel(adj: PhotoFilterAdj, onChange: (PhotoFilterAdj) -> Unit) =         "Green" to 0xFF00A651.toInt(),         "Blue" to 0xFF2E5CFF.toInt(),     )-    Row(-        modifier = Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()).padding(horizontal = 8.dp),-        horizontalArrangement = Arrangement.spacedBy(6.dp),-    ) {+    ButtonGroup(Modifier.fillMaxWidth().padding(horizontal = 8.dp)) {         presets.forEach { (name, color) ->-            FilterChip(-                selected = adj.color == color,-                onClick = { onChange(adj.copy(color = color)) },-                label = { Text(name, fontSize = 12.sp) },+            toggleableItem(+                checked = adj.color == color,+                label = name,+                onCheckedChange = { onChange(adj.copy(color = color)) },             )         }     }@@ -304,15 +295,12 @@ fun PhotoFilterPanel(adj: PhotoFilterAdj, onChange: (PhotoFilterAdj) -> Unit) =  @Composable fun SelectiveColorPanel(adj: SelectiveColorAdj, onChange: (SelectiveColorAdj) -> Unit) = PanelColumn {-    Row(-        modifier = Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()).padding(horizontal = 8.dp),-        horizontalArrangement = Arrangement.spacedBy(6.dp),-    ) {+    ButtonGroup(Modifier.fillMaxWidth().padding(horizontal = 8.dp)) {         SelectiveColorRange.entries.forEach { range ->-            FilterChip(-                selected = adj.range == range,-                onClick = { onChange(adj.copy(range = range)) },-                label = { Text(range.name, fontSize = 12.sp) },+            toggleableItem(+                checked = adj.range == range,+                label = range.name,+                onCheckedChange = { onChange(adj.copy(range = range)) },             )         }     }
photos/src/main/java/com/vayunmathur/photos/ui/BlurPanel.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/BlurPanel.kt b/photos/src/main/java/com/vayunmathur/photos/ui/BlurPanel.ktindex c4257fa517..ba646a3783 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/BlurPanel.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/BlurPanel.kt@@ -1,15 +1,12 @@ package com.vayunmathur.photos.ui  import androidx.compose.foundation.background-import androidx.compose.foundation.horizontalScroll-import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width-import androidx.compose.foundation.rememberScrollState-import com.vayunmathur.library.ui.FilterChip+import com.vayunmathur.library.ui.ButtonGroup import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.Slider import com.vayunmathur.library.ui.Text@@ -34,17 +31,12 @@ fun BlurPanel(             .background(MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.5f))             .padding(8.dp),     ) {-        Row(-            modifier = Modifier-                .fillMaxWidth()-                .horizontalScroll(rememberScrollState()),-            horizontalArrangement = Arrangement.spacedBy(4.dp),-        ) {+        ButtonGroup(Modifier.fillMaxWidth()) {             BlurMode.entries.forEach { mode ->-                FilterChip(-                    selected = blurParams.mode == mode,-                    onClick = { onBlurChanged(blurParams.copy(mode = mode)) },-                    label = { Text(mode.name, fontSize = 12.sp) },+                toggleableItem(+                    checked = blurParams.mode == mode,+                    label = mode.name,+                    onCheckedChange = { onBlurChanged(blurParams.copy(mode = mode)) },                 )             }         }
photos/src/main/java/com/vayunmathur/photos/ui/CurvesPanel.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/CurvesPanel.kt b/photos/src/main/java/com/vayunmathur/photos/ui/CurvesPanel.ktindex a95cbc7e44..e8628a8e7f 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/CurvesPanel.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/CurvesPanel.kt@@ -3,15 +3,12 @@ package com.vayunmathur.photos.ui import androidx.compose.foundation.Canvas import androidx.compose.foundation.background import androidx.compose.foundation.gestures.detectDragGestures-import androidx.compose.foundation.horizontalScroll-import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding-import androidx.compose.foundation.rememberScrollState-import com.vayunmathur.library.ui.FilterChip+import com.vayunmathur.library.ui.ButtonGroup import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.Text import androidx.compose.runtime.Composable@@ -56,17 +53,12 @@ fun CurvesPanel(             .background(MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.5f))             .padding(8.dp),     ) {-        Row(-            modifier = Modifier-                .fillMaxWidth()-                .horizontalScroll(rememberScrollState()),-            horizontalArrangement = Arrangement.spacedBy(4.dp),-        ) {+        ButtonGroup(Modifier.fillMaxWidth()) {             CurveChannel.entries.forEach { channel ->-                FilterChip(-                    selected = selectedChannel == channel,-                    onClick = { onChannelSelected(channel) },-                    label = { Text(channel.name, fontSize = 12.sp) },+                toggleableItem(+                    checked = selectedChannel == channel,+                    label = channel.name,+                    onCheckedChange = { onChannelSelected(channel) },                 )             }         }
photos/src/main/java/com/vayunmathur/photos/ui/DrawingSettingsPage.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/DrawingSettingsPage.kt b/photos/src/main/java/com/vayunmathur/photos/ui/DrawingSettingsPage.ktindex d01b06d440..94aa26b5bf 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/DrawingSettingsPage.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/DrawingSettingsPage.kt@@ -73,7 +73,7 @@ fun DrawingSettingsPage(         modifier = Modifier             .fillMaxWidth()             .padding(16.dp),-        shape = RoundedCornerShape(16.dp),+        shape = MaterialTheme.shapes.large,         color = MaterialTheme.colorScheme.surfaceContainerHigh     ) {         Column(modifier = Modifier.padding(16.dp)) {
photos/src/main/java/com/vayunmathur/photos/ui/SelectiveEditPanel.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/SelectiveEditPanel.kt b/photos/src/main/java/com/vayunmathur/photos/ui/SelectiveEditPanel.ktindex f3b2450ba5..867b1b7fa8 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/SelectiveEditPanel.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/SelectiveEditPanel.kt@@ -2,16 +2,14 @@ package com.vayunmathur.photos.ui  import androidx.compose.foundation.background import androidx.compose.foundation.clickable-import androidx.compose.foundation.horizontalScroll import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width-import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.RoundedCornerShape-import com.vayunmathur.library.ui.FilterChip+import com.vayunmathur.library.ui.ButtonGroup import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.Slider import com.vayunmathur.library.ui.Surface@@ -44,17 +42,12 @@ fun SelectiveEditPanel(             .background(MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.5f))             .padding(8.dp),     ) {-        Row(-            modifier = Modifier-                .fillMaxWidth()-                .horizontalScroll(rememberScrollState()),-            horizontalArrangement = Arrangement.spacedBy(4.dp),-        ) {+        ButtonGroup(Modifier.fillMaxWidth()) {             MaskType.entries.forEach { type ->-                FilterChip(-                    selected = mask.type == type,-                    onClick = { onMaskChanged(mask.copy(type = type)) },-                    label = { Text(type.name, fontSize = 12.sp) },+                toggleableItem(+                    checked = mask.type == type,+                    label = type.name,+                    onCheckedChange = { onMaskChanged(mask.copy(type = type)) },                 )             }         }
photos/src/main/java/com/vayunmathur/photos/ui/VideoEditPage.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/VideoEditPage.kt b/photos/src/main/java/com/vayunmathur/photos/ui/VideoEditPage.ktindex b61a95155c..7ca654c9a4 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/VideoEditPage.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/VideoEditPage.kt@@ -55,7 +55,7 @@ import androidx.media3.ui.compose.PlayerSurface import androidx.media3.ui.compose.SURFACE_TYPE_TEXTURE_VIEW import com.vayunmathur.library.ui.AppScaffold import com.vayunmathur.library.ui.Button-import com.vayunmathur.library.ui.CircularProgressIndicator+import com.vayunmathur.library.ui.LoadingIndicator import com.vayunmathur.library.ui.FilledTonalButton import com.vayunmathur.library.ui.IconButton import com.vayunmathur.library.ui.IconContentCut@@ -115,7 +115,7 @@ fun VideoEditPage(vm: VideoEditViewModel, id: Long, uri: String?) {     val currentPhoto = photo     if (currentPhoto == null) {         Box(Modifier.fillMaxSize().background(Color.Black), contentAlignment = Alignment.Center) {-            CircularProgressIndicator()+            LoadingIndicator()         }         return     }@@ -559,9 +559,9 @@ private fun ExportProgressDialog(progress: Float, onCancel: () -> Unit) {         text = {             Row(verticalAlignment = Alignment.CenterVertically) {                 if (progress > 0f) {-                    CircularProgressIndicator(progress = { progress })+                    LoadingIndicator(progress = { progress })                 } else {-                    CircularProgressIndicator()+                    LoadingIndicator()                 }                 Spacer(Modifier.width(16.dp))                 Text("${(progress * 100).toInt()}%")
photos/src/main/java/com/vayunmathur/photos/ui/WallpaperPage.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/ui/WallpaperPage.kt b/photos/src/main/java/com/vayunmathur/photos/ui/WallpaperPage.ktindex 64fe8cb030..b92ac6046b 100644--- a/photos/src/main/java/com/vayunmathur/photos/ui/WallpaperPage.kt+++ b/photos/src/main/java/com/vayunmathur/photos/ui/WallpaperPage.kt@@ -54,6 +54,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import androidx.lifecycle.viewmodel.compose.viewModel import com.vayunmathur.library.ui.CircularProgressIndicator+import com.vayunmathur.library.ui.LoadingIndicator import com.vayunmathur.library.ui.FilledTonalButton import com.vayunmathur.library.ui.IconNavigation import com.vayunmathur.library.ui.MaterialTheme@@ -186,7 +187,7 @@ fun WallpaperPage(                 when {                     loadState == WallpaperLoadState.Loading ||                         (bitmap == null && loadState == WallpaperLoadState.Idle) -> {-                        CircularProgressIndicator(+                        LoadingIndicator(                             modifier = Modifier.size(48.dp),                             color = Color.White,                         )