diff --git a/app/src/main/java/com/readrops/app/feeds/FolderExpandableItem.kt b/app/src/main/java/com/readrops/app/feeds/FolderExpandableItem.kt index b5202e3e..7356e374 100644 --- a/app/src/main/java/com/readrops/app/feeds/FolderExpandableItem.kt +++ b/app/src/main/java/com/readrops/app/feeds/FolderExpandableItem.kt @@ -5,17 +5,11 @@ import androidx.compose.animation.core.LinearOutSlowInEasing import androidx.compose.animation.core.tween import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.MoreVert -import androidx.compose.material3.DropdownMenu -import androidx.compose.material3.DropdownMenuItem import androidx.compose.material3.Icon -import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable @@ -30,6 +24,7 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextOverflow import com.readrops.app.R +import com.readrops.app.util.components.ThreeDotsMenu import com.readrops.app.util.theme.MediumSpacer import com.readrops.app.util.theme.spacing import com.readrops.db.entities.Feed @@ -46,7 +41,6 @@ fun FolderExpandableItem( onDeleteFolder: () -> Unit ) { var isFolderExpanded by remember { mutableStateOf(false) } - var isDropDownMenuExpanded by remember { mutableStateOf(false) } LaunchedEffect(isExpanded) { isFolderExpanded = isExpanded @@ -94,37 +88,18 @@ fun FolderExpandableItem( ) } - Box { - IconButton( - onClick = { isDropDownMenuExpanded = isDropDownMenuExpanded.not() } - ) { - Icon( - imageVector = Icons.Default.MoreVert, - contentDescription = null, - ) + ThreeDotsMenu( + items = mapOf( + 1 to stringResource(id = R.string.update), + 2 to stringResource(id = R.string.delete) + ), + onItemClick = { index -> + when (index) { + 1 -> onUpdateFolder() + else -> onDeleteFolder() + } } - - DropdownMenu( - expanded = isDropDownMenuExpanded, - onDismissRequest = { isDropDownMenuExpanded = false }, - ) { - DropdownMenuItem( - text = { Text(text = "Update") }, - onClick = { - isDropDownMenuExpanded = false - onUpdateFolder() - } - ) - - DropdownMenuItem( - text = { Text(text = stringResource(R.string.delete)) }, - onClick = { - isDropDownMenuExpanded = false - onDeleteFolder() - } - ) - } - } + ) } } diff --git a/app/src/main/java/com/readrops/app/notifications/NotificationsScreen.kt b/app/src/main/java/com/readrops/app/notifications/NotificationsScreen.kt index df8b8f26..03b8f0e3 100644 --- a/app/src/main/java/com/readrops/app/notifications/NotificationsScreen.kt +++ b/app/src/main/java/com/readrops/app/notifications/NotificationsScreen.kt @@ -1,7 +1,6 @@ package com.readrops.app.notifications import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding @@ -9,9 +8,6 @@ import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.ArrowBack -import androidx.compose.material.icons.filled.MoreVert -import androidx.compose.material3.DropdownMenu -import androidx.compose.material3.DropdownMenuItem import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon import androidx.compose.material3.IconButton @@ -37,6 +33,7 @@ import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow import com.readrops.app.R import com.readrops.app.util.components.AndroidScreen +import com.readrops.app.util.components.ThreeDotsMenu import com.readrops.app.util.theme.MediumSpacer import com.readrops.app.util.theme.spacing import com.readrops.db.entities.account.Account @@ -72,37 +69,18 @@ class NotificationsScreen(val account: Account) : AndroidScreen() { } }, actions = { - Box { - IconButton( - onClick = { isDropDownMenuExpanded = isDropDownMenuExpanded.not() } - ) { - Icon( - imageVector = Icons.Default.MoreVert, - contentDescription = null, - ) + ThreeDotsMenu( + items = mapOf( + 1 to if (state.allFeedNotificationsEnabled) { + stringResource(id = R.string.disable_all) + } else { + stringResource(id = R.string.enable_all) + } + ), + onItemClick = { + screenModel.setAllFeedsNotificationsState(!state.allFeedNotificationsEnabled) } - - DropdownMenu( - expanded = isDropDownMenuExpanded, - onDismissRequest = { isDropDownMenuExpanded = false }, - ) { - DropdownMenuItem( - text = { - Text( - text = if (state.allFeedNotificationsEnabled) { - stringResource(id = R.string.disable_all) - } else { - stringResource(id = R.string.enable_all) - } - ) - }, - onClick = { - isDropDownMenuExpanded = false - screenModel.setAllFeedsNotificationsState(enabled = !state.allFeedNotificationsEnabled) - } - ) - } - } + ) }, scrollBehavior = topAppBarScrollBehavior ) @@ -121,7 +99,6 @@ class NotificationsScreen(val account: Account) : AndroidScreen() { modifier = Modifier .fillMaxWidth() .padding(horizontal = MaterialTheme.spacing.mediumSpacing) - ) { Text( text = stringResource(id = R.string.enable_notifications) diff --git a/app/src/main/java/com/readrops/app/util/components/ThreeDotsMenu.kt b/app/src/main/java/com/readrops/app/util/components/ThreeDotsMenu.kt new file mode 100644 index 00000000..3cc7563f --- /dev/null +++ b/app/src/main/java/com/readrops/app/util/components/ThreeDotsMenu.kt @@ -0,0 +1,57 @@ +package com.readrops.app.util.components + +import androidx.compose.foundation.layout.Box +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.MoreVert +import androidx.compose.material3.DropdownMenu +import androidx.compose.material3.DropdownMenuItem +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Modifier + +@Composable +fun ThreeDotsMenu( + items: Map, + onItemClick: (Int) -> Unit, + modifier: Modifier = Modifier +) { + var isExpanded by remember { mutableStateOf(false) } + + Box( + modifier = modifier + ) { + IconButton( + onClick = { isExpanded = !isExpanded } + ) { + Icon( + imageVector = Icons.Default.MoreVert, + contentDescription = null, + ) + } + + DropdownMenu( + expanded = isExpanded, + onDismissRequest = { isExpanded = !isExpanded }, + ) { + for ((index, value) in items) { + DropdownMenuItem( + text = { + Text( + text = value + ) + }, + onClick = { + isExpanded = false + onItemClick(index) + } + ) + } + } + } +} \ No newline at end of file diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 3dd11884..53fe0487 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -171,4 +171,5 @@ Bibliothèques Open source Faire une donation Autres comptes + Mettre à jour \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 12a71a3c..50e29420 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -180,4 +180,5 @@ https://github.com/readrops/Readrops/blob/develop/CHANGELOG.md https://github.com/readrops/Readrops/issues Other accounts + Update \ No newline at end of file