filter_box

main
Herwig Birke 1 year ago
parent c07551c826
commit ae4290fb47

@ -32,6 +32,11 @@ class _MoviesScreenState extends State<MoviesScreen> {
List<GridColumn> _columns = [];
late List<Movie> _moviesList;
String searchText = '';
bool showInit = false;
bool showProg = false;
bool showDone = false;
Logger logger = getLogger();
Future<List<Movie>> generateMovieList() async {
@ -139,12 +144,17 @@ class _MoviesScreenState extends State<MoviesScreen> {
}
Future<void> showMovieDetails(int index) async {
List<DataGridCell<dynamic>> cells =
movieDataSource.effectiveRows.elementAt(index).getCells();
DataGridRow row = movieDataSource.effectiveRows.elementAt(index);
List<DataGridCell<dynamic>> cells = row.getCells();
String movieID = cells[MovieColumn.movieID].value.toString();
bool found = false;
int movieIndex;
int realIndex;
movieDataSource.clearFilters();
realIndex = movieDataSource.rows.indexOf(row);
for (movieIndex = 0; movieIndex < _moviesList.length; movieIndex++) {
if (_moviesList[movieIndex].movieID == int.parse(movieID)) {
@ -167,7 +177,7 @@ class _MoviesScreenState extends State<MoviesScreen> {
_moviesList[movieIndex].state = m.state;
Movie e = _moviesList[movieIndex];
movieDataSource._movieDataGridRows[index] = DataGridRow(cells: [
movieDataSource._movieDataGridRows[realIndex] = DataGridRow(cells: [
DataGridCell<int>(columnName: 'movieID', value: e.movieID),
DataGridCell<int>(columnName: 'state', value: e.state),
DataGridCell<String>(
@ -180,23 +190,37 @@ class _MoviesScreenState extends State<MoviesScreen> {
DataGridCell<String>(columnName: 'overview', value: e.overview),
]);
movieDataSource.updateDataGridSource(
rowColumnIndex: RowColumnIndex(index, 0));
movieDataSource.updateDataGridSource(
rowColumnIndex: RowColumnIndex(index, 1));
movieDataSource.updateDataGridSource(
rowColumnIndex: RowColumnIndex(index, 2));
movieDataSource.updateDataGridSource(
rowColumnIndex: RowColumnIndex(index, 3));
movieDataSource.updateDataGridSource(
rowColumnIndex: RowColumnIndex(index, 4));
movieDataSource.updateDataGridSource(
rowColumnIndex: RowColumnIndex(index, 5));
for (int i = 0; i < _columns.length; i++) {
movieDataSource.updateDataGridSource(
rowColumnIndex: RowColumnIndex(realIndex, i));
}
// movieDataSource.updateDataGridSource(
// rowColumnIndex: RowColumnIndex(realIndex, 0));
// movieDataSource.updateDataGridSource(
// rowColumnIndex: RowColumnIndex(realIndex, 1));
// movieDataSource.updateDataGridSource(
// rowColumnIndex: RowColumnIndex(realIndex, 2));
// movieDataSource.updateDataGridSource(
// rowColumnIndex: RowColumnIndex(realIndex, 3));
// movieDataSource.updateDataGridSource(
// rowColumnIndex: RowColumnIndex(realIndex, 4));
// movieDataSource.updateDataGridSource(
// rowColumnIndex: RowColumnIndex(realIndex, 5));
} else {}
filter();
}
}
void setFilter(String text, bool showInit, bool showProg, bool showDone) {
void setFilter(String text, bool sInit, bool sProg, bool sDone) {
searchText = text;
showInit = sInit;
showProg = sProg;
showDone = sDone;
filter();
}
void filter() {
movieDataSource.clearFilters();
if (showInit)
@ -230,7 +254,7 @@ class _MoviesScreenState extends State<MoviesScreen> {
'movieTitle',
FilterCondition(
type: FilterType.beginsWith,
value: text,
value: searchText,
filterOperator: FilterOperator.and,
filterBehavior: FilterBehavior.stringDataType,
));

@ -82,6 +82,13 @@ class _TVShowsScreenState extends State<TVShowsScreen> {
late bool initDone = false;
late List<TVShow> _tvshowsList;
String searchText = '';
bool showInit = false;
bool showProg = false;
bool showDone = false;
Logger logger = getLogger();
Future<List<TVShow>> generateTVShowList() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
@ -241,12 +248,18 @@ class _TVShowsScreenState extends State<TVShowsScreen> {
}
Future<void> showTVShowDetails(int index) async {
DataGridRow row = tvshowDataSource.effectiveRows.elementAt(index);
List<DataGridCell<dynamic>> cells =
tvshowDataSource.effectiveRows.elementAt(index).getCells();
row.getCells();
String seriesID = cells[TVShowColumn.seriesID].value.toString();
bool found = false;
int tvShowIndex;
int realIndex;
tvshowDataSource.clearFilters();
realIndex = tvshowDataSource.rows.indexOf(row);
for (tvShowIndex = 0; tvShowIndex < _tvshowsList.length; tvShowIndex++) {
if (_tvshowsList[tvShowIndex].seriesID == int.parse(seriesID)) {
@ -272,7 +285,7 @@ class _TVShowsScreenState extends State<TVShowsScreen> {
_tvshowsList[tvShowIndex].seriesState = t.seriesState;
TVShow e = _tvshowsList[tvShowIndex];
tvshowDataSource._tvshowDataGridRows[index] = DataGridRow(cells: [
tvshowDataSource._tvshowDataGridRows[realIndex] = DataGridRow(cells: [
DataGridCell<int>(columnName: 'seriesID', value: e.seriesID),
DataGridCell<int>(columnName: 'seriesState', value: e.seriesState),
DataGridCell<String>(columnName: 'status', value: e.status),
@ -290,13 +303,22 @@ class _TVShowsScreenState extends State<TVShowsScreen> {
for (int i = 0; i < _columns.length; i++) {
tvshowDataSource.updateDataGridSource(
rowColumnIndex: RowColumnIndex(index, i));
rowColumnIndex: RowColumnIndex(realIndex, i));
}
} else {}
filter();
}
}
void setFilter(String text, bool showInit, bool showProg, bool showDone) {
void setFilter(String text, bool sInit, bool sProg, bool sDone) {
searchText = text;
showInit = sInit;
showProg = sProg;
showDone = sDone;
filter();
}
void filter() {
tvshowDataSource.clearFilters();
if (showInit)
@ -330,7 +352,7 @@ class _TVShowsScreenState extends State<TVShowsScreen> {
'seriesName',
FilterCondition(
type: FilterType.beginsWith,
value: text,
value: searchText,
filterOperator: FilterOperator.and,
filterBehavior: FilterBehavior.stringDataType,
));

Loading…
Cancel
Save