Skip to content
Snippets Groups Projects
Commit 8212bc25 authored by Markin Igor's avatar Markin Igor
Browse files

Persist chosen host.

parent 32ee7b12
Branches
No related tags found
1 merge request!1Mobile app initial implementation.
...@@ -10,6 +10,8 @@ PODS: ...@@ -10,6 +10,8 @@ PODS:
- Flutter - Flutter
- flutter_web_browser (0.11.0): - flutter_web_browser (0.11.0):
- Flutter - Flutter
- shared_preferences (0.0.1):
- Flutter
- uni_links (0.0.1): - uni_links (0.0.1):
- Flutter - Flutter
- url_launcher (0.0.1): - url_launcher (0.0.1):
...@@ -19,6 +21,7 @@ DEPENDENCIES: ...@@ -19,6 +21,7 @@ DEPENDENCIES:
- Flutter (from `.symlinks/flutter/ios`) - Flutter (from `.symlinks/flutter/ios`)
- flutter_app_auth_wrapper (from `.symlinks/plugins/flutter_app_auth_wrapper/ios`) - flutter_app_auth_wrapper (from `.symlinks/plugins/flutter_app_auth_wrapper/ios`)
- flutter_web_browser (from `.symlinks/plugins/flutter_web_browser/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`) - uni_links (from `.symlinks/plugins/uni_links/ios`)
- url_launcher (from `.symlinks/plugins/url_launcher/ios`) - url_launcher (from `.symlinks/plugins/url_launcher/ios`)
...@@ -33,6 +36,8 @@ EXTERNAL SOURCES: ...@@ -33,6 +36,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/flutter_app_auth_wrapper/ios" :path: ".symlinks/plugins/flutter_app_auth_wrapper/ios"
flutter_web_browser: flutter_web_browser:
:path: ".symlinks/plugins/flutter_web_browser/ios" :path: ".symlinks/plugins/flutter_web_browser/ios"
shared_preferences:
:path: ".symlinks/plugins/shared_preferences/ios"
uni_links: uni_links:
:path: ".symlinks/plugins/uni_links/ios" :path: ".symlinks/plugins/uni_links/ios"
url_launcher: url_launcher:
...@@ -43,6 +48,7 @@ SPEC CHECKSUMS: ...@@ -43,6 +48,7 @@ SPEC CHECKSUMS:
Flutter: 58dd7d1b27887414a370fcccb9e645c08ffd7a6a Flutter: 58dd7d1b27887414a370fcccb9e645c08ffd7a6a
flutter_app_auth_wrapper: e194830013782a9a914171728299f8f5b285b4ba flutter_app_auth_wrapper: e194830013782a9a914171728299f8f5b285b4ba
flutter_web_browser: bdea232160dec44dec86540bee05168cc844ef7c flutter_web_browser: bdea232160dec44dec86540bee05168cc844ef7c
shared_preferences: 1feebfa37bb57264736e16865e7ffae7fc99b523
uni_links: d97da20c7701486ba192624d99bffaaffcfc298a uni_links: d97da20c7701486ba192624d99bffaaffcfc298a
url_launcher: 0067ddb8f10d36786672aa0722a21717dba3a298 url_launcher: 0067ddb8f10d36786672aa0722a21717dba3a298
......
...@@ -5,6 +5,7 @@ import 'screens/home.dart'; ...@@ -5,6 +5,7 @@ import 'screens/home.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'dart:async'; import 'dart:async';
import 'dart:developer'; import 'dart:developer';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:uni_links/uni_links.dart'; import 'package:uni_links/uni_links.dart';
...@@ -20,7 +21,10 @@ class App extends StatelessWidget { ...@@ -20,7 +21,10 @@ class App extends StatelessWidget {
initialUri = null; 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 @override
...@@ -43,8 +47,9 @@ class App extends StatelessWidget { ...@@ -43,8 +47,9 @@ class App extends StatelessWidget {
} }
class MainApp extends StatefulWidget { class MainApp extends StatefulWidget {
MainApp({ @required this.initialUri }); MainApp({ @required this.initialUri, this.initialHost });
final Uri initialUri; final Uri initialUri;
final String initialHost;
@override @override
_MainAppState createState() => _MainAppState(); _MainAppState createState() => _MainAppState();
...@@ -86,7 +91,6 @@ class _MainAppState extends State<MainApp> { ...@@ -86,7 +91,6 @@ class _MainAppState extends State<MainApp> {
setState(() { setState(() {
_appMode = "oauth"; _appMode = "oauth";
_invokerURL = uri.queryParameters["invokerUrl"]; _invokerURL = uri.queryParameters["invokerUrl"];
_host = uri.queryParameters["host"];
}); });
} else { } else {
setState(() { setState(() {
...@@ -109,7 +113,7 @@ class _MainAppState extends State<MainApp> { ...@@ -109,7 +113,7 @@ class _MainAppState extends State<MainApp> {
mode: _appMode, mode: _appMode,
invokerURL: _invokerURL, invokerURL: _invokerURL,
setMode: setMode, setMode: setMode,
host: _host host: widget.initialHost
) )
); );
} }
......
...@@ -4,6 +4,7 @@ import 'package:flutter_app_auth_wrapper/flutter_app_auth_wrapper.dart'; ...@@ -4,6 +4,7 @@ import 'package:flutter_app_auth_wrapper/flutter_app_auth_wrapper.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
import 'dart:developer'; import 'dart:developer';
import 'dart:convert'; import 'dart:convert';
import 'package:shared_preferences/shared_preferences.dart';
import '../../config.dart'; import '../../config.dart';
...@@ -24,6 +25,10 @@ class _HomeState extends State<Home> { ...@@ -24,6 +25,10 @@ class _HomeState extends State<Home> {
@override @override
initState() { initState() {
super.initState(); super.initState();
setState(() {
_host = widget.host;
});
showMode(widget.mode); showMode(widget.mode);
FlutterAppAuthWrapper.eventStream().listen((data) { FlutterAppAuthWrapper.eventStream().listen((data) {
...@@ -128,10 +133,13 @@ class _HomeState extends State<Home> { ...@@ -128,10 +133,13 @@ class _HomeState extends State<Home> {
wrapInContainer( wrapInContainer(
DropdownButton<String>( DropdownButton<String>(
value: _host, value: _host,
onChanged: (String newValue) { onChanged: (String newValue) async {
setState(() { setState(() {
_host = newValue; _host = newValue;
}); });
final prefs = await SharedPreferences.getInstance();
prefs.setString("host", newValue);
}, },
items: Config.HOSTS items: Config.HOSTS
.map<DropdownMenuItem<String>>((String value) { .map<DropdownMenuItem<String>>((String value) {
......
...@@ -97,20 +97,6 @@ packages: ...@@ -97,20 +97,6 @@ packages:
url: "git@github.com:markin-io/flutter_web_browser.git" url: "git@github.com:markin-io/flutter_web_browser.git"
source: git source: git
version: "0.11.0" 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: image:
dependency: transitive dependency: transitive
description: description:
...@@ -160,6 +146,13 @@ packages: ...@@ -160,6 +146,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.3" 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: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
......
...@@ -26,9 +26,9 @@ dependencies: ...@@ -26,9 +26,9 @@ dependencies:
# Use # Use
git: git@github.com:markin-io/flutter_web_browser.git git: git@github.com:markin-io/flutter_web_browser.git
uni_links: 0.2.0 uni_links: 0.2.0
http: ^0.12.0
flutter_app_auth_wrapper: ^0.1.1+3 flutter_app_auth_wrapper: ^0.1.1+3
url_launcher: 5.1.0 url_launcher: 5.1.0
shared_preferences: 0.5.3+4
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment