Skip to content

Commit c20fb2d

Browse files
style: centge avatar section in landscape mode
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
1 parent 441fc12 commit c20fb2d

2 files changed

Lines changed: 23 additions & 59 deletions

File tree

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

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import androidx.compose.foundation.layout.Spacer
1414
import androidx.compose.foundation.layout.height
1515
import androidx.compose.foundation.layout.padding
1616
import androidx.compose.foundation.layout.size
17-
import androidx.compose.foundation.layout.width
1817
import androidx.compose.foundation.shape.CircleShape
1918
import androidx.compose.foundation.shape.RoundedCornerShape
2019
import androidx.compose.material3.FilledTonalIconButton
@@ -35,20 +34,6 @@ import androidx.compose.ui.viewinterop.AndroidView
3534
import com.nextcloud.talk.R
3635
import com.nextcloud.talk.utils.DisplayUtils
3736

38-
@Composable
39-
internal fun AvatarSection(
40-
state: ProfileUiState,
41-
callbacks: ProfileCallbacks,
42-
isLandscape: Boolean,
43-
modifier: Modifier = Modifier
44-
) {
45-
if (isLandscape) {
46-
AvatarSectionLandscape(state, callbacks, modifier)
47-
} else {
48-
AvatarSectionPortrait(state, callbacks, modifier)
49-
}
50-
}
51-
5237
@Composable
5338
private fun AvatarImage(state: ProfileUiState, avatarSize: Dp) {
5439
key(state.currentUser?.userId, state.avatarRefreshKey) {
@@ -67,47 +52,7 @@ private fun AvatarImage(state: ProfileUiState, avatarSize: Dp) {
6752
}
6853

6954
@Composable
70-
private fun AvatarSectionLandscape(state: ProfileUiState, callbacks: ProfileCallbacks, modifier: Modifier) {
71-
Column(modifier = modifier.padding(16.dp)) {
72-
Row(verticalAlignment = Alignment.Top) {
73-
AvatarImage(state, 72.dp)
74-
Spacer(modifier = Modifier.width(16.dp))
75-
Column {
76-
if (state.displayName.isNotEmpty()) {
77-
Text(
78-
text = state.displayName,
79-
style = MaterialTheme.typography.titleLarge,
80-
maxLines = 1,
81-
overflow = TextOverflow.Ellipsis
82-
)
83-
}
84-
if (state.baseUrl.isNotEmpty()) {
85-
Text(
86-
text = state.baseUrl,
87-
style = MaterialTheme.typography.bodyMedium,
88-
color = MaterialTheme.colorScheme.onSurfaceVariant,
89-
maxLines = 1,
90-
overflow = TextOverflow.Ellipsis,
91-
modifier = Modifier.padding(top = 2.dp)
92-
)
93-
}
94-
}
95-
}
96-
if (state.showAvatarButtons) {
97-
AvatarButtonsRow(callbacks = callbacks, modifier = Modifier.padding(top = 8.dp, start = 40.dp))
98-
}
99-
if (state.showProfileEnabledCard) {
100-
ProfileEnabledCard(
101-
isEnabled = state.isProfileEnabled,
102-
onCheckedChange = callbacks.onProfileEnabledChange,
103-
modifier = Modifier.padding(vertical = 8.dp)
104-
)
105-
}
106-
}
107-
}
108-
109-
@Composable
110-
private fun AvatarSectionPortrait(state: ProfileUiState, callbacks: ProfileCallbacks, modifier: Modifier) {
55+
fun AvatarSection(state: ProfileUiState, callbacks: ProfileCallbacks, modifier: Modifier) {
11156
Column(modifier = modifier.padding(top = 16.dp), horizontalAlignment = Alignment.CenterHorizontally) {
11257
AvatarImage(state, 96.dp)
11358
if (state.displayName.isNotEmpty()) {

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

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ fun ProfileScreen(state: ProfileUiState, callbacks: ProfileCallbacks, modifier:
5959
AvatarSection(
6060
state = state,
6161
callbacks = callbacks,
62-
isLandscape = true,
6362
modifier = Modifier.weight(FULL_WEIGHT)
6463
)
6564
ProfileContentPane(
@@ -79,8 +78,7 @@ fun ProfileScreen(state: ProfileUiState, callbacks: ProfileCallbacks, modifier:
7978
AvatarSection(
8079
state = state,
8180
callbacks = callbacks,
82-
modifier = Modifier.fillMaxWidth(),
83-
isLandscape = false
81+
modifier = Modifier.fillMaxWidth()
8482
)
8583
// weight(1f) — fills the space that remains after the avatar section.
8684
ProfileContentPane(
@@ -146,6 +144,27 @@ private fun PreviewDark() {
146144
}
147145
}
148146

147+
@Preview(
148+
name = "Landscape · Light",
149+
showBackground = true,
150+
widthDp = 891,
151+
heightDp = 411
152+
)
153+
@Preview(
154+
name = "Landscape · Dark",
155+
showBackground = true,
156+
widthDp = 891,
157+
heightDp = 411,
158+
uiMode = Configuration.UI_MODE_NIGHT_YES
159+
)
160+
@Composable
161+
private fun PreviewLandscape() {
162+
val colorScheme = if (isSystemInDarkTheme()) darkColorScheme() else lightColorScheme()
163+
MaterialTheme(colorScheme = colorScheme) {
164+
ProfileScreen(state = previewState, callbacks = previewCallbacks)
165+
}
166+
}
167+
149168
@Preview(name = "RTL · Arabic", showBackground = true, showSystemUi = true, locale = "ar")
150169
@Composable
151170
private fun PreviewRtlArabic() {

0 commit comments

Comments
 (0)