fix linting

add routename in privider
This commit is contained in:
lukas-heiligenbrunner 2022-08-29 17:20:35 +02:00
parent 01049d9381
commit c732ab31df
6 changed files with 41 additions and 39 deletions

View File

@ -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<DrawerPage> {
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;
// }
}

View File

@ -51,9 +51,9 @@ class Db {
/// get db size in bytes
Future<int> 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;
}

View File

@ -57,8 +57,8 @@ class _CategorieScreenState extends State<CategorieScreen> {
alignment: WrapAlignment.start,
children: snapshot.data!
.map((e) => TagTile(
tag: e,
))
tag: e,
))
.toList(growable: false),
),
),

View File

@ -37,16 +37,18 @@ class _SettingsScreenState extends State<SettingsScreen> {
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());

View File

@ -57,16 +57,18 @@ class _InfoViewState extends State<InfoView> {
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:"),

View File

@ -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';