diff --git a/lib/api/api.dart b/lib/api/api.dart index 030adcf..0d5edeb 100644 --- a/lib/api/api.dart +++ b/lib/api/api.dart @@ -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 query( @@ -20,7 +24,7 @@ class API { return resp.body; } else { - return ""; + throw TokenException(); } } } diff --git a/lib/preview/preview_grid.dart b/lib/preview/preview_grid.dart index 6246fcb..a87a310 100644 --- a/lib/preview/preview_grid.dart +++ b/lib/preview/preview_grid.dart @@ -56,7 +56,16 @@ class _PreviewGridState extends State { builder: (BuildContext context, AsyncSnapshot> 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 { diff --git a/lib/screen_loading.dart b/lib/screen_loading.dart index 62a0e66..093b00b 100644 --- a/lib/screen_loading.dart +++ b/lib/screen_loading.dart @@ -5,10 +5,11 @@ class ScreenLoading extends StatelessWidget { @override Widget build(BuildContext context) { - return Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: const [ + return Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: const [ SizedBox( width: 60, height: 60, @@ -18,6 +19,6 @@ class ScreenLoading extends StatelessWidget { padding: EdgeInsets.only(top: 16), child: Text('Awaiting result...'), ) - ]); + ])); } }