1package com.peachpasswords.ui.pairing23import androidx.activity.compose.BackHandler4import androidx.compose.material3.AlertDialog5import androidx.compose.material3.Text6import androidx.compose.material3.TextButton7import androidx.compose.runtime.Composable8import androidx.compose.ui.text.font.FontWeight9import com.peachpasswords.ui.theme.LocalPeachAccent10import com.peachpasswords.ui.theme.PeachType1112enum class BackgroundSyncAction { ALLOW, MANUAL_ONLY, DISMISS }1314internal fun shouldPromptForBackgroundSync(pairingSucceeded: Boolean): Boolean = pairingSucceeded1516internal fun backgroundSyncChoice(action: BackgroundSyncAction): Boolean =17 action != BackgroundSyncAction.MANUAL_ONLY1819@Composable20fun BackgroundSyncDialog(21 onChoice: (Boolean) -> Unit,22) {23 24 BackHandler { onChoice(backgroundSyncChoice(BackgroundSyncAction.DISMISS)) }25 AlertDialog(26 onDismissRequest = { onChoice(backgroundSyncChoice(BackgroundSyncAction.DISMISS)) },27 title = {28 Text("Sync in the background?", fontFamily = PeachType.Display)29 },30 text = {31 Text(32 "Allow Peach to keep your devices in step in the background, even when the app isn't open. " +33 "This keeps a small notification visible while sync is active and uses a tiny bit of battery.",34 fontFamily = PeachType.Body,35 )36 },37 confirmButton = {38 TextButton(onClick = { onChoice(backgroundSyncChoice(BackgroundSyncAction.ALLOW)) }) {39 Text(40 "Allow background sync",41 color = LocalPeachAccent.current,42 fontWeight = FontWeight.Bold,43 )44 }45 },46 dismissButton = {47 TextButton(onClick = { onChoice(backgroundSyncChoice(BackgroundSyncAction.MANUAL_ONLY)) }) {48 Text("Sync manually only")49 }50 },51 )52}