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) {
return DrawerContext(
child: body,
onChangePage: (newPage) {
setState(() {
_sec = newPage;
});
}, child: body);
},
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

@ -42,11 +42,13 @@ class _SettingsScreenState extends State<SettingsScreen> {
},
child: const Text("Delete cache!")),
Text("db size: ${dbsize / 1024} kb"),
ElevatedButton(onPressed: () {
ElevatedButton(
onPressed: () {
loginCtx.onLoggin(false);
Token.getInstance().setToken("", "");
Db().clear();
}, child: Text("Logout"))
},
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});
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)),
},
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';