kopia lustrzana https://gitlab.com/mysocialportal/relatica
Add buttons for pre-defined focus mode times and make click out of bounds dismiss
rodzic
0e5d7b8c79
commit
6ff5092d60
|
@ -8,6 +8,8 @@ import '../riverpod_controllers/focus_mode.dart';
|
|||
import '../routes.dart';
|
||||
import 'padding.dart';
|
||||
|
||||
const foreverDuration = Duration(days: 10000);
|
||||
|
||||
class FocusModeMenuItem extends ConsumerWidget {
|
||||
const FocusModeMenuItem({super.key});
|
||||
|
||||
|
@ -29,7 +31,10 @@ class FocusModeMenuItem extends ConsumerWidget {
|
|||
if (duration == null) {
|
||||
return;
|
||||
}
|
||||
final disableTime = DateTime.now().add(duration);
|
||||
|
||||
final disableTime = duration == foreverDuration
|
||||
? null
|
||||
: DateTime.now().add(duration);
|
||||
final update = FocusModeData(true, disableTime: disableTime);
|
||||
ref.read(focusModeProvider.notifier).setMode(update);
|
||||
if (context.mounted) {
|
||||
|
@ -51,7 +56,7 @@ Future<Duration?> _chooseDuration(
|
|||
|
||||
return showDialog<Duration?>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
barrierDismissible: true,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
content: Column(
|
||||
|
@ -65,6 +70,88 @@ Future<Duration?> _chooseDuration(
|
|||
.copyWith(fontWeight: FontWeight.bold),
|
||||
),
|
||||
const VerticalPadding(),
|
||||
Wrap(
|
||||
runSpacing: 10.0,
|
||||
spacing: 10.0,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
child: const Text('15 minutes'),
|
||||
onPressed: () {
|
||||
Navigator.pop(
|
||||
context,
|
||||
const Duration(
|
||||
minutes: 15,
|
||||
),
|
||||
); // showDialog() returns true
|
||||
},
|
||||
),
|
||||
ElevatedButton(
|
||||
child: const Text('30 minutes'),
|
||||
onPressed: () {
|
||||
Navigator.pop(
|
||||
context,
|
||||
const Duration(
|
||||
minutes: 30,
|
||||
),
|
||||
); // showDialog() returns true
|
||||
},
|
||||
),
|
||||
ElevatedButton(
|
||||
child: const Text('1 hour'),
|
||||
onPressed: () {
|
||||
Navigator.pop(
|
||||
context,
|
||||
const Duration(
|
||||
hours: 1,
|
||||
),
|
||||
); // showDialog() returns true
|
||||
},
|
||||
),
|
||||
ElevatedButton(
|
||||
child: const Text('6 hours'),
|
||||
onPressed: () {
|
||||
Navigator.pop(
|
||||
context,
|
||||
const Duration(
|
||||
hours: 6,
|
||||
),
|
||||
); // showDialog() returns true
|
||||
},
|
||||
),
|
||||
ElevatedButton(
|
||||
child: const Text('12 hours'),
|
||||
onPressed: () {
|
||||
Navigator.pop(
|
||||
context,
|
||||
const Duration(
|
||||
hours: 12,
|
||||
),
|
||||
); // showDialog() returns true
|
||||
},
|
||||
),
|
||||
ElevatedButton(
|
||||
child: const Text('1 day'),
|
||||
onPressed: () {
|
||||
Navigator.pop(
|
||||
context,
|
||||
const Duration(
|
||||
days: 1,
|
||||
),
|
||||
); // showDialog() returns true
|
||||
},
|
||||
),
|
||||
ElevatedButton(
|
||||
child: const Text('Forever'),
|
||||
onPressed: () {
|
||||
Navigator.pop(
|
||||
context,
|
||||
foreverDuration,
|
||||
); // showDialog() returns true
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
const VerticalPadding(),
|
||||
SizedBox(
|
||||
height: 100,
|
||||
child: Row(
|
||||
|
@ -107,7 +194,7 @@ Future<Duration?> _chooseDuration(
|
|||
),
|
||||
); // showDialog() returns true
|
||||
},
|
||||
)
|
||||
),
|
||||
]);
|
||||
},
|
||||
);
|
||||
|
|
Ładowanie…
Reference in New Issue