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> {
Screen _currentScreen = Screen.App;
bool _buttonsHidden = true;
@override
initState() {
super.initState();
......@@ -101,13 +103,13 @@ class _MainAppState extends State<MainApp> {
var token = json.decode(data.toString())["access_token"];
setScreen(Screen.App);
log("Open $_invokerURL");
try {
await launch("$_invokerURL?token=$token&host=$_host");
} catch (e) {
log("Error launching url $_invokerURL");
showErrorAlert(context, 'Unable to open URL $_invokerURL', openVereign);
}
revealButtons(1);
}, onError: (error) {
log("Err $error");
......@@ -121,20 +123,28 @@ class _MainAppState extends State<MainApp> {
errorMessage.toLowerCase().contains("the operation couldn")
) {
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
openVereign();
} else {
setScreen(Screen.App);
revealButtons(0);
}
} else {
showErrorAlert(context, Platform.isAndroid ? errorDetails : errorMessage, openVereign);
setScreen(Screen.App);
revealButtons(0);
}
});
initUniLinks();
// Show buttons after timeout
revealButtons(3);
}
@override
......@@ -153,6 +163,17 @@ class _MainAppState extends State<MainApp> {
});
}
revealButtons(delay) {
Timer(
Duration(seconds: delay),
() {
setState(() {
_buttonsHidden = false;
});
}
);
}
handleLinkChange(Uri uri) {
if (uri?.path == "/authorize") {
setState(() {
......@@ -187,6 +208,11 @@ class _MainAppState extends State<MainApp> {
return;
}
// Hide buttons so they wont blink after we close or finish oauth
setState(() {
_buttonsHidden = true;
});
setScreen(Screen.OAuth);
var params = Config.getOAuthParams(host: _host);
......@@ -225,6 +251,7 @@ class _MainAppState extends State<MainApp> {
setHost: setHost,
openDashboardClick: openVereign,
authorizeClick: startOAuth,
buttonsHidden: _buttonsHidden
)
);
}
......
......@@ -12,10 +12,12 @@ class Home extends StatefulWidget {
@required this.setHost,
@required this.authorizeClick,
@required this.openDashboardClick,
@required this.buttonsHidden,
});
final AppMode mode;
final String host;
final bool buttonsHidden;
final void Function(String) setHost;
final void Function() openDashboardClick;
final void Function() authorizeClick;
......@@ -25,25 +27,14 @@ class Home extends StatefulWidget {
}
class _HomeState extends State<Home> {
bool _hidden = true;
@override
initState() {
super.initState();
Timer(
Duration(seconds: 3),
() {
setState(() {
_hidden = false;
});
}
);
}
@override
Widget build(BuildContext context) {
if (_hidden) {
if (widget.buttonsHidden) {
return Scaffold();
}
......
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