Skip to content
Snippets Groups Projects
Commit 33957099 authored by igorwork's avatar igorwork Committed by Markin Igor
Browse files

Implement app modes and linkage

parent e08ed614
No related branches found
No related tags found
1 merge request!1Mobile app initial implementation.
......@@ -28,6 +28,15 @@
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="vereign"
android:host="app.vereign.com" />
</intent-filter>
</activity>
</application>
</manifest>
flutter_web_browser @ 4a4ca607
Subproject commit ff8f72e84690d36c0e2dd95e3463a30bf8a1e4cd
Subproject commit 4a4ca60794496b2dbf5bf7eb1f345038619b7855
......@@ -2,20 +2,26 @@ PODS:
- Flutter (1.0.0)
- flutter_web_browser (0.11.0):
- Flutter
- uni_links (0.0.1):
- Flutter
DEPENDENCIES:
- Flutter (from `.symlinks/flutter/ios`)
- flutter_web_browser (from `.symlinks/plugins/flutter_web_browser/ios`)
- uni_links (from `.symlinks/plugins/uni_links/ios`)
EXTERNAL SOURCES:
Flutter:
:path: ".symlinks/flutter/ios"
flutter_web_browser:
:path: ".symlinks/plugins/flutter_web_browser/ios"
uni_links:
:path: ".symlinks/plugins/uni_links/ios"
SPEC CHECKSUMS:
Flutter: 58dd7d1b27887414a370fcccb9e645c08ffd7a6a
flutter_web_browser: bdea232160dec44dec86540bee05168cc844ef7c
uni_links: d97da20c7701486ba192624d99bffaaffcfc298a
PODFILE CHECKSUM: 7fb83752f59ead6285236625b82473f90b1cb932
......
// app.dart
import 'package:flutter/material.dart';
import 'screens/home.dart';
class App extends StatelessWidget {
import 'package:flutter/services.dart';
import 'dart:async';
import 'dart:developer';
import 'package:uni_links/uni_links.dart';
import 'package:flutter_web_browser/flutter_web_browser.dart';
class App extends StatefulWidget {
@override
_AppState createState() => _AppState();
}
class _AppState extends State<App> {
StreamSubscription _sub;
String _appMode = "oauth";
@override
initState() {
super.initState();
initUniLinks();
}
@override
dispose() {
if (_sub != null) _sub.cancel();
super.dispose();
}
Future<Null> initUniLinks() async {
Uri initialUri;
try {
initialUri = await getInitialUri();
} on PlatformException {
initialUri = null;
} on FormatException {
initialUri = null;
}
updateAppMode(initialUri);
_sub = getUriLinksStream().listen((Uri uri) {
updateAppMode(uri);
}, onError: (err) {
log('got err: $err');
});
}
updateAppMode(uri) {
if (uri?.path == "/oauth2") {
setState(() {
_appMode = "oauth";
});
} else {
setState(() {
_appMode = "app";
});
}
}
@override
Widget build(BuildContext context) {
return MaterialApp(
......@@ -12,7 +73,12 @@ class App extends StatelessWidget {
textTheme: TextTheme(
button: TextStyle(color: Colors.white, fontSize: 18.0),
title: TextStyle(color: Colors.red))),
home: Home(),
home: new Scaffold(
appBar: new AppBar(),
body: Home(
mode: _appMode
)
),
);
}
}
\ No newline at end of file
import 'package:flutter/material.dart';
import 'package:flutter_web_browser/flutter_web_browser.dart';
import 'dart:developer';
class Home extends StatefulWidget {
Home({@required this.mode});
final String mode;
@override
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> {
final _links = ['vereign://app.vereign.com', 'vereign://app.vereign.com/oauth2', 'https://rosengeorgiev.dev.vereign.com', 'https://igormarkin.dev.vereign.com', 'https://gospodinbodurov.dev.vereign.com'];
@override
initState() {
super.initState();
showMode(widget.mode);
}
@override
void didUpdateWidget(Home oldWidget) {
// this method IS called when parent widget passes new "props"
// unlike React, this method IS called _before_ the build
// unlike React, this method ISN'T called after setState()
if (widget.mode != oldWidget.mode) {
showMode(widget.mode);
}
super.didUpdateWidget(oldWidget);
}
showMode(mode) {
if (mode == "app") {
FlutterWebBrowser.openWebPage(url: 'https://app.vereign.com', androidToolbarColor: Colors.deepPurple);
} else if (mode == "oauth") {
FlutterWebBrowser.openWebPage(url: 'https://app.vereign.com/oauth2', androidToolbarColor: Colors.deepPurple);
}
}
class Home extends StatelessWidget {
final _links = ['https://app.vereign.com', 'https://integration.vereign.com', 'https://rosengeorgiev.dev.vereign.com', 'https://igormarkin.dev.vereign.com', 'https://gospodinbodurov.dev.vereign.com'];
@override
Widget build(BuildContext context) {
return Scaffold(
......
......@@ -142,6 +142,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
uni_links:
dependency: "direct main"
description:
name: uni_links
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0"
vector_math:
dependency: transitive
description:
......
......@@ -25,6 +25,7 @@ dependencies:
flutter_web_browser:
# Use
path: ./deps/flutter_web_browser
uni_links: 0.2.0
dev_dependencies:
flutter_test:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment