wip: settings
This commit is contained in:
@@ -47,6 +47,7 @@ import androidx.navigation.NavType
|
||||
import androidx.navigation.compose.NavHost
|
||||
import androidx.navigation.compose.composable
|
||||
import androidx.navigation.compose.currentBackStackEntryAsState
|
||||
import androidx.navigation.compose.navigation
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
import androidx.navigation.navArgument
|
||||
import de.connect2x.trixnity.client.CryptoDriverModule
|
||||
@@ -69,8 +70,14 @@ import kotlinx.coroutines.launch
|
||||
import ru.risdeveau.pixeldragon.R
|
||||
import ru.risdeveau.pixeldragon.client
|
||||
import ru.risdeveau.pixeldragon.ui.item.Avatar
|
||||
import ru.risdeveau.pixeldragon.ui.layout.AccountSettingsScreen
|
||||
import ru.risdeveau.pixeldragon.ui.layout.AppearanceSettingsScreen
|
||||
import ru.risdeveau.pixeldragon.ui.layout.DevicesSettingsScreen
|
||||
import ru.risdeveau.pixeldragon.ui.layout.Room
|
||||
import ru.risdeveau.pixeldragon.ui.layout.RoomList
|
||||
import ru.risdeveau.pixeldragon.ui.layout.SettingsMainScreen
|
||||
import ru.risdeveau.pixeldragon.ui.layout.SettingsRoutes
|
||||
import ru.risdeveau.pixeldragon.ui.layout.settingsTitleForRoute
|
||||
import ru.risdeveau.pixeldragon.ui.theme.PixelDragonTheme
|
||||
import ru.risdeveau.pixeldragon.util.getMediaStore
|
||||
import ru.risdeveau.pixeldragon.util.getRoomStore
|
||||
@@ -130,6 +137,32 @@ class MainActivity : ComponentActivity() {
|
||||
text = "Not implemented"
|
||||
)
|
||||
}
|
||||
|
||||
navigation(
|
||||
route = SettingsRoutes.Graph,
|
||||
startDestination = SettingsRoutes.Main,
|
||||
) {
|
||||
composable(SettingsRoutes.Main) {
|
||||
SettingsMainScreen(
|
||||
modifier = Modifier.padding(innerPadding),
|
||||
onCategoryClick = { category ->
|
||||
navController.navigate(category.route)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
composable(SettingsRoutes.Account) {
|
||||
AccountSettingsScreen(Modifier.padding(innerPadding))
|
||||
}
|
||||
|
||||
composable(SettingsRoutes.Devices) {
|
||||
DevicesSettingsScreen(Modifier.padding(innerPadding))
|
||||
}
|
||||
|
||||
composable(SettingsRoutes.Appearance) {
|
||||
AppearanceSettingsScreen(Modifier.padding(innerPadding))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -176,6 +209,7 @@ private fun PixelDragonTopBar(
|
||||
val route = backStackEntry?.destination?.route
|
||||
val rid = backStackEntry?.arguments?.getString("rid")
|
||||
val isRoomLikeScreen = route == "room/{rid}" || route == "space/{rid}"
|
||||
val isSettingsScreen = route == SettingsRoutes.Graph || route?.startsWith("settings/") == true
|
||||
|
||||
val roomsFlow = remember(client) {
|
||||
client!!.room.getAll().flattenValues().map { it.toList() }
|
||||
@@ -190,20 +224,42 @@ private fun PixelDragonTopBar(
|
||||
}
|
||||
}
|
||||
|
||||
if (isRoomLikeScreen) {
|
||||
when {
|
||||
isRoomLikeScreen -> {
|
||||
RoomTopBar(
|
||||
room = currentRoom,
|
||||
fallbackTitle = rid ?: stringResource(R.string.app_name),
|
||||
onBack = { navController.popBackStack() },
|
||||
)
|
||||
} else {
|
||||
HomeTopBar(syncState = syncState)
|
||||
}
|
||||
|
||||
isSettingsScreen -> {
|
||||
RoomTopBar(
|
||||
room = null,
|
||||
fallbackTitle = settingsTitleForRoute(route),
|
||||
onBack = { navController.popBackStack() },
|
||||
)
|
||||
}
|
||||
|
||||
else -> {
|
||||
HomeTopBar(
|
||||
syncState = syncState,
|
||||
onAvatarClick = {
|
||||
navController.navigate(SettingsRoutes.Graph) {
|
||||
launchSingleTop = true
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
private fun HomeTopBar(syncState: SyncState) {
|
||||
private fun HomeTopBar(
|
||||
syncState: SyncState,
|
||||
onAvatarClick: () -> Unit,
|
||||
) {
|
||||
CenterAlignedTopAppBar(
|
||||
colors = topAppBarColors(
|
||||
containerColor = MaterialTheme.colorScheme.primaryContainer,
|
||||
@@ -227,13 +283,17 @@ private fun HomeTopBar(syncState: SyncState) {
|
||||
userAvatar = profile?.avatarUrl
|
||||
}
|
||||
|
||||
IconButton(onClick = onAvatarClick) {
|
||||
Avatar(
|
||||
Modifier.size(32.dp).clip(CircleShape),
|
||||
Modifier
|
||||
.size(32.dp)
|
||||
.clip(CircleShape),
|
||||
userAvatar,
|
||||
userName,
|
||||
MaterialTheme.colorScheme.background
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user