new categorie page
better folder structure more info on video info page
This commit is contained in:
63
lib/video_screen/actor_tile.dart
Normal file
63
lib/video_screen/actor_tile.dart
Normal file
@ -0,0 +1,63 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../platform.dart';
|
||||
import '../types/actor.dart';
|
||||
|
||||
class ActorTile extends StatefulWidget {
|
||||
const ActorTile({Key? key, required this.actor}) : super(key: key);
|
||||
final Actor actor;
|
||||
|
||||
@override
|
||||
State<ActorTile> createState() => _ActorTileState();
|
||||
}
|
||||
|
||||
class _ActorTileState extends State<ActorTile> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ClipRRect(
|
||||
borderRadius: BorderRadius.circular(20.0),
|
||||
child: Stack(
|
||||
children: [
|
||||
Container(
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
widget.actor.name,
|
||||
style: TextStyle(fontSize: isTV() ? 8 : 10.5),
|
||||
overflow: TextOverflow.clip,
|
||||
maxLines: 1,
|
||||
),
|
||||
SizedBox(
|
||||
height: 100,
|
||||
width: 100,
|
||||
)
|
||||
],
|
||||
),
|
||||
color: Color(0x6a94a6ff),
|
||||
),
|
||||
Positioned.fill(
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onLongPress: () {},
|
||||
onLongPressEnd: (details) {},
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// MaterialPageRoute(
|
||||
// builder: (context) =>
|
||||
// VideoScreen(metaData: widget.dta),
|
||||
// ),
|
||||
// );
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -2,12 +2,15 @@ import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:openmediacentermobile/screen_loading.dart';
|
||||
import 'package:openmediacentermobile/types/video_data.dart';
|
||||
import 'package:openmediacentermobile/video_screen/actor_tile.dart';
|
||||
|
||||
import '../api/api.dart';
|
||||
import '../types/actor.dart';
|
||||
|
||||
class ActorView extends StatefulWidget {
|
||||
const ActorView({Key? key, required this.videoId}) : super(key: key);
|
||||
final int videoId;
|
||||
const ActorView({Key? key, required this.vdata}) : super(key: key);
|
||||
final VideoData vdata;
|
||||
|
||||
@override
|
||||
State<ActorView> createState() => _ActorViewState();
|
||||
@ -26,7 +29,7 @@ class _ActorViewState extends State<ActorView> {
|
||||
|
||||
Future<List<Actor>> loadData() async {
|
||||
final data = await API
|
||||
.query("actor", "getActorsOfVideo", {'MovieId': widget.videoId});
|
||||
.query("actor", "getActorsOfVideo", {'MovieId': widget.vdata.movieId});
|
||||
if (data == 'null') {
|
||||
return [];
|
||||
}
|
||||
@ -46,11 +49,27 @@ class _ActorViewState extends State<ActorView> {
|
||||
return Text("Error");
|
||||
} else if (snapshot.hasData) {
|
||||
final actors = snapshot.data;
|
||||
if (actors?.isEmpty ?? true) {
|
||||
return Text("no actors available");
|
||||
} else {
|
||||
return Column(children: _renderActors(snapshot.data!));
|
||||
}
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(left: 10, right: 10, top: 30),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text("Likes: ${widget.vdata.likes}"),
|
||||
Text("Quality: ${widget.vdata.quality}"),
|
||||
Text("Length: ${widget.vdata.length}sec"),
|
||||
Text("Actors:"),
|
||||
actors?.isEmpty ?? true
|
||||
? Text("no actors available")
|
||||
: Row(
|
||||
children: _renderActors(snapshot.data!),
|
||||
),
|
||||
Text("Tags:"),
|
||||
Row(
|
||||
children: widget.vdata.tags
|
||||
.map((e) => Text(e.tagName))
|
||||
.toList(growable: false),
|
||||
)
|
||||
]));
|
||||
} else {
|
||||
return ScreenLoading();
|
||||
}
|
||||
@ -59,29 +78,6 @@ class _ActorViewState extends State<ActorView> {
|
||||
}
|
||||
|
||||
List<Widget> _renderActors(List<Actor> actors) {
|
||||
return actors
|
||||
.map((e) => Text(
|
||||
e.name,
|
||||
style: TextStyle(color: Colors.black),
|
||||
))
|
||||
.toList(growable: false);
|
||||
}
|
||||
}
|
||||
|
||||
class Actor {
|
||||
int actorId;
|
||||
String name;
|
||||
String thumbnail;
|
||||
|
||||
Actor(this.actorId, this.name, this.thumbnail);
|
||||
|
||||
factory Actor.fromJson(dynamic json) {
|
||||
return Actor(json['ActorId'] as int, json['Name'] as String,
|
||||
json['Thumbnail'] as String);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Actor{ActorId: $actorId, Name: $name, Thumbnail: $thumbnail}';
|
||||
return actors.map((e) => ActorTile(actor: e)).toList(growable: false);
|
||||
}
|
||||
}
|
||||
|
@ -6,13 +6,15 @@ import 'package:chewie/chewie.dart';
|
||||
import "package:dart_vlc/dart_vlc.dart";
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:openmediacentermobile/preview_tile.dart';
|
||||
import 'package:openmediacentermobile/preview/preview_tile.dart';
|
||||
import 'package:openmediacentermobile/screen_loading.dart';
|
||||
import 'package:openmediacentermobile/video_screen/actor_view.dart';
|
||||
import 'package:video_player/video_player.dart';
|
||||
|
||||
import '../api/api.dart';
|
||||
import '../api/token.dart';
|
||||
import '../platform.dart';
|
||||
import '../types/video_data.dart';
|
||||
|
||||
class VideoScreen extends StatefulWidget {
|
||||
const VideoScreen({Key? key, required this.metaData}) : super(key: key);
|
||||
@ -29,20 +31,26 @@ class _VideoScreenState extends State<VideoScreen> {
|
||||
|
||||
bool _appBarVisible = true;
|
||||
Timer? _appBarTimer;
|
||||
late Future<VideoData> _videoData;
|
||||
|
||||
void loadData() async {
|
||||
Future<VideoData> loadVideoData() async {
|
||||
final data =
|
||||
await API.query("video", "loadVideo", {'MovieId': widget.metaData.id});
|
||||
|
||||
final d = jsonDecode(data);
|
||||
final video = VideoData.fromJson(d);
|
||||
return video;
|
||||
}
|
||||
|
||||
void initPlayer() async {
|
||||
final videodata = await _videoData;
|
||||
|
||||
final url = d["MovieUrl"];
|
||||
final token = await Token.getInstance().getToken();
|
||||
if (token == null) return;
|
||||
|
||||
final baseurl = token.domain;
|
||||
// todo not static middle path
|
||||
final path = baseurl + "/videos/vids/" + url;
|
||||
final path = baseurl + "/videos/vids/" + videodata.movieUrl;
|
||||
|
||||
if (isDesktop()) {
|
||||
final media2 = Media.network(path);
|
||||
@ -73,6 +81,9 @@ class _VideoScreenState extends State<VideoScreen> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_videoData = loadVideoData();
|
||||
initPlayer();
|
||||
|
||||
if (isDesktop()) {
|
||||
RawKeyboard.instance.addListener((value) {
|
||||
if (value.logicalKey == LogicalKeyboardKey.arrowRight) {
|
||||
@ -85,7 +96,6 @@ class _VideoScreenState extends State<VideoScreen> {
|
||||
});
|
||||
}
|
||||
|
||||
loadData();
|
||||
_setAppBarTimer();
|
||||
}
|
||||
|
||||
@ -121,42 +131,63 @@ class _VideoScreenState extends State<VideoScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: MouseRegion(
|
||||
onHover: (PointerEvent event) {
|
||||
if (event.delta.dx != 0 || event.delta.dy != 0) {
|
||||
setState(() {
|
||||
_appBarVisible = true;
|
||||
});
|
||||
_setAppBarTimer();
|
||||
body: FutureBuilder(
|
||||
future: _videoData,
|
||||
builder: (context, AsyncSnapshot<VideoData> snapshot) {
|
||||
if (snapshot.hasError) {
|
||||
return Text("Error");
|
||||
} else if (snapshot.hasData) {
|
||||
return MouseRegion(
|
||||
onHover: (PointerEvent event) async {
|
||||
if (event.delta.dx != 0 || event.delta.dy != 0) {
|
||||
if (_appBarVisible) {
|
||||
await Future.delayed(Duration(milliseconds: 100));
|
||||
setState(() {
|
||||
_appBarVisible = false;
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
_appBarVisible = true;
|
||||
});
|
||||
_setAppBarTimer();
|
||||
}
|
||||
}
|
||||
},
|
||||
child: Stack(children: [
|
||||
PageView(
|
||||
scrollDirection: Axis.vertical,
|
||||
controller: _controller,
|
||||
children: [
|
||||
Center(
|
||||
child:
|
||||
isDesktop() ? videoDesktop() : videoNotDesktop()),
|
||||
ActorView(
|
||||
vdata: snapshot.data!,
|
||||
)
|
||||
]),
|
||||
if (_appBarVisible)
|
||||
new Positioned(
|
||||
top: 0.0,
|
||||
left: 0.0,
|
||||
right: 0.0,
|
||||
child: AppBar(
|
||||
title: Text(widget.metaData.title),
|
||||
leading: new IconButton(
|
||||
icon:
|
||||
new Icon(Icons.arrow_back_ios, color: Colors.grey),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
backgroundColor:
|
||||
Theme.of(context).primaryColor.withOpacity(0.3),
|
||||
elevation: 0.0,
|
||||
),
|
||||
),
|
||||
]),
|
||||
);
|
||||
} else {
|
||||
return ScreenLoading();
|
||||
}
|
||||
},
|
||||
child: Stack(children: [
|
||||
PageView(
|
||||
scrollDirection: Axis.vertical,
|
||||
controller: _controller,
|
||||
children: [
|
||||
Center(child: isDesktop() ? videoDesktop() : videoNotDesktop()),
|
||||
ActorView(
|
||||
videoId: widget.metaData.id,
|
||||
)
|
||||
]),
|
||||
if (_appBarVisible)
|
||||
new Positioned(
|
||||
top: 0.0,
|
||||
left: 0.0,
|
||||
right: 0.0,
|
||||
child: AppBar(
|
||||
title: Text(widget.metaData.title),
|
||||
leading: new IconButton(
|
||||
icon: new Icon(Icons.arrow_back_ios, color: Colors.grey),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
backgroundColor:
|
||||
Theme.of(context).primaryColor.withOpacity(0.3),
|
||||
elevation: 0.0,
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user