new categorie page
better folder structure more info on video info page
This commit is contained in:
82
lib/navigation/categorie_screen.dart
Normal file
82
lib/navigation/categorie_screen.dart
Normal file
@ -0,0 +1,82 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import '../navigation/video_feed.dart';
|
||||
import '../screen_loading.dart';
|
||||
|
||||
import '../api/api.dart';
|
||||
import '../types/tag.dart';
|
||||
|
||||
class CategorieScreen extends StatefulWidget {
|
||||
const CategorieScreen({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<CategorieScreen> createState() => _CategorieScreenState();
|
||||
}
|
||||
|
||||
class _CategorieScreenState extends State<CategorieScreen> {
|
||||
late Future<List<Tag>> _categories;
|
||||
|
||||
Future<List<Tag>> loadVideoData() async {
|
||||
final data = await API.query("tags", "getAllTags", {});
|
||||
|
||||
final d = (jsonDecode(data) ?? []) as List<dynamic>;
|
||||
final tags = d.map((e) => Tag.fromJson(e)).toList(growable: false);
|
||||
return tags;
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_categories = loadVideoData();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder(
|
||||
future: _categories,
|
||||
builder: (context, AsyncSnapshot<List<Tag>> snapshot) {
|
||||
if (snapshot.connectionState != ConnectionState.done) {
|
||||
return ScreenLoading();
|
||||
}
|
||||
|
||||
if (snapshot.hasError) {
|
||||
return Text("Error");
|
||||
} else if (snapshot.hasData) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.all(5),
|
||||
child: Wrap(
|
||||
spacing: 5,
|
||||
runSpacing: 5,
|
||||
alignment: WrapAlignment.start,
|
||||
children: snapshot.data!
|
||||
.map((e) => ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => Scaffold(
|
||||
appBar: AppBar(title: Text(e.tagName)),
|
||||
body: VideoFeed(tag: e),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: Color(0x6a94a6ff)),
|
||||
child: SizedBox(
|
||||
child: Center(child: Text(e.tagName)),
|
||||
height: 100,
|
||||
width: 100,
|
||||
),
|
||||
))
|
||||
.toList(growable: false),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return ScreenLoading();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
57
lib/navigation/shufflescreen.dart
Normal file
57
lib/navigation/shufflescreen.dart
Normal file
@ -0,0 +1,57 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:openmediacentermobile/preview/preview_grid.dart';
|
||||
import '../preview/preview_tile.dart';
|
||||
|
||||
import '../api/api.dart';
|
||||
import '../platform.dart';
|
||||
|
||||
class ShuffleScreen extends StatefulWidget {
|
||||
const ShuffleScreen({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<ShuffleScreen> createState() => _ShuffleScreenState();
|
||||
}
|
||||
|
||||
class _ShuffleScreenState extends State<ShuffleScreen> {
|
||||
Future<List<VideoT>> loadData(int nr) async {
|
||||
final data = await API.query("video", "getRandomMovies",
|
||||
{'Number': nr, 'Seed': Random().nextInt(0x7fffffff)});
|
||||
|
||||
final d = jsonDecode(data);
|
||||
|
||||
List<VideoT> dta =
|
||||
(d['Videos'] as List).map((e) => VideoT.fromJson(e)).toList();
|
||||
|
||||
return dta;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
double width = MediaQuery.of(context).size.width;
|
||||
return PreviewGrid(
|
||||
videoLoader: () {
|
||||
return loadData((isTV() ? width ~/ 200 : width ~/ 275) * 2);
|
||||
},
|
||||
footerBuilder: (state) => Column(
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 25,
|
||||
),
|
||||
TextButton.icon(
|
||||
onPressed: () {
|
||||
state.loadData();
|
||||
},
|
||||
icon: const Icon(Icons.update),
|
||||
label: const Text("Shuffle"),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 25,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
43
lib/navigation/video_feed.dart
Normal file
43
lib/navigation/video_feed.dart
Normal file
@ -0,0 +1,43 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:openmediacentermobile/api/api.dart';
|
||||
import 'package:openmediacentermobile/preview/preview_grid.dart';
|
||||
|
||||
import '../log/log.dart';
|
||||
import '../preview/preview_tile.dart';
|
||||
import '../types/tag.dart';
|
||||
|
||||
class VideoFeed extends StatefulWidget {
|
||||
const VideoFeed({Key? key, this.tag}) : super(key: key);
|
||||
final Tag? tag;
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return VideoFeedState();
|
||||
}
|
||||
}
|
||||
|
||||
class VideoFeedState extends State<VideoFeed> {
|
||||
Future<List<VideoT>> loadData() async {
|
||||
final data = await API.query(
|
||||
"video", "getMovies", {'Tag': widget.tag?.tagId ?? 1, 'Sort': 0});
|
||||
|
||||
final d = jsonDecode(data);
|
||||
|
||||
List<VideoT> dta =
|
||||
(d['Videos'] as List).map((e) => VideoT.fromJson(e)).toList();
|
||||
|
||||
return dta;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
double width = MediaQuery.of(context).size.width;
|
||||
Log.d(width);
|
||||
|
||||
return PreviewGrid(
|
||||
videoLoader: () => loadData(),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user