Skip to content
Snippets Groups Projects
Commit ea51b413 authored by paul's avatar paul Committed by Sebastian
Browse files

changed uiMode to enum

parent f6d1c258
Branches
Tags
1 merge request!15Resolve "Use enum instead of string for `uiMode`"
...@@ -33,7 +33,7 @@ import org.briarproject.briar.desktop.paul.theme.briarBlack ...@@ -33,7 +33,7 @@ import org.briarproject.briar.desktop.paul.theme.briarBlack
import org.briarproject.briar.desktop.paul.theme.briarBlue import org.briarproject.briar.desktop.paul.theme.briarBlue
@Composable @Composable
fun BriarSidebar(uiMode: String, setUiMode: (String) -> Unit) { fun BriarSidebar(uiMode: uiModes, setUiMode: (uiModes) -> Unit) {
Surface(modifier = Modifier.width(56.dp).fillMaxHeight(), color = briarBlue) { Surface(modifier = Modifier.width(56.dp).fillMaxHeight(), color = briarBlue) {
Column(verticalArrangement = Arrangement.Top) { Column(verticalArrangement = Arrangement.Top) {
IconButton( IconButton(
...@@ -51,25 +51,25 @@ fun BriarSidebar(uiMode: String, setUiMode: (String) -> Unit) { ...@@ -51,25 +51,25 @@ fun BriarSidebar(uiMode: String, setUiMode: (String) -> Unit) {
BriarSidebarButton( BriarSidebarButton(
uiMode = uiMode, uiMode = uiMode,
setUiMode = setUiMode, setUiMode = setUiMode,
"Contacts", uiModes.Contacts,
Icons.Filled.Contacts Icons.Filled.Contacts
) )
BriarSidebarButton( BriarSidebarButton(
uiMode = uiMode, uiMode = uiMode,
setUiMode = setUiMode, setUiMode = setUiMode,
"Private Groups", uiModes.Groups,
Icons.Filled.Group Icons.Filled.Group
) )
BriarSidebarButton( BriarSidebarButton(
uiMode = uiMode, uiMode = uiMode,
setUiMode = setUiMode, setUiMode = setUiMode,
"Forums", uiModes.Forums,
Icons.Filled.Forum Icons.Filled.Forum
) )
BriarSidebarButton( BriarSidebarButton(
uiMode = uiMode, uiMode = uiMode,
setUiMode = setUiMode, setUiMode = setUiMode,
"Blogs", uiModes.Blogs,
Icons.Filled.ChromeReaderMode Icons.Filled.ChromeReaderMode
) )
} }
...@@ -77,19 +77,19 @@ fun BriarSidebar(uiMode: String, setUiMode: (String) -> Unit) { ...@@ -77,19 +77,19 @@ fun BriarSidebar(uiMode: String, setUiMode: (String) -> Unit) {
BriarSidebarButton( BriarSidebarButton(
uiMode = uiMode, uiMode = uiMode,
setUiMode = setUiMode, setUiMode = setUiMode,
"Transports", uiModes.Transports,
Icons.Filled.WifiTethering Icons.Filled.WifiTethering
) )
BriarSidebarButton( BriarSidebarButton(
uiMode = uiMode, uiMode = uiMode,
setUiMode = setUiMode, setUiMode = setUiMode,
"Settings", uiModes.Settings,
Icons.Filled.Settings Icons.Filled.Settings
) )
BriarSidebarButton( BriarSidebarButton(
uiMode = uiMode, uiMode = uiMode,
setUiMode = setUiMode, setUiMode = setUiMode,
"Sign Out", uiModes.SignOut,
Icons.Filled.Logout Icons.Filled.Logout
) )
} }
...@@ -97,7 +97,7 @@ fun BriarSidebar(uiMode: String, setUiMode: (String) -> Unit) { ...@@ -97,7 +97,7 @@ fun BriarSidebar(uiMode: String, setUiMode: (String) -> Unit) {
} }
@Composable @Composable
fun BriarSidebarButton(uiMode: String, setUiMode: (String) -> Unit, thisMode: String, icon: ImageVector) { fun BriarSidebarButton(uiMode: uiModes, setUiMode: (uiModes) -> Unit, thisMode: uiModes, icon: ImageVector) {
val bg = if (uiMode == thisMode) briarBlack else briarBlue val bg = if (uiMode == thisMode) briarBlack else briarBlue
Column { Column {
IconButton( IconButton(
...@@ -105,7 +105,7 @@ fun BriarSidebarButton(uiMode: String, setUiMode: (String) -> Unit, thisMode: St ...@@ -105,7 +105,7 @@ fun BriarSidebarButton(uiMode: String, setUiMode: (String) -> Unit, thisMode: St
.padding(vertical = 4.dp, horizontal = 12.dp), .padding(vertical = 4.dp, horizontal = 12.dp),
onClick = { setUiMode(thisMode) } onClick = { setUiMode(thisMode) }
) { ) {
Icon(icon, thisMode, tint = Color.White, modifier = Modifier.size(30.dp)) Icon(icon, thisMode.toString(), tint = Color.White, modifier = Modifier.size(30.dp))
} }
} }
} }
...@@ -19,6 +19,16 @@ import org.briarproject.bramble.api.contact.Contact ...@@ -19,6 +19,16 @@ import org.briarproject.bramble.api.contact.Contact
import org.briarproject.briar.desktop.paul.theme.briarBlack import org.briarproject.briar.desktop.paul.theme.briarBlack
import org.briarproject.briar.desktop.paul.theme.divider import org.briarproject.briar.desktop.paul.theme.divider
enum class uiModes {
Contacts,
Groups,
Forums,
Blogs,
Transports,
Settings,
SignOut
}
/* /*
* This is the root of the tree, all state is held here and passed down to stateless composables, which render the UI * This is the root of the tree, all state is held here and passed down to stateless composables, which render the UI
* Desktop specific kotlin files are found in briarComposeDesktop (possibly briar-compose-desktop project in the future) * Desktop specific kotlin files are found in briarComposeDesktop (possibly briar-compose-desktop project in the future)
...@@ -29,10 +39,12 @@ fun BriarUIStateManager( ...@@ -29,10 +39,12 @@ fun BriarUIStateManager(
contacts: List<Contact> contacts: List<Contact>
) { ) {
// current selected mode, changed using the sidebar buttons // current selected mode, changed using the sidebar buttons
val (uiMode, setUiMode) = remember { mutableStateOf("Contacts") } val (uiMode, setUiMode) = remember { mutableStateOf(uiModes.Contacts) }
// TODO Figure out how to handle accounts with 0 contacts // TODO Figure out how to handle accounts with 0 contacts
// current selected contact // current selected contact
val (contact, setContact) = remember { mutableStateOf(contact(contacts)) } val (contact, setContact) = remember { mutableStateOf(contact(contacts)) }
// current selected private group
val (group, setGroup) = remember { mutableStateOf(contact(contacts)) }
// current selected forum // current selected forum
val (forum, setForum) = remember { mutableStateOf(0) } val (forum, setForum) = remember { mutableStateOf(0) }
// current blog state // current blog state
...@@ -46,7 +58,7 @@ fun BriarUIStateManager( ...@@ -46,7 +58,7 @@ fun BriarUIStateManager(
BriarSidebar(uiMode, setUiMode) BriarSidebar(uiMode, setUiMode)
Divider(color = divider, modifier = Modifier.fillMaxHeight().width(1.dp)) Divider(color = divider, modifier = Modifier.fillMaxHeight().width(1.dp))
when (uiMode) { when (uiMode) {
"Contacts" -> if (contact != null) PrivateMessageView( uiModes.Contacts -> if (contact != null) PrivateMessageView(
contact, contact,
contacts, contacts,
setContact setContact
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment