diff --git a/lib/widgets/movies/details/detailsScreen.dart b/lib/widgets/movies/details/detailsScreen.dart index c0b91e7..2f7cc97 100644 --- a/lib/widgets/movies/details/detailsScreen.dart +++ b/lib/widgets/movies/details/detailsScreen.dart @@ -317,7 +317,7 @@ class MovieDetailsScreen extends StatelessWidget { 'originalTitle': movieDetails.originalTitle, 'overview': movieDetails.overview, 'releaseDate': - DateFormat('yyyy-MM-dd').format(movieDetails.releaseDate), + DateFormat('yyyy-MM-dd').format(movieDetails.releaseDate), 'resolution': movieDetails.resolution, 'state': movieDetails.state.toString(), 'backdropPath': movieDetails.backdropPath, @@ -334,7 +334,7 @@ class MovieDetailsScreen extends StatelessWidget { ), ); } catch (e) { - print (e.toString()); + print(e.toString()); } return true; @@ -369,6 +369,28 @@ class MovieDetailsScreen extends StatelessWidget { Navigator.pop(context, null); }, ), + const VerticalDivider( + width: 10, + thickness: 3, + indent: 0, + endIndent: 0, + color: Colors.grey, + ), + IconButton( + icon: const Icon(Icons.update_outlined), + tooltip: 'Update movie', + onPressed: () { + //todo + }, + ), + IconButton( + icon: const Icon(Icons.delete_outline), + color: Colors.red, + tooltip: 'Delete movie', + onPressed: () { + //todo + }, + ), ], ), body: FutureBuilder( diff --git a/lib/widgets/tvshows/details/detailsScreen.dart b/lib/widgets/tvshows/details/detailsScreen.dart index 50a8473..0d2083d 100644 --- a/lib/widgets/tvshows/details/detailsScreen.dart +++ b/lib/widgets/tvshows/details/detailsScreen.dart @@ -40,8 +40,6 @@ class TVShowDetailsScreen extends StatelessWidget { path: dbPath, ); - print(url.toString()); - final r = http.post( url, headers: { @@ -77,7 +75,6 @@ class TVShowDetailsScreen extends StatelessWidget { }, ); - print (url); final response = await http.get(url); bool? error; String? errorMessage; @@ -335,9 +332,30 @@ class TVShowDetailsScreen extends StatelessWidget { } bool save() { + updateTVShow(); return true; } + Future updateTVShow() async { + return true; + } + + void settingsChanged( + String download, String localPath, String resolution, int cliffhanger) { + tvShowDetails.download = download; + tvShowDetails.localPath = localPath; + tvShowDetails.resolution = resolution; + tvShowDetails.cliffhanger = cliffhanger; + } + + void stateChanged(List seasonStatus) { + tvShowDetails.seasonStatus = seasonStatus; + + for (var s in tvShowDetails.seasonStatus) { + print('Season: ${s.seasonNumber}, State: ${s.state}'); + } + } + @override Widget build(BuildContext context) { String firstAiredYear = tvShow.firstAired.toString().substring(0, 4); @@ -351,8 +369,7 @@ class TVShowDetailsScreen extends StatelessWidget { tooltip: 'Save changes', onPressed: () { if (save()) { - testPost('bla'); - Navigator.pop(context); + Navigator.pop(context, tvShowDetails); } }, ), @@ -360,7 +377,29 @@ class TVShowDetailsScreen extends StatelessWidget { icon: const Icon(Icons.highlight_off), tooltip: 'Revert changes', onPressed: () { - Navigator.pop(context); + Navigator.pop(context, null); + }, + ), + const VerticalDivider( + width: 10, + thickness: 3, + indent: 0, + endIndent: 0, + color: Colors.grey, + ), + IconButton( + icon: const Icon(Icons.update_outlined), + tooltip: 'Update movie', + onPressed: () { + //todo + }, + ), + IconButton( + icon: const Icon(Icons.delete_outline), + color: Colors.red, + tooltip: 'Delete movie', + onPressed: () { + //todo }, ), ], @@ -409,6 +448,7 @@ class TVShowDetailsScreen extends StatelessWidget { localPath: tvShowDetails.localPath, resolution: tvShowDetails.resolution, cliffhanger: tvShowDetails.cliffhanger, + settingsChanged: settingsChanged, ), ), Padding( @@ -420,6 +460,7 @@ class TVShowDetailsScreen extends StatelessWidget { ), child: TVShowDetailsSeasons( seasonStatus: tvShowDetails.seasonStatus, + stateChanged: stateChanged, ), ), ], diff --git a/lib/widgets/tvshows/details/seasonBox.dart b/lib/widgets/tvshows/details/seasonBox.dart index 4200642..28dcba4 100644 --- a/lib/widgets/tvshows/details/seasonBox.dart +++ b/lib/widgets/tvshows/details/seasonBox.dart @@ -7,10 +7,16 @@ import 'package:multimedia/data/tvshows.dart'; enum SingingCharacter { init, prog, done } class TVShowDetailsSeasonBox extends StatefulWidget { - TVShowDetailsSeasonBox({super.key, required this.season}); + TVShowDetailsSeasonBox({ + super.key, + required this.season, + required this.stateChanged, + }); Season season; + final Function(int seasonNumber, String state) stateChanged; + @override State createState() => _TVShowDetailsSeasonBoxState(); } @@ -22,6 +28,8 @@ class _TVShowDetailsSeasonBoxState extends State { setState(() { widget.season.state = widget.season.state.replaceAllMapped(exp, (Match m) => "|1"); + + widget.stateChanged(widget.season.seasonNumber, widget.season.state); }); } @@ -31,6 +39,8 @@ class _TVShowDetailsSeasonBoxState extends State { setState(() { widget.season.state = widget.season.state.replaceAllMapped(exp, (Match m) => "|2"); + + widget.stateChanged(widget.season.seasonNumber, widget.season.state); }); } @@ -40,6 +50,8 @@ class _TVShowDetailsSeasonBoxState extends State { setState(() { widget.season.state = widget.season.state.replaceAllMapped(exp, (Match m) => "|3"); + + widget.stateChanged(widget.season.seasonNumber, widget.season.state); }); } @@ -53,6 +65,7 @@ class _TVShowDetailsSeasonBoxState extends State { } } widget.season.state = stateList.join(','); + widget.stateChanged(widget.season.seasonNumber, widget.season.state); } @override @@ -168,7 +181,7 @@ class _TVShowDetailsSeasonBoxState extends State { child: ElevatedButton( style: ElevatedButton.styleFrom( backgroundColor: - BoxColor.titleBackgroundColor), + BoxColor.titleBackgroundColor), onPressed: initClicked, child: Text( 'init', @@ -182,7 +195,7 @@ class _TVShowDetailsSeasonBoxState extends State { TableCell( child: Checkbox( side: MaterialStateBorderSide.resolveWith( - (states) => const BorderSide( + (states) => const BorderSide( width: 1.0, color: Colors.grey), ), value: s.split('|')[1] == '1', @@ -213,7 +226,7 @@ class _TVShowDetailsSeasonBoxState extends State { child: ElevatedButton( style: ElevatedButton.styleFrom( backgroundColor: - BoxColor.titleBackgroundColor), + BoxColor.titleBackgroundColor), onPressed: progClicked, child: Text( 'prog', @@ -227,7 +240,7 @@ class _TVShowDetailsSeasonBoxState extends State { TableCell( child: Checkbox( side: MaterialStateBorderSide.resolveWith( - (states) => const BorderSide( + (states) => const BorderSide( width: 1.0, color: Colors.grey), ), value: s.split('|')[1] == '2', @@ -258,7 +271,7 @@ class _TVShowDetailsSeasonBoxState extends State { child: ElevatedButton( style: ElevatedButton.styleFrom( backgroundColor: - BoxColor.titleBackgroundColor), + BoxColor.titleBackgroundColor), onPressed: doneClicked, child: Text( 'done', @@ -272,7 +285,7 @@ class _TVShowDetailsSeasonBoxState extends State { TableCell( child: Checkbox( side: MaterialStateBorderSide.resolveWith( - (states) => const BorderSide( + (states) => const BorderSide( width: 1.0, color: Colors.grey), ), value: s.split('|')[1] == '3', diff --git a/lib/widgets/tvshows/details/seasons.dart b/lib/widgets/tvshows/details/seasons.dart index 17a58f0..a0fb0b5 100644 --- a/lib/widgets/tvshows/details/seasons.dart +++ b/lib/widgets/tvshows/details/seasons.dart @@ -8,10 +8,24 @@ class TVShowDetailsSeasons extends StatefulWidget { TVShowDetailsSeasons({ super.key, required this.seasonStatus, + required this.stateChanged, }); List seasonStatus; + final Function(List) stateChanged; + + void stateChanged1(int seasonNumber, String state) { + print('start stateChanged1 in seasons ...'); + for (int seasonID = 0; seasonID < seasonStatus.length; seasonID++) { + if (seasonStatus[seasonID].seasonNumber == seasonNumber) { + seasonStatus[seasonID].state = state; + stateChanged(seasonStatus); + return; + } + } + } + @override State createState() => _TVShowDetailsSeasonsState(); } @@ -26,6 +40,7 @@ class _TVShowDetailsSeasonsState extends State { children: [ TVShowDetailsSeasonBox( season: s, + stateChanged: widget.stateChanged1, ), const SizedBox( height: 10, diff --git a/lib/widgets/tvshows/details/settingsBox.dart b/lib/widgets/tvshows/details/settingsBox.dart index 591c8be..3915364 100644 --- a/lib/widgets/tvshows/details/settingsBox.dart +++ b/lib/widgets/tvshows/details/settingsBox.dart @@ -7,18 +7,42 @@ import 'package:multimedia/widgets/tvshows/details/settingsBoxResolution.dart'; import 'package:multimedia/widgets/tvshows/details/settingsBoxCliffhanger.dart'; class TVShowDetailsSettingsBox extends StatelessWidget { - const TVShowDetailsSettingsBox({ + TVShowDetailsSettingsBox({ super.key, required this.downloadLink, required this.localPath, required this.resolution, required this.cliffhanger, + required this.settingsChanged, }); - final String downloadLink; - final String localPath; - final String resolution; - final int cliffhanger; + String downloadLink; + String localPath; + String resolution; + int cliffhanger; + + final Function(String downloadLink, String localPath, String resolution, + int cliffhanger) settingsChanged; + + void downloadLinkChanged(String downloadLink) { + this.downloadLink = downloadLink; + settingsChanged(downloadLink, localPath, resolution, cliffhanger); + } + + void localPathChanged(String localPath) { + this.localPath = localPath; + settingsChanged(downloadLink, localPath, resolution, cliffhanger); + } + + void resolutionChanged(String resolution) { + this.resolution = resolution; + settingsChanged(downloadLink, localPath, resolution, cliffhanger); + } + + void cliffhangerChanged(int cliffhanger) { + this.cliffhanger = cliffhanger; + settingsChanged(downloadLink, localPath, resolution, cliffhanger); + } Widget generateInputs(BuildContext context) { double width = MediaQuery.of(context).size.width; @@ -34,9 +58,11 @@ class TVShowDetailsSettingsBox extends StatelessWidget { children: [ TVShowDetailsSettingsBoxDownloadLink( downloadLink: downloadLink, + downloadLinkChanged: downloadLinkChanged, ), TVShowDetailsSettingsBoxResolution( resolution: resolution, + resolutionChanged: resolutionChanged, ), ], ), @@ -44,9 +70,11 @@ class TVShowDetailsSettingsBox extends StatelessWidget { children: [ TVShowDetailsSettingsBoxLocalPath( localPath: localPath, + localPathChanged: localPathChanged, ), TVShowDetailsSettingsBoxCliffhanger( cliffhanger: cliffhanger, + cliffhangerChanged: cliffhangerChanged, ), ], ), @@ -66,15 +94,19 @@ class TVShowDetailsSettingsBox extends StatelessWidget { children: [ TVShowDetailsSettingsBoxDownloadLink( downloadLink: downloadLink, + downloadLinkChanged: downloadLinkChanged, ), TVShowDetailsSettingsBoxLocalPath( localPath: localPath, + localPathChanged: localPathChanged, ), TVShowDetailsSettingsBoxResolution( resolution: resolution, + resolutionChanged: resolutionChanged, ), TVShowDetailsSettingsBoxCliffhanger( cliffhanger: cliffhanger, + cliffhangerChanged: cliffhangerChanged, ), ], ), diff --git a/lib/widgets/tvshows/details/settingsBoxCliffhanger.dart b/lib/widgets/tvshows/details/settingsBoxCliffhanger.dart index e102591..fe48b86 100644 --- a/lib/widgets/tvshows/details/settingsBoxCliffhanger.dart +++ b/lib/widgets/tvshows/details/settingsBoxCliffhanger.dart @@ -4,10 +4,13 @@ class TVShowDetailsSettingsBoxCliffhanger extends StatefulWidget { TVShowDetailsSettingsBoxCliffhanger({ super.key, required this.cliffhanger, + required this.cliffhangerChanged, }); int cliffhanger; + final Function(int cliffhanger) cliffhangerChanged; + @override State createState() => _TVShowDetailsSettingsBoxCliffhangerState(); @@ -51,6 +54,7 @@ class _TVShowDetailsSettingsBoxCliffhangerState onChanged: (bool? value) { setState(() { _curCliffhanger = value == true ? 1 : 0; + widget.cliffhangerChanged(_curCliffhanger); }); }, ), diff --git a/lib/widgets/tvshows/details/settingsBoxDownloadLink.dart b/lib/widgets/tvshows/details/settingsBoxDownloadLink.dart index a4d5764..8167048 100644 --- a/lib/widgets/tvshows/details/settingsBoxDownloadLink.dart +++ b/lib/widgets/tvshows/details/settingsBoxDownloadLink.dart @@ -4,36 +4,41 @@ class TVShowDetailsSettingsBoxDownloadLink extends StatelessWidget { const TVShowDetailsSettingsBoxDownloadLink({ super.key, required this.downloadLink, + required this.downloadLinkChanged, }); final String downloadLink; + final Function(String downloadLink) downloadLinkChanged; + @override Widget build(BuildContext context) { return 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, - ), + 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( + ), + TextFormField( decoration: const InputDecoration( border: OutlineInputBorder(), labelText: 'Download Link', ), initialValue: downloadLink, - ), - ], - ), + onChanged: (text) { + downloadLinkChanged(text); + }), + ], + ), ); } } diff --git a/lib/widgets/tvshows/details/settingsBoxLocalPath.dart b/lib/widgets/tvshows/details/settingsBoxLocalPath.dart index edd6466..6325ff0 100644 --- a/lib/widgets/tvshows/details/settingsBoxLocalPath.dart +++ b/lib/widgets/tvshows/details/settingsBoxLocalPath.dart @@ -4,36 +4,41 @@ class TVShowDetailsSettingsBoxLocalPath extends StatelessWidget { const TVShowDetailsSettingsBoxLocalPath({ super.key, required this.localPath, + required this.localPathChanged, }); final String localPath; + final Function(String localPath) localPathChanged; + @override Widget build(BuildContext context) { return Padding( - padding: const EdgeInsets.only( - left: 5.0, - right: 5.0, - top: 5.0, - bottom: 5.0, - ), - child: Column( - children: [ - const Text( - 'Local Path', - style: TextStyle( - fontWeight: FontWeight.bold, - ), + padding: const EdgeInsets.only( + left: 5.0, + right: 5.0, + top: 5.0, + bottom: 5.0, + ), + child: Column( + children: [ + const Text( + 'Local Path', + style: TextStyle( + fontWeight: FontWeight.bold, ), - TextFormField( + ), + TextFormField( decoration: const InputDecoration( border: OutlineInputBorder(), labelText: 'Local Path', ), initialValue: localPath, - ), - ], - ), + onChanged: (text) { + localPathChanged(text); + }), + ], + ), ); } } diff --git a/lib/widgets/tvshows/details/settingsBoxResolution.dart b/lib/widgets/tvshows/details/settingsBoxResolution.dart index 20f1a1a..8a5823f 100644 --- a/lib/widgets/tvshows/details/settingsBoxResolution.dart +++ b/lib/widgets/tvshows/details/settingsBoxResolution.dart @@ -4,10 +4,13 @@ class TVShowDetailsSettingsBoxResolution extends StatefulWidget { TVShowDetailsSettingsBoxResolution({ super.key, required this.resolution, + required this.resolutionChanged, }); String resolution; + final Function(String resolution) resolutionChanged; + @override State createState() => _TVShowDetailsSettingsBoxResolutionState(); @@ -42,38 +45,39 @@ class _TVShowDetailsSettingsBoxResolutionState @override Widget build(BuildContext context) { return Padding( - padding: const EdgeInsets.only( - left: 5.0, - right: 5.0, - top: 5.0, - bottom: 5.0, - ), - child: Column( - children: [ - const Text( - 'Resolution', - style: TextStyle( - fontWeight: FontWeight.bold, - ), + padding: const EdgeInsets.only( + left: 5.0, + right: 5.0, + top: 5.0, + bottom: 5.0, + ), + 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!; - }); - }, + ), + 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!; + widget.resolutionChanged(_curResolution); + }); + }, + ), + ], + ), ); } } diff --git a/lib/widgets/tvshows/listScreen.dart b/lib/widgets/tvshows/listScreen.dart index e7a1276..ed77be0 100644 --- a/lib/widgets/tvshows/listScreen.dart +++ b/lib/widgets/tvshows/listScreen.dart @@ -40,6 +40,10 @@ class _TVShowsScreenState extends State { String? dbHost = prefs.getString('dbHost'); String? dbPath = prefs.getString('dbPath'); + dbProtocol = 'https'; + dbHost = 'api.windesign.at'; + dbPath = '/multimedia.php'; + Uri url = Uri( scheme: dbProtocol, host: dbHost, @@ -70,8 +74,9 @@ class _TVShowsScreenState extends State { } } - List _tvshows = - await tvshowList.map((json) => TVShow.fromJson(json)).toList(); + List _tvshows = await tvshowList + .map((json) => TVShow.fromJson(json)) + .toList(); tvshowDataSource = TVShowDataSource(_tvshows, maxSeason); List _episodecount = await episodeList @@ -90,7 +95,7 @@ class _TVShowsScreenState extends State { return _tvshows; } catch (e) { - print (e.toString()); + print(e.toString()); } return [];