|
| 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 | +FilterValue? filterStatus = FilterValue.all; |
| 20 | +String trackerURISelected = ''; |
| 21 | + |
| 22 | +class _FilterByStatusState extends State<FilterByStatus> { |
| 23 | + @override |
| 24 | + void initState() { |
| 25 | + // TODO: implement initState |
| 26 | + super.initState(); |
| 27 | + } |
| 28 | + |
| 29 | + @override |
| 30 | + Widget build(BuildContext context) { |
| 31 | + return Container( |
| 32 | + decoration: BoxDecoration( |
| 33 | + borderRadius: BorderRadius.only( |
| 34 | + topRight: Radius.circular(15), topLeft: Radius.circular(15)), |
| 35 | + color: ThemeProvider.theme.primaryColorLight, |
| 36 | + ), |
| 37 | + height: 500, |
| 38 | + padding: EdgeInsets.symmetric(vertical: 25, horizontal: 20), |
| 39 | + child: SingleChildScrollView( |
| 40 | + scrollDirection: Axis.vertical, |
| 41 | + child: Column( |
| 42 | + crossAxisAlignment: CrossAxisAlignment.start, |
| 43 | + mainAxisSize: MainAxisSize.min, |
| 44 | + children: <Widget>[ |
| 45 | + Text("Filter by status", |
| 46 | + style: TextStyle( |
| 47 | + color: ThemeProvider.theme.textTheme.bodyText1?.color, |
| 48 | + fontSize: 24, |
| 49 | + fontWeight: FontWeight.bold)), |
| 50 | + ListTile( |
| 51 | + title: Text('All', |
| 52 | + style: TextStyle( |
| 53 | + color: ThemeProvider.theme.textTheme.bodyText1?.color, |
| 54 | + fontFamily: 'Montserrat', |
| 55 | + fontSize: 16, |
| 56 | + fontWeight: FontWeight.normal)), |
| 57 | + trailing: Radio<FilterValue>( |
| 58 | + value: FilterValue.all, |
| 59 | + groupValue: filterStatus, |
| 60 | + onChanged: (FilterValue? value) { |
| 61 | + setState(() { |
| 62 | + trackerURISelected = 'null'; |
| 63 | + filterStatus = value; |
| 64 | + }); |
| 65 | + }, |
| 66 | + ), |
| 67 | + ), |
| 68 | + ListTile( |
| 69 | + title: Text('Downloading', |
| 70 | + style: TextStyle( |
| 71 | + color: ThemeProvider.theme.textTheme.bodyText1?.color, |
| 72 | + fontFamily: 'Montserrat', |
| 73 | + fontSize: 16, |
| 74 | + fontWeight: FontWeight.normal)), |
| 75 | + trailing: Radio<FilterValue>( |
| 76 | + value: FilterValue.downloading, |
| 77 | + groupValue: filterStatus, |
| 78 | + onChanged: (FilterValue? value) { |
| 79 | + setState(() { |
| 80 | + trackerURISelected = 'null'; |
| 81 | + filterStatus = value; |
| 82 | + }); |
| 83 | + }, |
| 84 | + ), |
| 85 | + ), |
| 86 | + ListTile( |
| 87 | + title: Text('Seeding', |
| 88 | + style: TextStyle( |
| 89 | + color: ThemeProvider.theme.textTheme.bodyText1?.color, |
| 90 | + fontFamily: 'Montserrat', |
| 91 | + fontSize: 16, |
| 92 | + fontWeight: FontWeight.normal)), |
| 93 | + trailing: Radio<FilterValue>( |
| 94 | + value: FilterValue.seeding, |
| 95 | + groupValue: filterStatus, |
| 96 | + onChanged: (FilterValue? value) { |
| 97 | + setState(() { |
| 98 | + trackerURISelected = 'null'; |
| 99 | + filterStatus = value; |
| 100 | + }); |
| 101 | + }, |
| 102 | + ), |
| 103 | + ), |
| 104 | + ListTile( |
| 105 | + title: Text('Complete', |
| 106 | + style: TextStyle( |
| 107 | + color: ThemeProvider.theme.textTheme.bodyText1?.color, |
| 108 | + fontFamily: 'Montserrat', |
| 109 | + fontSize: 16, |
| 110 | + fontWeight: FontWeight.normal)), |
| 111 | + trailing: Radio<FilterValue>( |
| 112 | + value: FilterValue.complete, |
| 113 | + groupValue: filterStatus, |
| 114 | + onChanged: (FilterValue? value) { |
| 115 | + setState(() { |
| 116 | + trackerURISelected = 'null'; |
| 117 | + filterStatus = value; |
| 118 | + }); |
| 119 | + }, |
| 120 | + ), |
| 121 | + ), |
| 122 | + ListTile( |
| 123 | + title: Text('Stopped', |
| 124 | + style: TextStyle( |
| 125 | + color: ThemeProvider.theme.textTheme.bodyText1?.color, |
| 126 | + fontFamily: 'Montserrat', |
| 127 | + fontSize: 16, |
| 128 | + fontWeight: FontWeight.normal)), |
| 129 | + trailing: Radio<FilterValue>( |
| 130 | + value: FilterValue.stopped, |
| 131 | + groupValue: filterStatus, |
| 132 | + onChanged: (FilterValue? value) { |
| 133 | + setState(() { |
| 134 | + trackerURISelected = 'null'; |
| 135 | + filterStatus = value; |
| 136 | + }); |
| 137 | + }, |
| 138 | + ), |
| 139 | + ), |
| 140 | + ListTile( |
| 141 | + title: Text('Active', |
| 142 | + style: TextStyle( |
| 143 | + color: ThemeProvider.theme.textTheme.bodyText1?.color, |
| 144 | + fontFamily: 'Montserrat', |
| 145 | + fontSize: 16, |
| 146 | + fontWeight: FontWeight.normal)), |
| 147 | + trailing: Radio<FilterValue>( |
| 148 | + value: FilterValue.active, |
| 149 | + groupValue: filterStatus, |
| 150 | + onChanged: (FilterValue? value) { |
| 151 | + setState(() { |
| 152 | + trackerURISelected = 'null'; |
| 153 | + filterStatus = value; |
| 154 | + }); |
| 155 | + }, |
| 156 | + ), |
| 157 | + ), |
| 158 | + ListTile( |
| 159 | + title: Text('Inactive', |
| 160 | + style: TextStyle( |
| 161 | + color: ThemeProvider.theme.textTheme.bodyText1?.color, |
| 162 | + fontFamily: 'Montserrat', |
| 163 | + fontSize: 16, |
| 164 | + fontWeight: FontWeight.normal)), |
| 165 | + trailing: Radio<FilterValue>( |
| 166 | + value: FilterValue.inactive, |
| 167 | + groupValue: filterStatus, |
| 168 | + onChanged: (FilterValue? value) { |
| 169 | + setState(() { |
| 170 | + trackerURISelected = 'null'; |
| 171 | + filterStatus = value; |
| 172 | + }); |
| 173 | + }, |
| 174 | + ), |
| 175 | + ), |
| 176 | + SizedBox( |
| 177 | + height: 20, |
| 178 | + ), |
| 179 | + Text("Filter by trackers", |
| 180 | + style: TextStyle( |
| 181 | + color: ThemeProvider.theme.textTheme.bodyText1?.color, |
| 182 | + fontSize: 24, |
| 183 | + fontWeight: FontWeight.bold)), |
| 184 | + ListTile( |
| 185 | + title: Text('All', |
| 186 | + style: TextStyle( |
| 187 | + color: ThemeProvider.theme.textTheme.bodyText1?.color, |
| 188 | + fontFamily: 'Montserrat', |
| 189 | + fontSize: 16, |
| 190 | + fontWeight: FontWeight.normal)), |
| 191 | + trailing: Radio<FilterValue>( |
| 192 | + value: FilterValue.all, |
| 193 | + groupValue: filterStatus, |
| 194 | + onChanged: (FilterValue? value) { |
| 195 | + setState(() { |
| 196 | + trackerURISelected = 'null'; |
| 197 | + filterStatus = value; |
| 198 | + }); |
| 199 | + }, |
| 200 | + ), |
| 201 | + ), |
| 202 | + ListView.builder( |
| 203 | + shrinkWrap: true, |
| 204 | + physics: NeverScrollableScrollPhysics(), |
| 205 | + itemCount: trackerURIsList.length, |
| 206 | + itemBuilder: (BuildContext context, int index) { |
| 207 | + return ListTile( |
| 208 | + title: Text(trackerURIsList[index].toString(), |
| 209 | + style: TextStyle( |
| 210 | + color: |
| 211 | + ThemeProvider.theme.textTheme.bodyText1?.color, |
| 212 | + fontFamily: 'Montserrat', |
| 213 | + fontSize: 16, |
| 214 | + fontWeight: FontWeight.normal)), |
| 215 | + trailing: Radio<String>( |
| 216 | + value: trackerURIsList[index].toString(), |
| 217 | + groupValue: trackerURISelected, |
| 218 | + onChanged: (value) { |
| 219 | + print(value); |
| 220 | + setState(() { |
| 221 | + filterStatus = null; |
| 222 | + trackerURISelected = value.toString(); |
| 223 | + }); |
| 224 | + }, |
| 225 | + ), |
| 226 | + ); |
| 227 | + }), |
| 228 | + ], |
| 229 | + ), |
| 230 | + ), |
| 231 | + ); |
| 232 | + } |
| 233 | +} |
0 commit comments