@@ -6,7 +6,9 @@ import 'package:flood_mobile/Api/event_handler_api.dart';
6
6
import 'package:flood_mobile/Blocs/filter_torrent_bloc/filter_torrent_bloc.dart' ;
7
7
import 'package:flood_mobile/Blocs/graph_bloc/graph_bloc.dart' ;
8
8
import 'package:flood_mobile/Blocs/home_screen_bloc/home_screen_bloc.dart' ;
9
+ import 'package:flood_mobile/Blocs/sort_by_torrent_bloc/sort_by_torrent_bloc.dart' ;
9
10
import 'package:flood_mobile/Blocs/theme_bloc/theme_bloc.dart' ;
11
+ import 'package:flood_mobile/Model/torrent_model.dart' ;
10
12
import 'package:flood_mobile/Pages/torrent_screen/services/filtered_torrent_list.dart' ;
11
13
import 'package:flood_mobile/Pages/torrent_screen/widgets/bottom_floating_menu_button.dart' ;
12
14
import 'package:flood_mobile/Pages/torrent_screen/widgets/pull_to_reveal.dart' ;
@@ -45,131 +47,143 @@ class _TorrentScreenState extends State<TorrentScreen> {
45
47
width: double .infinity,
46
48
color: ThemeBloc .theme (widget.themeIndex).primaryColor,
47
49
child: (state.torrentList.length != 0 )
48
- ? BlocBuilder <SpeedGraphBloc , SpeedGraphState >(
49
- builder: (context, graphSstate) {
50
- return PullToRevealTopItemList (
51
- itemCount: showTorrentCount == 0
52
- ? 1
53
- : state.torrentList.length,
54
- itemBuilder: (BuildContext context, int index) {
55
- if (isFilteredTorrent (
56
- state.torrentList[index], stateFilterBloc))
57
- return TorrentTile (
58
- indexes: [index],
59
- model: state.torrentList[index],
60
- themeIndex: widget.themeIndex,
61
- );
62
- return showTorrentCount == 0
63
- ? Container (
64
- height: 300 ,
65
- width: double .infinity,
66
- alignment: Alignment .center,
67
- child: Column (
68
- mainAxisAlignment:
69
- MainAxisAlignment .center,
70
- children: [
71
- SText (
72
- text: context.l10n
73
- .torrents_list_no_torrents,
74
- themeIndex: widget.themeIndex,
75
- ),
76
- SizedBox (
77
- height: 5 ,
78
- ),
79
- ElevatedButton (
80
- style: ElevatedButton .styleFrom (
81
- backgroundColor:
82
- ThemeBloc .theme (widget
83
- .themeIndex)
50
+ ? BlocBuilder <SortByTorrentBloc , SortByTorrentState >(
51
+ builder: (context, sortByState) {
52
+ List <TorrentModel > torrentList = sortTorrents (
53
+ torrents: state.torrentList,
54
+ sortState:
55
+ BlocProvider .of <SortByTorrentBloc >(context)
56
+ .state,
57
+ );
58
+ return BlocBuilder <SpeedGraphBloc , SpeedGraphState >(
59
+ builder: (context, graphSstate) {
60
+ return PullToRevealTopItemList (
61
+ itemCount: showTorrentCount == 0
62
+ ? 1
63
+ : torrentList.length,
64
+ itemBuilder:
65
+ (BuildContext context, int index) {
66
+ if (isFilteredTorrent (
67
+ torrentList[index], stateFilterBloc))
68
+ return TorrentTile (
69
+ indexes: [index],
70
+ model: torrentList[index],
71
+ themeIndex: widget.themeIndex,
72
+ );
73
+ return showTorrentCount == 0
74
+ ? Container (
75
+ height: 300 ,
76
+ width: double .infinity,
77
+ alignment: Alignment .center,
78
+ child: Column (
79
+ mainAxisAlignment:
80
+ MainAxisAlignment .center,
81
+ children: [
82
+ SText (
83
+ text: context.l10n
84
+ .torrents_list_no_torrents,
85
+ themeIndex: widget.themeIndex,
86
+ ),
87
+ SizedBox (
88
+ height: 5 ,
89
+ ),
90
+ ElevatedButton (
91
+ style: ElevatedButton .styleFrom (
92
+ backgroundColor: ThemeBloc
93
+ .theme (widget
94
+ .themeIndex)
84
95
.primaryColorLight,
85
- foregroundColor:
86
- ThemeBloc .theme (widget
87
- .themeIndex)
88
- .textTheme
89
- .bodyLarge
90
- ? .color),
91
- onPressed: () {
92
- setState (() {
93
- BlocProvider .of<
94
- FilterTorrentBloc > (
95
- context)
96
- .add (
97
- SetFilterSelectedEvent (
98
- filterStatus:
99
- FilterValue .all,
100
- ),
101
- );
102
- });
103
- },
104
- child: Text (context
105
- .l10n.clear_filter_text))
106
- ],
107
- ),
108
- )
109
- : Container ();
110
- },
111
- revealableHeight:
112
- graphSstate.showChart ? hp / 3 : hp / 4.87 ,
113
- revealableBuilder: (BuildContext context,
114
- RevealableToggler opener,
115
- RevealableToggler closer,
116
- BoxConstraints constraints) {
117
- return Column (
118
- children: [
119
- Expanded (
120
- child: Padding (
121
- padding: EdgeInsets .only (
122
- right: wp * 0.05 ,
123
- left: wp * 0.05 ,
124
- top: hp * 0.01 ,
125
- bottom: hp * 0.02 ),
126
- child: Row (
127
- children: [
128
- SpeedTextIconWidget (
129
- themeIndex: widget.themeIndex,
130
- speedIcon:
131
- Icons .arrow_upward_rounded,
132
- speedText: state.upSpeed,
133
- speedColor: ThemeBloc .theme (
134
- widget.themeIndex)
135
- .primaryColorDark,
96
+ foregroundColor:
97
+ ThemeBloc .theme (widget
98
+ .themeIndex)
99
+ .textTheme
100
+ .bodyLarge
101
+ ? .color),
102
+ onPressed: () {
103
+ setState (() {
104
+ BlocProvider .of<
105
+ FilterTorrentBloc > (
106
+ context)
107
+ .add (
108
+ SetFilterSelectedEvent (
109
+ filterStatus:
110
+ FilterValue .all,
111
+ ),
112
+ );
113
+ });
114
+ },
115
+ child: Text (context.l10n
116
+ .clear_filter_text))
117
+ ],
136
118
),
137
- ShowChartButton (),
138
- SpeedTextIconWidget (
139
- themeIndex: widget.themeIndex,
140
- speedIcon:
141
- Icons .arrow_downward_rounded,
142
- speedText: state.downSpeed,
143
- speedColor: ThemeBloc .theme (
144
- widget.themeIndex)
145
- .colorScheme
146
- .secondary,
119
+ )
120
+ : Container ();
121
+ },
122
+ revealableHeight: graphSstate.showChart
123
+ ? hp / 3
124
+ : hp / 4.87 ,
125
+ revealableBuilder: (BuildContext context,
126
+ RevealableToggler opener,
127
+ RevealableToggler closer,
128
+ BoxConstraints constraints) {
129
+ return Column (
130
+ children: [
131
+ Expanded (
132
+ child: Padding (
133
+ padding: EdgeInsets .only (
134
+ right: wp * 0.05 ,
135
+ left: wp * 0.05 ,
136
+ top: hp * 0.01 ,
137
+ bottom: hp * 0.02 ),
138
+ child: Row (
139
+ children: [
140
+ SpeedTextIconWidget (
141
+ themeIndex: widget.themeIndex,
142
+ speedIcon: Icons
143
+ .arrow_upward_rounded,
144
+ speedText: state.upSpeed,
145
+ speedColor: ThemeBloc .theme (
146
+ widget.themeIndex)
147
+ .primaryColorDark,
148
+ ),
149
+ ShowChartButton (),
150
+ SpeedTextIconWidget (
151
+ themeIndex: widget.themeIndex,
152
+ speedIcon: Icons
153
+ .arrow_downward_rounded,
154
+ speedText: state.downSpeed,
155
+ speedColor: ThemeBloc .theme (
156
+ widget.themeIndex)
157
+ .colorScheme
158
+ .secondary,
159
+ ),
160
+ ],
147
161
),
148
- ],
149
- ),
150
- ),
151
- ),
152
- if (graphSstate.showChart)
153
- Expanded (
154
- flex: 2 ,
155
- child: Container (
156
- padding: EdgeInsets .only (
157
- right: wp * 0.01 ,
158
- left: wp * 0.01 ,
159
- bottom: hp * 0.025 ),
160
- width: double .infinity,
161
- child: SpeedGraph (
162
- model:
163
- BlocProvider .of <HomeScreenBloc >(
164
- context),
165
- themeIndex: widget.themeIndex,
166
162
),
167
163
),
168
- ),
169
- SearchTorrentTextField (
170
- themeIndex: widget.themeIndex,
171
- stateFilterBlocState: stateFilterBloc)
172
- ],
164
+ if (graphSstate.showChart)
165
+ Expanded (
166
+ flex: 2 ,
167
+ child: Container (
168
+ padding: EdgeInsets .only (
169
+ right: wp * 0.01 ,
170
+ left: wp * 0.01 ,
171
+ bottom: hp * 0.025 ),
172
+ width: double .infinity,
173
+ child: SpeedGraph (
174
+ model: BlocProvider .of<
175
+ HomeScreenBloc > (context),
176
+ themeIndex: widget.themeIndex,
177
+ ),
178
+ ),
179
+ ),
180
+ SearchTorrentTextField (
181
+ themeIndex: widget.themeIndex,
182
+ stateFilterBlocState:
183
+ stateFilterBloc)
184
+ ],
185
+ );
186
+ },
173
187
);
174
188
},
175
189
);
0 commit comments