use a Drawercontext to be able to have a specific scaffold for each page
This commit is contained in:
parent
9867b913f4
commit
01049d9381
@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:openmediacentermobile/navigation/settings_screen.dart';
|
import 'package:openmediacentermobile/navigation/settings_screen.dart';
|
||||||
|
import 'db/database.dart';
|
||||||
import 'navigation/actor_screen.dart';
|
import 'navigation/actor_screen.dart';
|
||||||
import 'navigation/categorie_screen.dart';
|
import 'navigation/categorie_screen.dart';
|
||||||
import 'navigation/shufflescreen.dart';
|
import 'navigation/shufflescreen.dart';
|
||||||
@ -17,7 +18,7 @@ class DrawerPage extends StatefulWidget {
|
|||||||
_DrawerPageState createState() => _DrawerPageState();
|
_DrawerPageState createState() => _DrawerPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Section { HOME, SHUFFLE, LOGOUT, CATEGORIE, ACTOR }
|
enum Section { HOME, SHUFFLE, SETTING, CATEGORIE, ACTOR }
|
||||||
|
|
||||||
class _DrawerPageState extends State<DrawerPage> {
|
class _DrawerPageState extends State<DrawerPage> {
|
||||||
Section _sec = Section.HOME;
|
Section _sec = Section.HOME;
|
||||||
@ -38,7 +39,7 @@ class _DrawerPageState extends State<DrawerPage> {
|
|||||||
title = "Shuffle";
|
title = "Shuffle";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Section.LOGOUT:
|
case Section.SETTING:
|
||||||
body = SettingsScreen();
|
body = SettingsScreen();
|
||||||
title = "Settings";
|
title = "Settings";
|
||||||
break;
|
break;
|
||||||
@ -54,75 +55,89 @@ class _DrawerPageState extends State<DrawerPage> {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
final loginCtx = LoginContext.of(context);
|
return DrawerContext((newPage) {
|
||||||
|
setState(() {
|
||||||
|
_sec = newPage;
|
||||||
|
});
|
||||||
|
}, child: body);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return Scaffold(
|
class MyDrawer extends StatelessWidget {
|
||||||
appBar: AppBar(
|
const MyDrawer({Key? key}) : super(key: key);
|
||||||
title: Text(title),
|
|
||||||
actions: [
|
@override
|
||||||
IconButton(
|
Widget build(BuildContext context) {
|
||||||
onPressed: () {
|
final ctx = DrawerContext.of(context);
|
||||||
loginCtx.onLoggin(false);
|
|
||||||
Token.getInstance().setToken("", "");
|
return Drawer(
|
||||||
},
|
child: ListView(children: [
|
||||||
icon: const Icon(Icons.logout))
|
ListTile(
|
||||||
],
|
title: const Text('Home'),
|
||||||
),
|
leading: const Icon(Icons.home),
|
||||||
body: body,
|
onTap: () {
|
||||||
drawer: Drawer(
|
ctx.onChangePage(Section.HOME);
|
||||||
child: ListView(children: [
|
Navigator.pop(context);
|
||||||
ListTile(
|
},
|
||||||
title: const Text('Home'),
|
),
|
||||||
leading: const Icon(Icons.home),
|
ListTile(
|
||||||
onTap: () {
|
title: const Text('Shuffle'),
|
||||||
setState(() {
|
leading: const Icon(Icons.update),
|
||||||
_sec = Section.HOME;
|
onTap: () {
|
||||||
});
|
ctx.onChangePage(Section.SHUFFLE);
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
title: const Text('Shuffle'),
|
title: const Text('Categories'),
|
||||||
leading: const Icon(Icons.update),
|
leading: const Icon(Icons.category),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
setState(() {
|
ctx.onChangePage(Section.CATEGORIE);
|
||||||
_sec = Section.SHUFFLE;
|
Navigator.pop(context);
|
||||||
});
|
},
|
||||||
Navigator.pop(context);
|
),
|
||||||
},
|
ListTile(
|
||||||
),
|
title: const Text('Actors'),
|
||||||
ListTile(
|
leading: const Icon(Icons.people),
|
||||||
title: const Text('Categories'),
|
onTap: () {
|
||||||
leading: const Icon(Icons.category),
|
ctx.onChangePage(Section.ACTOR);
|
||||||
onTap: () {
|
Navigator.pop(context);
|
||||||
setState(() {
|
},
|
||||||
_sec = Section.CATEGORIE;
|
),
|
||||||
});
|
ListTile(
|
||||||
Navigator.pop(context);
|
title: const Text('Settings'),
|
||||||
},
|
leading: const Icon(Icons.settings),
|
||||||
),
|
onTap: () {
|
||||||
ListTile(
|
ctx.onChangePage(Section.SETTING);
|
||||||
title: const Text('Actors'),
|
Navigator.pop(context);
|
||||||
leading: const Icon(Icons.people),
|
},
|
||||||
onTap: () {
|
),
|
||||||
setState(() {
|
]),
|
||||||
_sec = Section.ACTOR;
|
|
||||||
});
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: const Text('Settings'),
|
|
||||||
leading: const Icon(Icons.settings),
|
|
||||||
onTap: () {
|
|
||||||
setState(() {
|
|
||||||
_sec = Section.LOGOUT;
|
|
||||||
});
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class DrawerContext extends InheritedWidget {
|
||||||
|
const DrawerContext(this.onChangePage, {Key? key, required Widget child})
|
||||||
|
: super(key: key, child: child);
|
||||||
|
|
||||||
|
final void Function(Section) onChangePage;
|
||||||
|
|
||||||
|
static DrawerContext of(BuildContext context) {
|
||||||
|
final DrawerContext? result =
|
||||||
|
context.dependOnInheritedWidgetOfExactType<DrawerContext>();
|
||||||
|
assert(result != null, 'No DrawerContext found in context');
|
||||||
|
return result!;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool updateShouldNotify(covariant InheritedWidget oldWidget) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// @override
|
||||||
|
// bool updateShouldNotify(LoginContext old) {
|
||||||
|
// return loggedIn != old.loggedIn;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
@ -28,7 +28,7 @@ class Db {
|
|||||||
// Set the path to the database. Note: Using the `join` function from the
|
// Set the path to the database. Note: Using the `join` function from the
|
||||||
// `path` package is best practice to ensure the path is correctly
|
// `path` package is best practice to ensure the path is correctly
|
||||||
// constructed for each platform.
|
// constructed for each platform.
|
||||||
join(await getDatabasesPath(), 'previews.db'),
|
dbpath,
|
||||||
onCreate: (db, version) {
|
onCreate: (db, version) {
|
||||||
// Run the CREATE TABLE statement on the database.
|
// Run the CREATE TABLE statement on the database.
|
||||||
return db.execute(
|
return db.execute(
|
||||||
@ -41,6 +41,22 @@ class Db {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// delete all data but keep structure
|
||||||
|
Future<void> clear() async {
|
||||||
|
await _db.delete("previews");
|
||||||
|
// shrink the db file size
|
||||||
|
await _db.execute("VACUUM");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// get db size in bytes
|
||||||
|
Future<int> getDbSize() async {
|
||||||
|
final int cnt = (await Db().db().rawQuery("pragma page_count;"))[0]
|
||||||
|
["page_count"] as int;
|
||||||
|
final int pagesize =
|
||||||
|
(await Db().db().rawQuery("pragma page_size;"))[0]["page_size"] as int;
|
||||||
|
return cnt * pagesize;
|
||||||
|
}
|
||||||
|
|
||||||
Database db() {
|
Database db() {
|
||||||
return _db;
|
return _db;
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import "package:dart_vlc/dart_vlc.dart";
|
import "package:dart_vlc/dart_vlc.dart";
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:openmediacentermobile/app.dart';
|
|
||||||
|
|
||||||
|
import 'app.dart';
|
||||||
import 'db/database.dart';
|
import 'db/database.dart';
|
||||||
import 'log/log.dart';
|
import 'log/log.dart';
|
||||||
import 'login/logincontext.dart';
|
import 'login/logincontext.dart';
|
||||||
@ -10,29 +10,14 @@ import 'platform.dart';
|
|||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
Log.i("App init!");
|
Log.i("App init!");
|
||||||
DartVLC.initialize();
|
|
||||||
if (isDesktop()) {
|
if (isDesktop()) {
|
||||||
|
DartVLC.initialize();
|
||||||
} else {
|
} else {
|
||||||
await loadDeviceInfo();
|
await loadDeviceInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
Db().init();
|
Db().init();
|
||||||
|
|
||||||
// RawKeyboard.instance.addListener((event) {
|
|
||||||
// if (LogicalKeyboardKey.arrowLeft == event.logicalKey) {
|
|
||||||
// FocusManager.instance.primaryFocus?.focusInDirection(TraversalDirection.left);
|
|
||||||
// } else if (LogicalKeyboardKey.arrowRight == event.logicalKey) {
|
|
||||||
// FocusManager.instance.primaryFocus?.focusInDirection(TraversalDirection.right);
|
|
||||||
// } else if (LogicalKeyboardKey.arrowDown == event.logicalKey) {
|
|
||||||
// FocusManager.instance.primaryFocus?.focusInDirection(TraversalDirection.down);
|
|
||||||
// } else if (LogicalKeyboardKey.arrowUp == event.logicalKey) {
|
|
||||||
// FocusManager.instance.primaryFocus?.focusInDirection(TraversalDirection.up);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
runApp(Shortcuts(shortcuts: <LogicalKeySet, Intent>{
|
runApp(Shortcuts(shortcuts: <LogicalKeySet, Intent>{
|
||||||
LogicalKeySet(LogicalKeyboardKey.select): ActivateIntent(),
|
LogicalKeySet(LogicalKeyboardKey.select): ActivateIntent(),
|
||||||
}, child: const LoginContainer(child: App())));
|
}, child: const LoginContainer(child: App())));
|
||||||
|
|
||||||
// runApp(const LoginContainer(child: App()));
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:openmediacentermobile/types/actor.dart';
|
import 'package:openmediacentermobile/types/actor.dart';
|
||||||
import 'package:openmediacentermobile/preview/actor_tile.dart';
|
import 'package:openmediacentermobile/preview/actor_tile.dart';
|
||||||
|
|
||||||
|
import '../DrawerPage.dart';
|
||||||
import '../api/api.dart';
|
import '../api/api.dart';
|
||||||
import '../screen_loading.dart';
|
import '../screen_loading.dart';
|
||||||
|
|
||||||
@ -33,33 +34,38 @@ class _ActorScreenState extends State<ActorScreen> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return FutureBuilder(
|
return Scaffold(
|
||||||
future: _categories,
|
appBar: AppBar(
|
||||||
builder: (context, AsyncSnapshot<List<Actor>> snapshot) {
|
title: Text("Temp"),
|
||||||
if (snapshot.connectionState != ConnectionState.done) {
|
),
|
||||||
return ScreenLoading();
|
body: FutureBuilder(
|
||||||
}
|
future: _categories,
|
||||||
|
builder: (context, AsyncSnapshot<List<Actor>> snapshot) {
|
||||||
|
if (snapshot.connectionState != ConnectionState.done) {
|
||||||
|
return ScreenLoading();
|
||||||
|
}
|
||||||
|
|
||||||
if (snapshot.hasError) {
|
if (snapshot.hasError) {
|
||||||
return Text("Error");
|
return Text("Error");
|
||||||
} else if (snapshot.hasData) {
|
} else if (snapshot.hasData) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: EdgeInsets.all(5),
|
padding: EdgeInsets.all(5),
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Wrap(
|
child: Wrap(
|
||||||
spacing: 5,
|
spacing: 5,
|
||||||
runSpacing: 5,
|
runSpacing: 5,
|
||||||
alignment: WrapAlignment.start,
|
alignment: WrapAlignment.start,
|
||||||
children: snapshot.data!
|
children: snapshot.data!
|
||||||
.map((e) => ActorTile(actor: e))
|
.map((e) => ActorTile(actor: e))
|
||||||
.toList(growable: false),
|
.toList(growable: false),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return ScreenLoading();
|
return ScreenLoading();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
),
|
||||||
|
drawer: MyDrawer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ import 'dart:convert';
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:openmediacentermobile/preview/tag_tile.dart';
|
import 'package:openmediacentermobile/preview/tag_tile.dart';
|
||||||
|
import '../DrawerPage.dart';
|
||||||
import '../screen_loading.dart';
|
import '../screen_loading.dart';
|
||||||
|
|
||||||
import '../api/api.dart';
|
import '../api/api.dart';
|
||||||
@ -33,35 +34,40 @@ class _CategorieScreenState extends State<CategorieScreen> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return FutureBuilder(
|
return Scaffold(
|
||||||
future: _categories,
|
appBar: AppBar(
|
||||||
builder: (context, AsyncSnapshot<List<Tag>> snapshot) {
|
title: Text("Temp"),
|
||||||
if (snapshot.connectionState != ConnectionState.done) {
|
),
|
||||||
return ScreenLoading();
|
body: FutureBuilder(
|
||||||
}
|
future: _categories,
|
||||||
|
builder: (context, AsyncSnapshot<List<Tag>> snapshot) {
|
||||||
|
if (snapshot.connectionState != ConnectionState.done) {
|
||||||
|
return ScreenLoading();
|
||||||
|
}
|
||||||
|
|
||||||
if (snapshot.hasError) {
|
if (snapshot.hasError) {
|
||||||
return Text("Error");
|
return Text("Error");
|
||||||
} else if (snapshot.hasData) {
|
} else if (snapshot.hasData) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: EdgeInsets.all(5),
|
padding: EdgeInsets.all(5),
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Wrap(
|
child: Wrap(
|
||||||
spacing: 5,
|
spacing: 5,
|
||||||
runSpacing: 5,
|
runSpacing: 5,
|
||||||
alignment: WrapAlignment.start,
|
alignment: WrapAlignment.start,
|
||||||
children: snapshot.data!
|
children: snapshot.data!
|
||||||
.map((e) => TagTile(
|
.map((e) => TagTile(
|
||||||
tag: e,
|
tag: e,
|
||||||
))
|
))
|
||||||
.toList(growable: false),
|
.toList(growable: false),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return ScreenLoading();
|
return ScreenLoading();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
),
|
||||||
|
drawer: MyDrawer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../DrawerPage.dart';
|
||||||
|
import '../api/token.dart';
|
||||||
import '../db/database.dart';
|
import '../db/database.dart';
|
||||||
|
import '../login/logincontext.dart';
|
||||||
|
|
||||||
class SettingsScreen extends StatefulWidget {
|
class SettingsScreen extends StatefulWidget {
|
||||||
const SettingsScreen({Key? key}) : super(key: key);
|
const SettingsScreen({Key? key}) : super(key: key);
|
||||||
@ -15,33 +18,37 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
loadDBSize();
|
Db().getDbSize().then((v) => setState(() {
|
||||||
}
|
dbsize = v;
|
||||||
|
}));
|
||||||
void loadDBSize() async {
|
|
||||||
final int cnt = (await Db().db().rawQuery("pragma page_count;"))[0]
|
|
||||||
["page_count"] as int;
|
|
||||||
final int pagesize =
|
|
||||||
(await Db().db().rawQuery("pragma page_size;"))[0]["page_size"] as int;
|
|
||||||
setState(() {
|
|
||||||
dbsize = cnt * pagesize;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Column(
|
final loginCtx = LoginContext.of(context);
|
||||||
children: [
|
|
||||||
ElevatedButton(
|
return Scaffold(
|
||||||
onPressed: () async {
|
appBar: AppBar(
|
||||||
await Db().db().delete("previews");
|
title: Text("Temp"),
|
||||||
// shrink the db file size
|
),
|
||||||
await Db().db().execute("VACUUM");
|
body: Column(
|
||||||
loadDBSize();
|
children: [
|
||||||
},
|
ElevatedButton(
|
||||||
child: const Text("Delete cache!")),
|
onPressed: () async {
|
||||||
Text("db size: ${dbsize / 1024} kb")
|
await Db().clear();
|
||||||
],
|
Db().getDbSize().then((v) => setState(() {
|
||||||
);
|
dbsize = v;
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
child: const Text("Delete cache!")),
|
||||||
|
Text("db size: ${dbsize / 1024} kb"),
|
||||||
|
ElevatedButton(onPressed: () {
|
||||||
|
loginCtx.onLoggin(false);
|
||||||
|
Token.getInstance().setToken("", "");
|
||||||
|
Db().clear();
|
||||||
|
}, child: Text("Logout"))
|
||||||
|
],
|
||||||
|
),
|
||||||
|
drawer: MyDrawer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ import 'dart:convert';
|
|||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../DrawerPage.dart';
|
||||||
import '../preview/preview_grid.dart';
|
import '../preview/preview_grid.dart';
|
||||||
import '../api/api.dart';
|
import '../api/api.dart';
|
||||||
import '../platform.dart';
|
import '../platform.dart';
|
||||||
@ -30,27 +31,33 @@ class _ShuffleScreenState extends State<ShuffleScreen> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
double width = MediaQuery.of(context).size.width;
|
double width = MediaQuery.of(context).size.width;
|
||||||
return PreviewGrid(
|
|
||||||
videoLoader: () {
|
return Scaffold(
|
||||||
return loadData((isTV() ? width ~/ 200 : width ~/ 275) * 2);
|
appBar: AppBar(
|
||||||
},
|
title: Text("Temp"),
|
||||||
footerBuilder: (state) => Column(
|
),
|
||||||
children: [
|
body: PreviewGrid(
|
||||||
const SizedBox(
|
videoLoader: () {
|
||||||
height: 25,
|
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,
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
TextButton.icon(
|
),
|
||||||
onPressed: () {
|
drawer: MyDrawer());
|
||||||
state.loadData();
|
|
||||||
},
|
|
||||||
icon: const Icon(Icons.update),
|
|
||||||
label: const Text("Shuffle"),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 25,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:openmediacentermobile/DrawerPage.dart';
|
||||||
|
|
||||||
import '../api/api.dart';
|
import '../api/api.dart';
|
||||||
import '../log/log.dart';
|
import '../log/log.dart';
|
||||||
@ -36,8 +37,13 @@ class VideoFeedState extends State<VideoFeed> {
|
|||||||
double width = MediaQuery.of(context).size.width;
|
double width = MediaQuery.of(context).size.width;
|
||||||
Log.d(width);
|
Log.d(width);
|
||||||
|
|
||||||
return PreviewGrid(
|
return Scaffold(
|
||||||
videoLoader: () => loadData(),
|
appBar: AppBar(
|
||||||
);
|
title: Text(widget.tag?.tagName ?? "OpenMediaCenter"),
|
||||||
|
),
|
||||||
|
body: PreviewGrid(
|
||||||
|
videoLoader: () => loadData(),
|
||||||
|
),
|
||||||
|
drawer: widget.tag == null ? MyDrawer() : null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,10 +14,7 @@ class TagTile extends StatelessWidget {
|
|||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => Scaffold(
|
builder: (context) => VideoFeed(tag: tag),
|
||||||
appBar: AppBar(title: Text(tag.tagName)),
|
|
||||||
body: VideoFeed(tag: tag),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -7,6 +7,7 @@ import 'package:openmediacentermobile/types/video_data.dart';
|
|||||||
import 'package:openmediacentermobile/preview/actor_tile.dart';
|
import 'package:openmediacentermobile/preview/actor_tile.dart';
|
||||||
|
|
||||||
import '../api/api.dart';
|
import '../api/api.dart';
|
||||||
|
import '../log/log.dart';
|
||||||
import '../types/actor.dart';
|
import '../types/actor.dart';
|
||||||
|
|
||||||
class InfoView extends StatefulWidget {
|
class InfoView extends StatefulWidget {
|
||||||
@ -51,11 +52,21 @@ class _InfoViewState extends State<InfoView> {
|
|||||||
} else if (snapshot.hasData) {
|
} else if (snapshot.hasData) {
|
||||||
final actors = snapshot.data;
|
final actors = snapshot.data;
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: EdgeInsets.only(left: 10, right: 10, top: 30),
|
padding: EdgeInsets.only(left: 10, right: 10, top: 60),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text("Likes: ${widget.vdata.likes}"),
|
Text("Likes: ${widget.vdata.likes}"),
|
||||||
|
IconButton(onPressed: () async {
|
||||||
|
final data = await API
|
||||||
|
.query("video", "addLike", {'MovieId': widget.vdata.movieId});
|
||||||
|
final d = jsonDecode(data);
|
||||||
|
if (d["result"] != 'success') {
|
||||||
|
Log.w(d);
|
||||||
|
}
|
||||||
|
// bit hacky but it works
|
||||||
|
widget.vdata.likes += 1;
|
||||||
|
}, icon: Icon(Icons.thumb_up)),
|
||||||
Text("Quality: ${widget.vdata.quality}"),
|
Text("Quality: ${widget.vdata.quality}"),
|
||||||
Text("Length: ${widget.vdata.length}sec"),
|
Text("Length: ${widget.vdata.length}sec"),
|
||||||
Text("Actors:"),
|
Text("Actors:"),
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
import '../api/api.dart';
|
import '../api/api.dart';
|
||||||
import '../api/token.dart';
|
import '../api/token.dart';
|
||||||
@ -64,9 +65,9 @@ class _VideoScreenState extends State<VideoScreen> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
_controller.dispose();
|
_controller.dispose();
|
||||||
_appBarTimer?.cancel();
|
_appBarTimer?.cancel();
|
||||||
super.dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _setAppBarTimer() {
|
void _setAppBarTimer() {
|
||||||
|
Loading…
Reference in New Issue
Block a user