Skip to content

Commit a10212f

Browse files
style: Move profile enablement to list
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
1 parent c20fb2d commit a10212f

3 files changed

Lines changed: 44 additions & 45 deletions

File tree

app/src/main/java/com/nextcloud/talk/profile/AvatarSection.kt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,6 @@ fun AvatarSection(state: ProfileUiState, callbacks: ProfileCallbacks, modifier:
7878
if (state.showAvatarButtons) {
7979
AvatarButtonsRow(callbacks = callbacks, modifier = Modifier.padding(top = 8.dp, bottom = 8.dp))
8080
}
81-
if (state.showProfileEnabledCard) {
82-
ProfileEnabledCard(
83-
isEnabled = state.isProfileEnabled,
84-
onCheckedChange = callbacks.onProfileEnabledChange,
85-
modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp)
86-
)
87-
}
8881
}
8982
}
9083

app/src/main/java/com/nextcloud/talk/profile/ProfileContentPane.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ private fun ProfileItemList(
8080
contentPadding = PaddingValues(bottom = bottomPadding),
8181
modifier = modifier
8282
) {
83+
if (state.showProfileEnabledCard) {
84+
item(key = "profile_enabled_card") {
85+
ProfileEnabledCard(
86+
isEnabled = state.isProfileEnabled,
87+
onCheckedChange = callbacks.onProfileEnabledChange,
88+
modifier = Modifier.padding(start = 16.dp, top = 8.dp, bottom = 8.dp, end = 8.dp)
89+
)
90+
}
91+
}
8392
itemsIndexed(displayItems) { index, item ->
8493
val position = when {
8594
displayItems.size == 1 -> UserInfoDetailItemPosition.FIRST

app/src/main/java/com/nextcloud/talk/profile/ProfileEnabledCard.kt

Lines changed: 35 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ package com.nextcloud.talk.profile
88

99
import android.content.res.Configuration
1010
import androidx.compose.foundation.isSystemInDarkTheme
11+
import androidx.compose.foundation.clickable
12+
import androidx.compose.foundation.layout.Box
1113
import androidx.compose.foundation.layout.Row
1214
import androidx.compose.foundation.layout.Spacer
1315
import androidx.compose.foundation.layout.fillMaxWidth
1416
import androidx.compose.foundation.layout.padding
1517
import androidx.compose.foundation.layout.size
1618
import androidx.compose.foundation.layout.width
17-
import androidx.compose.material3.Card
1819
import androidx.compose.material3.Icon
1920
import androidx.compose.material3.MaterialTheme
2021
import androidx.compose.material3.Surface
@@ -34,45 +35,41 @@ import com.nextcloud.talk.R
3435

3536
@Composable
3637
fun ProfileEnabledCard(isEnabled: Boolean, onCheckedChange: (Boolean) -> Unit, modifier: Modifier = Modifier) {
37-
Row(
38-
modifier = modifier.fillMaxWidth(),
39-
verticalAlignment = Alignment.CenterVertically
38+
Box(
39+
modifier = Modifier
40+
.padding(top = 8.dp, bottom = 8.dp, start = 16.dp, end = 14.dp)
41+
.clickable { onCheckedChange(!isEnabled) }
4042
) {
41-
Icon(
42-
painter = painterResource(R.drawable.ic_id_card_24px),
43-
contentDescription = null,
44-
modifier = Modifier.size(24.dp),
45-
tint = MaterialTheme.colorScheme.primary
46-
)
47-
Spacer(modifier = Modifier.width(16.dp))
48-
Card(modifier = Modifier.weight(1f), onClick = { onCheckedChange(!isEnabled) }) {
49-
Row(
50-
modifier = Modifier
51-
.fillMaxWidth()
52-
.padding(horizontal = 16.dp, vertical = 12.dp),
53-
verticalAlignment = Alignment.CenterVertically
54-
) {
55-
Text(
56-
text = stringResource(
57-
if (isEnabled) {
58-
R.string.user_info_profile_disable
59-
} else {
60-
R.string.user_info_profile_enable
61-
}
62-
),
63-
style = MaterialTheme.typography.titleMedium,
64-
maxLines = 2,
65-
overflow = TextOverflow.Ellipsis,
66-
modifier = Modifier.weight(1f)
67-
)
68-
Spacer(modifier = Modifier.width(16.dp))
69-
Switch(
70-
checked = isEnabled,
71-
onCheckedChange = onCheckedChange
72-
)
73-
}
43+
Row(
44+
modifier = Modifier.fillMaxWidth(),
45+
verticalAlignment = Alignment.CenterVertically
46+
) {
47+
Icon(
48+
painter = painterResource(R.drawable.ic_id_card_24px),
49+
contentDescription = null,
50+
modifier = Modifier.size(24.dp),
51+
tint = MaterialTheme.colorScheme.primary
52+
)
53+
Spacer(modifier = Modifier.width(32.dp))
54+
Text(
55+
text = stringResource(
56+
if (isEnabled) {
57+
R.string.user_info_profile_disable
58+
} else {
59+
R.string.user_info_profile_enable
60+
}
61+
),
62+
style = MaterialTheme.typography.bodyLarge,
63+
maxLines = 2,
64+
overflow = TextOverflow.Ellipsis,
65+
modifier = Modifier.weight(1f)
66+
)
67+
Spacer(modifier = Modifier.width(16.dp))
68+
Switch(
69+
checked = isEnabled,
70+
onCheckedChange = onCheckedChange
71+
)
7472
}
75-
Spacer(modifier = Modifier.width(32.dp))
7673
}
7774
}
7875

0 commit comments

Comments
 (0)