outsourced lots of api calls to api folder
centered error message when failed loading video feed display server url on settings page
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import '../api/actor_api.dart';
|
||||
import '../api/video_api.dart';
|
||||
import '../dialog/add_actor_dialog.dart';
|
||||
import '../dialog/add_tag_dialog.dart';
|
||||
@ -8,9 +7,6 @@ import '../navigation/video_feed.dart';
|
||||
import '../screen_loading.dart';
|
||||
import '../types/video_data.dart';
|
||||
import '../preview/actor_tile.dart';
|
||||
|
||||
import '../api/api.dart';
|
||||
import '../log/log.dart';
|
||||
import '../types/actor.dart';
|
||||
|
||||
class InfoView extends StatefulWidget {
|
||||
@ -29,7 +25,7 @@ class _InfoViewState extends State<InfoView> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
setState(() {
|
||||
_data = loadData();
|
||||
_data = loadActorsOfVideo(widget.videoId);
|
||||
vdata = loadVideoData(widget.videoId);
|
||||
});
|
||||
}
|
||||
@ -39,19 +35,6 @@ class _InfoViewState extends State<InfoView> {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
}
|
||||
|
||||
Future<List<Actor>> loadData() async {
|
||||
final data = await API
|
||||
.query("actor", "getActorsOfVideo", {'MovieId': widget.videoId});
|
||||
if (data == 'null') {
|
||||
return [];
|
||||
}
|
||||
final d = jsonDecode(data);
|
||||
|
||||
List<Actor> dta = (d as List).map((e) => Actor.fromJson(e)).toList();
|
||||
|
||||
return dta;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder(
|
||||
@ -71,15 +54,10 @@ class _InfoViewState extends State<InfoView> {
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () async {
|
||||
final data = await API.query("video", "addLike",
|
||||
{'MovieId': videoData.movieId});
|
||||
final d = jsonDecode(data);
|
||||
if (d["result"] != 'success') {
|
||||
Log.w(d);
|
||||
}
|
||||
setState(() {
|
||||
vdata = loadVideoData(widget.videoId);
|
||||
});
|
||||
if (await addLike(videoData.movieId))
|
||||
setState(() {
|
||||
vdata = loadVideoData(widget.videoId);
|
||||
});
|
||||
},
|
||||
icon: Icon(Icons.thumb_up)),
|
||||
TextButton(
|
||||
@ -90,9 +68,8 @@ class _InfoViewState extends State<InfoView> {
|
||||
movieId: videoData.movieId,
|
||||
),
|
||||
);
|
||||
Log.d("finished dialog");
|
||||
setState(() {
|
||||
_data = loadData();
|
||||
_data = loadActorsOfVideo(widget.videoId);
|
||||
});
|
||||
},
|
||||
child: Text("Add Actor"),
|
||||
@ -105,7 +82,6 @@ class _InfoViewState extends State<InfoView> {
|
||||
movieId: videoData.movieId,
|
||||
),
|
||||
);
|
||||
Log.d("finished dialog");
|
||||
setState(() {
|
||||
vdata = loadVideoData(widget.videoId);
|
||||
});
|
||||
|
@ -92,7 +92,7 @@ class _VideoScreenState extends State<VideoScreen> {
|
||||
child: GestureDetector(
|
||||
onPanDown: (details) async {
|
||||
if (_appBarVisible) {
|
||||
await Future.delayed(Duration(milliseconds: 100));
|
||||
await Future.delayed(Duration(milliseconds: 300));
|
||||
setState(() {
|
||||
_appBarVisible = false;
|
||||
});
|
||||
|
Reference in New Issue
Block a user