-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
379 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
...n/kotlin/net/primal/android/profile/details/ui/ConfirmFollowUnfollowProfileAlertDialog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package net.primal.android.profile.details.ui | ||
|
||
import androidx.compose.material3.AlertDialog | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.TextButton | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.res.stringResource | ||
import net.primal.android.R | ||
import net.primal.android.theme.AppTheme | ||
|
||
@Composable | ||
fun ConfirmFollowUnfollowProfileAlertDialog( | ||
onClose: () -> Unit, | ||
onActionConfirmed: () -> Unit, | ||
profileAction: ProfileAction, | ||
) { | ||
val messages = when (profileAction) { | ||
ProfileAction.Follow -> { | ||
ApprovalMessages( | ||
title = stringResource(id = R.string.context_confirm_follow_title), | ||
text = stringResource(id = R.string.context_confirm_follow_text), | ||
positive = stringResource(id = R.string.context_confirm_follow_positive), | ||
negative = stringResource(id = R.string.context_confirm_follow_negative), | ||
) | ||
} | ||
ProfileAction.Unfollow -> { | ||
ApprovalMessages( | ||
title = stringResource(id = R.string.context_confirm_unfollow_title), | ||
text = stringResource(id = R.string.context_confirm_unfollow_text), | ||
positive = stringResource(id = R.string.context_confirm_unfollow_positive), | ||
negative = stringResource(id = R.string.context_confirm_unfollow_negative), | ||
) | ||
} | ||
} | ||
AlertDialog( | ||
containerColor = AppTheme.colorScheme.surfaceVariant, | ||
onDismissRequest = onClose, | ||
title = { | ||
Text( | ||
text = messages.title, | ||
style = AppTheme.typography.titleLarge, | ||
) | ||
}, | ||
text = { | ||
Text( | ||
text = messages.text, | ||
style = AppTheme.typography.bodyLarge, | ||
) | ||
}, | ||
dismissButton = { | ||
TextButton(onClick = onClose) { | ||
Text(text = messages.negative) | ||
} | ||
}, | ||
confirmButton = { | ||
TextButton(onClick = onActionConfirmed) { | ||
Text( | ||
text = messages.positive, | ||
) | ||
} | ||
}, | ||
) | ||
} | ||
|
||
private data class ApprovalMessages( | ||
val title: String, | ||
val text: String, | ||
val positive: String, | ||
val negative: String, | ||
) | ||
|
||
enum class ProfileAction { | ||
Follow, | ||
Unfollow, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.