Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
Crm Attendance
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dio Maulana
Crm Attendance
Commits
b1f93059
Commit
b1f93059
authored
Jun 05, 2023
by
Dio Maulana
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed onboarding load
parent
9cb9c600
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
23 deletions
+64
-23
pref.dart
lib/helper/pref.dart
+4
-2
onboarding.dart
lib/page/onboarding/onboarding.dart
+59
-20
strings.dart
lib/resource/strings.dart
+1
-1
No files found.
lib/helper/pref.dart
View file @
b1f93059
...
@@ -7,14 +7,16 @@ String? getLatitude() {
...
@@ -7,14 +7,16 @@ String? getLatitude() {
return
prefs
.
getString
(
_latitude
);
return
prefs
.
getString
(
_latitude
);
}
}
Future
<
void
>
setLatitude
(
String
value
)
async
{
Future
<
String
>
setLatitude
(
String
value
)
async
{
prefs
.
setString
(
_latitude
,
value
);
prefs
.
setString
(
_latitude
,
value
);
return
value
;
}
}
String
?
getLongitude
()
{
String
?
getLongitude
()
{
return
prefs
.
getString
(
_longitude
);
return
prefs
.
getString
(
_longitude
);
}
}
Future
<
void
>
setLongitude
(
String
value
)
async
{
Future
<
String
>
setLongitude
(
String
value
)
async
{
prefs
.
setString
(
_longitude
,
value
);
prefs
.
setString
(
_longitude
,
value
);
return
value
;
}
}
lib/page/onboarding/onboarding.dart
View file @
b1f93059
...
@@ -36,15 +36,7 @@ class _OnBoardingViewState extends State<OnBoardingView> {
...
@@ -36,15 +36,7 @@ class _OnBoardingViewState extends State<OnBoardingView> {
super
.
initState
();
super
.
initState
();
getUserPermission
().
then
((
value
)
{
getUserPermission
().
then
((
value
)
{
if
(
value
)
{
if
(
value
)
{
getNearestBranch
().
then
((
branchBool
)
{
getUserLocationAndNearestBranch
();
if
(
branchBool
)
{
// ambil list shift kalau ada outlet
getShiftList
();
}
else
{
// setstate aja, gausah ambil list shift karena gak ada utlet
setState
(()
{});
}
});
}
}
});
});
...
@@ -94,14 +86,27 @@ class _OnBoardingViewState extends State<OnBoardingView> {
...
@@ -94,14 +86,27 @@ class _OnBoardingViewState extends State<OnBoardingView> {
});
});
}
}
Future
<
void
>
getUserLocationAndNearestBranch
()
async
{
Position
position
=
await
Geolocator
.
getCurrentPosition
();
setLatitude
(
position
.
latitude
.
toString
()).
then
((
value
)
{
setLongitude
(
position
.
longitude
.
toString
()).
then
((
value
)
{
getNearestBranch
().
then
((
branchBool
)
{
if
(
branchBool
)
{
// ambil list shift kalau ada outlet
getShiftList
();
}
else
{
// setstate aja, gausah ambil list shift karena gak ada utlet
setState
(()
{});
}
});
});
});
}
Future
<
bool
>
getUserPermission
()
async
{
Future
<
bool
>
getUserPermission
()
async
{
LocationPermission
permission
=
await
Geolocator
.
requestPermission
();
LocationPermission
permission
=
await
Geolocator
.
requestPermission
();
if
(
permission
==
LocationPermission
.
always
||
if
(
permission
==
LocationPermission
.
always
||
permission
==
LocationPermission
.
whileInUse
)
{
permission
==
LocationPermission
.
whileInUse
)
{
Geolocator
.
getCurrentPosition
().
then
((
position
)
{
setLatitude
(
position
.
latitude
.
toString
());
setLongitude
(
position
.
longitude
.
toString
());
});
return
true
;
return
true
;
}
else
{
}
else
{
// ignore: use_build_context_synchronously
// ignore: use_build_context_synchronously
...
@@ -268,13 +273,47 @@ dengan sekali klik''',
...
@@ -268,13 +273,47 @@ dengan sekali klik''',
),
),
),
),
)
)
:
Text
(
:
Column
(
errorMessage
!,
children:
[
style:
getSemiBoldStyle
(
Text
(
color:
Colors
.
black
,
errorMessage
!,
fontSize:
16
,
style:
getSemiBoldStyle
(
),
color:
Colors
.
black
,
textAlign:
TextAlign
.
center
,
fontSize:
16
,
),
textAlign:
TextAlign
.
center
,
),
(
errorMessage
==
Strings
.
cantConnectToServer
)
?
GestureDetector
(
onTap:
()
{
Navigator
.
pushNamedAndRemoveUntil
(
context
,
Routes
.
onBoarding
,
(
route
)
=>
false
,
);
},
child:
Container
(
width:
60
,
height:
60
,
margin:
EdgeInsets
.
only
(
top:
AppMargin
.
m10
,
),
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
100
),
color:
ColorManager
.
primary
,
),
child:
const
Center
(
child:
Icon
(
Icons
.
refresh_rounded
,
color:
Colors
.
white
,
size:
23
,
),
),
),
)
:
const
SizedBox
(),
],
)
)
:
CircularProgressIndicator
(
:
CircularProgressIndicator
(
color:
ColorManager
.
primary
,
color:
ColorManager
.
primary
,
...
...
lib/resource/strings.dart
View file @
b1f93059
...
@@ -7,7 +7,7 @@ class Strings {
...
@@ -7,7 +7,7 @@ class Strings {
"Tidak ada outlet yang ditemukan dalam radius 10Km"
;
"Tidak ada outlet yang ditemukan dalam radius 10Km"
;
static
String
errorGetShiftList
=
static
String
errorGetShiftList
=
"Tidak dapat terhubung ke server, shift tidak ditemukan"
;
"Tidak dapat terhubung ke server, shift tidak ditemukan"
;
static
String
cantConnectToServer
=
"Can't connect to server"
;
static
String
cantConnectToServer
=
"Can't connect to server
, refresh page
"
;
static
String
serverError
=
"Something wrong with our server, refresh page"
;
static
String
serverError
=
"Something wrong with our server, refresh page"
;
static
String
succesGetData
=
"Success get data"
;
static
String
succesGetData
=
"Success get data"
;
static
String
pleaseWait
=
"Please wait..."
;
static
String
pleaseWait
=
"Please wait..."
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment