Merge pull request #309 from ouchadam/bug-allow-profile-to-scroll
Fix profile page not scrolling when the screen is small
This commit is contained in:
commit
2a17f9d165
|
@ -6,7 +6,9 @@ import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.foundation.shape.CircleShape
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
|
import androidx.compose.foundation.verticalScroll
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.CameraAlt
|
import androidx.compose.material.icons.filled.CameraAlt
|
||||||
import androidx.compose.material.icons.filled.Settings
|
import androidx.compose.material.icons.filled.Settings
|
||||||
|
@ -68,56 +70,57 @@ private fun ProfilePage(context: Context, viewModel: ProfileState, profile: Page
|
||||||
IconButton(onClick = { context.startActivity(Intent(context, SettingsActivity::class.java)) }) {
|
IconButton(onClick = { context.startActivity(Intent(context, SettingsActivity::class.java)) }) {
|
||||||
Icon(imageVector = Icons.Filled.Settings, contentDescription = "Settings")
|
Icon(imageVector = Icons.Filled.Settings, contentDescription = "Settings")
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
when (val state = profile.content) {
|
val scrollState = rememberScrollState()
|
||||||
is Lce.Loading -> CenteredLoading()
|
when (val state = profile.content) {
|
||||||
is Lce.Error -> GenericError { viewModel.dispatch(ProfileAction.ComponentLifecycle.Visible) }
|
is Lce.Loading -> CenteredLoading()
|
||||||
is Lce.Content -> {
|
is Lce.Error -> GenericError { viewModel.dispatch(ProfileAction.ComponentLifecycle.Visible) }
|
||||||
val configuration = LocalConfiguration.current
|
is Lce.Content -> {
|
||||||
val content = state.value
|
val configuration = LocalConfiguration.current
|
||||||
Column {
|
val content = state.value
|
||||||
Spacer(modifier = Modifier.fillMaxHeight(0.05f))
|
Column(modifier = Modifier.verticalScroll(scrollState).padding(top = 32.dp)) {
|
||||||
Box(modifier = Modifier.fillMaxWidth(), contentAlignment = Alignment.Center) {
|
Spacer(modifier = Modifier.fillMaxHeight(0.05f))
|
||||||
val fallbackLabel = content.me.displayName ?: content.me.userId.value
|
Box(modifier = Modifier.fillMaxWidth(), contentAlignment = Alignment.Center) {
|
||||||
val avatarSize = configuration.percentOfHeight(0.2f)
|
val fallbackLabel = content.me.displayName ?: content.me.userId.value
|
||||||
Box {
|
val avatarSize = configuration.percentOfHeight(0.2f)
|
||||||
CircleishAvatar(content.me.avatarUrl?.value, fallbackLabel, avatarSize)
|
Box {
|
||||||
|
CircleishAvatar(content.me.avatarUrl?.value, fallbackLabel, avatarSize)
|
||||||
|
|
||||||
// TODO enable once edit support is added
|
// TODO enable once edit support is added
|
||||||
if (false) {
|
if (false) {
|
||||||
IconButton(modifier = Modifier
|
IconButton(modifier = Modifier
|
||||||
.size(avatarSize * 0.314f)
|
.size(avatarSize * 0.314f)
|
||||||
.align(Alignment.BottomEnd)
|
.align(Alignment.BottomEnd)
|
||||||
.background(MaterialTheme.colorScheme.primary, shape = CircleShape)
|
.background(MaterialTheme.colorScheme.primary, shape = CircleShape)
|
||||||
.padding(12.dp),
|
.padding(12.dp),
|
||||||
onClick = {}
|
onClick = {}
|
||||||
) {
|
) {
|
||||||
Icon(Icons.Filled.CameraAlt, contentDescription = null, tint = MaterialTheme.colorScheme.onPrimary)
|
Icon(Icons.Filled.CameraAlt, contentDescription = null, tint = MaterialTheme.colorScheme.onPrimary)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Spacer(modifier = Modifier.fillMaxHeight(0.05f))
|
||||||
|
|
||||||
|
TextRow(
|
||||||
|
title = "Display name",
|
||||||
|
content = content.me.displayName ?: "Not set",
|
||||||
|
)
|
||||||
|
TextRow(
|
||||||
|
title = "User id",
|
||||||
|
content = content.me.userId.value,
|
||||||
|
)
|
||||||
|
TextRow(
|
||||||
|
title = "Homeserver",
|
||||||
|
content = content.me.homeServerUrl.value,
|
||||||
|
)
|
||||||
|
|
||||||
|
TextRow(
|
||||||
|
title = "Invitations",
|
||||||
|
content = "${content.invitationsCount} pending",
|
||||||
|
onClick = { viewModel.dispatch(ProfileAction.GoToInvitations) }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
Spacer(modifier = Modifier.fillMaxHeight(0.05f))
|
|
||||||
|
|
||||||
TextRow(
|
|
||||||
title = "Display name",
|
|
||||||
content = content.me.displayName ?: "Not set",
|
|
||||||
)
|
|
||||||
TextRow(
|
|
||||||
title = "User id",
|
|
||||||
content = content.me.userId.value,
|
|
||||||
)
|
|
||||||
TextRow(
|
|
||||||
title = "Homeserver",
|
|
||||||
content = content.me.homeServerUrl.value,
|
|
||||||
)
|
|
||||||
|
|
||||||
TextRow(
|
|
||||||
title = "Invitations",
|
|
||||||
content = "${content.invitationsCount} pending",
|
|
||||||
onClick = { viewModel.dispatch(ProfileAction.GoToInvitations) }
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue