Skip to content

Commit b09e995

Browse files
committed
fix some extra bugs
1 parent b969a92 commit b09e995

File tree

4 files changed

+265
-312
lines changed

4 files changed

+265
-312
lines changed

lib/Pages/torrent_screen/widgets/add_trackers_dialogue.dart

Lines changed: 131 additions & 162 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class AddTrackersDialogue extends StatefulWidget {
2525

2626
class _AddTrackersDialogueState extends State<AddTrackersDialogue>
2727
with TickerProviderStateMixin {
28-
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
2928
bool _showdropdown = false;
3029
late TextEditingController _textController;
3130
int _itemsVisibleInDropdown = 1;
@@ -79,6 +78,16 @@ class _AddTrackersDialogueState extends State<AddTrackersDialogue>
7978
final hp = MediaQuery.of(context).size.height;
8079
final wp = MediaQuery.of(context).size.width;
8180
return AlertDialog(
81+
title: Text(
82+
context.l10n.torrents_set_trackers_heading,
83+
key: Key('Set Trackers Text'),
84+
textAlign: TextAlign.center,
85+
style: TextStyle(
86+
color: ThemeBloc.theme(widget.themeIndex).textTheme.bodyLarge?.color,
87+
fontWeight: FontWeight.bold,
88+
fontSize: 20,
89+
),
90+
),
8291
insetPadding: EdgeInsets.zero,
8392
clipBehavior: Clip.antiAliasWithSaveLayer,
8493
key: Key('Add Trackers AlertDialog'),
@@ -91,158 +100,120 @@ class _AddTrackersDialogueState extends State<AddTrackersDialogue>
91100
Radius.circular(20),
92101
),
93102
),
94-
contentPadding: EdgeInsets.only(left: 20, right: 20, top: 20, bottom: 20),
103+
contentPadding: EdgeInsets.only(left: 20, right: 20, top: 20),
95104
content: Builder(builder: (context) {
96105
return AnimatedContainer(
97106
duration: Duration(milliseconds: 200),
98107
constraints: BoxConstraints(),
99108
height: _showdropdown
100-
? hp - (600 - (50 * _itemsVisibleInDropdown - 1))
101-
: hp - 650,
109+
? hp - (700 - (50 * _itemsVisibleInDropdown - 1))
110+
: hp - 700,
102111
width: wp - 100,
103-
child: Column(
104-
children: [
105-
Text(
106-
context.l10n.torrents_set_trackers_heading,
107-
key: Key('Set Trackers Text'),
108-
textAlign: TextAlign.center,
109-
style: TextStyle(
110-
color: ThemeBloc.theme(widget.themeIndex)
111-
.textTheme
112-
.bodyLarge
113-
?.color,
114-
fontWeight: FontWeight.bold,
115-
fontSize: 20,
116-
),
117-
),
118-
SizedBox(height: 40),
119-
Container(
120-
decoration: BoxDecoration(
121-
borderRadius: BorderRadius.circular(10),
122-
),
123-
child: Column(
124-
children: <Widget>[
125-
Form(
126-
key: _formKey,
127-
child: Row(
128-
children: <Widget>[
129-
Expanded(
130-
child: TextFormField(
131-
key: Key('Trackers Text Form Field'),
132-
controller: _textController,
133-
decoration: InputDecoration(
134-
fillColor: themeBloc.isDarkMode
135-
? ThemeBloc.theme(widget.themeIndex)
136-
.primaryColor
137-
: Colors.black45,
138-
border: OutlineInputBorder(
139-
borderRadius: BorderRadius.circular(10.0),
140-
),
141-
contentPadding: const EdgeInsets.symmetric(
142-
vertical: 17.0, horizontal: 15.0),
143-
filled: true,
144-
suffixIcon: IconButton(
145-
splashColor: Colors.transparent,
146-
icon: _showdropdown
147-
? Icon(
148-
Icons.keyboard_arrow_up_rounded,
149-
key: Key('Show Arrow Up Icon'),
150-
)
151-
: Icon(
152-
Icons.keyboard_arrow_down_rounded,
153-
key: Key('Show Arrow Down Icon'),
154-
),
155-
onPressed: () {
156-
SystemChannels.textInput
157-
.invokeMethod('TextInput.hide');
158-
setState(() {
159-
_showdropdown = !_showdropdown;
160-
_showdropdown
161-
? _animationController.forward()
162-
: _animationController.reverse();
163-
});
164-
}),
165-
hintStyle: TextStyle(
166-
color: themeBloc.isDarkMode
167-
? Colors.grey
168-
: Colors.black,
169-
fontSize: 18,
170-
fontWeight: FontWeight.w400),
171-
hintText:
172-
context.l10n.torrents_enter_trackers_hint,
173-
),
174-
style: TextStyle(
175-
color: ThemeBloc.theme(widget.themeIndex)
176-
.textTheme
177-
.bodyLarge
178-
?.color,
179-
fontSize: 18,
180-
fontWeight: FontWeight.w400),
181-
autocorrect: false,
182-
textAlign: TextAlign.start,
183-
autofocus: false,
184-
maxLines: 1,
185-
validator: (String? newValue) {
186-
if (newValue == null || newValue.isEmpty)
187-
return context.l10n
188-
.torrents_set_tags_textfield_validator;
189-
return null;
190-
},
191-
inputFormatters: [
192-
FilteringTextInputFormatter.deny(RegExp(r'\s')),
193-
],
194-
),
195-
)
196-
],
197-
),
112+
child: Container(
113+
decoration: BoxDecoration(
114+
borderRadius: BorderRadius.circular(10),
115+
),
116+
child: Column(
117+
children: <Widget>[
118+
TextFormField(
119+
key: Key('Trackers Text Form Field'),
120+
controller: _textController,
121+
decoration: InputDecoration(
122+
fillColor: themeBloc.isDarkMode
123+
? ThemeBloc.theme(widget.themeIndex).primaryColor
124+
: Colors.black45,
125+
border: OutlineInputBorder(
126+
borderRadius: BorderRadius.circular(10.0),
198127
),
199-
Container(
200-
key: Key('Trackers List Container'),
201-
decoration: BoxDecoration(
202-
borderRadius: BorderRadius.circular(10),
203-
color: themeBloc.isDarkMode
204-
? Colors.white
205-
: Colors.black12,
206-
),
207-
margin: EdgeInsets.only(top: 3),
208-
padding: EdgeInsets.only(top: 8),
209-
height: _animation.value,
210-
width: MediaQuery.of(context).size.width,
211-
child: Column(
212-
children: [
213-
Expanded(
214-
child: ListView.separated(
215-
controller: _scrollController,
216-
padding: EdgeInsets.symmetric(horizontal: 8),
217-
separatorBuilder: (context, index) =>
218-
Divider(color: Colors.grey),
219-
itemCount: _existingTrackers.length +
220-
_newEnterdTrackers.length,
221-
itemBuilder: (context, index) {
222-
if (index < _existingTrackers.length) {
223-
return _getCheckBoxListTile(
224-
_existingTrackers.keys.elementAt(index),
225-
index,
226-
themeBloc,
227-
_existingTrackers);
228-
} else {
229-
index -= _existingTrackers.length;
230-
return _getCheckBoxListTile(
231-
_newEnterdTrackers.keys.elementAt(index),
232-
index,
233-
themeBloc,
234-
_newEnterdTrackers);
235-
}
236-
},
237-
),
238-
),
239-
],
240-
),
241-
)
128+
contentPadding: const EdgeInsets.symmetric(
129+
vertical: 17.0, horizontal: 15.0),
130+
filled: true,
131+
suffixIcon: IconButton(
132+
splashColor: Colors.transparent,
133+
icon: _showdropdown
134+
? Icon(
135+
Icons.keyboard_arrow_up_rounded,
136+
key: Key('Show Arrow Up Icon'),
137+
)
138+
: Icon(
139+
Icons.keyboard_arrow_down_rounded,
140+
key: Key('Show Arrow Down Icon'),
141+
),
142+
onPressed: () {
143+
SystemChannels.textInput
144+
.invokeMethod('TextInput.hide');
145+
setState(() {
146+
_showdropdown = !_showdropdown;
147+
_showdropdown
148+
? _animationController.forward()
149+
: _animationController.reverse();
150+
});
151+
}),
152+
hintStyle: TextStyle(
153+
color:
154+
themeBloc.isDarkMode ? Colors.grey : Colors.black,
155+
fontSize: 18,
156+
fontWeight: FontWeight.w400),
157+
hintText: context.l10n.torrents_enter_trackers_hint,
158+
),
159+
style: TextStyle(
160+
color: ThemeBloc.theme(widget.themeIndex)
161+
.textTheme
162+
.bodyLarge
163+
?.color,
164+
fontSize: 18,
165+
fontWeight: FontWeight.w400),
166+
autocorrect: false,
167+
textAlign: TextAlign.start,
168+
autofocus: false,
169+
maxLines: 1,
170+
inputFormatters: [
171+
FilteringTextInputFormatter.deny(RegExp(r'\s')),
242172
],
243173
),
244-
)
245-
],
174+
Container(
175+
key: Key('Trackers List Container'),
176+
decoration: BoxDecoration(
177+
borderRadius: BorderRadius.circular(10),
178+
color: themeBloc.isDarkMode ? Colors.white : Colors.black12,
179+
),
180+
margin: EdgeInsets.only(top: 3),
181+
padding: EdgeInsets.only(top: 8),
182+
height: _animation.value,
183+
width: MediaQuery.of(context).size.width,
184+
child: Column(
185+
children: [
186+
Expanded(
187+
child: ListView.separated(
188+
controller: _scrollController,
189+
padding: EdgeInsets.symmetric(horizontal: 8),
190+
separatorBuilder: (context, index) =>
191+
Divider(color: Colors.grey),
192+
itemCount: _existingTrackers.length +
193+
_newEnterdTrackers.length,
194+
itemBuilder: (context, index) {
195+
if (index < _existingTrackers.length) {
196+
return _getCheckBoxListTile(
197+
_existingTrackers.keys.elementAt(index),
198+
index,
199+
themeBloc,
200+
_existingTrackers);
201+
} else {
202+
index -= _existingTrackers.length;
203+
return _getCheckBoxListTile(
204+
_newEnterdTrackers.keys.elementAt(index),
205+
index,
206+
themeBloc,
207+
_newEnterdTrackers);
208+
}
209+
},
210+
),
211+
),
212+
],
213+
),
214+
)
215+
],
216+
),
246217
),
247218
);
248219
}),
@@ -290,24 +261,22 @@ class _AddTrackersDialogueState extends State<AddTrackersDialogue>
290261
),
291262
onPressed: (() {
292263
setState(() {
293-
if (_formKey.currentState!.validate()) {
294-
widget.torrents.forEach((element) {
295-
TorrentApi.setTrackers(
296-
trackersList: _inputTrackersList,
297-
hashes: element.hash,
298-
context: context,
299-
);
300-
});
301-
EventHandlerApi.filterDataRephrasor(
302-
BlocProvider.of<HomeScreenBloc>(context).state.torrentList,
303-
context);
304-
final addTorrentSnackbar = addFloodSnackBar(
305-
SnackbarType.information,
306-
context.l10n.torrents_set_trackers_snackbar,
307-
context.l10n.button_dismiss);
308-
Navigator.of(context, rootNavigator: true).pop();
309-
ScaffoldMessenger.of(context).showSnackBar(addTorrentSnackbar);
310-
}
264+
widget.torrents.forEach((element) {
265+
TorrentApi.setTrackers(
266+
trackersList: _inputTrackersList,
267+
hashes: element.hash,
268+
context: context,
269+
);
270+
});
271+
EventHandlerApi.filterDataRephrasor(
272+
BlocProvider.of<HomeScreenBloc>(context).state.torrentList,
273+
context);
274+
final addTorrentSnackbar = addFloodSnackBar(
275+
SnackbarType.information,
276+
context.l10n.torrents_set_trackers_snackbar,
277+
context.l10n.button_dismiss);
278+
Navigator.of(context, rootNavigator: true).pop();
279+
ScaffoldMessenger.of(context).showSnackBar(addTorrentSnackbar);
311280
});
312281
}),
313282
child: Text(

0 commit comments

Comments
 (0)