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

Persist chosen host.

parent 32ee7b12
Branches
Tags
1 merge request!1Mobile app initial implementation.
......@@ -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
......
......@@ -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
)
);
}
......
......@@ -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) {
......
......@@ -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
......
......@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment