@@ -32,7 +32,9 @@ class _ListEditorDialogState extends State<ListEditorDialog> {
32
32
late TextEditingController scoreController;
33
33
late bool isPrivate;
34
34
late String suffixText;
35
+ Map <String , bool >? customListName;
35
36
TextEditingController ? noteController;
37
+ TextEditingController ? repeatController;
36
38
FuzzyDate ? startedAt;
37
39
FuzzyDate ? completedAt;
38
40
@@ -49,8 +51,11 @@ class _ListEditorDialogState extends State<ListEditorDialog> {
49
51
: "??" );
50
52
if (! widget.isCompact) {
51
53
noteController = TextEditingController (text: widget.media.notes ?? "" );
54
+ repeatController =
55
+ TextEditingController (text: widget.media.userRepeat.toString ());
52
56
startedAt = media.userStartedAt;
53
57
completedAt = media.userCompletedAt;
58
+ customListName = Map <String , bool >.from (media.inCustomListsOf ?? {});
54
59
}
55
60
isPrivate = media.isListPrivate;
56
61
suffixText =
@@ -62,6 +67,8 @@ class _ListEditorDialogState extends State<ListEditorDialog> {
62
67
super .dispose ();
63
68
progressController.dispose ();
64
69
scoreController.dispose ();
70
+ noteController? .dispose ();
71
+ repeatController? .dispose ();
65
72
}
66
73
67
74
@override
@@ -81,40 +88,38 @@ class _ListEditorDialogState extends State<ListEditorDialog> {
81
88
return CustomBottomDialog (
82
89
title: "List Editor" ,
83
90
viewList: [
84
- Column (
85
- children: [
86
- _buildStatusDropdown (fieldPadding),
87
- Padding (
88
- padding: fieldPadding,
89
- child: _buildProgressField (labelStyle, suffixStyle),
90
- ),
91
- Padding (
92
- padding: fieldPadding,
93
- child: _buildScoreField (labelStyle, suffixStyle),
94
- ),
95
- if (! widget.isCompact)
96
- Padding (
97
- padding: fieldPadding,
98
- child: _buildDatePickerRow (suffixStyle),
99
- ),
100
- Padding (
101
- padding: const EdgeInsets .symmetric (horizontal: 8.0 ),
102
- child: _buildPrivateSwitch (),
103
- ),
104
- if (! widget.isCompact)
105
- Expandable (
106
- backgroundColor: theme.surface,
107
- boxShadow: [],
108
- arrowWidget:
109
- const Icon (Icons .keyboard_arrow_up_rounded, size: 25.0 ),
110
- firstChild: const Text ('Other' , style: suffixStyle),
111
- secondChild: _buildOtherWidget (
112
- labelStyle,
113
- suffixStyle,
114
- fieldPadding,
91
+ Padding (
92
+ padding: fieldPadding,
93
+ child: Column (
94
+ children: [
95
+ _buildStatusDropdown (),
96
+ const SizedBox (height: 16 ),
97
+ _buildProgressField (labelStyle, suffixStyle),
98
+ const SizedBox (height: 8 ),
99
+ _buildScoreField (labelStyle, suffixStyle),
100
+ const SizedBox (height: 8 ),
101
+ if (! widget.isCompact) ...[
102
+ _buildDatePickerRow (suffixStyle),
103
+ const SizedBox (height: 8 ),
104
+ ],
105
+ _buildPrivateSwitch (),
106
+ const SizedBox (height: 8 ),
107
+ if (! widget.isCompact) ...[
108
+ Expandable (
109
+ backgroundColor: theme.surface,
110
+ boxShadow: [],
111
+ arrowWidget:
112
+ const Icon (Icons .keyboard_arrow_up_rounded, size: 25.0 ),
113
+ firstChild: const Text ('Other' , style: suffixStyle),
114
+ secondChild: _buildOtherWidget (
115
+ labelStyle,
116
+ suffixStyle,
117
+ ),
115
118
),
116
- ),
117
- ],
119
+ const SizedBox (height: 8 ),
120
+ ]
121
+ ],
122
+ ),
118
123
),
119
124
],
120
125
positiveText: 'Save' ,
@@ -123,9 +128,9 @@ class _ListEditorDialogState extends State<ListEditorDialog> {
123
128
);
124
129
}
125
130
126
- Widget _buildStatusDropdown (EdgeInsetsGeometry padding ) {
131
+ Widget _buildStatusDropdown () {
127
132
return buildDropdownMenu (
128
- padding: padding ,
133
+ padding: const EdgeInsets . all ( 0 ) ,
129
134
borderRadius: 16 ,
130
135
prefixIcon: Icons .playlist_play_rounded,
131
136
options: Anilist .status,
@@ -143,33 +148,76 @@ class _ListEditorDialogState extends State<ListEditorDialog> {
143
148
Widget _buildOtherWidget (
144
149
TextStyle labelStyle,
145
150
TextStyle suffixStyle,
146
- EdgeInsetsGeometry padding,
147
151
) {
148
152
return Column (
153
+ crossAxisAlignment: CrossAxisAlignment .start,
149
154
children: [
150
- Padding (
151
- padding: padding,
152
- child: TextField (
153
- controller: noteController,
154
- maxLines: null ,
155
- keyboardType: TextInputType .multiline,
156
- style: labelStyle,
157
- decoration: InputDecoration (
158
- labelText: "Note" ,
159
- labelStyle: labelStyle,
160
- prefixIcon: const Icon (Icons .edit_note_rounded),
161
- contentPadding: const EdgeInsets .symmetric (horizontal: 8.0 ),
162
- border: OutlineInputBorder (
163
- borderRadius: BorderRadius .circular (16 ),
164
- borderSide: const BorderSide (color: Colors .transparent),
165
- ),
155
+ const SizedBox (height: 8 ),
156
+ TextField (
157
+ controller: repeatController,
158
+ keyboardType: const TextInputType .numberWithOptions (decimal: false ),
159
+ style: labelStyle,
160
+ inputFormatters: [
161
+ FilteringTextInputFormatter .allow (RegExp (r'^[0-9]*$' )),
162
+ ],
163
+ decoration: InputDecoration (
164
+ labelText: "Total Repeats" ,
165
+ labelStyle: labelStyle,
166
+ suffixStyle: suffixStyle,
167
+ prefixIcon: const Icon (Icons .redo_rounded),
168
+ contentPadding: const EdgeInsets .symmetric (horizontal: 8.0 ),
169
+ border: OutlineInputBorder (
170
+ borderRadius: BorderRadius .circular (16 ),
171
+ borderSide: const BorderSide (color: Colors .transparent),
172
+ ),
173
+ ),
174
+ ),
175
+ const SizedBox (height: 8 ),
176
+ TextField (
177
+ controller: noteController,
178
+ maxLines: null ,
179
+ keyboardType: TextInputType .multiline,
180
+ style: labelStyle,
181
+ decoration: InputDecoration (
182
+ labelText: "Note" ,
183
+ labelStyle: labelStyle,
184
+ prefixIcon: const Icon (Icons .edit_note_rounded),
185
+ contentPadding: const EdgeInsets .symmetric (horizontal: 8.0 ),
186
+ border: OutlineInputBorder (
187
+ borderRadius: BorderRadius .circular (16 ),
188
+ borderSide: const BorderSide (color: Colors .transparent),
166
189
),
167
190
),
168
191
),
192
+ const SizedBox (height: 16 ),
193
+ ..._buildCustomListWidgets (suffixStyle),
169
194
],
170
195
);
171
196
}
172
197
198
+ List <Widget > _buildCustomListWidgets (TextStyle suffixStyle) {
199
+
200
+ if (customListName == null || customListName! .isEmpty) {
201
+ return [Text ("No custom lists available" , style: suffixStyle)];
202
+ }
203
+
204
+ return [
205
+ Text ("Custom Lists" , style: suffixStyle),
206
+ const SizedBox (height: 16 ),
207
+ ...customListName! .entries.map (
208
+ (entry) => SwitchListTile (
209
+ title: Text (entry.key),
210
+ value: entry.value,
211
+ onChanged: (value) {
212
+ setState (() {
213
+ customListName! [entry.key] = value;
214
+ });
215
+ },
216
+ ),
217
+ )
218
+ ];
219
+ }
220
+
173
221
Widget _buildProgressField (TextStyle labelStyle, TextStyle suffixStyle) {
174
222
return Row (
175
223
children: [
@@ -276,7 +324,7 @@ class _ListEditorDialogState extends State<ListEditorDialog> {
276
324
context: context,
277
325
initialDate: initialDate,
278
326
firstDate: DateTime (1900 ),
279
- lastDate: DateTime .now (). add ( const Duration (days : 365 * 5 )) ,
327
+ lastDate: DateTime .now (),
280
328
);
281
329
if (picked != null ) onDatePicked (picked);
282
330
},
@@ -350,14 +398,21 @@ class _ListEditorDialogState extends State<ListEditorDialog> {
350
398
.clamp (0 , 100 )
351
399
..isListPrivate = isPrivate;
352
400
401
+ List <String >? list;
353
402
if (! widget.isCompact) {
354
403
widget.media
355
404
..notes = noteController? .text
356
405
..userStartedAt = startedAt
357
- ..userCompletedAt = completedAt;
406
+ ..userCompletedAt = completedAt
407
+ ..userRepeat = int .tryParse (repeatController? .text ?? "1" ) ?? 1 ;
408
+ widget.media.inCustomListsOf = customListName;
409
+ list = customListName? .entries
410
+ .where ((entry) => entry.value)
411
+ .map ((entry) => entry.key)
412
+ .toList ();
358
413
}
359
414
360
- Anilist .mutations? .editList (widget.media);
415
+ Anilist .mutations? .editList (widget.media,customList : list );
361
416
Get .back ();
362
417
Refresh .activity[RefreshId .Anilist .homePage]? .value = true ;
363
418
}
0 commit comments