forked from Writand/writand
Merge branch 'frontend/link-settings-info' into 'main'
feat: buttons for popups linked Closes #40 See merge request EmmaVandewalle/writand!47
This commit is contained in:
commit
2cf09d7a93
3 changed files with 20 additions and 42 deletions
|
@ -29,6 +29,8 @@ import androidx.hilt.navigation.compose.hiltViewModel
|
||||||
import be.re.writand.screens.WUIGlobals
|
import be.re.writand.screens.WUIGlobals
|
||||||
import be.re.writand.screens.components.WLoadingIndicator
|
import be.re.writand.screens.components.WLoadingIndicator
|
||||||
import be.re.writand.screens.components.WText
|
import be.re.writand.screens.components.WText
|
||||||
|
import be.re.writand.screens.info.InfoPopup
|
||||||
|
import be.re.writand.screens.settings.SettingsPopup
|
||||||
import be.re.writand.ui.theme.MainGreen
|
import be.re.writand.ui.theme.MainGreen
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
|
|
||||||
|
@ -86,16 +88,8 @@ fun BottomScaffoldBar() {
|
||||||
)
|
)
|
||||||
.padding(horizontal = 10.dp)
|
.padding(horizontal = 10.dp)
|
||||||
) {
|
) {
|
||||||
Icon(
|
SettingsPopup()
|
||||||
imageVector = Icons.Default.Settings,
|
InfoPopup()
|
||||||
contentDescription = "Open settings",
|
|
||||||
modifier = Modifier.size(WUIGlobals.iconSize).clickable { /* TODO: link settings popup */ }
|
|
||||||
)
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Default.Info,
|
|
||||||
contentDescription = "More information",
|
|
||||||
modifier = Modifier.size(WUIGlobals.iconSize).clickable { /* TODO: link about popup */ }
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.Close
|
import androidx.compose.material.icons.filled.Close
|
||||||
|
import androidx.compose.material.icons.filled.Info
|
||||||
import androidx.compose.material3.Button
|
import androidx.compose.material3.Button
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
|
@ -54,28 +55,19 @@ fun InfoPopup(
|
||||||
vM: InfoPopupViewModel = hiltViewModel()
|
vM: InfoPopupViewModel = hiltViewModel()
|
||||||
) {
|
) {
|
||||||
val openDialog = remember { mutableStateOf(false) }
|
val openDialog = remember { mutableStateOf(false) }
|
||||||
val buttonTitle = remember {
|
|
||||||
mutableStateOf("Show Info")
|
|
||||||
}
|
|
||||||
|
|
||||||
Button(
|
|
||||||
modifier = Modifier
|
IconButton(onClick = { openDialog.value = !openDialog.value }) {
|
||||||
.fillMaxWidth()
|
Icon(
|
||||||
.padding(10.dp),
|
imageVector = Icons.Default.Info,
|
||||||
onClick = {
|
contentDescription = "More information",
|
||||||
openDialog.value = !openDialog.value
|
modifier = Modifier.size(WUIGlobals.iconSize)
|
||||||
if (!openDialog.value) {
|
)
|
||||||
buttonTitle.value = "Show Info"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
Text(text = buttonTitle.value, modifier = Modifier.padding(3.dp))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (openDialog.value) {
|
if (openDialog.value) {
|
||||||
val uiState by vM.uiState.collectAsState()
|
val uiState by vM.uiState.collectAsState()
|
||||||
|
|
||||||
buttonTitle.value = "Hide Info"
|
|
||||||
Dialog(
|
Dialog(
|
||||||
onDismissRequest = { openDialog.value = false },
|
onDismissRequest = { openDialog.value = false },
|
||||||
properties = DialogProperties(usePlatformDefaultWidth = false)
|
properties = DialogProperties(usePlatformDefaultWidth = false)
|
||||||
|
|
|
@ -2,6 +2,7 @@ package be.re.writand.screens.settings
|
||||||
|
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.border
|
import androidx.compose.foundation.border
|
||||||
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
|
@ -21,6 +22,7 @@ import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.automirrored.filled.KeyboardArrowLeft
|
import androidx.compose.material.icons.automirrored.filled.KeyboardArrowLeft
|
||||||
import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight
|
import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight
|
||||||
import androidx.compose.material.icons.filled.Close
|
import androidx.compose.material.icons.filled.Close
|
||||||
|
import androidx.compose.material.icons.filled.Settings
|
||||||
import androidx.compose.material3.Button
|
import androidx.compose.material3.Button
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
|
@ -63,9 +65,6 @@ fun SettingsPopup(
|
||||||
vM: EditorSettingsViewModel = hiltViewModel()
|
vM: EditorSettingsViewModel = hiltViewModel()
|
||||||
) {
|
) {
|
||||||
val openDialog = remember { mutableStateOf(false) }
|
val openDialog = remember { mutableStateOf(false) }
|
||||||
val buttonTitle = remember {
|
|
||||||
mutableStateOf("Show Pop Up")
|
|
||||||
}
|
|
||||||
|
|
||||||
// keep these variables for settings at the top level, so it remembers the state even though
|
// keep these variables for settings at the top level, so it remembers the state even though
|
||||||
// settings were temporarily closed
|
// settings were temporarily closed
|
||||||
|
@ -74,22 +73,15 @@ fun SettingsPopup(
|
||||||
mutableStateOf(items[0])
|
mutableStateOf(items[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
Button(
|
IconButton(onClick = { openDialog.value = !openDialog.value }) {
|
||||||
modifier = Modifier
|
Icon(
|
||||||
.fillMaxWidth()
|
imageVector = Icons.Default.Settings,
|
||||||
.padding(10.dp),
|
contentDescription = "Open settings",
|
||||||
onClick = {
|
modifier = Modifier.size(WUIGlobals.iconSize)
|
||||||
openDialog.value = !openDialog.value
|
)
|
||||||
if (!openDialog.value) {
|
|
||||||
buttonTitle.value = "Show Pop Up"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
Text(text = buttonTitle.value, modifier = Modifier.padding(3.dp))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (openDialog.value) {
|
if (openDialog.value) {
|
||||||
buttonTitle.value = "Hide Pop Up"
|
|
||||||
WPopup(
|
WPopup(
|
||||||
width = 800.dp,
|
width = 800.dp,
|
||||||
height = 600.dp,
|
height = 600.dp,
|
||||||
|
|
Loading…
Reference in a new issue