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:
Emma Vandewalle 2024-09-06 09:59:04 +00:00
commit 2cf09d7a93
3 changed files with 20 additions and 42 deletions

View file

@ -29,6 +29,8 @@ import androidx.hilt.navigation.compose.hiltViewModel
import be.re.writand.screens.WUIGlobals
import be.re.writand.screens.components.WLoadingIndicator
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 java.nio.file.Path
@ -86,16 +88,8 @@ fun BottomScaffoldBar() {
)
.padding(horizontal = 10.dp)
) {
Icon(
imageVector = Icons.Default.Settings,
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 */ }
)
SettingsPopup()
InfoPopup()
}
}

View file

@ -20,6 +20,7 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.filled.Info
import androidx.compose.material3.Button
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
@ -54,28 +55,19 @@ fun InfoPopup(
vM: InfoPopupViewModel = hiltViewModel()
) {
val openDialog = remember { mutableStateOf(false) }
val buttonTitle = remember {
mutableStateOf("Show Info")
}
Button(
modifier = Modifier
.fillMaxWidth()
.padding(10.dp),
onClick = {
openDialog.value = !openDialog.value
if (!openDialog.value) {
buttonTitle.value = "Show Info"
}
}
) {
Text(text = buttonTitle.value, modifier = Modifier.padding(3.dp))
IconButton(onClick = { openDialog.value = !openDialog.value }) {
Icon(
imageVector = Icons.Default.Info,
contentDescription = "More information",
modifier = Modifier.size(WUIGlobals.iconSize)
)
}
if (openDialog.value) {
val uiState by vM.uiState.collectAsState()
buttonTitle.value = "Hide Info"
Dialog(
onDismissRequest = { openDialog.value = false },
properties = DialogProperties(usePlatformDefaultWidth = false)

View file

@ -2,6 +2,7 @@ package be.re.writand.screens.settings
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
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.KeyboardArrowRight
import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.filled.Settings
import androidx.compose.material3.Button
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
@ -63,9 +65,6 @@ fun SettingsPopup(
vM: EditorSettingsViewModel = hiltViewModel()
) {
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
// settings were temporarily closed
@ -74,22 +73,15 @@ fun SettingsPopup(
mutableStateOf(items[0])
}
Button(
modifier = Modifier
.fillMaxWidth()
.padding(10.dp),
onClick = {
openDialog.value = !openDialog.value
if (!openDialog.value) {
buttonTitle.value = "Show Pop Up"
}
}
) {
Text(text = buttonTitle.value, modifier = Modifier.padding(3.dp))
IconButton(onClick = { openDialog.value = !openDialog.value }) {
Icon(
imageVector = Icons.Default.Settings,
contentDescription = "Open settings",
modifier = Modifier.size(WUIGlobals.iconSize)
)
}
if (openDialog.value) {
buttonTitle.value = "Hide Pop Up"
WPopup(
width = 800.dp,
height = 600.dp,