add load error in featurecontext
This commit is contained in:
parent
6f6fbb3897
commit
eff1ea0812
@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:openmediacentermobile/login/login_context.dart';
|
||||||
import '../api/settings_api.dart';
|
import '../api/settings_api.dart';
|
||||||
|
|
||||||
// todo maybe instead of feature context a context for all settings?
|
// todo maybe instead of feature context a context for all settings?
|
||||||
@ -35,29 +36,52 @@ class FeatureContainer extends StatefulWidget {
|
|||||||
class _FeatureContainerState extends State<FeatureContainer> {
|
class _FeatureContainerState extends State<FeatureContainer> {
|
||||||
bool? tvShowEnabled;
|
bool? tvShowEnabled;
|
||||||
bool? fullDeleteEnabled;
|
bool? fullDeleteEnabled;
|
||||||
|
bool fetcherror = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
loadInitialData().then((value) => setState(
|
loadInitialData()
|
||||||
() {
|
.then((value) => setState(
|
||||||
fullDeleteEnabled = value.fullDeleteEnabled;
|
() {
|
||||||
tvShowEnabled = value.tvShowEnabled;
|
fullDeleteEnabled = value.fullDeleteEnabled;
|
||||||
},
|
tvShowEnabled = value.tvShowEnabled;
|
||||||
));
|
},
|
||||||
|
))
|
||||||
|
.catchError((err) => setState(() => fetcherror = true));
|
||||||
|
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (tvShowEnabled == null || fullDeleteEnabled == null) {
|
if (fetcherror) {
|
||||||
|
final loginctx = LoginContext.of(context);
|
||||||
|
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
home: Container(
|
home: Scaffold(
|
||||||
color: Colors.white,
|
body: Center(
|
||||||
child: Center(
|
child:
|
||||||
child: Column(
|
Column(mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||||
children: [CircularProgressIndicator(), Text("loading features")],
|
Text("Fetch error"),
|
||||||
)),
|
MaterialButton(
|
||||||
|
onPressed: () => loginctx.onLoggin(false),
|
||||||
|
child: Text("Logout"),
|
||||||
|
)
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else if (tvShowEnabled == null || fullDeleteEnabled == null) {
|
||||||
|
return MaterialApp(
|
||||||
|
home: Scaffold(
|
||||||
|
body: Container(
|
||||||
|
color: Colors.white,
|
||||||
|
child: Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [CircularProgressIndicator(), Text("loading features")],
|
||||||
|
)),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user