diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 82d1b5a0f25cff021b288f598abd037978471525..19291101caa84057045aaf294209c0ffb6389f01 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -10,6 +10,8 @@ PODS: - Flutter - flutter_web_browser (0.11.0): - Flutter + - shared_preferences (0.0.1): + - Flutter - uni_links (0.0.1): - Flutter - url_launcher (0.0.1): @@ -19,6 +21,7 @@ DEPENDENCIES: - Flutter (from `.symlinks/flutter/ios`) - flutter_app_auth_wrapper (from `.symlinks/plugins/flutter_app_auth_wrapper/ios`) - flutter_web_browser (from `.symlinks/plugins/flutter_web_browser/ios`) + - shared_preferences (from `.symlinks/plugins/shared_preferences/ios`) - uni_links (from `.symlinks/plugins/uni_links/ios`) - url_launcher (from `.symlinks/plugins/url_launcher/ios`) @@ -33,6 +36,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/flutter_app_auth_wrapper/ios" flutter_web_browser: :path: ".symlinks/plugins/flutter_web_browser/ios" + shared_preferences: + :path: ".symlinks/plugins/shared_preferences/ios" uni_links: :path: ".symlinks/plugins/uni_links/ios" url_launcher: @@ -43,6 +48,7 @@ SPEC CHECKSUMS: Flutter: 58dd7d1b27887414a370fcccb9e645c08ffd7a6a flutter_app_auth_wrapper: e194830013782a9a914171728299f8f5b285b4ba flutter_web_browser: bdea232160dec44dec86540bee05168cc844ef7c + shared_preferences: 1feebfa37bb57264736e16865e7ffae7fc99b523 uni_links: d97da20c7701486ba192624d99bffaaffcfc298a url_launcher: 0067ddb8f10d36786672aa0722a21717dba3a298 diff --git a/lib/src/app.dart b/lib/src/app.dart index c33e29eaac255f31642b43010fb3ec489ed9e3f3..3e2b29d60263127e11faa00ddc88778a5d9eabd1 100644 --- a/lib/src/app.dart +++ b/lib/src/app.dart @@ -5,6 +5,7 @@ import 'screens/home.dart'; import 'package:flutter/services.dart'; import 'dart:async'; import 'dart:developer'; +import 'package:shared_preferences/shared_preferences.dart'; import 'package:uni_links/uni_links.dart'; @@ -20,7 +21,10 @@ class App extends StatelessWidget { initialUri = null; } - return new MainApp(initialUri: initialUri); + final prefs = await SharedPreferences.getInstance(); + final host = prefs.getString('host'); + + return new MainApp(initialUri: initialUri, initialHost: host); } @override @@ -43,8 +47,9 @@ class App extends StatelessWidget { } class MainApp extends StatefulWidget { - MainApp({ @required this.initialUri }); + MainApp({ @required this.initialUri, this.initialHost }); final Uri initialUri; + final String initialHost; @override _MainAppState createState() => _MainAppState(); @@ -86,7 +91,6 @@ class _MainAppState extends State<MainApp> { setState(() { _appMode = "oauth"; _invokerURL = uri.queryParameters["invokerUrl"]; - _host = uri.queryParameters["host"]; }); } else { setState(() { @@ -109,7 +113,7 @@ class _MainAppState extends State<MainApp> { mode: _appMode, invokerURL: _invokerURL, setMode: setMode, - host: _host + host: widget.initialHost ) ); } diff --git a/lib/src/screens/home.dart b/lib/src/screens/home.dart index 309b63caa814ce7d55f2937ebb764182aa66ac03..528c2bf3852fc50bbd8b249e20f85629b0925602 100644 --- a/lib/src/screens/home.dart +++ b/lib/src/screens/home.dart @@ -4,6 +4,7 @@ import 'package:flutter_app_auth_wrapper/flutter_app_auth_wrapper.dart'; import 'package:url_launcher/url_launcher.dart'; import 'dart:developer'; import 'dart:convert'; +import 'package:shared_preferences/shared_preferences.dart'; import '../../config.dart'; @@ -24,6 +25,10 @@ class _HomeState extends State<Home> { @override initState() { super.initState(); + setState(() { + _host = widget.host; + }); + showMode(widget.mode); FlutterAppAuthWrapper.eventStream().listen((data) { @@ -128,10 +133,13 @@ class _HomeState extends State<Home> { wrapInContainer( DropdownButton<String>( value: _host, - onChanged: (String newValue) { + onChanged: (String newValue) async { setState(() { _host = newValue; }); + + final prefs = await SharedPreferences.getInstance(); + prefs.setString("host", newValue); }, items: Config.HOSTS .map<DropdownMenuItem<String>>((String value) { diff --git a/pubspec.lock b/pubspec.lock index 53b08bfe62cefec32de5db18794c149a3861c8bd..72ff10c24912fe6b8bda37fc66e1699a54d054fc 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -97,20 +97,6 @@ packages: url: "git@github.com:markin-io/flutter_web_browser.git" source: git version: "0.11.0" - http: - dependency: "direct main" - description: - name: http - url: "https://pub.dartlang.org" - source: hosted - version: "0.12.0+2" - http_parser: - dependency: transitive - description: - name: http_parser - url: "https://pub.dartlang.org" - source: hosted - version: "3.1.3" image: dependency: transitive description: @@ -160,6 +146,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.3" + shared_preferences: + dependency: "direct main" + description: + name: shared_preferences + url: "https://pub.dartlang.org" + source: hosted + version: "0.5.3+4" sky_engine: dependency: transitive description: flutter diff --git a/pubspec.yaml b/pubspec.yaml index fded95b9e52d65650a6a7fdd6ae8dcef527845bf..34c820bf9eaad106bffbac3f75627471a6ef1920 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -26,9 +26,9 @@ dependencies: # Use git: git@github.com:markin-io/flutter_web_browser.git uni_links: 0.2.0 - http: ^0.12.0 flutter_app_auth_wrapper: ^0.1.1+3 url_launcher: 5.1.0 + shared_preferences: 0.5.3+4 dev_dependencies: flutter_test: