Skip to content

Commit 44f5ee5

Browse files
authored
Merge pull request #807 from tunjid/bugfix/1.2.5
Bugfix/1.2.5
2 parents 9736f4f + 187746d commit 44f5ee5

File tree

9 files changed

+94
-54
lines changed

9 files changed

+94
-54
lines changed

data/models/src/commonTest/kotlin/com/tunjid/heron/fakes/Profile.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ fun sampleProfile(): Profile {
2323
createdListCount = 0,
2424
createdFeedGeneratorCount = 0,
2525
createdStarterPackCount = 0,
26+
chat = Profile.ChatInfo(
27+
allowed = Profile.ChatInfo.Allowed.NoOne,
28+
),
2629
),
2730
labels = emptyList(),
2831
isLabeler = false,

feature/settings/src/androidMain/kotlin/com/tunjid/heron/settings/ui/AppearanceItem.android.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616

1717
package com.tunjid.heron.settings.ui
1818

19-
actual fun isDynamicThemingSupported(): Boolean {
20-
return true
21-
}
19+
import androidx.compose.runtime.Stable
2220

23-
actual fun isCompactNavigationSupported(): Boolean {
24-
return true
25-
}
21+
@Stable
22+
actual fun isDynamicThemingSupported(): Boolean = true
23+
24+
@Stable
25+
actual fun isCompactNavigationSupported(): Boolean = true

feature/settings/src/commonMain/kotlin/com/tunjid/heron/settings/ui/AppearanceItem.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
2020
import androidx.compose.material.icons.Icons
2121
import androidx.compose.material.icons.rounded.Palette
2222
import androidx.compose.runtime.Composable
23+
import androidx.compose.runtime.Stable
2324
import androidx.compose.ui.Modifier
2425
import com.tunjid.heron.data.core.models.Preferences
2526
import heron.feature.settings.generated.resources.Res
@@ -28,8 +29,10 @@ import heron.feature.settings.generated.resources.use_compact_navigation
2829
import heron.feature.settings.generated.resources.use_dynamic_theming
2930
import org.jetbrains.compose.resources.stringResource
3031

32+
@Stable
3133
expect fun isDynamicThemingSupported(): Boolean
3234

35+
@Stable
3336
expect fun isCompactNavigationSupported(): Boolean
3437

