|
| 1 | +import 'package:flood_mobile/Constants/theme_provider.dart'; |
| 2 | +import 'package:flood_mobile/Pages/torrent_screen.dart'; |
| 3 | +import 'package:flutter/material.dart'; |
| 4 | + |
| 5 | +class FilterByStatus extends StatefulWidget { |
| 6 | + @override |
| 7 | + _FilterByStatusState createState() => _FilterByStatusState(); |
| 8 | +} |
| 9 | + |
| 10 | +enum FilterValue { |
| 11 | + all, |
| 12 | + downloading, |
| 13 | + seeding, |
| 14 | + complete, |
| 15 | + stopped, |
| 16 | + active, |
| 17 | + inactive |
| 18 | +} |
| 19 | + |
| 20 | +FilterValue? filterStatus = FilterValue.all; |
| 21 | +String trackerURISelected = ''; |
| 22 | + |
| 23 | +class _FilterByStatusState extends State<FilterByStatus> { |
| 24 | + @override |
| 25 | + void initState() { |
| 26 | + // TODO: implement initState |
| 27 | + super.initState(); |
| 28 | + } |
| 29 | + |
| 30 | + @override |
| 31 | + Widget build(BuildContext context) { |
| 32 | + return Container( |
| 33 | + decoration: BoxDecoration( |
| 34 | + borderRadius: BorderRadius.only( |
| 35 | + topRight: Radius.circular(15), topLeft: Radius.circular(15)), |
| 36 | + color: ThemeProvider.theme.primaryColorLight, |
| 37 | + ), |
| 38 | + height: 500, |
| 39 | + padding: EdgeInsets.symmetric(vertical: 25, horizontal: 20), |
| 40 | + child: SingleChildScrollView( |
| 41 | + scrollDirection: Axis.vertical, |
| 42 | + child: Column( |
| 43 | + crossAxisAlignment: CrossAxisAlignment.start, |
| 44 | + mainAxisSize: MainAxisSize.min, |
| 45 | + children: <Widget>[ |
| 46 | + Text("Filter by status", |
| 47 | + style: TextStyle( |
| 48 | + color: ThemeProvider.theme.textTheme.bodyText1?.color, |
| 49 | + fontSize: 24, |
| 50 | + fontWeight: FontWeight.bold)), |
| 51 | + ListTile( |
| 52 | + leading: Icon( |
| 53 | + Icons.star_sharp, |
| 54 | + size: 20, |
| 55 | + ), |
| 56 | + minLeadingWidth: 2, |
| 57 | + visualDensity: VisualDensity(horizontal: -4, vertical: -2), |
| 58 | + title: Text('All', |
| 59 | + style: TextStyle( |
| 60 | + color: ThemeProvider.theme.textTheme.bodyText1?.color, |
| 61 | + fontFamily: 'Montserrat', |
| 62 | + fontSize: 16, |
| 63 | + fontWeight: FontWeight.normal)), |
| 64 | + trailing: Radio<FilterValue>( |
| 65 | + value: FilterValue.all, |
| 66 | + groupValue: filterStatus, |
| 67 | + onChanged: (FilterValue? value) { |
| 68 | + setState(() { |
| 69 | + trackerURISelected = 'null'; |
| 70 | + filterStatus = value; |
| 71 | + }); |
| 72 | + }, |
| 73 | + ), |
| 74 | + ), |
| 75 | + ListTile( |
| 76 | + leading: Icon( |
| 77 | + Icons.download, |
| 78 | + size: 20, |
| 79 | + ), |
| 80 | + minLeadingWidth: 2, |
| 81 | + visualDensity: VisualDensity(horizontal: -4, vertical: -2), |
| 82 | + title: Text('Downloading', |
| 83 | + style: TextStyle( |
| 84 | + color: ThemeProvider.theme.textTheme.bodyText1?.color, |
| 85 | + fontFamily: 'Montserrat', |
| 86 | + fontSize: 16, |
| 87 | + fontWeight: FontWeight.normal)), |
| 88 | + trailing: Radio<FilterValue>( |
| 89 | + value: FilterValue.downloading, |
| 90 | + groupValue: filterStatus, |
| 91 | + onChanged: (FilterValue? value) { |
| 92 | + setState(() { |
| 93 | + trackerURISelected = 'null'; |
| 94 | + filterStatus = value; |
| 95 | + }); |
| 96 | + }, |
| 97 | + ), |
| 98 | + ), |
| 99 | + ListTile( |
| 100 | + leading: Icon( |
| 101 | + Icons.upload_sharp, |
| 102 | + size: 20, |
| 103 | + ), |
| 104 | + minLeadingWidth: 2, |
| 105 | + visualDensity: VisualDensity(horizontal: -4, vertical: -2), |
| 106 | + title: Text('Seeding', |
| 107 | + style: TextStyle( |
| 108 | + color: ThemeProvider.theme.textTheme.bodyText1?.color, |
| 109 | + fontFamily: 'Montserrat', |
| 110 | + fontSize: 16, |
| 111 | + fontWeight: FontWeight.normal)), |
| 112 | + trailing: Radio<FilterValue>( |
| 113 | + value: FilterValue.seeding, |
| 114 | + groupValue: filterStatus, |
| 115 | + onChanged: (FilterValue? value) { |
| 116 | + setState(() { |
| 117 | + trackerURISelected = 'null'; |
| 118 | + filterStatus = value; |
| 119 | + }); |
| 120 | + }, |
| 121 | + ), |
| 122 | + ), |
| 123 | + ListTile( |
| 124 | + leading: Icon( |
| 125 | + Icons.done, |
| 126 | + size: 20, |
| 127 | + ), |
| 128 | + minLeadingWidth: 2, |
| 129 | + visualDensity: VisualDensity(horizontal: -4, vertical: -2), |
| 130 | + title: Text('Complete', |
| 131 | + style: TextStyle( |
| 132 | + color: ThemeProvider.theme.textTheme.bodyText1?.color, |
| 133 | + fontFamily: 'Montserrat', |
| 134 | + fontSize: 16, |
| 135 | + fontWeight: FontWeight.normal)), |
| 136 | + trailing: Radio<FilterValue>( |
| 137 | + value: FilterValue.complete, |
| 138 | + groupValue: filterStatus, |
| 139 | + onChanged: (FilterValue? value) { |
| 140 | + setState(() { |
| 141 | + trackerURISelected = 'null'; |
| 142 | + filterStatus = value; |
| 143 | + }); |
| 144 | + }, |
| 145 | + ), |
| 146 | + ), |
| 147 | + ListTile( |
| 148 | + leading: Icon( |
| 149 | + Icons.stop, |
| 150 | + size: 20, |
| 151 | + ), |
| 152 | + minLeadingWidth: 2, |
| 153 | + visualDensity: VisualDensity(horizontal: -4, vertical: -2), |
| 154 | + title: Text('Stopped', |
| 155 | + style: TextStyle( |
| 156 | + color: ThemeProvider.theme.textTheme.bodyText1?.color, |
| 157 | + fontFamily: 'Montserrat', |
| 158 | + fontSize: 16, |
| 159 | + fontWeight: FontWeight.normal)), |
| 160 | + trailing: Radio<FilterValue>( |
| 161 | + value: FilterValue.stopped, |
| 162 | + groupValue: filterStatus, |
| 163 | + onChanged: (FilterValue? value) { |
| 164 | + setState(() { |
| 165 | + trackerURISelected = 'null'; |
| 166 | + filterStatus = value; |
| 167 | + }); |
| 168 | + }, |
| 169 | + ), |
| 170 | + ), |
| 171 | + ListTile( |
| 172 | + leading: Icon( |
| 173 | + Icons.trending_up_outlined, |
| 174 | + size: 20, |
| 175 | + ), |
| 176 | + minLeadingWidth: 2, |
| 177 | + visualDensity: VisualDensity(horizontal: -4, vertical: -2), |
| 178 | + title: Text('Active', |
| 179 | + style: TextStyle( |
| 180 | + color: ThemeProvider.theme.textTheme.bodyText1?.color, |
| 181 | + fontFamily: 'Montserrat', |
| 182 | + fontSize: 16, |
| 183 | + fontWeight: FontWeight.normal)), |
| 184 | + trailing: Radio<FilterValue>( |
| 185 | + value: FilterValue.active, |
| 186 | + groupValue: filterStatus, |
| 187 | + onChanged: (FilterValue? value) { |
| 188 | + setState(() { |
| 189 | + trackerURISelected = 'null'; |
| 190 | + filterStatus = value; |
| 191 | + }); |
| 192 | + }, |
| 193 | + ), |
| 194 | + ), |
| 195 | + ListTile( |
| 196 | + leading: Icon( |
| 197 | + Icons.trending_down_outlined, |
| 198 | + size: 20, |
| 199 | + ), |
| 200 | + minLeadingWidth: 2, |
| 201 | + visualDensity: VisualDensity(horizontal: -4, vertical: -2), |
| 202 | + title: Text('Inactive', |
| 203 | + style: TextStyle( |
| 204 | + color: ThemeProvider.theme.textTheme.bodyText1?.color, |
| 205 | + fontFamily: 'Montserrat', |
| 206 | + fontSize: 16, |
| 207 | + fontWeight: FontWeight.normal)), |
| 208 | + trailing: Radio<FilterValue>( |
| 209 | + value: FilterValue.inactive, |
| 210 | + groupValue: filterStatus, |
| 211 | + onChanged: (FilterValue? value) { |
| 212 | + setState(() { |
| 213 | + trackerURISelected = 'null'; |
| 214 | + filterStatus = value; |
| 215 | + }); |
| 216 | + }, |
| 217 | + ), |
| 218 | + ), |
| 219 | + SizedBox( |
| 220 | + height: 20, |
| 221 | + ), |
| 222 | + Text("Filter by trackers", |
| 223 | + style: TextStyle( |
| 224 | + color: ThemeProvider.theme.textTheme.bodyText1?.color, |
| 225 | + fontSize: 24, |
| 226 | + fontWeight: FontWeight.bold)), |
| 227 | + ListTile( |
| 228 | + minLeadingWidth: 2, |
| 229 | + visualDensity: VisualDensity(horizontal: -4, vertical: -2), |
| 230 | + title: Text('All', |
| 231 | + style: TextStyle( |
| 232 | + color: ThemeProvider.theme.textTheme.bodyText1?.color, |
| 233 | + fontFamily: 'Montserrat', |
| 234 | + fontSize: 16, |
| 235 | + fontWeight: FontWeight.normal)), |
| 236 | + trailing: Radio<FilterValue>( |
| 237 | + value: FilterValue.all, |
| 238 | + groupValue: filterStatus, |
| 239 | + onChanged: (FilterValue? value) { |
| 240 | + setState(() { |
| 241 | + trackerURISelected = 'null'; |
| 242 | + filterStatus = value; |
| 243 | + }); |
| 244 | + }, |
| 245 | + ), |
| 246 | + ), |
| 247 | + ListView.builder( |
| 248 | + shrinkWrap: true, |
| 249 | + physics: NeverScrollableScrollPhysics(), |
| 250 | + itemCount: trackerURIsList.length, |
| 251 | + itemBuilder: (BuildContext context, int index) { |
| 252 | + return ListTile( |
| 253 | + minLeadingWidth: 2, |
| 254 | + visualDensity: VisualDensity(horizontal: -4, vertical: -2), |
| 255 | + title: Text(trackerURIsList[index].toString(), |
| 256 | + style: TextStyle( |
| 257 | + color: |
| 258 | + ThemeProvider.theme.textTheme.bodyText1?.color, |
| 259 | + fontFamily: 'Montserrat', |
| 260 | + fontSize: 16, |
| 261 | + fontWeight: FontWeight.normal)), |
| 262 | + trailing: Radio<String>( |
| 263 | + value: trackerURIsList[index].toString(), |
| 264 | + groupValue: trackerURISelected, |
| 265 | + onChanged: (value) { |
| 266 | + print(value); |
| 267 | + setState(() { |
| 268 | + filterStatus = null; |
| 269 | + trackerURISelected = value.toString(); |
| 270 | + }); |
| 271 | + }, |
| 272 | + ), |
| 273 | + ); |
| 274 | + }), |
| 275 | + ], |
| 276 | + ), |
| 277 | + ), |
| 278 | + ); |
| 279 | + } |
| 280 | +} |
0 commit comments