created settings screen
This commit is contained in:
@@ -34,6 +34,7 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.LoadRedirectScreen
|
||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.NotificationScreen
|
||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.ProfileScreen
|
||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.SearchScreen
|
||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.SettingsScreen
|
||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.ThreadScreen
|
||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.VideoScreen
|
||||
import kotlinx.coroutines.delay
|
||||
@@ -219,6 +220,15 @@ fun AppNavigation(
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
Route.Settings.let { route ->
|
||||
composable(route.route, route.arguments, content = {
|
||||
SettingsScreen(
|
||||
accountViewModel = accountViewModel,
|
||||
nav = nav
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
actionableNextPage?.let {
|
||||
|
||||
@@ -355,6 +355,15 @@ fun ListContent(
|
||||
route = Route.BlockedUsers.route
|
||||
)
|
||||
|
||||
NavigationRow(
|
||||
title = stringResource(R.string.settings),
|
||||
icon = Route.Settings.icon,
|
||||
tint = MaterialTheme.colors.onBackground,
|
||||
nav = nav,
|
||||
scaffoldState = scaffoldState,
|
||||
route = Route.Settings.route
|
||||
)
|
||||
|
||||
IconRow(
|
||||
title = stringResource(R.string.backup_keys),
|
||||
icon = R.drawable.ic_key,
|
||||
|
||||
@@ -128,6 +128,11 @@ sealed class Route(
|
||||
icon = R.drawable.ic_moments,
|
||||
arguments = listOf(navArgument("id") { type = NavType.StringType }).toImmutableList()
|
||||
)
|
||||
|
||||
object Settings : Route(
|
||||
route = "Settings",
|
||||
icon = com.google.android.exoplayer2.R.drawable.exo_ic_settings
|
||||
)
|
||||
}
|
||||
|
||||
// **
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
package com.vitorpamplona.amethyst.ui.screen.loggedIn
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.material.DropdownMenuItem
|
||||
import androidx.compose.material.ExperimentalMaterialApi
|
||||
import androidx.compose.material.ExposedDropdownMenuBox
|
||||
import androidx.compose.material.ExposedDropdownMenuDefaults
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.material.TextField
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.vitorpamplona.amethyst.ui.theme.DoubleVertSpacer
|
||||
import com.vitorpamplona.amethyst.ui.theme.StdPadding
|
||||
|
||||
@Composable
|
||||
fun SettingsScreen(
|
||||
accountViewModel: AccountViewModel,
|
||||
nav: (String) -> Unit
|
||||
) {
|
||||
val listItems = arrayOf("Always", "Wifi-only", "Never")
|
||||
val selectedItem = remember {
|
||||
mutableStateOf(listItems[0])
|
||||
}
|
||||
|
||||
val context = LocalContext.current
|
||||
Column(
|
||||
StdPadding
|
||||
) {
|
||||
Section("Account preferences")
|
||||
|
||||
Section("Application preferences")
|
||||
Text(
|
||||
"Media",
|
||||
fontWeight = FontWeight.Bold
|
||||
)
|
||||
DropDownSettings(
|
||||
selectedItem = selectedItem,
|
||||
listItems = listItems
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterialApi::class)
|
||||
@Composable
|
||||
fun DropDownSettings(
|
||||
selectedItem: MutableState<String>,
|
||||
listItems: Array<String>
|
||||
) {
|
||||
var expanded by remember {
|
||||
mutableStateOf(false)
|
||||
}
|
||||
ExposedDropdownMenuBox(
|
||||
expanded = expanded,
|
||||
onExpandedChange = {
|
||||
expanded = !expanded
|
||||
}
|
||||
) {
|
||||
TextField(
|
||||
value = selectedItem.value,
|
||||
onValueChange = {},
|
||||
readOnly = true,
|
||||
label = { Text(text = "Automatically load images/gifs") },
|
||||
trailingIcon = {
|
||||
ExposedDropdownMenuDefaults.TrailingIcon(
|
||||
expanded = expanded
|
||||
)
|
||||
},
|
||||
colors = ExposedDropdownMenuDefaults.textFieldColors()
|
||||
)
|
||||
|
||||
ExposedDropdownMenu(
|
||||
expanded = expanded,
|
||||
onDismissRequest = { expanded = false }
|
||||
) {
|
||||
listItems.forEach { selectedOption ->
|
||||
DropdownMenuItem(onClick = {
|
||||
selectedItem.value = selectedOption
|
||||
expanded = false
|
||||
}) {
|
||||
Text(text = selectedOption)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun Section(text: String) {
|
||||
Spacer(modifier = DoubleVertSpacer)
|
||||
Text(
|
||||
text = text,
|
||||
fontWeight = FontWeight.Bold,
|
||||
fontSize = 20.sp
|
||||
)
|
||||
Spacer(modifier = DoubleVertSpacer)
|
||||
}
|
||||
@@ -483,4 +483,5 @@
|
||||
|
||||
<string name="add_sensitive_content_label">Sensitive Content</string>
|
||||
<string name="add_sensitive_content_description">Adds sensitive content warning before showing this content</string>
|
||||
<string name="settings">Settings</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user