Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
Mobile App
Manage
Activity
Members
Labels
Plan
Issues
3
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Code
Mobile App
Merge requests
!1
Mobile app initial implementation.
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Mobile app initial implementation.
3-android-mobile-app-web-view
into
master
Overview
0
Commits
37
Pipelines
0
Changes
86
Merged
Igor Markin
requested to merge
3-android-mobile-app-web-view
into
master
5 years ago
Overview
0
Commits
37
Pipelines
0
Changes
3
Expand
Closes
#3 (closed)
0
0
Merge request reports
Viewing commit
e76f24da
Prev
Next
Show latest version
3 files
+
52
−
23
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
e76f24da
Add Splash screen.
· e76f24da
Markin Igor
authored
5 years ago
lib/src/app.dart
0 → 100644
+
120
−
0
Options
// app.dart
import
'screens/splashscreen.dart'
;
import
'package:flutter/material.dart'
;
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'
;
class
App
extends
StatelessWidget
{
Future
<
Widget
>
initApplication
()
async
{
Uri
initialUri
;
try
{
initialUri
=
await
getInitialUri
();
}
on
PlatformException
{
initialUri
=
null
;
}
on
FormatException
{
initialUri
=
null
;
}
final
prefs
=
await
SharedPreferences
.
getInstance
();
final
host
=
prefs
.
getString
(
'host'
);
return
new
MainApp
(
initialUri:
initialUri
,
initialHost:
host
);
}
@override
Widget
build
(
BuildContext
context
)
{
return
MaterialApp
(
title:
'Vereign'
,
theme:
ThemeData
(
primaryColor:
Color
(
0xFFd51d32
),
fontFamily:
"Arial"
,
textTheme:
TextTheme
(
button:
TextStyle
(
color:
Colors
.
white
,
fontSize:
18.0
),
title:
TextStyle
(
color:
Colors
.
red
))),
home:
new
SplashScreen
(
navigateAfterFuture:
initApplication
,
)
);
}
}
class
MainApp
extends
StatefulWidget
{
MainApp
({
@required
this
.
initialUri
,
this
.
initialHost
});
final
Uri
initialUri
;
final
String
initialHost
;
@override
_MainAppState
createState
()
=
>
_MainAppState
();
}
class
_MainAppState
extends
State
<
MainApp
>
{
StreamSubscription
_sub
;
String
_appMode
=
""
;
// Url of the app which invoked OAuth
String
_invokerURL
;
String
_host
;
@override
initState
()
{
super
.
initState
();
initUniLinks
();
}
@override
dispose
()
{
if
(
_sub
!=
null
)
_sub
.
cancel
();
super
.
dispose
();
}
Future
<
Null
>
initUniLinks
()
async
{
updateAppMode
(
widget
.
initialUri
);
_sub
=
getUriLinksStream
()
.
listen
((
Uri
uri
)
{
updateAppMode
(
uri
);
},
onError:
(
err
)
{
log
(
'got err:
$err
'
);
});
}
updateAppMode
(
Uri
uri
)
{
if
(
uri
?.
path
==
"/authorize"
)
{
setState
(()
{
_appMode
=
"oauth"
;
_invokerURL
=
uri
.
queryParameters
[
"invokerUrl"
];
});
}
else
{
setState
(()
{
_appMode
=
"app"
;
});
}
}
setMode
(
String
mode
)
{
setState
(()
{
_appMode
=
mode
;
});
}
@override
Widget
build
(
BuildContext
context
)
{
return
new
Scaffold
(
appBar:
new
AppBar
(
title:
Text
(
"Vereign"
)),
body:
Home
(
mode:
_appMode
,
invokerURL:
_invokerURL
,
setMode:
setMode
,
host:
widget
.
initialHost
)
);
}
}
\ No newline at end of file
Loading