diff --git a/lib/DrawerPage.dart b/lib/DrawerPage.dart index 4fdd490..1fc50f6 100644 --- a/lib/DrawerPage.dart +++ b/lib/DrawerPage.dart @@ -1,14 +1,10 @@ import 'package:flutter/material.dart'; import 'package:openmediacentermobile/navigation/settings_screen.dart'; -import 'db/database.dart'; import 'navigation/actor_screen.dart'; import 'navigation/categorie_screen.dart'; import 'navigation/shufflescreen.dart'; import 'navigation/video_feed.dart'; -import 'api/token.dart'; -import 'login/logincontext.dart'; - class DrawerPage extends StatefulWidget { const DrawerPage({Key? key, required this.title}) : super(key: key); @@ -55,11 +51,15 @@ class _DrawerPageState extends State { break; } - return DrawerContext((newPage) { - setState(() { - _sec = newPage; - }); - }, child: body); + return DrawerContext( + child: body, + onChangePage: (newPage) { + setState(() { + _sec = newPage; + }); + }, + routeName: title, + ); } } @@ -117,12 +117,16 @@ class MyDrawer extends StatelessWidget { } } - class DrawerContext extends InheritedWidget { - const DrawerContext(this.onChangePage, {Key? key, required Widget child}) - : super(key: key, child: child); + const DrawerContext({ + Key? key, + required Widget child, + required this.onChangePage, + required this.routeName, + }) : super(key: key, child: child); final void Function(Section) onChangePage; + final String routeName; static DrawerContext of(BuildContext context) { final DrawerContext? result = @@ -135,9 +139,4 @@ class DrawerContext extends InheritedWidget { bool updateShouldNotify(covariant InheritedWidget oldWidget) { return false; } - -// @override -// bool updateShouldNotify(LoginContext old) { -// return loggedIn != old.loggedIn; -// } } diff --git a/lib/db/database.dart b/lib/db/database.dart index 6fc543f..b3af8bf 100644 --- a/lib/db/database.dart +++ b/lib/db/database.dart @@ -51,9 +51,9 @@ class Db { /// get db size in bytes Future getDbSize() async { final int cnt = (await Db().db().rawQuery("pragma page_count;"))[0] - ["page_count"] as int; + ["page_count"] as int; final int pagesize = - (await Db().db().rawQuery("pragma page_size;"))[0]["page_size"] as int; + (await Db().db().rawQuery("pragma page_size;"))[0]["page_size"] as int; return cnt * pagesize; } diff --git a/lib/navigation/categorie_screen.dart b/lib/navigation/categorie_screen.dart index f3a9d27..a398787 100644 --- a/lib/navigation/categorie_screen.dart +++ b/lib/navigation/categorie_screen.dart @@ -57,8 +57,8 @@ class _CategorieScreenState extends State { alignment: WrapAlignment.start, children: snapshot.data! .map((e) => TagTile( - tag: e, - )) + tag: e, + )) .toList(growable: false), ), ), diff --git a/lib/navigation/settings_screen.dart b/lib/navigation/settings_screen.dart index 489a0b0..2785eb4 100644 --- a/lib/navigation/settings_screen.dart +++ b/lib/navigation/settings_screen.dart @@ -37,16 +37,18 @@ class _SettingsScreenState extends State { onPressed: () async { await Db().clear(); Db().getDbSize().then((v) => setState(() { - dbsize = v; - })); + 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")) + ElevatedButton( + onPressed: () { + loginCtx.onLoggin(false); + Token.getInstance().setToken("", ""); + Db().clear(); + }, + child: Text("Logout")) ], ), drawer: MyDrawer()); diff --git a/lib/video_screen/info_view.dart b/lib/video_screen/info_view.dart index 8dd3d4f..4d71734 100644 --- a/lib/video_screen/info_view.dart +++ b/lib/video_screen/info_view.dart @@ -57,16 +57,18 @@ class _InfoViewState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ 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)), + 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("Length: ${widget.vdata.length}sec"), Text("Actors:"), diff --git a/lib/video_screen/videoscreen.dart b/lib/video_screen/videoscreen.dart index 6b99ee2..8136c0b 100644 --- a/lib/video_screen/videoscreen.dart +++ b/lib/video_screen/videoscreen.dart @@ -1,7 +1,6 @@ import 'dart:async'; import 'dart:convert'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import '../api/api.dart'; import '../api/token.dart';