3538
@Composable
@@ -49,12 +52,16 @@ fun AppearanceItem(
4952
icon = Icons.Rounded.Palette,
5053
) {
5154
SettingsToggleItem(
55+
modifier = Modifier
56+
.fillMaxWidth(),
5257
text = stringResource(Res.string.use_dynamic_theming),
5358
enabled = isDynamicThemingSupported,
5459
checked = signedInProfilePreferences.useDynamicTheming,
5560
onCheckedChange = setDynamicThemingPreference,
5661
)
5762
SettingsToggleItem(
63+
modifier = Modifier
64+
.fillMaxWidth(),
5865
text = stringResource(Res.string.use_compact_navigation),
5966
enabled = isCompactNavigationSupported,
6067
checked = signedInProfilePreferences.useCompactNavigation,

feature/settings/src/commonMain/kotlin/com/tunjid/heron/settings/ui/ContentAndMediaItem.kt

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,10 @@
1616

1717
package com.tunjid.heron.settings.ui
1818

19-
import androidx.compose.foundation.layout.Arrangement
20-
import androidx.compose.foundation.layout.Row
2119
import androidx.compose.foundation.layout.fillMaxWidth
2220
import androidx.compose.material.icons.Icons
2321
import androidx.compose.material.icons.rounded.Newspaper
24-
import androidx.compose.material3.Switch
25-
import androidx.compose.material3.Text
2622
import androidx.compose.runtime.Composable
27-
import androidx.compose.ui.Alignment
2823
import androidx.compose.ui.Modifier
2924
import com.tunjid.heron.data.core.models.Preferences
3025
import heron.feature.settings.generated.resources.Res
@@ -44,18 +39,13 @@ fun ContentAndMediaItem(
4439
title = stringResource(Res.string.content_and_media),
4540
icon = Icons.Rounded.Newspaper,
4641
) {
47-
Row(
48-
modifier = Modifier.fillMaxWidth(),
49-
horizontalArrangement = Arrangement.SpaceBetween,
50-
verticalAlignment = Alignment.CenterVertically,
51-
) {
52-
Text(
53-
text = stringResource(Res.string.refresh_timelines_on_launch),
54-
)
55-
Switch(
56-
checked = signedInProfilePreferences.refreshHomeTimelineOnLaunch,
57-
onCheckedChange = setRefreshHomeTimelineOnLaunch,
58-
)
59-
}
42+
SettingsToggleItem(
43+
modifier = Modifier
44+
.fillMaxWidth(),
45+
text = stringResource(Res.string.refresh_timelines_on_launch),
46+
enabled = true,
47+
checked = signedInProfilePreferences.refreshHomeTimelineOnLaunch,
48+
onCheckedChange = setRefreshHomeTimelineOnLaunch,
49+
)
6050
}
6151
}

feature/settings/src/commonMain/kotlin/com/tunjid/heron/settings/ui/OpenSourceLibrariesItem.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ private fun LibrariesHorizontalGrid(
9090
LazyHorizontalGrid(
9191
modifier = modifier,
9292
rows = GridCells.Adaptive(56.dp),
93-
horizontalArrangement = Arrangement.spacedBy(8.dp),
93+
horizontalArrangement = Arrangement.spacedBy(16.dp),
9494
) {
9595
items(
9696
items = libs,

feature/settings/src/commonMain/kotlin/com/tunjid/heron/settings/ui/SettingsItemRow.kt

Lines changed: 56 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import androidx.compose.animation.fadeOut
2424
import androidx.compose.animation.shrinkOut
2525
import androidx.compose.animation.slideInVertically
2626
import androidx.compose.animation.slideOutVertically
27-
import androidx.compose.foundation.clickable
27+
import androidx.compose.foundation.layout.Arrangement
2828
import androidx.compose.foundation.layout.Column
2929
import androidx.compose.foundation.layout.ColumnScope
3030
import androidx.compose.foundation.layout.Row
@@ -33,6 +33,8 @@ import androidx.compose.foundation.layout.Spacer
3333
import androidx.compose.foundation.layout.fillMaxWidth
3434
import androidx.compose.foundation.layout.padding
3535
import androidx.compose.foundation.layout.width
36+
import androidx.compose.foundation.selection.toggleable
37+
import androidx.compose.foundation.shape.RoundedCornerShape
3638
import androidx.compose.material.icons.Icons
3739
import androidx.compose.material.icons.filled.ExpandLess
3840
import androidx.compose.material3.Icon
@@ -46,9 +48,11 @@ import androidx.compose.runtime.saveable.rememberSaveable
4648
import androidx.compose.runtime.setValue
4749
import androidx.compose.ui.Alignment
4850
import androidx.compose.ui.Modifier
51+
import androidx.compose.ui.draw.clip
4952
import androidx.compose.ui.graphics.Color
5053
import androidx.compose.ui.graphics.graphicsLayer
5154
import androidx.compose.ui.graphics.vector.ImageVector
55+
import androidx.compose.ui.semantics.Role
5256
import androidx.compose.ui.semantics.contentDescription
5357
import androidx.compose.ui.semantics.semantics
5458
import androidx.compose.ui.unit.IntSize
@@ -68,14 +72,17 @@ fun SettingsItemRow(
6872
) {
6973
Row(
7074
verticalAlignment = Alignment.CenterVertically,
71-
modifier = modifier
72-
.semantics {
73-
contentDescription = title
74-
}
75-
.fillMaxWidth()
76-
.padding(
77-
horizontal = 24.dp,
78-
vertical = 8.dp,
75+
modifier = SettingsItemClipModifier
76+
.then(
77+
modifier
78+
.semantics {
79+
contentDescription = title
80+
}
81+
.fillMaxWidth()
82+
.padding(
83+
horizontal = 24.dp,
84+
vertical = 8.dp,
85+
),
7986
),
8087
) {
8188
Icon(
@@ -108,9 +115,16 @@ fun ExpandableSettingsItemRow(
108115
var isExpanded by rememberSaveable { mutableStateOf(false) }
109116

110117
Column(
111-
modifier = modifier
112-
.fillMaxWidth()
113-
.clickable { isExpanded = !isExpanded },
118+
modifier = SettingsItemClipModifier
119+
.then(
120+
modifier
121+
.fillMaxWidth()
122+
.toggleable(
123+
value = isExpanded,
124+
onValueChange = { isExpanded = it },
125+
role = Role.Button,
126+
),
127+
),
114128
) {
115129
SettingsItemRow(
116130
modifier = Modifier
@@ -147,6 +161,9 @@ fun ExpandableSettingsItemRow(
147161
content = {
148162
Column(
149163
modifier = Modifier
164+
// Inset expanded content from the start to disambiguate
165+
// it from other items
166+
.padding(start = 8.dp)
150167
.fillMaxWidth(),
151168
) {
152169
content()
@@ -158,28 +175,51 @@ fun ExpandableSettingsItemRow(
158175

159176
@Composable
160177
fun SettingsToggleItem(
178+
modifier: Modifier = Modifier,
161179
text: String,
162180
enabled: Boolean,
163181
checked: Boolean,
164182
onCheckedChange: (Boolean) -> Unit,
165183
) {
166184
Row(
167-
modifier = Modifier.fillMaxWidth(),
185+
modifier = SettingsItemClipModifier
186+
.then(
187+
modifier
188+
.toggleable(
189+
value = checked,
190+
onValueChange = onCheckedChange,
191+
enabled = enabled,
192+
role = Role.Switch,
193+
)
194+
.padding(
195+
horizontal = 8.dp,
196+
vertical = 4.dp,
197+
),
198+
),
168199
verticalAlignment = Alignment.CenterVertically,
200+
horizontalArrangement = Arrangement.SpaceBetween,
169201
) {
170202
Text(
203+
modifier = Modifier
204+
.weight(1f),
171205
text = text,
172206
)
173-
Spacer(Modifier.weight(1f))
174-
Spacer(Modifier.width(16.dp))
207+
Spacer(
208+
modifier = Modifier
209+
.width(16.dp),
210+
)
175211
Switch(
176212
enabled = enabled,
177213
checked = checked,
178-
onCheckedChange = onCheckedChange,
214+
onCheckedChange = null,
179215
)
180216
}
181217
}
182218

183219
private val EnterTransition = fadeIn() + slideInVertically { -it }
184220
private val ExitTransition =
185221
shrinkOut { IntSize(it.width, 0) } + slideOutVertically { -it } + fadeOut()
222+
223+
private val SettingsItemShape = RoundedCornerShape(8.dp)
224+
private val SettingsItemClipModifier = Modifier
225+
.clip(SettingsItemShape)

feature/settings/src/desktopMain/kotlin/com/tunjid/heron/settings/ui/AppearanceItem.jvm.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616

1717
package com.tunjid.heron.settings.ui
1818

19-
actual fun isDynamicThemingSupported(): Boolean {
20-
return false
21-
}
19+
import androidx.compose.runtime.Stable
2220

23-
actual fun isCompactNavigationSupported(): Boolean {
24-
return false
25-
}
21+
@Stable
22+
actual fun isDynamicThemingSupported(): Boolean = false
23+
24+
@Stable
25+
actual fun isCompactNavigationSupported(): Boolean = false

feature/settings/src/iosMain/kotlin/com/tunjid/heron/settings/ui/AppearanceItem.ios.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616

1717
package com.tunjid.heron.settings.ui
1818

19-
actual fun isDynamicThemingSupported(): Boolean {
20-
return false
21-
}
19+
import androidx.compose.runtime.Stable
2220

23-
actual fun isCompactNavigationSupported(): Boolean {
24-
return true
25-
}
21+
@Stable
22+
actual fun isDynamicThemingSupported(): Boolean = false
23+
24+
@Stable
25+
actual fun isCompactNavigationSupported(): Boolean = true

ui/core/src/commonMain/kotlin/com/tunjid/heron/ui/Tokens.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ object UiTokens {
6161

6262
fun bottomNavHeight(
6363
isCompact: Boolean,
64-
): Dp = if (isCompact) 64.dp else 80.dp
64+
): Dp = if (isCompact) 48.dp else 80.dp
6565

6666
@Composable
6767
fun bottomNavAndInsetPaddingValues(

0 commit comments

Comments
 (0)