Add config option reset

This commit is contained in:
problematicconsumer
2023-12-12 18:07:02 +03:30
parent 4c2a412820
commit 5e436e3f13
8 changed files with 84 additions and 24 deletions

View File

@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:gap/gap.dart';
import 'package:hiddify/core/localization/translations.dart';
import 'package:hiddify/core/model/failures.dart';
import 'package:hiddify/core/model/range.dart';
import 'package:hiddify/features/config_option/model/config_option_entity.dart';
import 'package:hiddify/features/config_option/model/config_option_patch.dart';
@@ -45,6 +46,14 @@ class ConfigOptionsPage extends HookConsumerWidget {
);
},
),
PopupMenuItem(
child: Text(t.settings.config.resetBtn),
onTap: () async {
await ref
.read(configOptionNotifierProvider.notifier)
.resetOption();
},
),
];
},
),
@@ -377,7 +386,26 @@ class ConfigOptionsPage extends HookConsumerWidget {
const Gap(24),
],
),
// TODO show appropriate error/loading widgets
AsyncError(:final error) => Center(
child: SingleChildScrollView(
child: Column(
children: [
const Icon(Icons.error),
const Gap(2),
Text(t.presentShortError(error)),
const Gap(2),
TextButton(
onPressed: () async {
await ref
.read(configOptionNotifierProvider.notifier)
.resetOption();
},
child: Text(t.settings.config.resetBtn),
),
],
),
),
),
_ => const SizedBox(),
},
);