refactor: use by remember and private the functions.

Signed-off-by: KaiserBh <kaiserbh@proton.me>
This commit is contained in:
KaiserBh 2023-11-20 06:02:51 +11:00
parent 389336b823
commit d17aa201d5
No known key found for this signature in database
GPG Key ID: 14D73B142042BBA9

View File

@ -392,14 +392,14 @@ private fun getGoogleDrivePreferences(): List<Preference> {
@Composable @Composable
private fun getGoogleDrivePurge(): Preference.PreferenceItem.TextPreference { private fun getGoogleDrivePurge(): Preference.PreferenceItem.TextPreference {
val scope = rememberCoroutineScope() val scope = rememberCoroutineScope()
val showPurgeDialog = remember { mutableStateOf(false) }
val context = LocalContext.current val context = LocalContext.current
val googleDriveSync = remember { GoogleDriveSyncService(context) } val googleDriveSync = remember { GoogleDriveSyncService(context) }
var showPurgeDialog by remember { mutableStateOf(false) }
if (showPurgeDialog.value) { if (showPurgeDialog) {
PurgeConfirmationDialog( PurgeConfirmationDialog(
onConfirm = { onConfirm = {
showPurgeDialog.value = false showPurgeDialog = false
scope.launch { scope.launch {
val result = googleDriveSync.deleteSyncDataFromGoogleDrive() val result = googleDriveSync.deleteSyncDataFromGoogleDrive()
when (result) { when (result) {
@ -415,18 +415,18 @@ private fun getGoogleDrivePurge(): Preference.PreferenceItem.TextPreference {
} }
} }
}, },
onDismissRequest = { showPurgeDialog.value = false }, onDismissRequest = { showPurgeDialog = false },
) )
} }
return Preference.PreferenceItem.TextPreference( return Preference.PreferenceItem.TextPreference(
title = stringResource(MR.strings.pref_google_drive_purge_sync_data), title = stringResource(MR.strings.pref_google_drive_purge_sync_data),
onClick = { showPurgeDialog.value = true }, onClick = { showPurgeDialog = true },
) )
} }
@Composable @Composable
fun PurgeConfirmationDialog( private fun PurgeConfirmationDialog(
onConfirm: () -> Unit, onConfirm: () -> Unit,
onDismissRequest: () -> Unit, onDismissRequest: () -> Unit,
) { ) {
@ -543,7 +543,7 @@ private fun getAutomaticSyncGroup(syncPreferences: SyncPreferences): Preference.
} }
@Composable @Composable
fun SyncConfirmationDialog( private fun SyncConfirmationDialog(
onConfirm: () -> Unit, onConfirm: () -> Unit,
onDismissRequest: () -> Unit, onDismissRequest: () -> Unit,
) { ) {