better error message and loading view
This commit is contained in:
parent
02bf3fb341
commit
395b501925
@ -2,7 +2,11 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:openmediacentermobile/api/token.dart';
|
||||
import 'token.dart';
|
||||
|
||||
class TokenException implements Exception {
|
||||
String wdExpMsg() => 'Invalid token in storage!';
|
||||
}
|
||||
|
||||
class API {
|
||||
static Future<String> query(
|
||||
@ -20,7 +24,7 @@ class API {
|
||||
|
||||
return resp.body;
|
||||
} else {
|
||||
return "";
|
||||
throw TokenException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,16 @@ class _PreviewGridState extends State<PreviewGrid> {
|
||||
builder:
|
||||
(BuildContext context, AsyncSnapshot<List<VideoT>> snapshot) {
|
||||
if (snapshot.hasError) {
|
||||
return Text("Error");
|
||||
return Column(
|
||||
children: [
|
||||
Text("Error"),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
loadData();
|
||||
},
|
||||
child: Text("Reload page"))
|
||||
],
|
||||
);
|
||||
} else if (snapshot.hasData) {
|
||||
return _mainGrid(snapshot.data!, width);
|
||||
} else {
|
||||
|
@ -5,7 +5,8 @@ class ScreenLoading extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: const <Widget>[
|
||||
@ -18,6 +19,6 @@ class ScreenLoading extends StatelessWidget {
|
||||
padding: EdgeInsets.only(top: 16),
|
||||
child: Text('Awaiting result...'),
|
||||
)
|
||||
]);
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user