update movie, tvshow

This commit is contained in:
2024-05-16 12:46:26 +02:00
parent 140e0bd339
commit 4b77501676
10 changed files with 233 additions and 87 deletions
+24 -2
View File
@@ -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<Object>(
+47 -6
View File
@@ -40,8 +40,6 @@ class TVShowDetailsScreen extends StatelessWidget {
path: dbPath,
);
print(url.toString());
final r = http.post(
url,
headers: <String, String>{
@@ -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<bool> 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<Season> 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,
),
),
],
+20 -7
View File
@@ -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<TVShowDetailsSeasonBox> createState() => _TVShowDetailsSeasonBoxState();
}
@@ -22,6 +28,8 @@ class _TVShowDetailsSeasonBoxState extends State<TVShowDetailsSeasonBox> {
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<TVShowDetailsSeasonBox> {
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<TVShowDetailsSeasonBox> {
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<TVShowDetailsSeasonBox> {
}
}
widget.season.state = stateList.join(',');
widget.stateChanged(widget.season.seasonNumber, widget.season.state);
}
@override
@@ -168,7 +181,7 @@ class _TVShowDetailsSeasonBoxState extends State<TVShowDetailsSeasonBox> {
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor:
BoxColor.titleBackgroundColor),
BoxColor.titleBackgroundColor),
onPressed: initClicked,
child: Text(
'init',
@@ -182,7 +195,7 @@ class _TVShowDetailsSeasonBoxState extends State<TVShowDetailsSeasonBox> {
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<TVShowDetailsSeasonBox> {
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor:
BoxColor.titleBackgroundColor),
BoxColor.titleBackgroundColor),
onPressed: progClicked,
child: Text(
'prog',
@@ -227,7 +240,7 @@ class _TVShowDetailsSeasonBoxState extends State<TVShowDetailsSeasonBox> {
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<TVShowDetailsSeasonBox> {
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor:
BoxColor.titleBackgroundColor),
BoxColor.titleBackgroundColor),
onPressed: doneClicked,
child: Text(
'done',
@@ -272,7 +285,7 @@ class _TVShowDetailsSeasonBoxState extends State<TVShowDetailsSeasonBox> {
TableCell(
child: Checkbox(
side: MaterialStateBorderSide.resolveWith(
(states) => const BorderSide(
(states) => const BorderSide(
width: 1.0, color: Colors.grey),
),
value: s.split('|')[1] == '3',
+15
View File
@@ -8,10 +8,24 @@ class TVShowDetailsSeasons extends StatefulWidget {
TVShowDetailsSeasons({
super.key,
required this.seasonStatus,
required this.stateChanged,
});
List<Season> seasonStatus;
final Function(List<Season>) 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<TVShowDetailsSeasons> createState() => _TVShowDetailsSeasonsState();
}
@@ -26,6 +40,7 @@ class _TVShowDetailsSeasonsState extends State<TVShowDetailsSeasons> {
children: [
TVShowDetailsSeasonBox(
season: s,
stateChanged: widget.stateChanged1,
),
const SizedBox(
height: 10,
+37 -5
View File
@@ -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,
),
],
),
@@ -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<TVShowDetailsSettingsBoxCliffhanger> createState() =>
_TVShowDetailsSettingsBoxCliffhangerState();
@@ -51,6 +54,7 @@ class _TVShowDetailsSettingsBoxCliffhangerState
onChanged: (bool? value) {
setState(() {
_curCliffhanger = value == true ? 1 : 0;
widget.cliffhangerChanged(_curCliffhanger);
});
},
),
@@ -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);
}),
],
),
);
}
}
@@ -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);
}),
],
),
);
}
}
@@ -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<TVShowDetailsSettingsBoxResolution> 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);
});
},
),
],
),
);
}
}
+8 -3
View File
@@ -40,6 +40,10 @@ class _TVShowsScreenState extends State<TVShowsScreen> {
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<TVShowsScreen> {
}
}
List<TVShow> _tvshows =
await tvshowList.map<TVShow>((json) => TVShow.fromJson(json)).toList();
List<TVShow> _tvshows = await tvshowList
.map<TVShow>((json) => TVShow.fromJson(json))
.toList();
tvshowDataSource = TVShowDataSource(_tvshows, maxSeason);
List<EpisodeCount> _episodecount = await episodeList
@@ -90,7 +95,7 @@ class _TVShowsScreenState extends State<TVShowsScreen> {
return _tvshows;
} catch (e) {
print (e.toString());
print(e.toString());
}
return [];