Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow checking the checkbox by tapping on the corresponding label #1294

Merged
merged 1 commit into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 26 additions & 21 deletions lib/routes/initial_walkthrough/dialogs/beta_warning_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,29 +78,28 @@ class BetaWarningDialogState extends State<BetaWarningDialog> {
),
Padding(
padding: const EdgeInsets.only(top: 16.0, bottom: 0.0),
child: Row(
children: [
Theme(
data: themeData.copyWith(
unselectedWidgetColor: themeData.textTheme.labelLarge.color,
),
child: Checkbox(
activeColor: themeData.canvasColor,
value: _isUnderstood,
onChanged: (value) {
setState(() {
_isUnderstood = value;
});
},
child: GestureDetector(
onTap: () => _setIsUnderstood(),
child: Row(
children: [
Theme(
data: themeData.copyWith(
unselectedWidgetColor: themeData.textTheme.labelLarge.color,
),
child: Checkbox(
activeColor: themeData.canvasColor,
value: _isUnderstood,
onChanged: (_) => _setIsUnderstood(),
),
),
),
Text(
texts.beta_warning_understand,
style: themeData.primaryTextTheme.displaySmall.copyWith(
fontSize: 16,
Text(
texts.beta_warning_understand,
style: themeData.primaryTextTheme.displaySmall.copyWith(
fontSize: 16,
),
),
),
],
],
),
),
),
Visibility(
Expand All @@ -122,4 +121,10 @@ class BetaWarningDialogState extends State<BetaWarningDialog> {
),
];
}

void _setIsUnderstood() {
setState(() {
_isUnderstood = !_isUnderstood;
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,32 +81,39 @@ class BackupPhraseGeneratorConfirmationPageState extends State<BackupPhraseGener
final texts = context.texts();
return Expanded(
flex: 1,
child: Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Theme(
data: themeData.copyWith(
unselectedWidgetColor: Colors.white,
child: GestureDetector(
onTap: () => _setIsUnderstood(),
child: Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Theme(
data: themeData.copyWith(
unselectedWidgetColor: Colors.white,
),
child: Checkbox(
activeColor: Colors.white,
checkColor: themeData.canvasColor,
value: _isUnderstood,
onChanged: (_) => _setIsUnderstood(),
),
),
child: Checkbox(
activeColor: Colors.white,
checkColor: themeData.canvasColor,
value: _isUnderstood,
onChanged: (value) => setState(() {
_isUnderstood = value;
}),
Text(
texts.backup_phrase_action_confirm,
style: theme.backupPhraseConfirmationTextStyle,
),
),
Text(
texts.backup_phrase_action_confirm,
style: theme.backupPhraseConfirmationTextStyle,
),
],
],
),
),
);
}

void _setIsUnderstood() {
setState(() {
_isUnderstood = !_isUnderstood;
});
}

Widget _buildNextBtn(BuildContext context, bool isUnderstood) {
final texts = context.texts();
return Padding(
Expand Down
53 changes: 29 additions & 24 deletions lib/widgets/enable_backup_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ class _DoNotPromptAgainCheckbox extends StatefulWidget {
class _DoNotPromptAgainCheckboxState extends State<_DoNotPromptAgainCheckbox> {
@override
Widget build(BuildContext context) {
final backupBloc = AppBlocsProvider.of<BackupBloc>(context);
final texts = context.texts();
final themeData = Theme.of(context);
final contentTextStyle = themeData.primaryTextTheme.displaySmall.copyWith(
Expand All @@ -133,36 +132,42 @@ class _DoNotPromptAgainCheckboxState extends State<_DoNotPromptAgainCheckbox> {

return Padding(
padding: const EdgeInsets.only(top: 16.0),
child: Row(
children: <Widget>[
Theme(
data: themeData.copyWith(
unselectedWidgetColor: themeData.textTheme.labelLarge.color,
),
child: Checkbox(
activeColor: Colors.white,
checkColor: themeData.canvasColor,
value: !widget.backupSettings.promptOnError,
onChanged: (v) {
backupBloc.backupSettingsSink.add(
widget.backupSettings.copyWith(
promptOnError: !v,
),
);
},
child: GestureDetector(
onTap: () => _setDoNotPromptAgain(),
child: Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Theme(
data: themeData.copyWith(
unselectedWidgetColor: themeData.textTheme.labelLarge.color,
),
child: Checkbox(
activeColor: Colors.white,
checkColor: themeData.canvasColor,
value: !widget.backupSettings.promptOnError,
onChanged: (_) => _setDoNotPromptAgain(),
),
),
),
Expanded(
child: AutoSizeText(
AutoSizeText(
texts.backup_dialog_do_not_prompt_again,
style: contentTextStyle,
maxLines: 1,
minFontSize: MinFontSize(context).minFontSize,
stepGranularity: 0.1,
group: widget.autoSizeGroup,
),
)
],
)
],
),
),
);
}

void _setDoNotPromptAgain() {
final backupBloc = AppBlocsProvider.of<BackupBloc>(context);
backupBloc.backupSettingsSink.add(
widget.backupSettings.copyWith(
promptOnError: !widget.backupSettings.promptOnError,
),
);
}
Expand Down
51 changes: 28 additions & 23 deletions lib/widgets/payment_failed_report_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class PaymentFailedReportDialog extends StatefulWidget {
}

class PaymentFailedReportDialogState extends State<PaymentFailedReportDialog> {
bool _doneAsk;
bool _dontAsk;
AccountSettings _settings;
StreamSubscription<AccountSettings> _settingsSubscription;

Expand Down Expand Up @@ -74,29 +74,28 @@ class PaymentFailedReportDialogState extends State<PaymentFailedReportDialog> {
),
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: Row(
children: [
Theme(
data: themeData.copyWith(
unselectedWidgetColor: themeData.textTheme.labelLarge.color,
child: GestureDetector(
onTap: () => _setDontAsk(),
child: Row(
children: [
Theme(
data: themeData.copyWith(
unselectedWidgetColor: themeData.textTheme.labelLarge.color,
),
child: Checkbox(
activeColor: themeData.canvasColor,
value: _dontAsk ?? _settings.failedPaymentBehavior != BugReportBehavior.PROMPT,
onChanged: (_) => _setDontAsk(),
),
),
child: Checkbox(
activeColor: themeData.canvasColor,
value: _doneAsk ?? _settings.failedPaymentBehavior != BugReportBehavior.PROMPT,
onChanged: (v) {
setState(() {
_doneAsk = v;
});
},
Text(
texts.payment_failed_report_dialog_do_not_ask_again,
style: themeData.primaryTextTheme.displaySmall.copyWith(
fontSize: 16,
),
),
),
Text(
texts.payment_failed_report_dialog_do_not_ask_again,
style: themeData.primaryTextTheme.displaySmall.copyWith(
fontSize: 16,
),
),
],
],
),
),
),
],
Expand Down Expand Up @@ -127,8 +126,14 @@ class PaymentFailedReportDialogState extends State<PaymentFailedReportDialog> {
);
}

void _setDontAsk() {
setState(() {
_dontAsk = !_dontAsk;
});
}

void onSubmit(bool yesNo) {
var dontAsk = _doneAsk ?? _settings.failedPaymentBehavior != BugReportBehavior.PROMPT;
var dontAsk = _dontAsk ?? _settings.failedPaymentBehavior != BugReportBehavior.PROMPT;
if (dontAsk) {
widget._accountBloc.accountSettingsSink.add(_settings.copyWith(
failedPaymentBehavior: yesNo ? BugReportBehavior.SEND_REPORT : BugReportBehavior.IGNORE));
Expand Down
Loading