fix: bottom sheet animation

and improve dialogs API state
This commit is contained in:
FunkyMuse 2023-10-15 12:40:20 +02:00
parent ef179890da
commit eda91d9274
21 changed files with 130 additions and 160 deletions

View file

@ -136,18 +136,17 @@ class AboutActivity : ComponentActivity() {
DialogMember { DialogMember {
ConfirmationAdvancedAlertDialog( ConfirmationAdvancedAlertDialog(
alertDialogState = this, 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)}", message = "${getString(R.string.before_asking_question_read_faq)}\n\n${getString(R.string.make_sure_latest)}",
messageId = null, messageId = null,
positive = R.string.read_faq, positive = R.string.read_faq,
negative = R.string.skip negative = R.string.skip
) ) { success ->
if (success) {
launchFAQActivity()
} else {
launchEmailIntent()
}
}
} }
} }
@ -157,18 +156,17 @@ class AboutActivity : ComponentActivity() {
DialogMember { DialogMember {
ConfirmationAdvancedAlertDialog( ConfirmationAdvancedAlertDialog(
alertDialogState = this, 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)}", message = "${getString(R.string.before_asking_question_read_faq)}\n\n${getString(R.string.make_sure_latest)}",
messageId = null, messageId = null,
positive = R.string.read_faq, positive = R.string.read_faq,
negative = R.string.skip negative = R.string.skip
) ) { success ->
if (success) {
launchFAQActivity()
} else {
launchRateUsPrompt(showRateStarsDialog)
}
}
} }
} }

View file

