diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/AboutActivity.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/AboutActivity.kt index d9727b228..efceac3e4 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/AboutActivity.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/AboutActivity.kt @@ -136,18 +136,17 @@ class AboutActivity : ComponentActivity() { DialogMember { ConfirmationAdvancedAlertDialog( alertDialogState = this, - callback = { success -> - if (success) { - launchFAQActivity() - } else { - launchEmailIntent() - } - }, message = "${getString(R.string.before_asking_question_read_faq)}\n\n${getString(R.string.make_sure_latest)}", messageId = null, positive = R.string.read_faq, negative = R.string.skip - ) + ) { success -> + if (success) { + launchFAQActivity() + } else { + launchEmailIntent() + } + } } } @@ -157,18 +156,17 @@ class AboutActivity : ComponentActivity() { DialogMember { ConfirmationAdvancedAlertDialog( alertDialogState = this, - callback = { success -> - if (success) { - launchFAQActivity() - } else { - launchRateUsPrompt(showRateStarsDialog) - } - }, message = "${getString(R.string.before_asking_question_read_faq)}\n\n${getString(R.string.make_sure_latest)}", messageId = null, positive = R.string.read_faq, negative = R.string.skip - ) + ) { success -> + if (success) { + launchFAQActivity() + } else { + launchRateUsPrompt(showRateStarsDialog) + } + } } } diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/ManageBlockedNumbersActivity.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/ManageBlockedNumbersActivity.kt index adb278592..2e5b2d956 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/ManageBlockedNumbersActivity.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/ManageBlockedNumbersActivity.kt @@ -80,18 +80,17 @@ class ManageBlockedNumbersActivity : BaseSimpleActivity() { addBlockedNumberDialogState.DialogMember { AddOrEditBlockedNumberAlertDialog( - blockedNumber = clickedBlockedNumber, alertDialogState = addBlockedNumberDialogState, + blockedNumber = clickedBlockedNumber, deleteBlockedNumber = { blockedNumber -> deleteBlockedNumber(blockedNumber) updateBlockedNumbers() - }, - addBlockedNumber = { blockedNumber -> - addBlockedNumber(blockedNumber) - clickedBlockedNumber = null - updateBlockedNumbers() } - ) + ) { blockedNumber -> + addBlockedNumber(blockedNumber) + clickedBlockedNumber = null + updateBlockedNumbers() + } } ManageBlockedNumbersScreen( diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/compose/bottom_sheet/BottomSheetDialogState.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/compose/bottom_sheet/BottomSheetDialogState.kt index ba5d48b31..04344beaf 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/compose/bottom_sheet/BottomSheetDialogState.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/compose/bottom_sheet/BottomSheetDialogState.kt @@ -2,12 +2,15 @@ package com.simplemobiletools.commons.compose.bottom_sheet import androidx.compose.foundation.layout.WindowInsets import androidx.compose.material3.BottomSheetDefaults -import androidx.compose.material3.SheetState +import androidx.compose.material3.ModalBottomSheet import androidx.compose.material3.SheetValue import androidx.compose.material3.rememberModalBottomSheetState import androidx.compose.runtime.* import androidx.compose.runtime.saveable.mapSaver import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.ui.Modifier +import com.simplemobiletools.commons.compose.alert_dialog.dialogContainerColor +import com.simplemobiletools.commons.compose.alert_dialog.dialogElevation @Composable fun rememberBottomSheetDialogState( @@ -82,25 +85,34 @@ class BottomSheetDialogState( } @Composable - fun DialogMember( - content: @Composable ( - state: SheetState, - insets: WindowInsets - ) -> Unit + fun BottomSheetContent( + modifier: Modifier = Modifier, + content: @Composable () -> Unit ) { val bottomSheetState = rememberSheetState() val windowInsets = rememberWindowInsets() LaunchedEffect(isOpen) { - if (isOpen) { + if (isOpen && !bottomSheetState.isVisible) { bottomSheetState.show() } else { bottomSheetState.hide() } } - if (bottomSheetState.isVisible) { - content(bottomSheetState, windowInsets) + if (isOpen) { + ModalBottomSheet( + modifier = modifier, + onDismissRequest = ::close, + sheetState = bottomSheetState, + windowInsets = windowInsets, + dragHandle = {}, //leave empty as we provide our own dialog surfaces + shape = bottomSheetDialogShape, + containerColor = dialogContainerColor, + tonalElevation = dialogElevation, + ) { + content() + } } } } diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/compose/extensions/ComposeActivityExtensions.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/compose/extensions/ComposeActivityExtensions.kt index c2c4e0282..c58a31912 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/compose/extensions/ComposeActivityExtensions.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/compose/extensions/ComposeActivityExtensions.kt @@ -15,9 +15,9 @@ fun FakeVersionCheck() { DialogMember { ConfirmationAlertDialog( alertDialogState = this, + message = FAKE_VERSION_APP_LABEL, positive = R.string.ok, - negative = null, - message = FAKE_VERSION_APP_LABEL + negative = null ) { context.getActivity().launchViewIntent(DEVELOPER_PLAY_STORE_URL) } @@ -35,9 +35,9 @@ fun CheckAppOnSdCard() { DialogMember { ConfirmationAlertDialog( alertDialogState = this, + messageId = R.string.app_on_sd_card, positive = R.string.ok, - negative = null, - messageId = R.string.app_on_sd_card + negative = null ) {} } } diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/AddBlockedNumberDialog.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/AddBlockedNumberDialog.kt index 89ecf991d..599a3624e 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/AddBlockedNumberDialog.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/AddBlockedNumberDialog.kt @@ -22,9 +22,9 @@ import com.simplemobiletools.commons.models.BlockedNumber @Composable fun AddOrEditBlockedNumberAlertDialog( - modifier: Modifier = Modifier, - blockedNumber: BlockedNumber?, alertDialogState: AlertDialogState, + blockedNumber: BlockedNumber?, + modifier: Modifier = Modifier, deleteBlockedNumber: (String) -> Unit, addBlockedNumber: (String) -> Unit ) { @@ -100,10 +100,9 @@ fun AddOrEditBlockedNumberAlertDialog( private fun AddOrEditBlockedNumberAlertDialogPreview() { AppThemeSurface { AddOrEditBlockedNumberAlertDialog( + alertDialogState = rememberAlertDialogState(), blockedNumber = null, - deleteBlockedNumber = {}, - addBlockedNumber = {}, - alertDialogState = rememberAlertDialogState() - ) + deleteBlockedNumber = {} + ) {} } } diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/AppSideloadedDialog.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/AppSideloadedDialog.kt index 4f629dca1..5fa8fa0be 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/AppSideloadedDialog.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/AppSideloadedDialog.kt @@ -60,8 +60,8 @@ class AppSideloadedDialog(val activity: Activity, val callback: () -> Unit) { @Composable fun AppSideLoadedAlertDialog( + alertDialogState: AlertDialogState, modifier: Modifier = Modifier, - alertDialogState: AlertDialogState = rememberAlertDialogState(), onDownloadClick: (url: String) -> Unit, onCancelClick: () -> Unit ) { @@ -112,6 +112,6 @@ fun AppSideLoadedAlertDialog( @MyDevices private fun AppSideLoadedAlertDialogPreview() { AppThemeSurface { - AppSideLoadedAlertDialog(alertDialogState = rememberAlertDialogState(), onDownloadClick = {}, onCancelClick = {}) + AppSideLoadedAlertDialog(alertDialogState = rememberAlertDialogState(), onDownloadClick = {}) {} } } diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/BottomSheetChooserDialog.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/BottomSheetChooserDialog.kt index ddc6ae328..aa5047863 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/BottomSheetChooserDialog.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/BottomSheetChooserDialog.kt @@ -4,9 +4,10 @@ import android.os.Bundle import android.view.ViewGroup import androidx.compose.foundation.Image import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.padding -import androidx.compose.material3.* +import androidx.compose.material3.ListItem +import androidx.compose.material3.ListItemDefaults +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Modifier @@ -19,12 +20,11 @@ import androidx.fragment.app.FragmentManager import com.simplemobiletools.commons.R import com.simplemobiletools.commons.adapters.setupSimpleListItem import com.simplemobiletools.commons.compose.alert_dialog.dialogContainerColor -import com.simplemobiletools.commons.compose.alert_dialog.dialogElevation import com.simplemobiletools.commons.compose.alert_dialog.dialogTextColor import com.simplemobiletools.commons.compose.bottom_sheet.BottomSheetColumnDialogSurface import com.simplemobiletools.commons.compose.bottom_sheet.BottomSheetDialogState import com.simplemobiletools.commons.compose.bottom_sheet.BottomSheetSpacerEdgeToEdge -import com.simplemobiletools.commons.compose.bottom_sheet.bottomSheetDialogShape +import com.simplemobiletools.commons.compose.bottom_sheet.rememberBottomSheetDialogState import com.simplemobiletools.commons.compose.extensions.MyDevices import com.simplemobiletools.commons.compose.theme.AppThemeSurface import com.simplemobiletools.commons.compose.theme.SimpleTheme @@ -82,35 +82,11 @@ open class BottomSheetChooserDialog : BaseBottomSheetDialogFragment() { @Composable fun ChooserBottomSheetDialog( bottomSheetDialogState: BottomSheetDialogState, - windowInsets: WindowInsets, - bottomSheetState : SheetState, + items: ImmutableList, modifier: Modifier = Modifier, - items: ImmutableList, onItemClicked: (SimpleListItem) -> Unit ) { - ModalBottomSheet( - modifier = modifier, - onDismissRequest = bottomSheetDialogState::close, - sheetState = bottomSheetState, - windowInsets = windowInsets, - dragHandle = {}, //leave empty as we provide our own ColumnScope - shape = bottomSheetDialogShape, - containerColor = dialogContainerColor, - tonalElevation = dialogElevation, - ) { - ChooserScreenContent(items = items, onItemClicked = { - onItemClicked(it) - bottomSheetDialogState.close() - }) - } -} - -@Composable -private fun ChooserScreenContent( - items: ImmutableList, - onItemClicked: (SimpleListItem) -> Unit -) { - BottomSheetColumnDialogSurface { + BottomSheetColumnDialogSurface(modifier) { Text( text = stringResource(id = R.string.please_select_destination), color = dialogTextColor, @@ -126,6 +102,7 @@ private fun ChooserScreenContent( modifier = Modifier .clickable { onItemClicked(item) + bottomSheetDialogState.close() }, headlineContent = { Text(stringResource(id = item.textRes), color = color) @@ -166,13 +143,6 @@ private fun ChooserBottomSheetDialogPreview() { SimpleListItem(4, R.string.choose_contact, R.drawable.ic_add_person_vector) ).toImmutableList() } - ChooserScreenContent(items = list, onItemClicked = {}) - /* https://issuetracker.google.com/issues/304300690 - ChooserBottomSheetDialog( - bottomSheetDialogState = rememberBottomSheetDialogState(), - items = list, - onItemClicked = {}, - modifier = Modifier.fillMaxSize() - )*/ + ChooserBottomSheetDialog(bottomSheetDialogState = rememberBottomSheetDialogState(), items = list, onItemClicked = {}) } } diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/CallConfirmationDialog.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/CallConfirmationDialog.kt index 0da4868c4..e60efa8e9 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/CallConfirmationDialog.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/CallConfirmationDialog.kt @@ -60,9 +60,9 @@ class CallConfirmationDialog(val activity: BaseSimpleActivity, val callee: Strin @Composable fun CallConfirmationAlertDialog( - modifier: Modifier = Modifier, alertDialogState: AlertDialogState, callee: String, + modifier: Modifier = Modifier, callback: () -> Unit ) { androidx.compose.material3.AlertDialog( @@ -139,6 +139,7 @@ private fun CallConfirmationAlertDialogPreview() { AppThemeSurface { CallConfirmationAlertDialog( alertDialogState = rememberAlertDialogState(), - callee = "Simple Mobile Tools", callback = {}) + callee = "Simple Mobile Tools" + ) {} } } diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/ChangeDateTimeFormatDialog.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/ChangeDateTimeFormatDialog.kt index 562b76c56..baedbe67e 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/ChangeDateTimeFormatDialog.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/ChangeDateTimeFormatDialog.kt @@ -105,8 +105,8 @@ class ChangeDateTimeFormatDialog(val activity: Activity, val callback: () -> Uni @Composable fun ChangeDateTimeFormatAlertDialog( alertDialogState: AlertDialogState, - modifier: Modifier = Modifier, is24HourChecked: Boolean, + modifier: Modifier = Modifier, callback: (selectedFormat: String, is24HourChecked: Boolean) -> Unit ) { val context = LocalContext.current @@ -254,6 +254,6 @@ internal fun DialogCheckBoxWithRadioAlignmentComponent( @MyDevices private fun ChangeDateTimeFormatAlertDialogPreview() { AppThemeSurface { - ChangeDateTimeFormatAlertDialog(alertDialogState = rememberAlertDialogState(), callback = { _, _ -> }, is24HourChecked = true) + ChangeDateTimeFormatAlertDialog(alertDialogState = rememberAlertDialogState(), is24HourChecked = true) { _, _ -> } } } diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/ChangeViewTypeDialog.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/ChangeViewTypeDialog.kt index 309ef088c..c19bcdaa5 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/ChangeViewTypeDialog.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/ChangeViewTypeDialog.kt @@ -69,8 +69,8 @@ data class ViewType(val title: String, val type: Int) @Composable fun ChangeViewTypeAlertDialog( alertDialogState: AlertDialogState, - modifier: Modifier = Modifier, selectedViewType: Int, + modifier: Modifier = Modifier, onTypeChosen: (type: Int) -> Unit ) { val context = LocalContext.current @@ -137,6 +137,6 @@ private fun getSelectedValue( @Composable private fun ChangeViewTypeAlertDialogPreview() { AppThemeSurface { - ChangeViewTypeAlertDialog(alertDialogState = rememberAlertDialogState(), onTypeChosen = {}, selectedViewType = VIEW_TYPE_GRID) + ChangeViewTypeAlertDialog(alertDialogState = rememberAlertDialogState(), selectedViewType = VIEW_TYPE_GRID) {} } } diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/ColorPickerDialog.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/ColorPickerDialog.kt index 15ff2e031..2de2931d9 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/ColorPickerDialog.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/ColorPickerDialog.kt @@ -145,9 +145,8 @@ class ColorPickerDialog( @Composable fun ColorPickerAlertDialog( alertDialogState: AlertDialogState, + @ColorInt color: Int, modifier: Modifier = Modifier, - @ColorInt - color: Int, removeDimmedBackground: Boolean = false, addDefaultColorButton: Boolean = false, onActiveColorChange: (color: Int) -> Unit, @@ -418,7 +417,7 @@ private fun ColorPickerAlertDialogPreview() { ColorPickerAlertDialog( alertDialogState = rememberAlertDialogState(), color = colorResource(id = R.color.color_primary).toArgb(), - onActiveColorChange = {}, - onButtonPressed = { _, _ -> }) + onActiveColorChange = {} + ) { _, _ -> } } } diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/ConfirmationAdvancedDialog.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/ConfirmationAdvancedDialog.kt index b1c1cbaa2..f76b920f0 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/ConfirmationAdvancedDialog.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/ConfirmationAdvancedDialog.kt @@ -60,8 +60,8 @@ class ConfirmationAdvancedDialog( @Composable fun ConfirmationAdvancedAlertDialog( - modifier: Modifier = Modifier, alertDialogState: AlertDialogState, + modifier: Modifier = Modifier, message: String = "", messageId: Int? = R.string.proceed_with_deletion, positive: Int? = R.string.yes, @@ -116,7 +116,8 @@ fun ConfirmationAdvancedAlertDialog( @MyDevices private fun ConfirmationAdvancedAlertDialogPreview() { AppThemeSurface { - ConfirmationAdvancedAlertDialog(alertDialogState = rememberAlertDialogState(), - callback = {}) + ConfirmationAdvancedAlertDialog( + alertDialogState = rememberAlertDialogState() + ) {} } } diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/ConfirmationDialog.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/ConfirmationDialog.kt index bd6ef2e9e..2bfa98798 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/ConfirmationDialog.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/ConfirmationDialog.kt @@ -66,8 +66,8 @@ class ConfirmationDialog( @Composable fun ConfirmationAlertDialog( - modifier: Modifier = Modifier, alertDialogState: AlertDialogState, + modifier: Modifier = Modifier, message: String = "", messageId: Int? = R.string.proceed_with_deletion, positive: Int? = R.string.yes, @@ -133,7 +133,8 @@ fun ConfirmationAlertDialog( @MyDevices private fun ConfirmationAlertDialogPreview() { AppThemeSurface { - ConfirmationAlertDialog(alertDialogState = rememberAlertDialogState(), - callback = {}) + ConfirmationAlertDialog( + alertDialogState = rememberAlertDialogState() + ) {} } } diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/CreateNewFolderDialog.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/CreateNewFolderDialog.kt index 3632c1285..75f0f290b 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/CreateNewFolderDialog.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/CreateNewFolderDialog.kt @@ -108,8 +108,8 @@ class CreateNewFolderDialog(val activity: BaseSimpleActivity, val path: String, @Composable fun CreateNewFolderAlertDialog( alertDialogState: AlertDialogState, - modifier: Modifier = Modifier, path: String, + modifier: Modifier = Modifier, callback: (path: String) -> Unit ) { val focusRequester = remember { FocusRequester() } @@ -209,8 +209,7 @@ private fun CreateNewFolderAlertDialogPreview() { AppThemeSurface { CreateNewFolderAlertDialog( alertDialogState = rememberAlertDialogState(), - path = "Internal/", - callback = {} - ) + path = "Internal/" + ) {} } } diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/FileConflictDialog.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/FileConflictDialog.kt index de7019db9..5696e74f6 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/FileConflictDialog.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/FileConflictDialog.kt @@ -93,9 +93,9 @@ class FileConflictDialog( @Composable fun FileConflictAlertDialog( alertDialogState: AlertDialogState, - modifier: Modifier = Modifier, fileDirItem: FileDirItemReadOnly, showApplyToAll: Boolean, + modifier: Modifier = Modifier, callback: (resolution: Int, applyForAll: Boolean) -> Unit ) { val context = LocalContext.current @@ -207,8 +207,7 @@ private fun FileConflictAlertDialogPreview() { FileConflictAlertDialog( alertDialogState = rememberAlertDialogState(), fileDirItem = FileDirItem("", name = "test", children = 1).asReadOnly(), - showApplyToAll = true, - callback = { _, _ -> } - ) + showApplyToAll = true + ) { _, _ -> } } } diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/LineColorPickerDialog.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/LineColorPickerDialog.kt index 5746cfe8d..def0dc2d2 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/LineColorPickerDialog.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/LineColorPickerDialog.kt @@ -168,9 +168,9 @@ class LineColorPickerDialog( @Composable fun LineColorPickerAlertDialog( alertDialogState: AlertDialogState, - modifier: Modifier = Modifier, @ColorInt color: Int, isPrimaryColorPicker: Boolean, + modifier: Modifier = Modifier, primaryColors: Int = R.array.md_primary_colors, appIconIDs: ArrayList? = null, onActiveColorChange: (color: Int) -> Unit, @@ -330,7 +330,7 @@ private fun LineColorPickerAlertDialogPreview() { LineColorPickerAlertDialog(alertDialogState = rememberAlertDialogState(), color = R.color.color_primary, isPrimaryColorPicker = true, - onActiveColorChange = {}, - onButtonPressed = { _, _ -> }) + onActiveColorChange = {} + ) { _, _ -> } } } diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/OpenDeviceSettingsDialog.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/OpenDeviceSettingsDialog.kt index 10c8bff09..d98ae7a8e 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/OpenDeviceSettingsDialog.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/OpenDeviceSettingsDialog.kt @@ -38,8 +38,8 @@ class OpenDeviceSettingsDialog(val activity: BaseSimpleActivity, message: String @Composable fun OpenDeviceSettingsAlertDialog( alertDialogState: AlertDialogState, - modifier: Modifier = Modifier, - message: String + message: String, + modifier: Modifier = Modifier ) { val context = LocalContext.current diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/PermissionRequiredDialog.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/PermissionRequiredDialog.kt index e96e48a53..6a161f979 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/PermissionRequiredDialog.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/PermissionRequiredDialog.kt @@ -44,10 +44,10 @@ class PermissionRequiredDialog( @Composable fun PermissionRequiredAlertDialog( alertDialogState: AlertDialogState, - modifier: Modifier = Modifier, text: String, - positiveActionCallback: () -> Unit, - negativeActionCallback: (() -> Unit)? = null + modifier: Modifier = Modifier, + negativeActionCallback: (() -> Unit)? = null, + positiveActionCallback: () -> Unit ) { AlertDialog( containerColor = dialogContainerColor, @@ -95,8 +95,7 @@ private fun PermissionRequiredAlertDialogPreview() { PermissionRequiredAlertDialog( alertDialogState = rememberAlertDialogState(), text = "Test", - positiveActionCallback = {}, negativeActionCallback = {} - ) + ) {} } } diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/RadioGroupDialog.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/RadioGroupDialog.kt index 7cd00f984..55b1b1e87 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/RadioGroupDialog.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/RadioGroupDialog.kt @@ -103,8 +103,8 @@ class RadioGroupDialog( @Composable fun RadioGroupAlertDialog( alertDialogState: AlertDialogState, - modifier: Modifier = Modifier, items: ImmutableList, + modifier: Modifier = Modifier, selectedItemId: Int = -1, titleId: Int = 0, showOKButton: Boolean = false, @@ -188,11 +188,10 @@ private fun RadioGroupDialogAlertDialogPreview(@PreviewParameter(BooleanPreviewP RadioItem(2, "Test 2"), RadioItem(3, "Test 3"), ).toImmutableList(), - callback = {}, - cancelCallback = {}, - showOKButton = showOKButton, + selectedItemId = 1, titleId = R.string.title, - selectedItemId = 1 - ) + showOKButton = showOKButton, + cancelCallback = {} + ) {} } } diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/WritePermissionDialog.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/WritePermissionDialog.kt index 3eb3763c3..9b32a9202 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/WritePermissionDialog.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/WritePermissionDialog.kt @@ -138,8 +138,8 @@ class WritePermissionDialog(activity: Activity, val writePermissionDialogMode: W @Composable fun WritePermissionAlertDialog( alertDialogState: AlertDialogState, - modifier: Modifier = Modifier, writePermissionDialogMode: WritePermissionDialog.WritePermissionDialogMode, + modifier: Modifier = Modifier, callback: () -> Unit, onCancelCallback: () -> Unit ) { @@ -316,8 +316,7 @@ private fun WritePermissionAlertDialogPreview(@PreviewParameter(WritePermissionD WritePermissionAlertDialog( alertDialogState = rememberAlertDialogState(), writePermissionDialogMode = WritePermissionDialog.WritePermissionDialogMode.OpenDocumentTreeSDK30("."), - callback = {}, - onCancelCallback = {} - ) + callback = {} + ) {} } } diff --git a/samples/src/main/kotlin/com/simplemobiletools/commons/samples/activities/TestDialogActivity.kt b/samples/src/main/kotlin/com/simplemobiletools/commons/samples/activities/TestDialogActivity.kt index 4689eca2c..09f865d69 100644 --- a/samples/src/main/kotlin/com/simplemobiletools/commons/samples/activities/TestDialogActivity.kt +++ b/samples/src/main/kotlin/com/simplemobiletools/commons/samples/activities/TestDialogActivity.kt @@ -101,7 +101,7 @@ class TestDialogActivity : ComponentActivity() { @Composable private fun getChooserBottomSheetDialogState() = rememberBottomSheetDialogState().apply { - DialogMember { state, insets -> + BottomSheetContent { val list = remember { listOf( SimpleListItem(1, R.string.record_video, R.drawable.ic_camera_vector), @@ -110,13 +110,11 @@ class TestDialogActivity : ComponentActivity() { ).toImmutableList() } ChooserBottomSheetDialog( - bottomSheetDialogState = this, - items = list, - windowInsets = insets, - bottomSheetState = state, - onItemClicked = { - toast("Selected ${getString(it.textRes)}") - }) + bottomSheetDialogState = this@apply, + items = list + ) { + toast("Selected ${getString(it.textRes)}") + } } } @@ -151,9 +149,8 @@ class TestDialogActivity : ComponentActivity() { WritePermissionAlertDialog( alertDialogState = this, writePermissionDialogMode = WritePermissionDialog.WritePermissionDialogMode.OpenDocumentTreeSDK30("."), - callback = {}, - onCancelCallback = {} - ) + callback = {} + ) {} } } @@ -206,16 +203,15 @@ class TestDialogActivity : ComponentActivity() { RadioItem(6, "Test 6"), RadioItem(6, "Test 7"), ).toImmutableList(), - showOKButton = true, selectedItemId = 2, + titleId = R.string.title, + showOKButton = true, cancelCallback = { Log.d("getRadioGroupDialogAlertDialogState", "cancelCallback") - }, - callback = { - Log.d("getRadioGroupDialogAlertDialogState", "Selected $it") - }, - titleId = R.string.title - ) + } + ) { + Log.d("getRadioGroupDialogAlertDialogState", "Selected $it") + } } } @@ -244,11 +240,11 @@ class TestDialogActivity : ComponentActivity() { alertDialogState = this, color = baseConfig.customPrimaryColor, isPrimaryColorPicker = true, - onButtonPressed = { wasPositivePressed, color -> - Log.d("getLineColorPickerAlertDialogState", "wasPositivePressed=$wasPositivePressed color=${color.toHex()}") - }, onActiveColorChange = { color -> + onActiveColorChange = { color -> Log.d("getLineColorPickerAlertDialogState", "onActiveColorChange=${color.toHex()}") - }) + }) { wasPositivePressed, color -> + Log.d("getLineColorPickerAlertDialogState", "wasPositivePressed=$wasPositivePressed color=${color.toHex()}") + } } } @@ -269,11 +265,11 @@ class TestDialogActivity : ComponentActivity() { alertDialogState = this, color = config.customTextColor, removeDimmedBackground = true, - onButtonPressed = { wasPositivePressed, color -> - Log.d("getColorPickerAlertDialogState", "wasPositivePressed=$wasPositivePressed color=${color.toHex()}") - }, onActiveColorChange = { color -> + onActiveColorChange = { color -> Log.d("getColorPickerAlertDialogState", "onActiveColorChange=${color.toHex()}") - }) + }) { wasPositivePressed, color -> + Log.d("getColorPickerAlertDialogState", "wasPositivePressed=$wasPositivePressed color=${color.toHex()}") + } } } @@ -287,7 +283,7 @@ class TestDialogActivity : ComponentActivity() { @Composable private fun getCallConfirmationAlertDialogState() = rememberAlertDialogState().apply { DialogMember { - CallConfirmationAlertDialog(alertDialogState = this, callee = "Simple Mobile Tools", callback = {}) + CallConfirmationAlertDialog(alertDialogState = this, callee = "Simple Mobile Tools") {} } } @@ -310,7 +306,7 @@ class TestDialogActivity : ComponentActivity() { @Composable private fun getConfirmationAlertDialogState() = rememberAlertDialogState().apply { DialogMember { - ConfirmationAlertDialog(alertDialogState = this, callback = {}, dialogTitle = "Some fancy title") + ConfirmationAlertDialog(alertDialogState = this, dialogTitle = "Some fancy title") {} } } @@ -318,7 +314,7 @@ class TestDialogActivity : ComponentActivity() { private fun getAppSideLoadedDialogState() = rememberAlertDialogState().apply { DialogMember { - AppSideLoadedAlertDialog(onDownloadClick = {}, onCancelClick = {}, alertDialogState = this) + AppSideLoadedAlertDialog(alertDialogState = this, onDownloadClick = {}) {} } } @@ -326,7 +322,7 @@ class TestDialogActivity : ComponentActivity() { private fun getAddBlockedNumberDialogState() = rememberAlertDialogState().apply { DialogMember { - AddOrEditBlockedNumberAlertDialog(blockedNumber = null, deleteBlockedNumber = {}, addBlockedNumber = {}, alertDialogState = this) + AddOrEditBlockedNumberAlertDialog(alertDialogState = this, blockedNumber = null, deleteBlockedNumber = {}) {} } } @@ -334,7 +330,7 @@ class TestDialogActivity : ComponentActivity() { private fun getConfirmationAdvancedAlertDialogState() = rememberAlertDialogState().apply { DialogMember { - ConfirmationAdvancedAlertDialog(alertDialogState = this, callback = {}) + ConfirmationAdvancedAlertDialog(alertDialogState = this) {} } } @@ -344,9 +340,8 @@ class TestDialogActivity : ComponentActivity() { DialogMember { PermissionRequiredAlertDialog( alertDialogState = this, - text = "Test permission", - positiveActionCallback = {} - ) + text = "Test permission" + ) {} } }