Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Few fixes for opening up webpage with stored data

Michael Rademakercac226995aa4
diff --git a/console/generic_app/lib/ConsoleProviders/GeofenceProvider.dart b/console/generic_app/lib/ConsoleProviders/GeofenceProvider.dart
index 4fb59a2c6..022e55f3a 100644
--- a/console/generic_app/lib/ConsoleProviders/GeofenceProvider.dart
+++ b/console/generic_app/lib/ConsoleProviders/GeofenceProvider.dart
@@ -40,7 +40,7 @@ class GeofenceProvider {
String geofenceString = sharedPreferences.getString(geofencesKey);
List<GeofenceDefinition> geofences;
if (geofenceString != null) {
- geofences = List<GeofenceDefinition>.from(json.decode(geofenceString));
+ geofences = List<GeofenceDefinition>.from(json.decode(geofenceString).map((item) => GeofenceDefinition.fromJson(item)));
} else {
geofences = new List<GeofenceDefinition>();
}
diff --git a/console/generic_app/lib/ui/SplashPage.dart b/console/generic_app/lib/ui/SplashPage.dart
index 2d748b5fb..6c66092c0 100644
--- a/console/generic_app/lib/ui/SplashPage.dart
+++ b/console/generic_app/lib/ui/SplashPage.dart
@@ -25,18 +25,19 @@ class _SplashPageState extends State<SplashPage> {
@override
Widget build(BuildContext context) {
return new FutureBuilder(
- future: _getProjectData(),
+ future: Future.delayed(Duration(seconds: 3), _getProjectData),
builder: (BuildContext context, AsyncSnapshot snapshot) {
- Timer(Duration(seconds: 3), () {
- if (snapshot.hasData) {
+ if (snapshot.hasData) {
+ Future.delayed(Duration.zero, () {
if (snapshot.data) {
- _getConsoleAppConfig();
+ Navigator.pushReplacement(context,
+ MaterialPageRoute(builder: (context) => WebViewPage(initialUrl: CurrentConsoleAppConfig.instance.url)));
+ } else {
+ Navigator.pushReplacement(context,
+ MaterialPageRoute(builder: (context) => ProjectPage()));
}
- } else {
- Navigator.pushReplacement(context,
- CupertinoPageRoute(builder: (context) => ProjectPage()));
- }
- });
+ });
+ }
return Scaffold(
body: Align(
alignment: Alignment.center,
@@ -53,24 +54,22 @@ class _SplashPageState extends State<SplashPage> {
_projectName = _sharedPreferences.getString("project");
_realmName = _sharedPreferences.getString("realm");
- return _projectName != null && _realmName != null;
+ bool hasData = _projectName != null && _realmName != null;
+ if (hasData) {
+ await _getConsoleAppConfig();
+ }
+
+ return hasData;
}
- void _getConsoleAppConfig() {
+ Future _getConsoleAppConfig() async {
var apiManager = new ApiManager("https://$_projectName.openremote.io/api/$_realmName");
- apiManager.get(["app", "config"], ConsoleAppConfig.fromJson).then((value) {
+ return apiManager
+ .get(["app", "config"], ConsoleAppConfig.fromJson).then((value) {
print(value);
CurrentConsoleAppConfig.instance.updateConfig(value, _projectName);
- Navigator.pushReplacement(
- context,
- CupertinoPageRoute(
- builder: (context) => WebViewPage(
- initialUrl: CurrentConsoleAppConfig.instance.url,
- )));
}).catchError((onError) {
print(onError);
- Navigator.pushReplacement(
- context, CupertinoPageRoute(builder: (context) => ProjectPage()));
});
}
}
diff --git a/console/generic_app/lib/ui/WebViewPage.dart b/console/generic_app/lib/ui/WebViewPage.dart
index 08c7ab997..9c4f02197 100644
--- a/console/generic_app/lib/ui/WebViewPage.dart
+++ b/console/generic_app/lib/ui/WebViewPage.dart
@@ -70,7 +70,7 @@ class _WebViewPageState extends State<WebViewPage> {
}
}
- return WillPopScope( onWillPop: _onBackPressed, child: Scaffold(body: SafeArea(child: stack)));
+ return WillPopScope( onWillPop: _onBackPressed, child: Scaffold(body: stack));
}
_notifyClient(Map<String, dynamic> data) {