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

Hide buttons more.

parent 08a8d51f
No related branches found
No related tags found
1 merge request!2Resolve "Rework auth flow."
...@@ -85,6 +85,8 @@ class _MainAppState extends State<MainApp> { ...@@ -85,6 +85,8 @@ class _MainAppState extends State<MainApp> {
Screen _currentScreen = Screen.App; Screen _currentScreen = Screen.App;
bool _buttonsHidden = true;
@override @override
initState() { initState() {
super.initState(); super.initState();
...@@ -101,13 +103,13 @@ class _MainAppState extends State<MainApp> { ...@@ -101,13 +103,13 @@ class _MainAppState extends State<MainApp> {
var token = json.decode(data.toString())["access_token"]; var token = json.decode(data.toString())["access_token"];
setScreen(Screen.App); setScreen(Screen.App);
log("Open $_invokerURL");
try { try {
await launch("$_invokerURL?token=$token&host=$_host"); await launch("$_invokerURL?token=$token&host=$_host");
} catch (e) { } catch (e) {
log("Error launching url $_invokerURL"); showErrorAlert(context, 'Unable to open URL $_invokerURL', openVereign);
} }
revealButtons(1);
}, onError: (error) { }, onError: (error) {
log("Err $error"); log("Err $error");
...@@ -121,20 +123,28 @@ class _MainAppState extends State<MainApp> { ...@@ -121,20 +123,28 @@ class _MainAppState extends State<MainApp> {
errorMessage.toLowerCase().contains("the operation couldn") errorMessage.toLowerCase().contains("the operation couldn")
) { ) {
if (Platform.isAndroid) { if (Platform.isAndroid) {
// Show only for android, because iOS will show the same alert as // Reveal after three seconds
revealButtons(3);
// Open only for android, because iOS will show the same alert as
// was for Auth request // was for Auth request
openVereign(); openVereign();
} else { } else {
setScreen(Screen.App); setScreen(Screen.App);
revealButtons(0);
} }
} else { } else {
showErrorAlert(context, Platform.isAndroid ? errorDetails : errorMessage, openVereign); showErrorAlert(context, Platform.isAndroid ? errorDetails : errorMessage, openVereign);
setScreen(Screen.App); setScreen(Screen.App);
revealButtons(0);
} }
}); });
initUniLinks(); initUniLinks();
// Show buttons after timeout
revealButtons(3);
} }
@override @override
...@@ -153,6 +163,17 @@ class _MainAppState extends State<MainApp> { ...@@ -153,6 +163,17 @@ class _MainAppState extends State<MainApp> {
}); });
} }
revealButtons(delay) {
Timer(
Duration(seconds: delay),
() {
setState(() {
_buttonsHidden = false;
});
}
);
}
handleLinkChange(Uri uri) { handleLinkChange(Uri uri) {
if (uri?.path == "/authorize") { if (uri?.path == "/authorize") {
setState(() { setState(() {
...@@ -187,6 +208,11 @@ class _MainAppState extends State<MainApp> { ...@@ -187,6 +208,11 @@ class _MainAppState extends State<MainApp> {
return; return;
} }
// Hide buttons so they wont blink after we close or finish oauth
setState(() {
_buttonsHidden = true;
});
setScreen(Screen.OAuth); setScreen(Screen.OAuth);
var params = Config.getOAuthParams(host: _host); var params = Config.getOAuthParams(host: _host);
...@@ -225,6 +251,7 @@ class _MainAppState extends State<MainApp> { ...@@ -225,6 +251,7 @@ class _MainAppState extends State<MainApp> {
setHost: setHost, setHost: setHost,
openDashboardClick: openVereign, openDashboardClick: openVereign,
authorizeClick: startOAuth, authorizeClick: startOAuth,
buttonsHidden: _buttonsHidden
) )
); );
} }
......
...@@ -12,10 +12,12 @@ class Home extends StatefulWidget { ...@@ -12,10 +12,12 @@ class Home extends StatefulWidget {
@required this.setHost, @required this.setHost,
@required this.authorizeClick, @required this.authorizeClick,
@required this.openDashboardClick, @required this.openDashboardClick,
@required this.buttonsHidden,
}); });
final AppMode mode; final AppMode mode;
final String host; final String host;
final bool buttonsHidden;
final void Function(String) setHost; final void Function(String) setHost;
final void Function() openDashboardClick; final void Function() openDashboardClick;
final void Function() authorizeClick; final void Function() authorizeClick;
...@@ -25,25 +27,14 @@ class Home extends StatefulWidget { ...@@ -25,25 +27,14 @@ class Home extends StatefulWidget {
} }
class _HomeState extends State<Home> { class _HomeState extends State<Home> {
bool _hidden = true;
@override @override
initState() { initState() {
super.initState(); super.initState();
Timer(
Duration(seconds: 3),
() {
setState(() {
_hidden = false;
});
}
);
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (_hidden) { if (widget.buttonsHidden) {
return Scaffold(); return Scaffold();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment