Приложение
This commit is contained in:
185
client-mobile/settings/presentation/SettingsScreen.kt
Normal file
185
client-mobile/settings/presentation/SettingsScreen.kt
Normal file
@@ -0,0 +1,185 @@
|
||||
package settings.presentation
|
||||
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.*
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import ru.knot.messager.R
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun SettingsScreen(
|
||||
onBack: () -> Unit = {},
|
||||
onLogout: () -> Unit = {}
|
||||
) {
|
||||
var notificationsEnabled by remember { mutableStateOf(true) }
|
||||
var previewEnabled by remember { mutableStateOf(true) }
|
||||
var privacyOnlineStatus by remember { mutableStateOf(true) }
|
||||
var darkThemeEnabled by remember { mutableStateOf(true) }
|
||||
|
||||
Scaffold(
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
title = { Text(stringResource(R.string.settings)) },
|
||||
navigationIcon = {
|
||||
IconButton(onClick = onBack) {
|
||||
Icon(Icons.Default.ArrowBack, contentDescription = null)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
) { paddingValues ->
|
||||
LazyColumn(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(paddingValues)
|
||||
.padding(horizontal = 16.dp)
|
||||
) {
|
||||
item { SectionHeader(stringResource(R.string.notifications)) }
|
||||
item {
|
||||
SettingsToggleItem(
|
||||
icon = Icons.Default.Notifications,
|
||||
title = "Включить уведомления",
|
||||
subtitle = "Звуки и вибрация",
|
||||
checked = notificationsEnabled,
|
||||
onCheckedChange = { notificationsEnabled = it }
|
||||
)
|
||||
}
|
||||
item {
|
||||
SettingsToggleItem(
|
||||
icon = Icons.Default.Visibility,
|
||||
title = "Предпросмотр сообщений",
|
||||
subtitle = "Показывать текст в уведомлениях",
|
||||
checked = previewEnabled,
|
||||
onCheckedChange = { previewEnabled = it }
|
||||
)
|
||||
}
|
||||
|
||||
item { Spacer(modifier = Modifier.height(16.dp)) }
|
||||
item { SectionHeader("Конфиденциальность") }
|
||||
item {
|
||||
SettingsToggleItem(
|
||||
icon = Icons.Default.Lock,
|
||||
title = "Статус «В сети»",
|
||||
subtitle = "Кто видит время вашего посещения",
|
||||
checked = privacyOnlineStatus,
|
||||
onCheckedChange = { privacyOnlineStatus = it }
|
||||
)
|
||||
}
|
||||
item {
|
||||
SettingsClickItem(
|
||||
icon = Icons.Default.Block,
|
||||
title = "Черный список",
|
||||
subtitle = "0 пользователей",
|
||||
onClick = { /* TODO */ }
|
||||
)
|
||||
}
|
||||
|
||||
item { Spacer(modifier = Modifier.height(16.dp)) }
|
||||
item { SectionHeader("Внешний вид") }
|
||||
item {
|
||||
SettingsToggleItem(
|
||||
icon = Icons.Default.DarkMode,
|
||||
title = "Темная тема",
|
||||
subtitle = "Indigo стиль",
|
||||
checked = darkThemeEnabled,
|
||||
onCheckedChange = { darkThemeEnabled = it }
|
||||
)
|
||||
}
|
||||
item {
|
||||
SettingsClickItem(
|
||||
icon = Icons.Default.Language,
|
||||
title = "Язык приложения",
|
||||
subtitle = "Русский",
|
||||
onClick = { /* TODO: Language Picker */ }
|
||||
)
|
||||
}
|
||||
|
||||
item { Spacer(modifier = Modifier.height(24.dp)) }
|
||||
item {
|
||||
Button(
|
||||
onClick = onLogout,
|
||||
modifier = Modifier.fillMaxWidth().height(56.dp),
|
||||
colors = ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.errorContainer, contentColor = MaterialTheme.colorScheme.error),
|
||||
shape = RoundedCornerShape(24.dp)
|
||||
) {
|
||||
Icon(Icons.Default.Logout, contentDescription = null)
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
Text("Выйти из аккаунта")
|
||||
}
|
||||
}
|
||||
item { Spacer(modifier = Modifier.height(100.dp)) } // Padding for BottomBar
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun SectionHeader(title: String) {
|
||||
Text(
|
||||
text = title,
|
||||
style = MaterialTheme.typography.titleSmall,
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
modifier = Modifier.padding(vertical = 8.dp, horizontal = 4.dp)
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun SettingsToggleItem(
|
||||
icon: ImageVector,
|
||||
title: String,
|
||||
subtitle: String,
|
||||
checked: Boolean,
|
||||
onCheckedChange: (Boolean) -> Unit
|
||||
) {
|
||||
Surface(
|
||||
modifier = Modifier.fillMaxWidth().padding(vertical = 4.dp).clip(RoundedCornerShape(24.dp)),
|
||||
color = MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.5f)
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier.padding(16.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Icon(icon, contentDescription = null, tint = MaterialTheme.colorScheme.primary)
|
||||
Column(modifier = Modifier.weight(1f).padding(start = 16.dp)) {
|
||||
Text(title, style = MaterialTheme.typography.bodyLarge)
|
||||
Text(subtitle, style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||
}
|
||||
Switch(checked = checked, onCheckedChange = onCheckedChange)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun SettingsClickItem(
|
||||
icon: ImageVector,
|
||||
title: String,
|
||||
subtitle: String,
|
||||
onClick: () -> Unit
|
||||
) {
|
||||
Surface(
|
||||
modifier = Modifier.fillMaxWidth().padding(vertical = 4.dp).clip(RoundedCornerShape(24.dp)),
|
||||
color = MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.5f),
|
||||
onClick = onClick
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier.padding(16.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Icon(icon, contentDescription = null, tint = MaterialTheme.colorScheme.primary)
|
||||
Column(modifier = Modifier.weight(1f).padding(start = 16.dp)) {
|
||||
Text(title, style = MaterialTheme.typography.bodyLarge)
|
||||
Text(subtitle, style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||
}
|
||||
Icon(Icons.Default.ChevronRight, contentDescription = null, tint = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user