@ -80,18 +80,17 @@ class ManageBlockedNumbersActivity : BaseSimpleActivity() {
addBlockedNumberDialogState.DialogMember { addBlockedNumberDialogState.DialogMember {
AddOrEditBlockedNumberAlertDialog( AddOrEditBlockedNumberAlertDialog(
blockedNumber = clickedBlockedNumber,
alertDialogState = addBlockedNumberDialogState, alertDialogState = addBlockedNumberDialogState,
blockedNumber = clickedBlockedNumber,
deleteBlockedNumber = { blockedNumber -> deleteBlockedNumber = { blockedNumber ->
deleteBlockedNumber(blockedNumber) deleteBlockedNumber(blockedNumber)
updateBlockedNumbers() updateBlockedNumbers()
},
addBlockedNumber = { blockedNumber ->
addBlockedNumber(blockedNumber)
clickedBlockedNumber = null
updateBlockedNumbers()
} }
) ) { blockedNumber ->
addBlockedNumber(blockedNumber)
clickedBlockedNumber = null
updateBlockedNumbers()
}
} }
ManageBlockedNumbersScreen( ManageBlockedNumbersScreen(

View file

@ -2,12 +2,15 @@ package com.simplemobiletools.commons.compose.bottom_sheet
import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.material3.BottomSheetDefaults import androidx.compose.material3.BottomSheetDefaults
import androidx.compose.material3.SheetState import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.SheetValue import androidx.compose.material3.SheetValue
import androidx.compose.material3.rememberModalBottomSheetState import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.* import androidx.compose.runtime.*
import androidx.compose.runtime.saveable.mapSaver import androidx.compose.runtime.saveable.mapSaver
import androidx.compose.runtime.saveable.rememberSaveable 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 @Composable
fun rememberBottomSheetDialogState( fun rememberBottomSheetDialogState(
@ -82,25 +85,34 @@ class BottomSheetDialogState(
} }
@Composable @Composable
fun DialogMember( fun BottomSheetContent(
content: @Composable ( modifier: Modifier = Modifier,
state: SheetState, content: @Composable () -> Unit
insets: WindowInsets
) -> Unit
) { ) {
val bottomSheetState = rememberSheetState() val bottomSheetState = rememberSheetState()
val windowInsets = rememberWindowInsets() val windowInsets = rememberWindowInsets()
LaunchedEffect(isOpen) { LaunchedEffect(isOpen) {
if (isOpen) { if (isOpen && !bottomSheetState.isVisible) {
bottomSheetState.show() bottomSheetState.show()
} else { } else {
bottomSheetState.hide() bottomSheetState.hide()
} }
} }
if (bottomSheetState.isVisible) { if (isOpen) {
content(bottomSheetState, windowInsets) 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()
}
} }
} }
} }

View file

@ -15,9 +15,9 @@ fun FakeVersionCheck() {
DialogMember { DialogMember {
ConfirmationAlertDialog( ConfirmationAlertDialog(
alertDialogState = this, alertDialogState = this,
message = FAKE_VERSION_APP_LABEL,
positive = R.string.ok, positive = R.string.ok,
negative = null, negative = null
message = FAKE_VERSION_APP_LABEL
) { ) {
context.getActivity().launchViewIntent(DEVELOPER_PLAY_STORE_URL) context.getActivity().launchViewIntent(DEVELOPER_PLAY_STORE_URL)
} }
@ -35,9 +35,9 @@ fun CheckAppOnSdCard() {
DialogMember { DialogMember {
ConfirmationAlertDialog( ConfirmationAlertDialog(
alertDialogState = this, alertDialogState = this,
messageId = R.string.app_on_sd_card,
positive = R.string.ok, positive = R.string.ok,
negative = null, negative = null
messageId = R.string.app_on_sd_card
) {} ) {}
} }
} }

View file

@ -22,9 +22,9 @@ import com.simplemobiletools.commons.models.BlockedNumber
@Composable @Composable
fun AddOrEditBlockedNumberAlertDialog( fun AddOrEditBlockedNumberAlertDialog(
modifier: Modifier = Modifier,
blockedNumber: BlockedNumber?,
alertDialogState: AlertDialogState, alertDialogState: AlertDialogState,
blockedNumber: BlockedNumber?,
modifier: Modifier = Modifier,
deleteBlockedNumber: (String) -> Unit, deleteBlockedNumber: (String) -> Unit,
addBlockedNumber: (String) -> Unit addBlockedNumber: (String) -> Unit
) { ) {
@ -100,10 +100,9 @@ fun AddOrEditBlockedNumberAlertDialog(
private fun AddOrEditBlockedNumberAlertDialogPreview() { private fun AddOrEditBlockedNumberAlertDialogPreview() {
AppThemeSurface { AppThemeSurface {
AddOrEditBlockedNumberAlertDialog( AddOrEditBlockedNumberAlertDialog(
alertDialogState = rememberAlertDialogState(),
blockedNumber = null, blockedNumber = null,
deleteBlockedNumber = {}, deleteBlockedNumber = {}
addBlockedNumber = {}, ) {}
alertDialogState = rememberAlertDialogState()
)
} }
} }

View file

@ -60,8 +60,8 @@ class AppSideloadedDialog(val activity: Activity, val callback: () -> Unit) {
@Composable @Composable
fun AppSideLoadedAlertDialog( fun AppSideLoadedAlertDialog(
alertDialogState: AlertDialogState,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
alertDialogState: AlertDialogState = rememberAlertDialogState(),
onDownloadClick: (url: String) -> Unit, onDownloadClick: (url: String) -> Unit,
onCancelClick: () -> Unit onCancelClick: () -> Unit
) { ) {
@ -112,6 +112,6 @@ fun AppSideLoadedAlertDialog(
@MyDevices @MyDevices
private fun AppSideLoadedAlertDialogPreview() { private fun AppSideLoadedAlertDialogPreview() {
AppThemeSurface { AppThemeSurface {
AppSideLoadedAlertDialog(alertDialogState = rememberAlertDialogState(), onDownloadClick = {}, onCancelClick = {}) AppSideLoadedAlertDialog(alertDialogState = rememberAlertDialogState(), onDownloadClick = {}) {}
} }
} }

View file

@ -4,9 +4,10 @@ import android.os.Bundle
import android.view.ViewGroup import android.view.ViewGroup
import androidx.compose.foundation.Image import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.padding 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.Composable
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
@ -19,12 +20,11 @@ import androidx.fragment.app.FragmentManager
import com.simplemobiletools.commons.R import com.simplemobiletools.commons.R
import com.simplemobiletools.commons.adapters.setupSimpleListItem import com.simplemobiletools.commons.adapters.setupSimpleListItem
import com.simplemobiletools.commons.compose.alert_dialog.dialogContainerColor 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.alert_dialog.dialogTextColor
import com.simplemobiletools.commons.compose.bottom_sheet.BottomSheetColumnDialogSurface import com.simplemobiletools.commons.compose.bottom_sheet.BottomSheetColumnDialogSurface
import com.simplemobiletools.commons.compose.bottom_sheet.BottomSheetDialogState import com.simplemobiletools.commons.compose.bottom_sheet.BottomSheetDialogState
import com.simplemobiletools.commons.compose.bottom_sheet.BottomSheetSpacerEdgeToEdge 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.extensions.MyDevices
import com.simplemobiletools.commons.compose.theme.AppThemeSurface import com.simplemobiletools.commons.compose.theme.AppThemeSurface
import com.simplemobiletools.commons.compose.theme.SimpleTheme import com.simplemobiletools.commons.compose.theme.SimpleTheme
@ -82,35 +82,11 @@ open class BottomSheetChooserDialog : BaseBottomSheetDialogFragment() {
@Composable @Composable
fun ChooserBottomSheetDialog( fun ChooserBottomSheetDialog(
bottomSheetDialogState: BottomSheetDialogState, bottomSheetDialogState: BottomSheetDialogState,
windowInsets: WindowInsets, items: ImmutableList<SimpleListItem>,
bottomSheetState : SheetState,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
items: ImmutableList<SimpleListItem>,
onItemClicked: (SimpleListItem) -> Unit onItemClicked: (SimpleListItem) -> Unit
) { ) {
ModalBottomSheet( BottomSheetColumnDialogSurface(modifier) {
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<SimpleListItem>,
onItemClicked: (SimpleListItem) -> Unit
) {
BottomSheetColumnDialogSurface {
Text( Text(
text = stringResource(id = R.string.please_select_destination), text = stringResource(id = R.string.please_select_destination),
color = dialogTextColor, color = dialogTextColor,
@ -126,6 +102,7 @@ private fun ChooserScreenContent(
modifier = Modifier modifier = Modifier
.clickable { .clickable {
onItemClicked(item) onItemClicked(item)
bottomSheetDialogState.close()
}, },
headlineContent = { headlineContent = {
Text(stringResource(id = item.textRes), color = color) 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) SimpleListItem(4, R.string.choose_contact, R.drawable.ic_add_person_vector)
).toImmutableList() ).toImmutableList()
} }
ChooserScreenContent(items = list, onItemClicked = {}) ChooserBottomSheetDialog(bottomSheetDialogState = rememberBottomSheetDialogState(), items = list, onItemClicked = {})
/* https://issuetracker.google.com/issues/304300690
ChooserBottomSheetDialog(
bottomSheetDialogState = rememberBottomSheetDialogState(),
items = list,
onItemClicked = {},
modifier = Modifier.fillMaxSize()
)*/
} }
} }

View file

@ -60,9 +60,9 @@ class CallConfirmationDialog(val activity: BaseSimpleActivity, val callee: Strin
@Composable @Composable
fun CallConfirmationAlertDialog( fun CallConfirmationAlertDialog(
modifier: Modifier = Modifier,
alertDialogState: AlertDialogState, alertDialogState: AlertDialogState,
callee: String, callee: String,
modifier: Modifier = Modifier,
callback: () -> Unit callback: () -> Unit
) { ) {
androidx.compose.material3.AlertDialog( androidx.compose.material3.AlertDialog(
@ -139,6 +139,7 @@ private fun CallConfirmationAlertDialogPreview() {
AppThemeSurface { AppThemeSurface {
CallConfirmationAlertDialog( CallConfirmationAlertDialog(
alertDialogState = rememberAlertDialogState(), alertDialogState = rememberAlertDialogState(),
callee = "Simple Mobile Tools", callback = {}) callee = "Simple Mobile Tools"
) {}
} }
} }

View file

@ -105,8 +105,8 @@ class ChangeDateTimeFormatDialog(val activity: Activity, val callback: () -> Uni
@Composable @Composable
fun ChangeDateTimeFormatAlertDialog( fun ChangeDateTimeFormatAlertDialog(
alertDialogState: AlertDialogState, alertDialogState: AlertDialogState,
modifier: Modifier = Modifier,
is24HourChecked: Boolean, is24HourChecked: Boolean,
modifier: Modifier = Modifier,
callback: (selectedFormat: String, is24HourChecked: Boolean) -> Unit callback: (selectedFormat: String, is24HourChecked: Boolean) -> Unit
) { ) {
val context = LocalContext.current val context = LocalContext.current
@ -254,6 +254,6 @@ internal fun DialogCheckBoxWithRadioAlignmentComponent(
@MyDevices @MyDevices
private fun ChangeDateTimeFormatAlertDialogPreview() { private fun ChangeDateTimeFormatAlertDialogPreview() {
AppThemeSurface { AppThemeSurface {
ChangeDateTimeFormatAlertDialog(alertDialogState = rememberAlertDialogState(), callback = { _, _ -> }, is24HourChecked = true) ChangeDateTimeFormatAlertDialog(alertDialogState = rememberAlertDialogState(), is24HourChecked = true) { _, _ -> }
} }
} }

View file

@ -69,8 +69,8 @@ data class ViewType(val title: String, val type: Int)
@Composable @Composable
fun ChangeViewTypeAlertDialog( fun ChangeViewTypeAlertDialog(
alertDialogState: AlertDialogState, alertDialogState: AlertDialogState,
modifier: Modifier = Modifier,
selectedViewType: Int, selectedViewType: Int,
modifier: Modifier = Modifier,
onTypeChosen: (type: Int) -> Unit onTypeChosen: (type: Int) -> Unit
) { ) {
val context = LocalContext.current val context = LocalContext.current
@ -137,6 +137,6 @@ private fun getSelectedValue(
@Composable @Composable
private fun ChangeViewTypeAlertDialogPreview() { private fun ChangeViewTypeAlertDialogPreview() {
AppThemeSurface { AppThemeSurface {
ChangeViewTypeAlertDialog(alertDialogState = rememberAlertDialogState(), onTypeChosen = {}, selectedViewType = VIEW_TYPE_GRID) ChangeViewTypeAlertDialog(alertDialogState = rememberAlertDialogState(), selectedViewType = VIEW_TYPE_GRID) {}
} }
} }

View file

@ -145,9 +145,8 @@ class ColorPickerDialog(
@Composable @Composable
fun ColorPickerAlertDialog( fun ColorPickerAlertDialog(
alertDialogState: AlertDialogState, alertDialogState: AlertDialogState,
@ColorInt color: Int,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
@ColorInt
color: Int,
removeDimmedBackground: Boolean = false, removeDimmedBackground: Boolean = false,
addDefaultColorButton: Boolean = false, addDefaultColorButton: Boolean = false,
onActiveColorChange: (color: Int) -> Unit, onActiveColorChange: (color: Int) -> Unit,
@ -418,7 +417,7 @@ private fun ColorPickerAlertDialogPreview() {
ColorPickerAlertDialog( ColorPickerAlertDialog(
alertDialogState = rememberAlertDialogState(), alertDialogState = rememberAlertDialogState(),
color = colorResource(id = R.color.color_primary).toArgb(), color = colorResource(id = R.color.color_primary).toArgb(),
onActiveColorChange = {}, onActiveColorChange = {}
onButtonPressed = { _, _ -> }) ) { _, _ -> }
} }
} }

View file

@ -60,8 +60,8 @@ class ConfirmationAdvancedDialog(
@Composable @Composable
fun ConfirmationAdvancedAlertDialog( fun ConfirmationAdvancedAlertDialog(
modifier: Modifier = Modifier,
alertDialogState: AlertDialogState, alertDialogState: AlertDialogState,
modifier: Modifier = Modifier,
message: String = "", message: String = "",
messageId: Int? = R.string.proceed_with_deletion, messageId: Int? = R.string.proceed_with_deletion,
positive: Int? = R.string.yes, positive: Int? = R.string.yes,
@ -116,7 +116,8 @@ fun ConfirmationAdvancedAlertDialog(
@MyDevices @MyDevices
private fun ConfirmationAdvancedAlertDialogPreview() { private fun ConfirmationAdvancedAlertDialogPreview() {
AppThemeSurface { AppThemeSurface {
ConfirmationAdvancedAlertDialog(alertDialogState = rememberAlertDialogState(), ConfirmationAdvancedAlertDialog(
callback = {}) alertDialogState = rememberAlertDialogState()
) {}
} }
} }

View file

@ -66,8 +66,8 @@ class ConfirmationDialog(
@Composable @Composable
fun ConfirmationAlertDialog( fun ConfirmationAlertDialog(
modifier: Modifier = Modifier,
alertDialogState: AlertDialogState, alertDialogState: AlertDialogState,
modifier: Modifier = Modifier,
message: String = "", message: String = "",
messageId: Int? = R.string.proceed_with_deletion, messageId: Int? = R.string.proceed_with_deletion,
positive: Int? = R.string.yes, positive: Int? = R.string.yes,
@ -133,7 +133,8 @@ fun ConfirmationAlertDialog(
@MyDevices @MyDevices
private fun ConfirmationAlertDialogPreview() { private fun ConfirmationAlertDialogPreview() {
AppThemeSurface { AppThemeSurface {
ConfirmationAlertDialog(alertDialogState = rememberAlertDialogState(), ConfirmationAlertDialog(
callback = {}) alertDialogState = rememberAlertDialogState()
) {}
} }
} }

View file

@ -108,8 +108,8 @@ class CreateNewFolderDialog(val activity: BaseSimpleActivity, val path: String,
@Composable @Composable
fun CreateNewFolderAlertDialog( fun CreateNewFolderAlertDialog(
alertDialogState: AlertDialogState, alertDialogState: AlertDialogState,
modifier: Modifier = Modifier,
path: String, path: String,
modifier: Modifier = Modifier,
callback: (path: String) -> Unit callback: (path: String) -> Unit
) { ) {
val focusRequester = remember { FocusRequester() } val focusRequester = remember { FocusRequester() }
@ -209,8 +209,7 @@ private fun CreateNewFolderAlertDialogPreview() {
AppThemeSurface { AppThemeSurface {
CreateNewFolderAlertDialog( CreateNewFolderAlertDialog(
alertDialogState = rememberAlertDialogState(), alertDialogState = rememberAlertDialogState(),
path = "Internal/", path = "Internal/"
callback = {} ) {}
)
} }
} }

View file

@ -93,9 +93,9 @@ class FileConflictDialog(
@Composable @Composable
fun FileConflictAlertDialog( fun FileConflictAlertDialog(
alertDialogState: AlertDialogState, alertDialogState: AlertDialogState,
modifier: Modifier = Modifier,
fileDirItem: FileDirItemReadOnly, fileDirItem: FileDirItemReadOnly,
showApplyToAll: Boolean, showApplyToAll: Boolean,
modifier: Modifier = Modifier,
callback: (resolution: Int, applyForAll: Boolean) -> Unit callback: (resolution: Int, applyForAll: Boolean) -> Unit
) { ) {
val context = LocalContext.current val context = LocalContext.current
@ -207,8 +207,7 @@ private fun FileConflictAlertDialogPreview() {
FileConflictAlertDialog( FileConflictAlertDialog(
alertDialogState = rememberAlertDialogState(), alertDialogState = rememberAlertDialogState(),
fileDirItem = FileDirItem("", name = "test", children = 1).asReadOnly(), fileDirItem = FileDirItem("", name = "test", children = 1).asReadOnly(),
showApplyToAll = true, showApplyToAll = true
callback = { _, _ -> } ) { _, _ -> }
)
} }
} }

View file

@ -168,9 +168,9 @@ class LineColorPickerDialog(
@Composable @Composable
fun LineColorPickerAlertDialog( fun LineColorPickerAlertDialog(
alertDialogState: AlertDialogState, alertDialogState: AlertDialogState,
modifier: Modifier = Modifier,
@ColorInt color: Int, @ColorInt color: Int,
isPrimaryColorPicker: Boolean, isPrimaryColorPicker: Boolean,
modifier: Modifier = Modifier,
primaryColors: Int = R.array.md_primary_colors, primaryColors: Int = R.array.md_primary_colors,
appIconIDs: ArrayList<Int>? = null, appIconIDs: ArrayList<Int>? = null,
onActiveColorChange: (color: Int) -> Unit, onActiveColorChange: (color: Int) -> Unit,
@ -330,7 +330,7 @@ private fun LineColorPickerAlertDialogPreview() {
LineColorPickerAlertDialog(alertDialogState = rememberAlertDialogState(), LineColorPickerAlertDialog(alertDialogState = rememberAlertDialogState(),
color = R.color.color_primary, color = R.color.color_primary,
isPrimaryColorPicker = true, isPrimaryColorPicker = true,
onActiveColorChange = {}, onActiveColorChange = {}
onButtonPressed = { _, _ -> }) ) { _, _ -> }
} }
} }

View file

@ -38,8 +38,8 @@ class OpenDeviceSettingsDialog(val activity: BaseSimpleActivity, message: String
@Composable @Composable
fun OpenDeviceSettingsAlertDialog( fun OpenDeviceSettingsAlertDialog(
alertDialogState: AlertDialogState, alertDialogState: AlertDialogState,
modifier: Modifier = Modifier, message: String,
message: String modifier: Modifier = Modifier
) { ) {
val context = LocalContext.current val context = LocalContext.current

View file

@ -44,10 +44,10 @@ class PermissionRequiredDialog(
@Composable @Composable
fun PermissionRequiredAlertDialog( fun PermissionRequiredAlertDialog(
alertDialogState: AlertDialogState, alertDialogState: AlertDialogState,
modifier: Modifier = Modifier,
text: String, text: String,
positiveActionCallback: () -> Unit, modifier: Modifier = Modifier,
negativeActionCallback: (() -> Unit)? = null negativeActionCallback: (() -> Unit)? = null,
positiveActionCallback: () -> Unit
) { ) {
AlertDialog( AlertDialog(
containerColor = dialogContainerColor, containerColor = dialogContainerColor,
@ -95,8 +95,7 @@ private fun PermissionRequiredAlertDialogPreview() {
PermissionRequiredAlertDialog( PermissionRequiredAlertDialog(
alertDialogState = rememberAlertDialogState(), alertDialogState = rememberAlertDialogState(),
text = "Test", text = "Test",
positiveActionCallback = {},
negativeActionCallback = {} negativeActionCallback = {}
) ) {}
} }
} }

View file

@ -103,8 +103,8 @@ class RadioGroupDialog(
@Composable @Composable
fun RadioGroupAlertDialog( fun RadioGroupAlertDialog(
alertDialogState: AlertDialogState, alertDialogState: AlertDialogState,
modifier: Modifier = Modifier,
items: ImmutableList<RadioItem>, items: ImmutableList<RadioItem>,
modifier: Modifier = Modifier,
selectedItemId: Int = -1, selectedItemId: Int = -1,
titleId: Int = 0, titleId: Int = 0,
showOKButton: Boolean = false, showOKButton: Boolean = false,
@ -188,11 +188,10 @@ private fun RadioGroupDialogAlertDialogPreview(@PreviewParameter(BooleanPreviewP
RadioItem(2, "Test 2"), RadioItem(2, "Test 2"),
RadioItem(3, "Test 3"), RadioItem(3, "Test 3"),
).toImmutableList(), ).toImmutableList(),
callback = {}, selectedItemId = 1,
cancelCallback = {},
showOKButton = showOKButton,
titleId = R.string.title, titleId = R.string.title,
selectedItemId = 1 showOKButton = showOKButton,
) cancelCallback = {}
) {}
} }
} }

View file

@ -138,8 +138,8 @@ class WritePermissionDialog(activity: Activity, val writePermissionDialogMode: W
@Composable @Composable
fun WritePermissionAlertDialog( fun WritePermissionAlertDialog(
alertDialogState: AlertDialogState, alertDialogState: AlertDialogState,
modifier: Modifier = Modifier,
writePermissionDialogMode: WritePermissionDialog.WritePermissionDialogMode, writePermissionDialogMode: WritePermissionDialog.WritePermissionDialogMode,
modifier: Modifier = Modifier,
callback: () -> Unit, callback: () -> Unit,
onCancelCallback: () -> Unit onCancelCallback: () -> Unit
) { ) {
@ -316,8 +316,7 @@ private fun WritePermissionAlertDialogPreview(@PreviewParameter(WritePermissionD
WritePermissionAlertDialog( WritePermissionAlertDialog(
alertDialogState = rememberAlertDialogState(), alertDialogState = rememberAlertDialogState(),
writePermissionDialogMode = WritePermissionDialog.WritePermissionDialogMode.OpenDocumentTreeSDK30("."), writePermissionDialogMode = WritePermissionDialog.WritePermissionDialogMode.OpenDocumentTreeSDK30("."),
callback = {}, callback = {}
onCancelCallback = {} ) {}
)
} }
} }

View file

@ -101,7 +101,7 @@ class TestDialogActivity : ComponentActivity() {
@Composable @Composable
private fun getChooserBottomSheetDialogState() = rememberBottomSheetDialogState().apply { private fun getChooserBottomSheetDialogState() = rememberBottomSheetDialogState().apply {
DialogMember { state, insets -> BottomSheetContent {
val list = remember { val list = remember {
listOf( listOf(
SimpleListItem(1, R.string.record_video, R.drawable.ic_camera_vector), SimpleListItem(1, R.string.record_video, R.drawable.ic_camera_vector),
@ -110,13 +110,11 @@ class TestDialogActivity : ComponentActivity() {
).toImmutableList() ).toImmutableList()
} }
ChooserBottomSheetDialog( ChooserBottomSheetDialog(
bottomSheetDialogState = this, bottomSheetDialogState = this@apply,
items = list, items = list
windowInsets = insets, ) {
bottomSheetState = state, toast("Selected ${getString(it.textRes)}")
onItemClicked = { }
toast("Selected ${getString(it.textRes)}")
})
} }
} }
@ -151,9 +149,8 @@ class TestDialogActivity : ComponentActivity() {
WritePermissionAlertDialog( WritePermissionAlertDialog(
alertDialogState = this, alertDialogState = this,
writePermissionDialogMode = WritePermissionDialog.WritePermissionDialogMode.OpenDocumentTreeSDK30("."), writePermissionDialogMode = WritePermissionDialog.WritePermissionDialogMode.OpenDocumentTreeSDK30("."),
callback = {}, callback = {}
onCancelCallback = {} ) {}
)
} }
} }
@ -206,16 +203,15 @@ class TestDialogActivity : ComponentActivity() {
RadioItem(6, "Test 6"), RadioItem(6, "Test 6"),
RadioItem(6, "Test 7"), RadioItem(6, "Test 7"),
).toImmutableList(), ).toImmutableList(),
showOKButton = true,
selectedItemId = 2, selectedItemId = 2,
titleId = R.string.title,
showOKButton = true,
cancelCallback = { cancelCallback = {
Log.d("getRadioGroupDialogAlertDialogState", "cancelCallback") Log.d("getRadioGroupDialogAlertDialogState", "cancelCallback")
}, }
callback = { ) {
Log.d("getRadioGroupDialogAlertDialogState", "Selected $it") Log.d("getRadioGroupDialogAlertDialogState", "Selected $it")
}, }
titleId = R.string.title
)
} }
} }
@ -244,11 +240,11 @@ class TestDialogActivity : ComponentActivity() {
alertDialogState = this, alertDialogState = this,
color = baseConfig.customPrimaryColor, color = baseConfig.customPrimaryColor,
isPrimaryColorPicker = true, isPrimaryColorPicker = true,
onButtonPressed = { wasPositivePressed, color -> onActiveColorChange = { color ->
Log.d("getLineColorPickerAlertDialogState", "wasPositivePressed=$wasPositivePressed color=${color.toHex()}")
}, onActiveColorChange = { color ->
Log.d("getLineColorPickerAlertDialogState", "onActiveColorChange=${color.toHex()}") 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, alertDialogState = this,
color = config.customTextColor, color = config.customTextColor,
removeDimmedBackground = true, removeDimmedBackground = true,
onButtonPressed = { wasPositivePressed, color -> onActiveColorChange = { color ->
Log.d("getColorPickerAlertDialogState", "wasPositivePressed=$wasPositivePressed color=${color.toHex()}")
}, onActiveColorChange = { color ->
Log.d("getColorPickerAlertDialogState", "onActiveColorChange=${color.toHex()}") Log.d("getColorPickerAlertDialogState", "onActiveColorChange=${color.toHex()}")
}) }) { wasPositivePressed, color ->
Log.d("getColorPickerAlertDialogState", "wasPositivePressed=$wasPositivePressed color=${color.toHex()}")
}
} }
} }
@ -287,7 +283,7 @@ class TestDialogActivity : ComponentActivity() {
@Composable @Composable
private fun getCallConfirmationAlertDialogState() = rememberAlertDialogState().apply { private fun getCallConfirmationAlertDialogState() = rememberAlertDialogState().apply {
DialogMember { DialogMember {
CallConfirmationAlertDialog(alertDialogState = this, callee = "Simple Mobile Tools", callback = {}) CallConfirmationAlertDialog(alertDialogState = this, callee = "Simple Mobile Tools") {}
} }
} }
@ -310,7 +306,7 @@ class TestDialogActivity : ComponentActivity() {
@Composable @Composable
private fun getConfirmationAlertDialogState() = rememberAlertDialogState().apply { private fun getConfirmationAlertDialogState() = rememberAlertDialogState().apply {
DialogMember { 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() = private fun getAppSideLoadedDialogState() =
rememberAlertDialogState().apply { rememberAlertDialogState().apply {
DialogMember { DialogMember {
AppSideLoadedAlertDialog(onDownloadClick = {}, onCancelClick = {}, alertDialogState = this) AppSideLoadedAlertDialog(alertDialogState = this, onDownloadClick = {}) {}
} }
} }
@ -326,7 +322,7 @@ class TestDialogActivity : ComponentActivity() {
private fun getAddBlockedNumberDialogState() = private fun getAddBlockedNumberDialogState() =
rememberAlertDialogState().apply { rememberAlertDialogState().apply {
DialogMember { DialogMember {
AddOrEditBlockedNumberAlertDialog(blockedNumber = null, deleteBlockedNumber = {}, addBlockedNumber = {}, alertDialogState = this) AddOrEditBlockedNumberAlertDialog(alertDialogState = this, blockedNumber = null, deleteBlockedNumber = {}) {}
} }
} }
@ -334,7 +330,7 @@ class TestDialogActivity : ComponentActivity() {
private fun getConfirmationAdvancedAlertDialogState() = private fun getConfirmationAdvancedAlertDialogState() =
rememberAlertDialogState().apply { rememberAlertDialogState().apply {
DialogMember { DialogMember {
ConfirmationAdvancedAlertDialog(alertDialogState = this, callback = {}) ConfirmationAdvancedAlertDialog(alertDialogState = this) {}
} }
} }
@ -344,9 +340,8 @@ class TestDialogActivity : ComponentActivity() {
DialogMember { DialogMember {
PermissionRequiredAlertDialog( PermissionRequiredAlertDialog(
alertDialogState = this, alertDialogState = this,
text = "Test permission", text = "Test permission"
positiveActionCallback = {} ) {}
)
} }
} }