From 91fbf5645a8523a7e39f0a8bb6e23b748a7b9439 Mon Sep 17 00:00:00 2001 From: EmmaVandewalle Date: Fri, 6 Sep 2024 11:45:50 +0200 Subject: [PATCH] feat: buttons for popups linked --- .../re/writand/screens/filetree/Filetree.kt | 14 ++++------- .../be/re/writand/screens/info/InfoPopup.kt | 24 +++++++------------ .../writand/screens/settings/SettingsPopup.kt | 24 +++++++------------ 3 files changed, 20 insertions(+), 42 deletions(-) diff --git a/app/src/main/java/be/re/writand/screens/filetree/Filetree.kt b/app/src/main/java/be/re/writand/screens/filetree/Filetree.kt index 2b395ae..9228589 100644 --- a/app/src/main/java/be/re/writand/screens/filetree/Filetree.kt +++ b/app/src/main/java/be/re/writand/screens/filetree/Filetree.kt @@ -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() } } diff --git a/app/src/main/java/be/re/writand/screens/info/InfoPopup.kt b/app/src/main/java/be/re/writand/screens/info/InfoPopup.kt index 2022c84..6efc6f9 100644 --- a/app/src/main/java/be/re/writand/screens/info/InfoPopup.kt +++ b/app/src/main/java/be/re/writand/screens/info/InfoPopup.kt @@ -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) diff --git a/app/src/main/java/be/re/writand/screens/settings/SettingsPopup.kt b/app/src/main/java/be/re/writand/screens/settings/SettingsPopup.kt index 1b73c1e..ff5ef7c 100644 --- a/app/src/main/java/be/re/writand/screens/settings/SettingsPopup.kt +++ b/app/src/main/java/be/re/writand/screens/settings/SettingsPopup.kt @@ -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,