filter_box
This commit is contained in:
@@ -197,28 +197,43 @@ class _MoviesScreenState extends State<MoviesScreen> {
|
||||
}
|
||||
|
||||
void setFilter(String text, bool showInit, bool showProg, bool showDone) {
|
||||
// movieDataSource.clearFilters();
|
||||
movieDataSource.clearFilters();
|
||||
|
||||
if (showInit)
|
||||
movieDataSource.addFilter(
|
||||
'state', FilterCondition(type: FilterType.equals, value: 1));
|
||||
else
|
||||
movieDataSource.removeFilter(
|
||||
'state', FilterCondition(type: FilterType.equals, value: 1));
|
||||
'state',
|
||||
FilterCondition(
|
||||
type: FilterType.equals,
|
||||
value: 1,
|
||||
filterOperator: FilterOperator.or),
|
||||
);
|
||||
|
||||
if (showProg)
|
||||
movieDataSource.addFilter(
|
||||
'state', FilterCondition(type: FilterType.equals, value: 2));
|
||||
else
|
||||
movieDataSource.removeFilter(
|
||||
'state', FilterCondition(type: FilterType.equals, value: 2));
|
||||
'state',
|
||||
FilterCondition(
|
||||
type: FilterType.equals,
|
||||
value: 2,
|
||||
filterOperator: FilterOperator.or,
|
||||
));
|
||||
|
||||
if (showDone)
|
||||
movieDataSource.addFilter(
|
||||
'state', FilterCondition(type: FilterType.equals, value: 3));
|
||||
else
|
||||
movieDataSource.removeFilter(
|
||||
'state', FilterCondition(type: FilterType.equals, value: 3));
|
||||
'state',
|
||||
FilterCondition(
|
||||
type: FilterType.equals,
|
||||
value: 3,
|
||||
filterOperator: FilterOperator.or,
|
||||
));
|
||||
|
||||
movieDataSource.addFilter(
|
||||
'movieTitle',
|
||||
FilterCondition(
|
||||
type: FilterType.beginsWith,
|
||||
value: text,
|
||||
filterOperator: FilterOperator.and,
|
||||
filterBehavior: FilterBehavior.stringDataType,
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -237,7 +252,6 @@ class _MoviesScreenState extends State<MoviesScreen> {
|
||||
headerColor: Color(0xff009889),
|
||||
),
|
||||
child: SfDataGrid(
|
||||
allowFiltering: true,
|
||||
source: movieDataSource,
|
||||
selectionMode: SelectionMode.single,
|
||||
navigationMode: GridNavigationMode.row,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:convert';
|
||||
import 'package:multimedia/widgets/tvshows/details/details_screen.dart';
|
||||
import 'package:multimedia/widgets/tvshows/filter_box.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
@@ -287,7 +288,7 @@ class _TVShowsScreenState extends State<TVShowsScreen> {
|
||||
...setSeasonData(maxSeason, e.seasonStatus),
|
||||
]);
|
||||
|
||||
for (int i = 0;i < _columns.length;i++) {
|
||||
for (int i = 0; i < _columns.length; i++) {
|
||||
tvshowDataSource.updateDataGridSource(
|
||||
rowColumnIndex: RowColumnIndex(index, i));
|
||||
}
|
||||
@@ -295,6 +296,46 @@ class _TVShowsScreenState extends State<TVShowsScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
void setFilter(String text, bool showInit, bool showProg, bool showDone) {
|
||||
tvshowDataSource.clearFilters();
|
||||
|
||||
if (showInit)
|
||||
tvshowDataSource.addFilter(
|
||||
'seriesState',
|
||||
FilterCondition(
|
||||
type: FilterType.equals,
|
||||
value: 1,
|
||||
filterOperator: FilterOperator.or),
|
||||
);
|
||||
|
||||
if (showProg)
|
||||
tvshowDataSource.addFilter(
|
||||
'seriesState',
|
||||
FilterCondition(
|
||||
type: FilterType.equals,
|
||||
value: 2,
|
||||
filterOperator: FilterOperator.or,
|
||||
));
|
||||
|
||||
if (showDone)
|
||||
tvshowDataSource.addFilter(
|
||||
'seriesState',
|
||||
FilterCondition(
|
||||
type: FilterType.equals,
|
||||
value: 3,
|
||||
filterOperator: FilterOperator.or,
|
||||
));
|
||||
|
||||
tvshowDataSource.addFilter(
|
||||
'seriesName',
|
||||
FilterCondition(
|
||||
type: FilterType.beginsWith,
|
||||
value: text,
|
||||
filterOperator: FilterOperator.and,
|
||||
filterBehavior: FilterBehavior.stringDataType,
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -302,36 +343,44 @@ class _TVShowsScreenState extends State<TVShowsScreen> {
|
||||
future: generateTVShowList(),
|
||||
builder: (context, data) {
|
||||
return data.hasData
|
||||
? SfDataGridTheme(
|
||||
data: const SfDataGridThemeData(
|
||||
headerColor: Color(0xff009889),
|
||||
),
|
||||
child: SfDataGrid(
|
||||
source: tvshowDataSource,
|
||||
selectionMode: SelectionMode.single,
|
||||
navigationMode: GridNavigationMode.row,
|
||||
columns: _columns,
|
||||
controller: _dataGridController,
|
||||
columnWidthMode: ColumnWidthMode.auto,
|
||||
columnWidthCalculationRange:
|
||||
ColumnWidthCalculationRange.allRows,
|
||||
onCellTap: (DataGridCellTapDetails details) {
|
||||
int index = details.rowColumnIndex.rowIndex - 1;
|
||||
if (index < 0) {
|
||||
return;
|
||||
}
|
||||
showTVShowDetails(index);
|
||||
},
|
||||
onCellDoubleTap: (DataGridCellDoubleTapDetails details) {
|
||||
print(details.rowColumnIndex);
|
||||
},
|
||||
onCellLongPress: (DataGridCellLongPressDetails details) {
|
||||
print(details.rowColumnIndex);
|
||||
},
|
||||
onCellSecondaryTap: (DataGridCellTapDetails details) {
|
||||
print(details.rowColumnIndex);
|
||||
},
|
||||
),
|
||||
? Column(
|
||||
children: [
|
||||
TVShowFilterBox(setFilter: setFilter),
|
||||
Expanded(
|
||||
child: SfDataGridTheme(
|
||||
data: const SfDataGridThemeData(
|
||||
headerColor: Color(0xff009889),
|
||||
),
|
||||
child: SfDataGrid(
|
||||
source: tvshowDataSource,
|
||||
selectionMode: SelectionMode.single,
|
||||
navigationMode: GridNavigationMode.row,
|
||||
columns: _columns,
|
||||
controller: _dataGridController,
|
||||
columnWidthMode: ColumnWidthMode.auto,
|
||||
columnWidthCalculationRange:
|
||||
ColumnWidthCalculationRange.allRows,
|
||||
onCellTap: (DataGridCellTapDetails details) {
|
||||
int index = details.rowColumnIndex.rowIndex - 1;
|
||||
if (index < 0) {
|
||||
return;
|
||||
}
|
||||
showTVShowDetails(index);
|
||||
},
|
||||
onCellDoubleTap:
|
||||
(DataGridCellDoubleTapDetails details) {
|
||||
print(details.rowColumnIndex);
|
||||
},
|
||||
onCellLongPress:
|
||||
(DataGridCellLongPressDetails details) {
|
||||
print(details.rowColumnIndex);
|
||||
},
|
||||
onCellSecondaryTap: (DataGridCellTapDetails details) {
|
||||
print(details.rowColumnIndex);
|
||||
},
|
||||
),
|
||||
)),
|
||||
],
|
||||
)
|
||||
: const Center(
|
||||
child: CircularProgressIndicator(
|
||||
|
||||
Reference in New Issue
Block a user