~cytrogen/fluent-reader-mobile

ref: b39dfad9d08734897c1271b30d4ce8decea2bdd3 fluent-reader-mobile/lib/components/mark_all_action_sheet.dart -rw-r--r-- 1.7 KiB
b39dfad9 — Preckrasno Add Ukrainian (ua) translation (#53) 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import 'package:fluent_reader_lite/components/responsive_action_sheet.dart';
import 'package:fluent_reader_lite/generated/l10n.dart';
import 'package:fluent_reader_lite/utils/global.dart';
import 'package:flutter/cupertino.dart';

class MarkAllActionSheet extends StatelessWidget {
  final Set<String> sids;

  MarkAllActionSheet(this.sids, {Key key}) : super(key: key);

  DateTime _offset(int days) {
    return DateTime.now().subtract(Duration(days: days));
  }

  void _markAll(BuildContext context, {DateTime date}) {
    Navigator.of(context, rootNavigator: true).pop();
    Global.itemsModel.markAllRead(sids, date: date);
  }

  @override
  Widget build(BuildContext context) {
    final sheet = CupertinoActionSheet(
      title: Text(S.of(context).markAll),
      actions: [
        CupertinoActionSheetAction(
          isDestructiveAction: true,
          child: Text(S.of(context).allArticles),
          onPressed: () { _markAll(context); },
        ),
        CupertinoActionSheetAction(
          child: Text(S.of(context).daysAgo(1)),
          onPressed: () { _markAll(context, date: _offset(1)); },
        ),
        CupertinoActionSheetAction(
          child: Text(S.of(context).daysAgo(3)),
          onPressed: () { _markAll(context, date: _offset(3)); },
        ),
        CupertinoActionSheetAction(
          child: Text(S.of(context).daysAgo(7)),
          onPressed: () { _markAll(context, date: _offset(7)); },
        ),
      ],
      cancelButton: CupertinoActionSheetAction(
        child: Text(S.of(context).cancel),
        onPressed: () { 
          Navigator.of(context, rootNavigator: true).pop();
        },
      ),
    ); 
    return ResponsiveActionSheet(sheet);    
  }
}