diff --git a/android/app/src/main/java/com/masterdns/vpn/ui/profiles/ProfilesScreen.kt b/android/app/src/main/java/com/masterdns/vpn/ui/profiles/ProfilesScreen.kt index bb76830..d7175b2 100644 --- a/android/app/src/main/java/com/masterdns/vpn/ui/profiles/ProfilesScreen.kt +++ b/android/app/src/main/java/com/masterdns/vpn/ui/profiles/ProfilesScreen.kt @@ -50,6 +50,7 @@ fun ProfilesScreen( var editingProfile by remember { mutableStateOf(null) } var importedDraft by remember { mutableStateOf(null) } var importedResolvers by remember { mutableStateOf(null) } + var profilePendingDelete by remember { mutableStateOf(null) } val context = androidx.compose.ui.platform.LocalContext.current val snackbarHostState = remember { SnackbarHostState() } val scope = rememberCoroutineScope() @@ -195,12 +196,42 @@ fun ProfilesScreen( editingProfile = profile showEditor = true }, - onDelete = { viewModel.deleteProfile(profile) } + onDelete = { profilePendingDelete = profile } ) } } } } + + profilePendingDelete?.let { profile -> + AlertDialog( + onDismissRequest = { profilePendingDelete = null }, + title = { Text(stringResource(R.string.profiles_delete_confirm_title)) }, + text = { + Text( + stringResource( + R.string.profiles_delete_confirm_message, + profile.name.ifBlank { stringResource(R.string.profiles_dialog_new_title) } + ) + ) + }, + confirmButton = { + TextButton( + onClick = { + viewModel.deleteProfile(profile) + profilePendingDelete = null + } + ) { + Text(stringResource(R.string.profiles_delete)) + } + }, + dismissButton = { + TextButton(onClick = { profilePendingDelete = null }) { + Text(stringResource(R.string.action_cancel)) + } + } + ) + } } @Composable diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index 64dc1e5..69f7f50 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -78,6 +78,8 @@ Edit Settings Delete + Delete profile? + Delete "%1$s"? This cannot be undone. Edit Profile New Profile Profile Name