Skip to content

Commit

Permalink
Move backup call to BackupBloc
Browse files Browse the repository at this point in the history
  • Loading branch information
erdemyerebasmaz committed Oct 4, 2023
1 parent 8a532ce commit a0ca68a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
3 changes: 3 additions & 0 deletions lib/bloc/backup/backup_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@ class BackupBloc extends Cubit<BackupState?> {
emit(BackupState(status: BackupStatus.FAILED));
});
}

/// Start the backup process
Future<void> backup() async => await _breezLib.backup();
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class AccountRequiredActionsIndicator extends StatelessWidget {
useRootNavigator: false,
useSafeArea: false,
context: context,
builder: (_) => EnableBackupDialog(context, ServiceInjector().breezSDK),
builder: (_) => const EnableBackupDialog(),
);
},
),
Expand Down
18 changes: 6 additions & 12 deletions lib/routes/home/widgets/enable_backup_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import 'package:auto_size_text/auto_size_text.dart';
import 'package:breez_sdk/breez_bridge.dart' as bridge;
import 'package:breez_translations/breez_translations_locales.dart';
import 'package:c_breez/bloc/backup/backup_bloc.dart';
import 'package:c_breez/utils/min_font_size.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

class EnableBackupDialog extends StatefulWidget {
final BuildContext context;
final bridge.BreezSDK breezLib;

const EnableBackupDialog(this.context, this.breezLib);
const EnableBackupDialog();

@override
EnableBackupDialogState createState() {
Expand All @@ -20,10 +18,6 @@ class EnableBackupDialogState extends State<EnableBackupDialog> {
final AutoSizeGroup _autoSizeGroup = AutoSizeGroup();
@override
Widget build(BuildContext context) {
return createEnableBackupDialog(context);
}

Widget createEnableBackupDialog(BuildContext context) {
final texts = context.texts();
return Theme(
data: Theme.of(context).copyWith(
Expand Down Expand Up @@ -57,7 +51,7 @@ class EnableBackupDialogState extends State<EnableBackupDialog> {
),
actions: [
TextButton(
onPressed: () => Navigator.pop(widget.context),
onPressed: () => Navigator.pop(context),
child: Text(
texts.backup_dialog_option_cancel,
style: Theme.of(context).primaryTextTheme.labelLarge,
Expand All @@ -66,8 +60,8 @@ class EnableBackupDialogState extends State<EnableBackupDialog> {
),
TextButton(
onPressed: (() {
Navigator.pop(widget.context);
widget.breezLib.backup();
Navigator.pop(context);
context.read<BackupBloc>().backup();
}),
child: Text(
texts.backup_dialog_option_ok_default,
Expand Down

0 comments on commit a0ca68a

Please sign in to comment.