Skip to content

Commit

Permalink
🎨 Make the hive boxes clearing can use no context.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexV525 committed Feb 18, 2020
1 parent 76af1d5 commit 201bf9d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions lib/constants/hive_boxes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,16 @@ class HiveBoxes {
changelogBox = await Hive.openBox<ChangeLog>('openjmu_changelog');
}

static void clearBoxes(context) async {
final confirm = await ConfirmationBottomSheet.show(
context,
title: '清除应用数据',
showConfirm: true,
content: '清除数据会将您的所有应用内容(包括设置、应用消息)清除。\n确定继续吗?',
);
static void clearBoxes({context}) async {
bool confirm = true;
if (context != null) {
confirm = await ConfirmationBottomSheet.show(
context,
title: '清除应用数据',
showConfirm: true,
content: '清除数据会将您的所有应用内容(包括设置、应用消息)清除。\n确定继续吗?',
);
}
if (confirm) {
debugPrint('Clearing Hive Boxes...');
await appMessagesBox?.clear();
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/home/my_info_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ class MyInfoPageState extends State<MyInfoPage> {
color: Theme.of(context).primaryColor,
),
child: GestureDetector(
onLongPress: () => HiveBoxes.clearBoxes(context),
onLongPress: () => HiveBoxes.clearBoxes(context: context),
child: Text(
'(DANGER)\n清除应用数据',
style: TextStyle(
Expand Down

0 comments on commit 201bf9d

Please sign in to comment.