@@ -5,6 +5,7 @@ import 'package:pikapika/screens/components/ComicList.dart';
5
5
import 'package:pikapika/screens/components/CommonData.dart' ;
6
6
import 'package:pikapika/screens/components/ContentBuilder.dart' ;
7
7
8
+ import '../basic/config/Address.dart' ;
8
9
import 'components/Badge.dart' ;
9
10
import 'components/Common.dart' ;
10
11
@@ -71,36 +72,75 @@ class ComicSubscribesScreen extends StatefulWidget {
71
72
}
72
73
73
74
class _ComicSubscribesScreenState extends State <ComicSubscribesScreen > {
74
- Future <List <ComicSubscribe >> _future = method.allSubscribed ();
75
- Key _key = UniqueKey ();
75
+ @override
76
+ void initState () {
77
+ super .initState ();
78
+ subscribedEvent.subscribe (_setState);
79
+ }
80
+
81
+ @override
82
+ void dispose () {
83
+ subscribedEvent.unsubscribe (_setState);
84
+ super .dispose ();
85
+ }
86
+
87
+ void _setState (_) {
88
+ setState (() {});
89
+ }
76
90
77
91
@override
78
92
Widget build (BuildContext context) {
79
93
return Scaffold (
80
94
appBar: AppBar (
81
- title: const Text ('订阅 ' ),
95
+ title: const Text ('更新提醒 ' ),
82
96
actions: [
83
97
commonPopMenu (context),
98
+ addressPopMenu (context),
99
+ _popMenu (context),
84
100
],
85
101
),
86
- body: ContentBuilder (
87
- future: _future,
88
- key: _key,
89
- onRefresh: () async {
90
- setState (() {
91
- _future = method.allSubscribed ();
92
- _key = UniqueKey ();
93
- });
94
- },
95
- successBuilder: (BuildContext context,
96
- AsyncSnapshot <List <ComicSubscribe >> snapshot) {
97
- List <ComicSimple > comicList = [];
98
- for (var comicSubscribe in snapshot.requireData) {
99
- comicList.add (ComicSimple .fromJson (comicSubscribe.toSimpleJson ()));
100
- }
101
- return ComicList (comicList);
102
- },
103
- ),
102
+ body: _body (context),
104
103
);
105
104
}
105
+
106
+ Widget _body (BuildContext context) {
107
+ final subs = allSubscribed.values.toList ();
108
+ List <ComicSimple > comicList = [];
109
+ for (var comicSubscribe in subs) {
110
+ comicList.add (ComicSimple .fromJson (comicSubscribe.toSimpleJson ()));
111
+ }
112
+ return ComicList (comicList);
113
+ }
114
+ }
115
+
116
+ Widget _popMenu (BuildContext context) {
117
+ return PopupMenuButton <int >(
118
+ icon: const Icon (Icons .more_vert),
119
+ itemBuilder: (BuildContext context) => < PopupMenuItem <int >> [
120
+ const PopupMenuItem <int >(
121
+ value: 0 ,
122
+ child: ListTile (
123
+ leading: Icon (Icons .share),
124
+ title: Text ("检查更新" ),
125
+ ),
126
+ ),
127
+ const PopupMenuItem <int >(
128
+ value: 1 ,
129
+ child: ListTile (
130
+ leading: Icon (Icons .image_search),
131
+ title: Text ("取消所有更新提醒" ),
132
+ ),
133
+ ),
134
+ ],
135
+ onSelected: (int value) {
136
+ switch (value) {
137
+ case 0 :
138
+ updateSubscribedForce ();
139
+ break ;
140
+ case 1 :
141
+ removeAllSubscribed ();
142
+ break ;
143
+ }
144
+ },
145
+ );
106
146
}
0 commit comments