From 5ab3a2a4a23ac48ba2c8f92b698b610c830197c2 Mon Sep 17 00:00:00 2001 From: Herwig Birke Date: Tue, 16 Apr 2024 16:16:59 +0200 Subject: [PATCH] movie and tvshow list --- lib/main.dart | 6 +- .../listScreen.dart} | 104 +++---- lib/widgets/tabsScreen.dart | 5 +- lib/widgets/tvshowDetailsScreen.dart | 125 -------- lib/widgets/tvshowDetailsSeasonBox.dart | 72 ----- lib/widgets/tvshowDetailsSeasons.dart | 38 --- lib/widgets/tvshowDetailsSettingsBox.dart | 210 ------------- .../details/castBox.dart} | 26 +- .../details/companiesBox.dart} | 26 +- .../details/countriesBox.dart} | 26 +- .../details/crewBox.dart} | 26 +- .../tvshows/details/detailsScreen.dart | 135 ++++++++ .../details/genreBox.dart} | 26 +- .../details/overviewBox.dart} | 30 +- lib/widgets/tvshows/details/seasonBox.dart | 293 ++++++++++++++++++ lib/widgets/tvshows/details/seasons.dart | 38 +++ lib/widgets/tvshows/details/settingsBox.dart | 98 ++++++ .../details/settingsBoxCliffhanger.dart | 59 ++++ .../details/settingsBoxDownloadLink.dart | 42 +++ .../tvshows/details/settingsBoxLocalPath.dart | 34 ++ .../details/settingsBoxResolution.dart | 74 +++++ .../listScreen.dart} | 244 ++++++++------- 22 files changed, 1029 insertions(+), 708 deletions(-) rename lib/widgets/{moviesScreen.dart => movies/listScreen.dart} (68%) delete mode 100644 lib/widgets/tvshowDetailsScreen.dart delete mode 100644 lib/widgets/tvshowDetailsSeasonBox.dart delete mode 100644 lib/widgets/tvshowDetailsSeasons.dart delete mode 100644 lib/widgets/tvshowDetailsSettingsBox.dart rename lib/widgets/{tvshowDetailsCastBox.dart => tvshows/details/castBox.dart} (88%) rename lib/widgets/{tvshowDetailsCompaniesBox.dart => tvshows/details/companiesBox.dart} (85%) rename lib/widgets/{tvshowDetailsCountriesBox.dart => tvshows/details/countriesBox.dart} (85%) rename lib/widgets/{tvshowDetailsCrewBox.dart => tvshows/details/crewBox.dart} (88%) create mode 100644 lib/widgets/tvshows/details/detailsScreen.dart rename lib/widgets/{tvshowDetailsGenreBox.dart => tvshows/details/genreBox.dart} (85%) rename lib/widgets/{tvshowDetailsOverviewBox.dart => tvshows/details/overviewBox.dart} (68%) create mode 100644 lib/widgets/tvshows/details/seasonBox.dart create mode 100644 lib/widgets/tvshows/details/seasons.dart create mode 100644 lib/widgets/tvshows/details/settingsBox.dart create mode 100644 lib/widgets/tvshows/details/settingsBoxCliffhanger.dart create mode 100644 lib/widgets/tvshows/details/settingsBoxDownloadLink.dart create mode 100644 lib/widgets/tvshows/details/settingsBoxLocalPath.dart create mode 100644 lib/widgets/tvshows/details/settingsBoxResolution.dart rename lib/widgets/{tvshowsScreen.dart => tvshows/listScreen.dart} (64%) diff --git a/lib/main.dart b/lib/main.dart index 303c846..e2b5f1a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -24,10 +24,12 @@ void main() async { String? dbPassword = prefs.getString('dbPassword'); // if (dbProtocol == null) { - prefs.setString('dbProtocol', 'http'); + //prefs.setString('dbProtocol', 'http'); + prefs.setString('dbProtocol', 'https'); // } // if (dbHost == null) { - prefs.setString('dbHost', '192.168.0.70'); + //prefs.setString('dbHost', '192.168.0.70'); + prefs.setString('dbHost', 'api.windesign.at'); // } // if (dbProtocol == null) { // prefs.setString('dbProtocol', 'https'); diff --git a/lib/widgets/moviesScreen.dart b/lib/widgets/movies/listScreen.dart similarity index 68% rename from lib/widgets/moviesScreen.dart rename to lib/widgets/movies/listScreen.dart index 86ba698..8280c94 100644 --- a/lib/widgets/moviesScreen.dart +++ b/lib/widgets/movies/listScreen.dart @@ -53,7 +53,7 @@ class _MoviesScreenState extends State { var list = movies['data']; List _movies = - await list.map((json) => Movie.fromJson(json)).toList(); + await list.map((json) => Movie.fromJson(json)).toList(); movieDataSource = MovieDataSource(_movies); return _movies; } @@ -121,24 +121,24 @@ class _MoviesScreenState extends State { 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.fill, - ), - ) + data: const SfDataGridThemeData( + headerColor: Color(0xff009889), + ), + child: SfDataGrid( + source: movieDataSource, + selectionMode: SelectionMode.single, + navigationMode: GridNavigationMode.row, + columns: _columns, + controller: _dataGridController, + columnWidthMode: ColumnWidthMode.fill, + ), + ) : const Center( - child: CircularProgressIndicator( - strokeWidth: 2, - value: 0.8, - ), - ); + child: CircularProgressIndicator( + strokeWidth: 2, + value: 0.8, + ), + ); }, ), ); @@ -154,17 +154,17 @@ class MovieDataSource extends DataGridSource { void buildDataGridRow() { _movieDataGridRows = movies .map((e) => DataGridRow(cells: [ - DataGridCell(columnName: 'movieID', value: e.movieID), - DataGridCell(columnName: 'state', value: e.state), - DataGridCell( - columnName: 'movieTitle', value: e.movieTitle), - DataGridCell( - columnName: 'releaseDate', - value: DateFormat('yyyy-MM-dd').format(e.releaseDate)), - DataGridCell( - columnName: 'resolution', value: e.resolution), - DataGridCell(columnName: 'overview', value: e.overview), - ])) + DataGridCell(columnName: 'movieID', value: e.movieID), + DataGridCell(columnName: 'state', value: e.state), + DataGridCell( + columnName: 'movieTitle', value: e.movieTitle), + DataGridCell( + columnName: 'releaseDate', + value: DateFormat('yyyy-MM-dd').format(e.releaseDate)), + DataGridCell( + columnName: 'resolution', value: e.resolution), + DataGridCell(columnName: 'overview', value: e.overview), + ])) .toList(); } @@ -179,32 +179,32 @@ class MovieDataSource extends DataGridSource { DataGridRowAdapter buildRow(DataGridRow row) { return DataGridRowAdapter( cells: row.getCells().map((e) { - Color colorBG = Colors.white; - Color colorFG = Colors.black; + Color colorBG = Colors.white; + Color colorFG = Colors.black; - if (e.columnName == 'movieTitle') { - int state = row.getCells().toList()[1].value; + if (e.columnName == 'movieTitle') { + int state = row.getCells().toList()[1].value; - if (state == 1) { - colorBG = StateColor.init; - } else if (state == 2) { - colorBG = StateColor.prog; - colorFG = Colors.white; - } else { - colorBG = StateColor.done; - } - } + if (state == 1) { + colorBG = StateColor.init; + } else if (state == 2) { + colorBG = StateColor.prog; + colorFG = Colors.white; + } else { + colorBG = StateColor.done; + } + } - return Container( - alignment: Alignment.centerLeft, - padding: const EdgeInsets.all(8.0), - color: colorBG, - child: Text( - e.value.toString(), - style: TextStyle(color: colorFG), - ), - ); - }).toList()); + return Container( + alignment: Alignment.centerLeft, + padding: const EdgeInsets.all(8.0), + color: colorBG, + child: Text( + e.value.toString(), + style: TextStyle(color: colorFG), + ), + ); + }).toList()); } void updateDataGrid() { diff --git a/lib/widgets/tabsScreen.dart b/lib/widgets/tabsScreen.dart index 1bde59c..b3fa2e5 100644 --- a/lib/widgets/tabsScreen.dart +++ b/lib/widgets/tabsScreen.dart @@ -1,8 +1,7 @@ import 'package:flutter/material.dart'; -import 'package:multimedia/widgets/tvshowsScreen.dart'; -import 'package:multimedia/widgets/moviesScreen.dart'; - +import 'package:multimedia/widgets/tvshows/listScreen.dart'; +import 'package:multimedia/widgets/movies/listScreen.dart'; class TabsScreen extends StatefulWidget { const TabsScreen({super.key}); diff --git a/lib/widgets/tvshowDetailsScreen.dart b/lib/widgets/tvshowDetailsScreen.dart deleted file mode 100644 index 7ec1239..0000000 --- a/lib/widgets/tvshowDetailsScreen.dart +++ /dev/null @@ -1,125 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:multimedia/widgets/tvshowDetailsCompaniesBox.dart'; -import 'package:multimedia/widgets/tvshowDetailsCountriesBox.dart'; -import 'package:multimedia/widgets/tvshowDetailsCrewBox.dart'; -import 'package:multimedia/widgets/tvshowDetailsCastBox.dart'; -import 'package:multimedia/widgets/tvshowDetailsGenreBox.dart'; -import 'package:multimedia/widgets/tvshowDetailsOverviewBox.dart'; -import 'package:multimedia/widgets/tvshowDetailsSeasons.dart'; -import 'package:multimedia/widgets/tvshowDetailsSettingsBox.dart'; -import 'package:transparent_image/transparent_image.dart'; - -import '../data/tvshows.dart'; - -class TVShowDetailsScreen extends StatelessWidget { - TVShowDetailsScreen({ - super.key, - required this.tvShow, - }); - - final TVShow tvShow; - String firstAiredYear = '?'; - - @override - Widget build(BuildContext context) { - String url = 'http://image.tmdb.org/t/p/original${tvShow.backdropPath}'; - - firstAiredYear = tvShow.firstAired.toString().substring(0, 4); - return Scaffold( - appBar: AppBar( - title: Text("${tvShow.seriesName} ($firstAiredYear)"), - ), - body: Stack(children: [ - Container( - decoration: BoxDecoration( - image: DecorationImage( - image: NetworkImage(url), - fit: BoxFit.cover, - ), - ), - ), - Column( - children: [ - Padding( - padding: const EdgeInsets.only( - left: 10.0, - right: 10.0, - top: 10.0, - bottom: 5.0, - ), - child: TVShowDetailsOverviewBox( - overview: tvShow.overview, - ), - ), - Padding( - padding: const EdgeInsets.only( - left: 10.0, - right: 10.0, - top: 5.0, - bottom: 5.0, - ), - child: Row( - children: [ - Expanded( - child: TVShowDetailsCastBox( - cast: tvShow.cast, - ), - ), - const SizedBox( - width: 10, - ), - Expanded( - child: TVShowDetailsCrewBox( - crew: tvShow.crew, - ), - ), - const SizedBox( - width: 10, - ), - Expanded( - child: TVShowDetailsGenreBox( - genre: tvShow.genre, - ), - ), - const SizedBox( - width: 10, - ), - Expanded( - child: TVShowDetailsCompaniesBox( - companies: tvShow.productionCompanies, - ), - ), - const SizedBox( - width: 10, - ), - Expanded( - child: TVShowDetailsCountriesBox( - countries: tvShow.originCountries, - ), - ), - ], - ), - ), - Padding( - padding: const EdgeInsets.only( - left: 10.0, - right: 10.0, - top: 5.0, - bottom: 5.0, - ), - child: TVShowDetailsSettingsBox( - downloadLink: tvShow.download, - localPath: tvShow.localPath, - resolution: tvShow.resolution, - cliffhanger: tvShow.cliffhanger, - ), - ), - TVShowDetailsSeasons( - seasonStatus: tvShow.seasonStatus, - ), - ], - ), - ]), - ); - } -} diff --git a/lib/widgets/tvshowDetailsSeasonBox.dart b/lib/widgets/tvshowDetailsSeasonBox.dart deleted file mode 100644 index 084295a..0000000 --- a/lib/widgets/tvshowDetailsSeasonBox.dart +++ /dev/null @@ -1,72 +0,0 @@ -import 'package:flutter/material.dart'; - -import 'package:multimedia/constants.dart'; - -import '../data/tvshows.dart'; - -class TVShowDetailsSeasonBox extends StatelessWidget { - TVShowDetailsSeasonBox({super.key, required this.season}); - - Season season; - - @override - Widget build(BuildContext context) { - - return Container( - decoration: BoxDecoration( - color: BoxColor.backgroundColor, - borderRadius: const BorderRadius.all( - Radius.circular(10.0), - ), - ), - child: Column( - children: [ - Padding( - padding: const EdgeInsets.only( - left: 5.0, - right: 5.0, - top: 10.0, - bottom: 5.0, - ), - child: Container( - decoration: BoxDecoration( - color: BoxColor.titleBackgroundColor, - borderRadius: const BorderRadius.all( - Radius.circular(10.0), - ), - ), - child: Expanded( - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Text( - 'Season ${season.seasonNumber}', - style: TextStyle( - fontWeight: FontWeight.bold, - color: BoxColor.titleColor), - textAlign: TextAlign.center, - ), - ], - ), - ), - ), - ), - Center( - child: Padding( - padding: const EdgeInsets.symmetric( - vertical: 10, horizontal: 10), - child: Container( - alignment: Alignment.centerLeft, - child: Text( - 'aaa', - style: const TextStyle(fontSize: 14.0), - ), - ), - ), - ), - ], - ), - ); - } -} diff --git a/lib/widgets/tvshowDetailsSeasons.dart b/lib/widgets/tvshowDetailsSeasons.dart deleted file mode 100644 index 0f3d87b..0000000 --- a/lib/widgets/tvshowDetailsSeasons.dart +++ /dev/null @@ -1,38 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:multimedia/widgets/tvshowDetailsSeasonBox.dart'; - -import '../constants.dart'; -import '../data/tvshows.dart'; - -class TVShowDetailsSeasons extends StatefulWidget { - TVShowDetailsSeasons({ - super.key, - required this.seasonStatus, - }); - - List seasonStatus; - - @override - State createState() => _TVShowDetailsSeasonsState(); -} - -class _TVShowDetailsSeasonsState extends State { - @override - Widget build(BuildContext context) { - return Container( - decoration: BoxDecoration( - color: BoxColor.backgroundColor, - borderRadius: const BorderRadius.all( - Radius.circular(10.0), - ), - ), - child: Column( - children: [ - TVShowDetailsSeasonBox( - season: widget.seasonStatus[0], - ), - ], - ), - ); - } -} diff --git a/lib/widgets/tvshowDetailsSettingsBox.dart b/lib/widgets/tvshowDetailsSettingsBox.dart deleted file mode 100644 index 3d5af50..0000000 --- a/lib/widgets/tvshowDetailsSettingsBox.dart +++ /dev/null @@ -1,210 +0,0 @@ -import 'package:flutter/material.dart'; - -import 'package:multimedia/constants.dart'; - -class TVShowDetailsSettingsBox extends StatefulWidget { - TVShowDetailsSettingsBox({ - super.key, - required this.downloadLink, - required this.localPath, - required this.resolution, - required this.cliffhanger, - }); - - String downloadLink; - String localPath; - String resolution; - int cliffhanger; - - @override - State createState() => - _TVShowDetailsSettingsBoxState(); -} - -class _TVShowDetailsSettingsBoxState extends State { - var resolutions = [ - '360p', - '480i', - '480p', - '576i', - '576p', - '720i', - '720p', - '1080i', - '1080p', - '1440i', - '1440p', - '2160p', - ]; - - var _curResolution = ''; - var _curCliffhanger = 0; - - @override - void initState() { - _curResolution = widget.resolution; - _curCliffhanger = widget.cliffhanger; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Container( - decoration: BoxDecoration( - color: BoxColor.backgroundColor, - borderRadius: const BorderRadius.all( - Radius.circular(10.0), - ), - ), - child: Column( - children: [ - Padding( - padding: const EdgeInsets.only( - left: 5.0, - right: 5.0, - top: 10.0, - bottom: 5.0, - ), - child: Container( - decoration: BoxDecoration( - color: BoxColor.titleBackgroundColor, - borderRadius: const BorderRadius.all( - Radius.circular(10.0), - ), - ), - child: Expanded( - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Text( - 'Settings', - style: TextStyle( - fontWeight: FontWeight.bold, - color: BoxColor.titleColor), - textAlign: TextAlign.center, - ), - ], - ), - ), - ), - ), - Row( - children: [ - Expanded( - flex: 10, - child: Padding( - padding: const EdgeInsets.only( - left: 5.0, - right: 5.0, - top: 5.0, - bottom: 5.0, - ), - child: Column( - children: [ - const Text( - 'Download Link', - style: TextStyle( - fontWeight: FontWeight.bold, - ), - ), - TextFormField( - decoration: const InputDecoration( - border: OutlineInputBorder(), - labelText: 'Download Link', - ), - initialValue: widget.downloadLink, - ), - ], - ), - ), - ), - Expanded( - flex: 10, - child: Column( - children: [ - const Text( - 'Local Path', - style: TextStyle( - fontWeight: FontWeight.bold, - ), - ), - TextFormField( - decoration: const InputDecoration( - border: OutlineInputBorder(), - labelText: 'Local Path', - ), - initialValue: widget.localPath, - ), - ], - ), - ), - const SizedBox( - width: 5, - ), - Expanded( - flex: 2, - child: Column( - children: [ - const Text( - 'Resolution', - style: TextStyle( - fontWeight: FontWeight.bold, - ), - ), - DropdownButtonFormField( - decoration: const InputDecoration( - border: OutlineInputBorder(), - labelText: 'Resolution', - ), - dropdownColor: const Color.fromARGB(255, 127, 127, 127), - value: _curResolution, - items: resolutions.map((String res) { - return DropdownMenuItem(value: res, child: Text(res)); - }).toList(), - onChanged: (String? newValue) { - setState(() { - _curResolution = newValue!; - }); - }, - ), - ], - ), - ), - Expanded( - flex: 1, - child: Column( - children: [ - const Text( - 'Cliffhanger', - style: TextStyle( - fontWeight: FontWeight.bold, - ), - ), - const SizedBox( - height: 10, - ), - Checkbox( - side: MaterialStateBorderSide.resolveWith( - (states) => BorderSide(width: 1.0, color: Colors.grey), - ), - value: (_curCliffhanger == 1), - onChanged: (bool? value) { - setState(() { - _curCliffhanger = value == true ? 1 : 0; - }); - }, - ), - const SizedBox( - height: 10, - ), - ], - ), - ), - ], - ), - ], - ), - ); - } -} diff --git a/lib/widgets/tvshowDetailsCastBox.dart b/lib/widgets/tvshows/details/castBox.dart similarity index 88% rename from lib/widgets/tvshowDetailsCastBox.dart rename to lib/widgets/tvshows/details/castBox.dart index e547a1c..831d7f3 100644 --- a/lib/widgets/tvshowDetailsCastBox.dart +++ b/lib/widgets/tvshows/details/castBox.dart @@ -34,20 +34,18 @@ class TVShowDetailsCastBox extends StatelessWidget { Radius.circular(10.0), ), ), - child: Expanded( - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Text( - 'Cast', - style: TextStyle( - fontWeight: FontWeight.bold, - color: BoxColor.titleColor), - textAlign: TextAlign.center, - ), - ], - ), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Text( + 'Cast', + style: TextStyle( + fontWeight: FontWeight.bold, + color: BoxColor.titleColor), + textAlign: TextAlign.center, + ), + ], ), ), ), diff --git a/lib/widgets/tvshowDetailsCompaniesBox.dart b/lib/widgets/tvshows/details/companiesBox.dart similarity index 85% rename from lib/widgets/tvshowDetailsCompaniesBox.dart rename to lib/widgets/tvshows/details/companiesBox.dart index 99cccab..72d7bd8 100644 --- a/lib/widgets/tvshowDetailsCompaniesBox.dart +++ b/lib/widgets/tvshows/details/companiesBox.dart @@ -34,20 +34,18 @@ class TVShowDetailsCompaniesBox extends StatelessWidget { Radius.circular(10.0), ), ), - child: Expanded( - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Text( - 'Production Companies', - style: TextStyle( - fontWeight: FontWeight.bold, - color: BoxColor.titleColor), - textAlign: TextAlign.center, - ), - ], - ), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Text( + 'Production Companies', + style: TextStyle( + fontWeight: FontWeight.bold, + color: BoxColor.titleColor), + textAlign: TextAlign.center, + ), + ], ), ), ), diff --git a/lib/widgets/tvshowDetailsCountriesBox.dart b/lib/widgets/tvshows/details/countriesBox.dart similarity index 85% rename from lib/widgets/tvshowDetailsCountriesBox.dart rename to lib/widgets/tvshows/details/countriesBox.dart index eba7859..b2247b7 100644 --- a/lib/widgets/tvshowDetailsCountriesBox.dart +++ b/lib/widgets/tvshows/details/countriesBox.dart @@ -34,20 +34,18 @@ class TVShowDetailsCountriesBox extends StatelessWidget { Radius.circular(10.0), ), ), - child: Expanded( - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Text( - 'Production Countries', - style: TextStyle( - fontWeight: FontWeight.bold, - color: BoxColor.titleColor), - textAlign: TextAlign.center, - ), - ], - ), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Text( + 'Production Countries', + style: TextStyle( + fontWeight: FontWeight.bold, + color: BoxColor.titleColor), + textAlign: TextAlign.center, + ), + ], ), ), ), diff --git a/lib/widgets/tvshowDetailsCrewBox.dart b/lib/widgets/tvshows/details/crewBox.dart similarity index 88% rename from lib/widgets/tvshowDetailsCrewBox.dart rename to lib/widgets/tvshows/details/crewBox.dart index 7482dc9..324cc48 100644 --- a/lib/widgets/tvshowDetailsCrewBox.dart +++ b/lib/widgets/tvshows/details/crewBox.dart @@ -34,20 +34,18 @@ class TVShowDetailsCrewBox extends StatelessWidget { Radius.circular(10.0), ), ), - child: Expanded( - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Text( - 'Crew', - style: TextStyle( - fontWeight: FontWeight.bold, - color: BoxColor.titleColor), - textAlign: TextAlign.center, - ), - ], - ), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Text( + 'Crew', + style: TextStyle( + fontWeight: FontWeight.bold, + color: BoxColor.titleColor), + textAlign: TextAlign.center, + ), + ], ), ), ), diff --git a/lib/widgets/tvshows/details/detailsScreen.dart b/lib/widgets/tvshows/details/detailsScreen.dart new file mode 100644 index 0000000..d4e6c8c --- /dev/null +++ b/lib/widgets/tvshows/details/detailsScreen.dart @@ -0,0 +1,135 @@ +import 'package:flutter/material.dart'; +import 'package:multimedia/widgets/tvshows/details/companiesBox.dart'; +import 'package:multimedia/widgets/tvshows/details/countriesBox.dart'; +import 'package:multimedia/widgets/tvshows/details/crewBox.dart'; +import 'package:multimedia/widgets/tvshows/details/castBox.dart'; +import 'package:multimedia/widgets/tvshows/details/genreBox.dart'; +import 'package:multimedia/widgets/tvshows/details/overviewBox.dart'; +import 'package:multimedia/widgets/tvshows/details/seasons.dart'; +import 'package:multimedia/widgets/tvshows/details/settingsBox.dart'; +import 'package:transparent_image/transparent_image.dart'; + +import 'package:multimedia/data/tvshows.dart'; + +class TVShowDetailsScreen extends StatelessWidget { + TVShowDetailsScreen({ + super.key, + required this.tvShow, + }); + + final TVShow tvShow; + String firstAiredYear = '?'; + + @override + Widget build(BuildContext context) { + String url = 'http://image.tmdb.org/t/p/original${tvShow.backdropPath}'; + + firstAiredYear = tvShow.firstAired.toString().substring(0, 4); + return Scaffold( + appBar: AppBar( + title: Text("${tvShow.seriesName} ($firstAiredYear)"), + ), + body: Stack(children: [ + Container( + decoration: BoxDecoration( + image: DecorationImage( + image: NetworkImage(url), + fit: BoxFit.cover, + ), + ), + ), + SingleChildScrollView( + child: Column( + children: [ + Padding( + padding: const EdgeInsets.only( + left: 10.0, + right: 10.0, + top: 10.0, + bottom: 5.0, + ), + child: TVShowDetailsOverviewBox( + overview: tvShow.overview, + ), + ), + Padding( + padding: const EdgeInsets.only( + left: 10.0, + right: 10.0, + top: 5.0, + bottom: 5.0, + ), + child: Row( + children: [ + Expanded( + child: TVShowDetailsCastBox( + cast: tvShow.cast, + ), + ), + const SizedBox( + width: 10, + ), + Expanded( + child: TVShowDetailsCrewBox( + crew: tvShow.crew, + ), + ), + const SizedBox( + width: 10, + ), + Expanded( + child: TVShowDetailsGenreBox( + genre: tvShow.genre, + ), + ), + const SizedBox( + width: 10, + ), + Expanded( + child: TVShowDetailsCompaniesBox( + companies: tvShow.productionCompanies, + ), + ), + const SizedBox( + width: 10, + ), + Expanded( + child: TVShowDetailsCountriesBox( + countries: tvShow.originCountries, + ), + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.only( + left: 10.0, + right: 10.0, + top: 5.0, + bottom: 5.0, + ), + child: TVShowDetailsSettingsBox( + downloadLink: tvShow.download, + localPath: tvShow.localPath, + resolution: tvShow.resolution, + cliffhanger: tvShow.cliffhanger, + ), + ), + Padding( + padding: const EdgeInsets.only( + left: 10.0, + right: 10.0, + top: 5.0, + bottom: 5.0, + ), + child: TVShowDetailsSeasons( + seasonStatus: tvShow.seasonStatus, + ), + ), + ], + ), + ), + ]), + ); + } +} diff --git a/lib/widgets/tvshowDetailsGenreBox.dart b/lib/widgets/tvshows/details/genreBox.dart similarity index 85% rename from lib/widgets/tvshowDetailsGenreBox.dart rename to lib/widgets/tvshows/details/genreBox.dart index 964420b..bdb2fa8 100644 --- a/lib/widgets/tvshowDetailsGenreBox.dart +++ b/lib/widgets/tvshows/details/genreBox.dart @@ -34,20 +34,18 @@ class TVShowDetailsGenreBox extends StatelessWidget { Radius.circular(10.0), ), ), - child: Expanded( - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Text( - 'Genre', - style: TextStyle( - fontWeight: FontWeight.bold, - color: BoxColor.titleColor), - textAlign: TextAlign.center, - ), - ], - ), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Text( + 'Genre', + style: TextStyle( + fontWeight: FontWeight.bold, + color: BoxColor.titleColor), + textAlign: TextAlign.center, + ), + ], ), ), ), diff --git a/lib/widgets/tvshowDetailsOverviewBox.dart b/lib/widgets/tvshows/details/overviewBox.dart similarity index 68% rename from lib/widgets/tvshowDetailsOverviewBox.dart rename to lib/widgets/tvshows/details/overviewBox.dart index b1b2089..2cf613c 100644 --- a/lib/widgets/tvshowDetailsOverviewBox.dart +++ b/lib/widgets/tvshows/details/overviewBox.dart @@ -9,7 +9,6 @@ class TVShowDetailsOverviewBox extends StatelessWidget { @override Widget build(BuildContext context) { - return Container( decoration: BoxDecoration( color: BoxColor.backgroundColor, @@ -33,27 +32,24 @@ class TVShowDetailsOverviewBox extends StatelessWidget { Radius.circular(10.0), ), ), - child: Expanded( - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Text( - 'Overview', - style: TextStyle( - fontWeight: FontWeight.bold, - color: BoxColor.titleColor), - textAlign: TextAlign.center, - ), - ], - ), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Text( + 'Overview', + style: TextStyle( + fontWeight: FontWeight.bold, + color: BoxColor.titleColor), + textAlign: TextAlign.center, + ), + ], ), ), ), Center( child: Padding( - padding: const EdgeInsets.symmetric( - vertical: 10, horizontal: 10), + padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10), child: Container( alignment: Alignment.centerLeft, child: Text( diff --git a/lib/widgets/tvshows/details/seasonBox.dart b/lib/widgets/tvshows/details/seasonBox.dart new file mode 100644 index 0000000..7fba89d --- /dev/null +++ b/lib/widgets/tvshows/details/seasonBox.dart @@ -0,0 +1,293 @@ +import 'package:flutter/material.dart'; + +import 'package:multimedia/constants.dart'; + +import 'package:multimedia/data/tvshows.dart'; + +enum SingingCharacter { init, prog, done } + +class TVShowDetailsSeasonBox extends StatefulWidget { + TVShowDetailsSeasonBox({super.key, required this.season}); + + Season season; + + @override + State createState() => _TVShowDetailsSeasonBoxState(); +} + +class _TVShowDetailsSeasonBoxState extends State { + void initClicked() { + final exp = RegExp(r'([|][0-9])'); + + setState(() { + widget.season.state = + widget.season.state.replaceAllMapped(exp, (Match m) => "|1"); + }); + } + + void progClicked() { + final exp = RegExp(r'([|][0-9])'); + + setState(() { + widget.season.state = + widget.season.state.replaceAllMapped(exp, (Match m) => "|2"); + }); + } + + void doneClicked() { + final exp = RegExp(r'([|][0-9])'); + + setState(() { + widget.season.state = + widget.season.state.replaceAllMapped(exp, (Match m) => "|3"); + }); + } + + void setEpisodeState(String episode, int state) { + List stateList = widget.season.state.split(','); + + for (var x = 0; x < stateList.length; x++) { + if (stateList[x].split('|')[0] == episode) { + stateList[x] = '${stateList[x].split('|')[0]}|$state'; + break; + } + } + widget.season.state = stateList.join(','); + } + + @override + Widget build(BuildContext context) { + List stateList = widget.season.state.split(','); + int maxEpisode = 0; + Map stateListMap = {}; + + for (var x = 0; x < stateList.length; x++) { + List tmp = stateList[x].split('|'); + stateListMap[tmp[0]] = tmp[1]; + + int episode = int.parse(tmp[0]); + if (episode > maxEpisode) { + maxEpisode = episode; + } + } + + String stateString = ""; + + for (int x = 0; x < maxEpisode; x++) { + String s = '0'; + int key = x + 1; + + if (stateListMap.containsKey('$key')) { + s = stateListMap['$key']; + } + + stateString = stateString + s; + } + + Map colWidths = {}; + + for (int i = 0; i <= maxEpisode; i++) { + colWidths.addEntries({i: IntrinsicColumnWidth()}.entries); + } + + return Container( + decoration: BoxDecoration( + color: BoxColor.backgroundColor, + borderRadius: const BorderRadius.all( + Radius.circular(10.0), + ), + ), + child: Column( + children: [ + Padding( + padding: const EdgeInsets.only( + left: 5.0, + right: 5.0, + top: 10.0, + bottom: 5.0, + ), + child: Container( + decoration: BoxDecoration( + color: BoxColor.titleBackgroundColor, + borderRadius: const BorderRadius.all( + Radius.circular(10.0), + ), + ), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Text( + 'Season ${widget.season.seasonNumber}', + style: TextStyle( + fontWeight: FontWeight.bold, + color: BoxColor.titleColor), + textAlign: TextAlign.center, + ), + ], + ), + ), + ), + Center( + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10), + child: Container( + alignment: Alignment.centerLeft, + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Table( + columnWidths: colWidths, + children: [ + TableRow(children: [ + const TableCell( + child: Center( + child: Text(''), + ), + ), + for (var s in stateList) + TableCell( + child: Center( + child: Text(s.split('|')[0].toString()), + ), + ), + const TableCell( + child: Text(''), + ), + ]), + TableRow(children: [ + TableCell( + child: Padding( + padding: const EdgeInsets.symmetric( + vertical: 2, + horizontal: 2, + ), + child: Container( + decoration: BoxDecoration( + color: BoxColor.titleBackgroundColor, + borderRadius: BorderRadius.circular(17)), + child: ElevatedButton( + onPressed: initClicked, + child: Text( + 'init', + style: TextStyle(color: BoxColor.titleColor), + ), + ), + ), + ), + ), + for (var s in stateList) + TableCell( + child: Checkbox( + side: MaterialStateBorderSide.resolveWith( + (states) => const BorderSide( + width: 1.0, color: Colors.grey), + ), + value: s.split('|')[1] == '1', + onChanged: (bool? value) { + if (value == true) { + setState(() { + setEpisodeState(s.split('|')[0], 1); + }); + } + }, + ), + ), + const TableCell( + child: Text(''), + ), + ]), + TableRow(children: [ + TableCell( + child: Padding( + padding: const EdgeInsets.symmetric( + vertical: 2, + horizontal: 2, + ), + child: Container( + decoration: BoxDecoration( + color: BoxColor.titleBackgroundColor, + borderRadius: BorderRadius.circular(17)), + child: ElevatedButton( + onPressed: progClicked, + child: Text( + 'prog', + style: TextStyle(color: BoxColor.titleColor), + ), + ), + ), + ), + ), + for (var s in stateList) + TableCell( + child: Checkbox( + side: MaterialStateBorderSide.resolveWith( + (states) => const BorderSide( + width: 1.0, color: Colors.grey), + ), + value: s.split('|')[1] == '2', + onChanged: (bool? value) { + if (value == true) { + setState(() { + setEpisodeState(s.split('|')[0], 2); + }); + } + }, + ), + ), + const TableCell( + child: Text(''), + ), + ]), + TableRow(children: [ + TableCell( + child: Padding( + padding: const EdgeInsets.symmetric( + vertical: 2, + horizontal: 2, + ), + child: Container( + decoration: BoxDecoration( + color: BoxColor.titleBackgroundColor, + borderRadius: BorderRadius.circular(17)), + child: ElevatedButton( + onPressed: doneClicked, + child: Text( + 'done', + style: TextStyle(color: BoxColor.titleColor), + ), + ), + ), + ), + ), + for (var s in stateList) + TableCell( + child: Checkbox( + side: MaterialStateBorderSide.resolveWith( + (states) => const BorderSide( + width: 1.0, color: Colors.grey), + ), + value: s.split('|')[1] == '3', + onChanged: (bool? value) { + if (value == true) { + setState(() { + setEpisodeState(s.split('|')[0], 3); + }); + } + }, + ), + ), + const TableCell( + child: Text(''), + ), + ]), + ], + ), + ), + ), + ), + ), + ], + ), + ); + } +} diff --git a/lib/widgets/tvshows/details/seasons.dart b/lib/widgets/tvshows/details/seasons.dart new file mode 100644 index 0000000..17a58f0 --- /dev/null +++ b/lib/widgets/tvshows/details/seasons.dart @@ -0,0 +1,38 @@ +import 'package:flutter/material.dart'; +import 'package:multimedia/widgets/tvshows/details/seasonBox.dart'; + +import 'package:multimedia/constants.dart'; +import 'package:multimedia/data/tvshows.dart'; + +class TVShowDetailsSeasons extends StatefulWidget { + TVShowDetailsSeasons({ + super.key, + required this.seasonStatus, + }); + + List seasonStatus; + + @override + State createState() => _TVShowDetailsSeasonsState(); +} + +class _TVShowDetailsSeasonsState extends State { + @override + Widget build(BuildContext context) { + return Column( + children: [ + for (var s in widget.seasonStatus) + Column( + children: [ + TVShowDetailsSeasonBox( + season: s, + ), + const SizedBox( + height: 10, + ), + ], + ), + ], + ); + } +} diff --git a/lib/widgets/tvshows/details/settingsBox.dart b/lib/widgets/tvshows/details/settingsBox.dart new file mode 100644 index 0000000..5ed5702 --- /dev/null +++ b/lib/widgets/tvshows/details/settingsBox.dart @@ -0,0 +1,98 @@ +import 'package:flutter/material.dart'; + +import 'package:multimedia/constants.dart'; +import 'package:multimedia/widgets/tvshows/details/settingsBoxDownloadLink.dart'; +import 'package:multimedia/widgets/tvshows/details/settingsBoxLocalPath.dart'; +import 'package:multimedia/widgets/tvshows/details/settingsBoxResolution.dart'; +import 'package:multimedia/widgets/tvshows/details/settingsBoxCliffhanger.dart'; + +class TVShowDetailsSettingsBox extends StatelessWidget { + const TVShowDetailsSettingsBox({ + super.key, + required this.downloadLink, + required this.localPath, + required this.resolution, + required this.cliffhanger, + }); + + final String downloadLink; + final String localPath; + final String resolution; + final int cliffhanger; + + List generateInputs(BuildContext context) { +// double width = MediaQuery.of(context).size.width; + + return [ + TVShowDetailsSettingsBoxDownloadLink( + downloadLink: downloadLink, + ), + const SizedBox( + width: 5, + ), + TVShowDetailsSettingsBoxLocalPath( + localPath: localPath, + ), + const SizedBox( + width: 5, + ), + TVShowDetailsSettingsBoxResolution( + resolution: resolution, + ), + const SizedBox( + width: 5, + ), + TVShowDetailsSettingsBoxCliffhanger( + cliffhanger: cliffhanger, + ), + ]; + } + + @override + Widget build(BuildContext context) { + return Container( + decoration: BoxDecoration( + color: BoxColor.backgroundColor, + borderRadius: const BorderRadius.all( + Radius.circular(10.0), + ), + ), + child: Column( + children: [ + Padding( + padding: const EdgeInsets.only( + left: 5.0, + right: 5.0, + top: 10.0, + bottom: 5.0, + ), + child: Container( + decoration: BoxDecoration( + color: BoxColor.titleBackgroundColor, + borderRadius: const BorderRadius.all( + Radius.circular(10.0), + ), + ), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Text( + 'Settings', + style: TextStyle( + fontWeight: FontWeight.bold, + color: BoxColor.titleColor), + textAlign: TextAlign.center, + ), + ], + ), + ), + ), + Row( + children: generateInputs(context), + ), + ], + ), + ); + } +} diff --git a/lib/widgets/tvshows/details/settingsBoxCliffhanger.dart b/lib/widgets/tvshows/details/settingsBoxCliffhanger.dart new file mode 100644 index 0000000..a44acaa --- /dev/null +++ b/lib/widgets/tvshows/details/settingsBoxCliffhanger.dart @@ -0,0 +1,59 @@ +import 'package:flutter/material.dart'; + +class TVShowDetailsSettingsBoxCliffhanger extends StatefulWidget { + TVShowDetailsSettingsBoxCliffhanger({ + super.key, + required this.cliffhanger, + }); + + int cliffhanger; + + @override + State createState() => + _TVShowDetailsSettingsBoxCliffhangerState(); +} + +class _TVShowDetailsSettingsBoxCliffhangerState + extends State { + @override + void initState() { + _curCliffhanger = widget.cliffhanger; + super.initState(); + } + + var _curCliffhanger = 0; + + @override + Widget build(BuildContext context) { + return Expanded( + flex: 1, + child: Column( + children: [ + const Text( + 'Cliffhanger', + style: TextStyle( + fontWeight: FontWeight.bold, + ), + ), + const SizedBox( + height: 10, + ), + Checkbox( + side: MaterialStateBorderSide.resolveWith( + (states) => BorderSide(width: 1.0, color: Colors.grey), + ), + value: (_curCliffhanger == 1), + onChanged: (bool? value) { + setState(() { + _curCliffhanger = value == true ? 1 : 0; + }); + }, + ), + const SizedBox( + height: 10, + ), + ], + ), + ); + } +} diff --git a/lib/widgets/tvshows/details/settingsBoxDownloadLink.dart b/lib/widgets/tvshows/details/settingsBoxDownloadLink.dart new file mode 100644 index 0000000..421877c --- /dev/null +++ b/lib/widgets/tvshows/details/settingsBoxDownloadLink.dart @@ -0,0 +1,42 @@ +import 'package:flutter/material.dart'; + +class TVShowDetailsSettingsBoxDownloadLink extends StatelessWidget { + const TVShowDetailsSettingsBoxDownloadLink({ + super.key, + required this.downloadLink, + }); + + final String downloadLink; + + @override + Widget build(BuildContext context) { + return Expanded( + flex: 10, + child: Padding( + padding: const EdgeInsets.only( + left: 5.0, + right: 5.0, + top: 5.0, + bottom: 5.0, + ), + child: Column( + children: [ + const Text( + 'Download Link', + style: TextStyle( + fontWeight: FontWeight.bold, + ), + ), + TextFormField( + decoration: const InputDecoration( + border: OutlineInputBorder(), + labelText: 'Download Link', + ), + initialValue: downloadLink, + ), + ], + ), + ), + ); + } +} diff --git a/lib/widgets/tvshows/details/settingsBoxLocalPath.dart b/lib/widgets/tvshows/details/settingsBoxLocalPath.dart new file mode 100644 index 0000000..99b86a2 --- /dev/null +++ b/lib/widgets/tvshows/details/settingsBoxLocalPath.dart @@ -0,0 +1,34 @@ +import 'package:flutter/material.dart'; + +class TVShowDetailsSettingsBoxLocalPath extends StatelessWidget { + const TVShowDetailsSettingsBoxLocalPath({ + super.key, + required this.localPath, + }); + + final String localPath; + + @override + Widget build(BuildContext context) { + return Expanded( + flex: 10, + child: Column( + children: [ + const Text( + 'Local Path', + style: TextStyle( + fontWeight: FontWeight.bold, + ), + ), + TextFormField( + decoration: const InputDecoration( + border: OutlineInputBorder(), + labelText: 'Local Path', + ), + initialValue: localPath, + ), + ], + ), + ); + } +} diff --git a/lib/widgets/tvshows/details/settingsBoxResolution.dart b/lib/widgets/tvshows/details/settingsBoxResolution.dart new file mode 100644 index 0000000..9bc3364 --- /dev/null +++ b/lib/widgets/tvshows/details/settingsBoxResolution.dart @@ -0,0 +1,74 @@ +import 'package:flutter/material.dart'; + +class TVShowDetailsSettingsBoxResolution extends StatefulWidget { + TVShowDetailsSettingsBoxResolution({ + super.key, + required this.resolution, + }); + + String resolution; + + @override + State createState() => + _TVShowDetailsSettingsBoxResolutionState(); +} + +class _TVShowDetailsSettingsBoxResolutionState + extends State { + var resolutions = [ + '', + '360p', + '480i', + '480p', + '576i', + '576p', + '720i', + '720p', + '1080i', + '1080p', + '1440i', + '1440p', + '2160p', + ]; + + var _curResolution = ''; + + @override + void initState() { + _curResolution = widget.resolution; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Expanded( + flex: 2, + child: Column( + children: [ + const Text( + 'Resolution', + style: TextStyle( + fontWeight: FontWeight.bold, + ), + ), + DropdownButtonFormField( + decoration: const InputDecoration( + border: OutlineInputBorder(), + labelText: 'Resolution', + ), + dropdownColor: const Color.fromARGB(255, 127, 127, 127), + value: _curResolution, + items: resolutions.map((String res) { + return DropdownMenuItem(value: res, child: Text(res)); + }).toList(), + onChanged: (String? newValue) { + setState(() { + _curResolution = newValue!; + }); + }, + ), + ], + ), + ); + } +} diff --git a/lib/widgets/tvshowsScreen.dart b/lib/widgets/tvshows/listScreen.dart similarity index 64% rename from lib/widgets/tvshowsScreen.dart rename to lib/widgets/tvshows/listScreen.dart index 4e46fd7..cb4f52e 100644 --- a/lib/widgets/tvshowsScreen.dart +++ b/lib/widgets/tvshows/listScreen.dart @@ -1,7 +1,7 @@ import 'dart:ui' as ui; import 'dart:convert'; -import 'package:multimedia/widgets/tvshowDetailsScreen.dart'; +import 'package:multimedia/widgets/tvshows/details/detailsScreen.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:intl/intl.dart'; @@ -70,7 +70,7 @@ class _TVShowsScreenState extends State { } List _tvshows = - await tvshowList.map((json) => TVShow.fromJson(json)).toList(); + await tvshowList.map((json) => TVShow.fromJson(json)).toList(); tvshowDataSource = TVShowDataSource(_tvshows, maxSeason); List _episodecount = await episodeList @@ -186,7 +186,7 @@ class _TVShowsScreenState extends State { void showTVShowDetails(int index) { List> cells = - tvshowDataSource.effectiveRows.elementAt(index).getCells(); + tvshowDataSource.effectiveRows.elementAt(index).getCells(); String seriesID = cells[TVShowColumn.seriesID].value.toString(); bool found = false; @@ -203,7 +203,8 @@ class _TVShowsScreenState extends State { Navigator.push( context, MaterialPageRoute( - builder: (ctx) => TVShowDetailsScreen(tvShow: _tvshowsList[tvShowIndex]))); + builder: (ctx) => + TVShowDetailsScreen(tvShow: _tvshowsList[tvShowIndex]))); } } @@ -215,39 +216,42 @@ class _TVShowsScreenState extends State { 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, - onCellDoubleTap: (DataGridCellDoubleTapDetails details) { - int index = details.rowColumnIndex.rowIndex - 1; - if (index < 0) { - return; - } - showTVShowDetails(index); - }, - onCellLongPress: (DataGridCellLongPressDetails details) { - print(details.rowColumnIndex); - }, - onCellSecondaryTap: (DataGridCellTapDetails details) { - print(details.rowColumnIndex); - }, - ), - ) + 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( - strokeWidth: 2, - value: 0.8, - ), - ); + child: CircularProgressIndicator( + strokeWidth: 2, + value: 0.8, + ), + ); }, ), ); @@ -310,24 +314,24 @@ class TVShowDataSource extends DataGridSource { void buildDataGridRow() { _tvshowDataGridRows = tvshows .map((e) => DataGridRow(cells: [ - DataGridCell(columnName: 'seriesID', value: e.seriesID), - DataGridCell( - columnName: 'seriesState', value: e.seriesState), - DataGridCell(columnName: 'status', value: e.status), - DataGridCell( - columnName: 'cliffhanger', value: e.cliffhanger), - DataGridCell( - columnName: 'backdropPath', value: e.backdropPath), - DataGridCell(columnName: 'overview', value: e.overview), - DataGridCell( - columnName: 'seriesName', value: e.seriesName), - DataGridCell( - columnName: 'firstAired', - value: DateFormat('yyyy-MM-dd').format(e.firstAired)), - DataGridCell( - columnName: 'resolution', value: e.resolution), - ...setSeasonData(maxSeason, e.seasonStatus), - ])) + DataGridCell(columnName: 'seriesID', value: e.seriesID), + DataGridCell( + columnName: 'seriesState', value: e.seriesState), + DataGridCell(columnName: 'status', value: e.status), + DataGridCell( + columnName: 'cliffhanger', value: e.cliffhanger), + DataGridCell( + columnName: 'backdropPath', value: e.backdropPath), + DataGridCell(columnName: 'overview', value: e.overview), + DataGridCell( + columnName: 'seriesName', value: e.seriesName), + DataGridCell( + columnName: 'firstAired', + value: DateFormat('yyyy-MM-dd').format(e.firstAired)), + DataGridCell( + columnName: 'resolution', value: e.resolution), + ...setSeasonData(maxSeason, e.seasonStatus), + ])) .toList(); } @@ -364,13 +368,13 @@ class TVShowDataSource extends DataGridSource { return Row(children: [ ...stateColor.map((col) => Text( - '1', - style: TextStyle( - fontFamily: 'geometric', - fontSize: 30, - color: col, - ), - )), + '1', + style: TextStyle( + fontFamily: 'geometric', + fontSize: 30, + color: col, + ), + )), ]); } @@ -378,72 +382,74 @@ class TVShowDataSource extends DataGridSource { DataGridRowAdapter buildRow(DataGridRow row) { return DataGridRowAdapter( cells: row.getCells().map((e) { - Color colorBG = Colors.white; - Color colorFG = Colors.black; - FontWeight fontWeight = FontWeight.normal; - FontStyle fontStyle = FontStyle.normal; + Color colorBG = Colors.white; + Color colorFG = Colors.black; + FontWeight fontWeight = FontWeight.normal; + FontStyle fontStyle = FontStyle.normal; - if (e.columnName == 'seriesName') { - int seriesState = row.getCells().toList()[TVShowColumn.seriesState].value; - String status = row.getCells().toList()[TVShowColumn.state].value; - int cliffhanger = row.getCells().toList()[TVShowColumn.cliffhanger].value; + if (e.columnName == 'seriesName') { + int seriesState = + row.getCells().toList()[TVShowColumn.seriesState].value; + String status = row.getCells().toList()[TVShowColumn.state].value; + int cliffhanger = + row.getCells().toList()[TVShowColumn.cliffhanger].value; - if (seriesState == 1) { - colorBG = StateColor.init; - } else if (seriesState == 2) { - colorBG = StateColor.prog; - colorFG = Colors.white; - } else { - colorBG = StateColor.done; - } + if (seriesState == 1) { + colorBG = StateColor.init; + } else if (seriesState == 2) { + colorBG = StateColor.prog; + colorFG = Colors.white; + } else { + colorBG = StateColor.done; + } - if (cliffhanger == 1) { - fontStyle = FontStyle.italic; - } + if (cliffhanger == 1) { + fontStyle = FontStyle.italic; + } - if (status == 'In Production' || status == 'Returning Series') { - fontWeight = FontWeight.bold; - } - } + if (status == 'In Production' || status == 'Returning Series') { + fontWeight = FontWeight.bold; + } + } - if (e.columnName.startsWith('season')) { - Row row = generateSeasonState(e.value.toString()); + if (e.columnName.startsWith('season')) { + Row row = generateSeasonState(e.value.toString()); - return Container( - alignment: Alignment.center, - padding: const EdgeInsets.symmetric(horizontal: 16), - child: row, - ); - } + return Container( + alignment: Alignment.center, + padding: const EdgeInsets.symmetric(horizontal: 16), + child: row, + ); + } - if (e.columnName.startsWith('seriesName')) { - return Container( - alignment: Alignment.centerLeft, - padding: const EdgeInsets.all(8.0), - color: colorBG, - child: Text( - e.value.toString(), - style: TextStyle( - color: colorFG, - fontWeight: fontWeight, - fontStyle: fontStyle, + if (e.columnName.startsWith('seriesName')) { + return Container( + alignment: Alignment.centerLeft, + padding: const EdgeInsets.all(8.0), + color: colorBG, + child: Text( + e.value.toString(), + style: TextStyle( + color: colorFG, + fontWeight: fontWeight, + fontStyle: fontStyle, + ), + ), + ); + } + + return Container( + alignment: Alignment.centerLeft, + padding: const EdgeInsets.all(8.0), + child: Text( + e.value.toString(), + style: TextStyle( + fontWeight: fontWeight, + fontStyle: fontStyle, + ), ), - ), - ); - } - - return Container( - alignment: Alignment.centerLeft, - padding: const EdgeInsets.all(8.0), - child: Text( - e.value.toString(), - style: TextStyle( - fontWeight: fontWeight, - fontStyle: fontStyle, - ), - ), - ); - }).toList()); + ); + }).toList()); } void updateDataGrid() {