Filter
This commit is contained in:
@@ -15,6 +15,9 @@ import 'package:multimedia/widgets/movies/details/companies_box.dart';
|
||||
import 'package:multimedia/widgets/movies/details/countries_box.dart';
|
||||
import 'package:multimedia/widgets/movies/details/settings_box.dart';
|
||||
|
||||
import 'package:logger/logger.dart';
|
||||
import 'package:multimedia/log_printer.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class MovieDetailsScreen extends StatelessWidget {
|
||||
MovieDetailsScreen({
|
||||
@@ -24,6 +27,7 @@ class MovieDetailsScreen extends StatelessWidget {
|
||||
|
||||
final Movie movie;
|
||||
late Movie movieDetails;
|
||||
Logger logger = getLogger();
|
||||
|
||||
Future<Movie> loadMovieDetails(int movieID) async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
@@ -290,52 +294,52 @@ class MovieDetailsScreen extends StatelessWidget {
|
||||
}
|
||||
|
||||
Future<bool> updateMovie() async {
|
||||
// SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
|
||||
// String? dbProtocol = prefs.getString('dbProtocol');
|
||||
// String? dbHost = prefs.getString('dbHost');
|
||||
// String? dbPath = prefs.getString('dbPath');
|
||||
String? dbProtocol = prefs.getString('dbProtocol');
|
||||
String? dbHost = prefs.getString('dbHost');
|
||||
String? dbPath = prefs.getString('dbPath');
|
||||
|
||||
// Uri url = Uri(
|
||||
// scheme: dbProtocol,
|
||||
// host: dbHost,
|
||||
// path: dbPath,
|
||||
// );
|
||||
Uri url = Uri(
|
||||
scheme: dbProtocol,
|
||||
host: dbHost,
|
||||
path: dbPath,
|
||||
);
|
||||
|
||||
// try {
|
||||
// final r = await http.post(
|
||||
// url,
|
||||
// headers: <String, String>{
|
||||
// 'Content-Type': 'application/json; charset=UTF-8',
|
||||
// },
|
||||
// body: jsonEncode(
|
||||
// <String, String>{
|
||||
// 'module': 'movie',
|
||||
// 'function': 'update',
|
||||
// 'movieID': movieDetails.movieID.toString(),
|
||||
// 'movieTitle': movieDetails.movieTitle,
|
||||
// 'originalTitle': movieDetails.originalTitle,
|
||||
// 'overview': movieDetails.overview,
|
||||
// 'releaseDate':
|
||||
// DateFormat('yyyy-MM-dd').format(movieDetails.releaseDate),
|
||||
// 'resolution': movieDetails.resolution,
|
||||
// 'state': movieDetails.state.toString(),
|
||||
// 'backdropPath': movieDetails.backdropPath,
|
||||
// 'languages': movieDetails.languages,
|
||||
// 'productionCountries': movieDetails.productionCountries,
|
||||
// 'productionCompanies': movieDetails.productionCompanies,
|
||||
// 'voteAverage': movieDetails.voteAverage.toString(),
|
||||
// 'voteCount': movieDetails.voteCount.toString(),
|
||||
// 'cast': movieDetails.cast,
|
||||
// 'crew': movieDetails.crew,
|
||||
// 'genre': movieDetails.genre,
|
||||
// 'localPath': movieDetails.localPath,
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
// } catch (e) {
|
||||
// print(e.toString());
|
||||
// }
|
||||
try {
|
||||
final r = await http.post(
|
||||
url,
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
body: jsonEncode(
|
||||
<String, String>{
|
||||
'module': 'movie',
|
||||
'function': 'update',
|
||||
'movieID': movieDetails.movieID.toString(),
|
||||
'movieTitle': movieDetails.movieTitle,
|
||||
'originalTitle': movieDetails.originalTitle,
|
||||
'overview': movieDetails.overview,
|
||||
'releaseDate':
|
||||
DateFormat('yyyy-MM-dd').format(movieDetails.releaseDate),
|
||||
'resolution': movieDetails.resolution,
|
||||
'state': movieDetails.state.toString(),
|
||||
'backdropPath': movieDetails.backdropPath,
|
||||
'languages': movieDetails.languages,
|
||||
'productionCountries': movieDetails.productionCountries,
|
||||
'productionCompanies': movieDetails.productionCompanies,
|
||||
'voteAverage': movieDetails.voteAverage.toString(),
|
||||
'voteCount': movieDetails.voteCount.toString(),
|
||||
'cast': movieDetails.cast,
|
||||
'crew': movieDetails.crew,
|
||||
'genre': movieDetails.genre,
|
||||
'localPath': movieDetails.localPath,
|
||||
},
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
logger.e(e.toString());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:convert';
|
||||
import 'package:multimedia/widgets/movies/details/details_screen.dart';
|
||||
import 'package:multimedia/widgets/movies/filter_box.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
@@ -13,6 +14,9 @@ import 'package:multimedia/data/movies.dart';
|
||||
|
||||
import 'package:multimedia/constants.dart';
|
||||
|
||||
import 'package:logger/logger.dart';
|
||||
import 'package:multimedia/log_printer.dart';
|
||||
|
||||
class MoviesScreen extends StatefulWidget {
|
||||
const MoviesScreen({
|
||||
super.key,
|
||||
@@ -28,6 +32,8 @@ class _MoviesScreenState extends State<MoviesScreen> {
|
||||
List<GridColumn> _columns = [];
|
||||
late List<Movie> _moviesList;
|
||||
|
||||
Logger logger = getLogger();
|
||||
|
||||
Future<List<Movie>> generateMovieList() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
|
||||
@@ -165,7 +171,7 @@ class _MoviesScreenState extends State<MoviesScreen> {
|
||||
DataGridCell<int>(columnName: 'movieID', value: e.movieID),
|
||||
DataGridCell<int>(columnName: 'state', value: e.state),
|
||||
DataGridCell<String>(
|
||||
columnName: 'backdropPath', value: e.backdropPath),
|
||||
columnName: 'backdropPath', value: e.backdropPath),
|
||||
DataGridCell<String>(columnName: 'movieTitle', value: e.movieTitle),
|
||||
DataGridCell<String>(
|
||||
columnName: 'releaseDate',
|
||||
@@ -186,11 +192,35 @@ class _MoviesScreenState extends State<MoviesScreen> {
|
||||
rowColumnIndex: RowColumnIndex(index, 4));
|
||||
movieDataSource.updateDataGridSource(
|
||||
rowColumnIndex: RowColumnIndex(index, 5));
|
||||
} else {
|
||||
}
|
||||
} else {}
|
||||
}
|
||||
}
|
||||
|
||||
void setFilter(String text, bool showInit, bool showProg, bool showDone) {
|
||||
// movieDataSource.clearFilters();
|
||||
|
||||
if (showInit)
|
||||
movieDataSource.addFilter(
|
||||
'state', FilterCondition(type: FilterType.equals, value: 1));
|
||||
else
|
||||
movieDataSource.removeFilter(
|
||||
'state', FilterCondition(type: FilterType.equals, value: 1));
|
||||
|
||||
if (showProg)
|
||||
movieDataSource.addFilter(
|
||||
'state', FilterCondition(type: FilterType.equals, value: 2));
|
||||
else
|
||||
movieDataSource.removeFilter(
|
||||
'state', FilterCondition(type: FilterType.equals, value: 2));
|
||||
|
||||
if (showDone)
|
||||
movieDataSource.addFilter(
|
||||
'state', FilterCondition(type: FilterType.equals, value: 3));
|
||||
else
|
||||
movieDataSource.removeFilter(
|
||||
'state', FilterCondition(type: FilterType.equals, value: 3));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -198,36 +228,45 @@ class _MoviesScreenState extends State<MoviesScreen> {
|
||||
future: generateMovieList(),
|
||||
builder: (context, data) {
|
||||
return data.hasData
|
||||
? SfDataGridTheme(
|
||||
data: const SfDataGridThemeData(
|
||||
headerColor: Color(0xff009889),
|
||||
),
|
||||
child: SfDataGrid(
|
||||
source: movieDataSource,
|
||||
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;
|
||||
}
|
||||
showMovieDetails(index);
|
||||
},
|
||||
onCellDoubleTap: (DataGridCellDoubleTapDetails details) {
|
||||
print(details.rowColumnIndex);
|
||||
},
|
||||
onCellLongPress: (DataGridCellLongPressDetails details) {
|
||||
print(details.rowColumnIndex);
|
||||
},
|
||||
onCellSecondaryTap: (DataGridCellTapDetails details) {
|
||||
print(details.rowColumnIndex);
|
||||
},
|
||||
),
|
||||
? Column(
|
||||
children: [
|
||||
MovieFilterBox(setFilter: setFilter),
|
||||
Expanded(
|
||||
child: SfDataGridTheme(
|
||||
data: const SfDataGridThemeData(
|
||||
headerColor: Color(0xff009889),
|
||||
),
|
||||
child: SfDataGrid(
|
||||
allowFiltering: true,
|
||||
source: movieDataSource,
|
||||
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;
|
||||
}
|
||||
showMovieDetails(index);
|
||||
},
|
||||
onCellDoubleTap:
|
||||
(DataGridCellDoubleTapDetails details) {
|
||||
print(details.rowColumnIndex);
|
||||
},
|
||||
onCellLongPress:
|
||||
(DataGridCellLongPressDetails details) {
|
||||
print(details.rowColumnIndex);
|
||||
},
|
||||
onCellSecondaryTap: (DataGridCellTapDetails details) {
|
||||
print(details.rowColumnIndex);
|
||||
},
|
||||
),
|
||||
)),
|
||||
],
|
||||
)
|
||||
: const Center(
|
||||
child: CircularProgressIndicator(
|
||||
@@ -247,6 +286,8 @@ class MovieDataSource extends DataGridSource {
|
||||
buildDataGridRow();
|
||||
}
|
||||
|
||||
Logger logger = getLogger();
|
||||
|
||||
void buildDataGridRow() {
|
||||
_movieDataGridRows = movies
|
||||
.map<DataGridRow>((e) => DataGridRow(cells: [
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
@@ -341,57 +342,57 @@ class TVShowDetailsScreen extends StatelessWidget {
|
||||
}
|
||||
|
||||
Future<bool> updateTVShow() async {
|
||||
// SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
|
||||
// String? dbProtocol = prefs.getString('dbProtocol');
|
||||
// String? dbHost = prefs.getString('dbHost');
|
||||
// String? dbPath = prefs.getString('dbPath');
|
||||
String? dbProtocol = prefs.getString('dbProtocol');
|
||||
String? dbHost = prefs.getString('dbHost');
|
||||
String? dbPath = prefs.getString('dbPath');
|
||||
|
||||
// Uri url = Uri(
|
||||
// scheme: dbProtocol,
|
||||
// host: dbHost,
|
||||
// path: dbPath,
|
||||
// );
|
||||
Uri url = Uri(
|
||||
scheme: dbProtocol,
|
||||
host: dbHost,
|
||||
path: dbPath,
|
||||
);
|
||||
|
||||
// var seasonState = jsonEncode(tvShowDetails.seasonStatus.map((e) => e.toJson()).toList());
|
||||
var seasonState = jsonEncode(tvShowDetails.seasonStatus.map((e) => e.toJson()).toList());
|
||||
|
||||
// try {
|
||||
// final r = await http.post(
|
||||
// url,
|
||||
// headers: <String, String>{
|
||||
// 'Content-Type': 'application/json; charset=UTF-8',
|
||||
// },
|
||||
// body: jsonEncode(
|
||||
// <String, dynamic>{
|
||||
// 'module': 'tvshow',
|
||||
// 'function': 'update',
|
||||
// 'seriesID': tvShowDetails.seriesID.toString(),
|
||||
// 'seriesName': tvShowDetails.seriesName,
|
||||
// 'overview': tvShowDetails.overview,
|
||||
// 'firstAired':
|
||||
// DateFormat('yyyy-MM-dd').format(tvShowDetails.firstAired),
|
||||
// 'resolution': tvShowDetails.resolution,
|
||||
// 'cliffhanger': tvShowDetails.cliffhanger.toString(),
|
||||
// 'status': tvShowDetails.status.toString(),
|
||||
// 'backdropPath': tvShowDetails.backdropPath,
|
||||
// 'seriesState': tvShowDetails.seriesState.toString(),
|
||||
// 'languages': tvShowDetails.languages,
|
||||
// 'networks': tvShowDetails.networks,
|
||||
// 'productionCompanies': tvShowDetails.productionCompanies,
|
||||
// 'voteAverage': tvShowDetails.voteAverage.toString(),
|
||||
// 'voteCount': tvShowDetails.voteCount.toString(),
|
||||
// 'cast': tvShowDetails.cast,
|
||||
// 'crew': tvShowDetails.crew,
|
||||
// 'genre': tvShowDetails.genre,
|
||||
// 'download': tvShowDetails.download,
|
||||
// 'localPath': tvShowDetails.localPath,
|
||||
// 'seasons': seasonState,
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
// } catch (e) {
|
||||
// logger.e(e.toString());
|
||||
// }
|
||||
try {
|
||||
final r = await http.post(
|
||||
url,
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
body: jsonEncode(
|
||||
<String, dynamic>{
|
||||
'module': 'tvshow',
|
||||
'function': 'update',
|
||||
'seriesID': tvShowDetails.seriesID.toString(),
|
||||
'seriesName': tvShowDetails.seriesName,
|
||||
'overview': tvShowDetails.overview,
|
||||
'firstAired':
|
||||
DateFormat('yyyy-MM-dd').format(tvShowDetails.firstAired),
|
||||
'resolution': tvShowDetails.resolution,
|
||||
'cliffhanger': tvShowDetails.cliffhanger.toString(),
|
||||
'status': tvShowDetails.status.toString(),
|
||||
'backdropPath': tvShowDetails.backdropPath,
|
||||
'seriesState': tvShowDetails.seriesState.toString(),
|
||||
'languages': tvShowDetails.languages,
|
||||
'networks': tvShowDetails.networks,
|
||||
'productionCompanies': tvShowDetails.productionCompanies,
|
||||
'voteAverage': tvShowDetails.voteAverage.toString(),
|
||||
'voteCount': tvShowDetails.voteCount.toString(),
|
||||
'cast': tvShowDetails.cast,
|
||||
'crew': tvShowDetails.crew,
|
||||
'genre': tvShowDetails.genre,
|
||||
'download': tvShowDetails.download,
|
||||
'localPath': tvShowDetails.localPath,
|
||||
'seasons': seasonState,
|
||||
},
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
logger.e(e.toString());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,9 @@ import 'package:multimedia/data/tvshows.dart';
|
||||
|
||||
import 'package:multimedia/constants.dart';
|
||||
|
||||
import 'package:logger/logger.dart';
|
||||
import 'package:multimedia/log_printer.dart';
|
||||
|
||||
String convertState(String state) {
|
||||
List<String> stateList = state.split(',');
|
||||
int maxEpisode = 0;
|
||||
@@ -348,6 +351,8 @@ class TVShowDataSource extends DataGridSource {
|
||||
buildDataGridRow();
|
||||
}
|
||||
|
||||
Logger logger = getLogger();
|
||||
|
||||
void buildDataGridRow() {
|
||||
_tvshowDataGridRows = tvshows
|
||||
.map<DataGridRow>((e) => DataGridRow(cells: [
|
||||
|
||||
Reference in New Issue
Block a user