Merge pull request #649 from strongville/feat/editWidgetsSBM
Add menu entry "Edit widgets" if button on the widgets list is not shown
This commit is contained in:
commit
36b83ad07b
@ -9,6 +9,7 @@ import androidx.compose.animation.graphics.res.rememberAnimatedVectorPainter
|
|||||||
import androidx.compose.animation.graphics.vector.AnimatedImageVector
|
import androidx.compose.animation.graphics.vector.AnimatedImageVector
|
||||||
import androidx.compose.foundation.layout.RowScope
|
import androidx.compose.foundation.layout.RowScope
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.rounded.Edit
|
||||||
import androidx.compose.material.icons.rounded.HelpOutline
|
import androidx.compose.material.icons.rounded.HelpOutline
|
||||||
import androidx.compose.material.icons.rounded.Settings
|
import androidx.compose.material.icons.rounded.Settings
|
||||||
import androidx.compose.material.icons.rounded.Wallpaper
|
import androidx.compose.material.icons.rounded.Wallpaper
|
||||||
@ -20,6 +21,7 @@ import androidx.compose.material3.LocalContentColor
|
|||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
@ -27,7 +29,10 @@ import androidx.compose.runtime.setValue
|
|||||||
import androidx.compose.ui.graphics.toArgb
|
import androidx.compose.ui.graphics.toArgb
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import de.mm20.launcher2.ui.R
|
import de.mm20.launcher2.ui.R
|
||||||
|
import de.mm20.launcher2.ui.launcher.LauncherScaffoldVM
|
||||||
|
import de.mm20.launcher2.ui.launcher.widgets.WidgetsVM
|
||||||
import de.mm20.launcher2.ui.settings.SettingsActivity
|
import de.mm20.launcher2.ui.settings.SettingsActivity
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@ -38,6 +43,8 @@ fun RowScope.SearchBarMenu(
|
|||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
var showOverflowMenu by remember { mutableStateOf(false) }
|
var showOverflowMenu by remember { mutableStateOf(false) }
|
||||||
val rightIcon = AnimatedImageVector.animatedVectorResource(R.drawable.anim_ic_menu_clear)
|
val rightIcon = AnimatedImageVector.animatedVectorResource(R.drawable.anim_ic_menu_clear)
|
||||||
|
val launcherVM: LauncherScaffoldVM = viewModel()
|
||||||
|
val widgetsVM: WidgetsVM = viewModel()
|
||||||
|
|
||||||
IconButton(onClick = {
|
IconButton(onClick = {
|
||||||
if (searchBarValue.isNotBlank()) onSearchBarValueChange("")
|
if (searchBarValue.isNotBlank()) onSearchBarValueChange("")
|
||||||
@ -70,6 +77,22 @@ fun RowScope.SearchBarMenu(
|
|||||||
Icon(imageVector = Icons.Rounded.Wallpaper, contentDescription = null)
|
Icon(imageVector = Icons.Rounded.Wallpaper, contentDescription = null)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
val editButton by widgetsVM.editButton.collectAsState()
|
||||||
|
val searchOpen by launcherVM.isSearchOpen
|
||||||
|
if (!searchOpen && editButton == false) {
|
||||||
|
DropdownMenuItem(
|
||||||
|
onClick = {
|
||||||
|
launcherVM.setWidgetEditMode(editMode = true)
|
||||||
|
showOverflowMenu = false
|
||||||
|
},
|
||||||
|
text = {
|
||||||
|
Text(stringResource(R.string.menu_edit_widgets))
|
||||||
|
},
|
||||||
|
leadingIcon = {
|
||||||
|
Icon(imageVector = Icons.Rounded.Edit, contentDescription = null)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
DropdownMenuItem(
|
DropdownMenuItem(
|
||||||
onClick = {
|
onClick = {
|
||||||
context.startActivity(Intent(context, SettingsActivity::class.java))
|
context.startActivity(Intent(context, SettingsActivity::class.java))
|
||||||
|
|||||||
@ -149,7 +149,7 @@ fun WidgetColumn(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val editButton by viewModel.editButton.collectAsState()
|
val editButton by viewModel.editButton.collectAsState()
|
||||||
if (editButton == true) {
|
if (editMode || editButton == true) {
|
||||||
val icon =
|
val icon =
|
||||||
AnimatedImageVector.animatedVectorResource(R.drawable.anim_ic_edit_add)
|
AnimatedImageVector.animatedVectorResource(R.drawable.anim_ic_edit_add)
|
||||||
ExtendedFloatingActionButton(
|
ExtendedFloatingActionButton(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user