Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make accounts list in drawer scrollable #1174

Merged
merged 2 commits into from
Aug 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions app/src/main/java/com/jerboa/ui/components/drawer/Drawer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Add
import androidx.compose.material.icons.outlined.Bookmarks
Expand Down Expand Up @@ -311,33 +313,34 @@ fun DrawerAddAccountMode(

accountsWithoutCurrent?.remove(currentAccount)

Column {
IconAndTextDrawerItem(
text = stringResource(R.string.home_add_account),
icon = Icons.Outlined.Add,
onClick = onAddAccount,
)
accountsWithoutCurrent?.forEach {
Column(Modifier.verticalScroll(rememberScrollState())) {
if (!currentAccount.isAnon()) {
IconAndTextDrawerItem(
text = stringResource(R.string.home_switch_to, it.name, it.instance),
icon = Icons.Outlined.Login,
onClick = { onSwitchAccountClick(it) },
text = stringResource(R.string.home_sign_out),
icon = Icons.Outlined.Close,
onClick = onSignOutClick,
)
}

if (!currentAccount.isAnon()) {
IconAndTextDrawerItem(
text = stringResource(R.string.home_switch_anon),
icon = Icons.Outlined.Login,
onClick = onSwitchAnon,
)
}

accountsWithoutCurrent?.forEach {
IconAndTextDrawerItem(
text = stringResource(R.string.home_sign_out),
icon = Icons.Outlined.Close,
onClick = onSignOutClick,
text = stringResource(R.string.home_switch_to, it.name, it.instance),
icon = Icons.Outlined.Login,
onClick = { onSwitchAccountClick(it) },
)
}

IconAndTextDrawerItem(
text = stringResource(R.string.home_add_account),
icon = Icons.Outlined.Add,
onClick = onAddAccount,
)
}
}

Expand Down Expand Up @@ -387,7 +390,9 @@ fun DrawerHeader(
) {
if (showWarningIcon) {
Icon(
modifier = Modifier.weight(0.1f).padding(end = SMALL_PADDING),
modifier = Modifier
.weight(0.1f)
.padding(end = SMALL_PADDING),
imageVector = Icons.Outlined.WarningAmber,
contentDescription = stringResource(R.string.warning),
tint = MaterialTheme.colorScheme.error,
Expand Down