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
3de480a8
Commit
3de480a8
authored
Jun 28, 2023
by
Dio Maulana
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
config dalam file json
parent
0cf77a68
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
5 deletions
+33
-5
config.json
assets/config.json
+7
-0
api.dart
lib/api/api.dart
+7
-0
main.dart
lib/main.dart
+19
-5
No files found.
assets/config.json
0 → 100644
View file @
3de480a8
{
"base_url"
:
"https://hibiscus-dev.ravku.com/"
,
"end_point"
:
"rav/attendance/"
,
"brand"
:
"EXC"
,
"title"
:
"Excelso Attendance"
,
"debug"
:
true
}
\ No newline at end of file
lib/api/api.dart
View file @
3de480a8
...
...
@@ -10,6 +10,7 @@ import 'package:excelso_attendance/models/shift.dart';
import
'package:excelso_attendance/resource/constanta_string.dart'
;
import
'package:excelso_attendance/resource/strings.dart'
;
import
'package:geolocator/geolocator.dart'
;
import
'package:get_ip_address/get_ip_address.dart'
;
import
'package:http/http.dart'
as
http
;
class
Api
{
...
...
@@ -147,6 +148,8 @@ class Api {
String
branchId
,
String
nik
,
String
shiftId
,
String
photoBase64
)
async
{
String
apiUrl
=
"
$baseUrl${endPoint}
clock_in"
;
Position
position
=
await
Geolocator
.
getCurrentPosition
();
IpAddress
ipAddress
=
IpAddress
(
type:
RequestType
.
json
);
dynamic
dataIp
=
await
ipAddress
.
getIpAddress
();
try
{
Map
<
String
,
dynamic
>
data
=
{
"branch_id"
:
branchId
,
...
...
@@ -156,6 +159,7 @@ class Api {
"user_lat"
:
position
.
latitude
,
"user_long"
:
position
.
longitude
,
"photo_base64"
:
"data:image/jpeg;base64,
$photoBase64
"
,
"ip"
:
dataIp
[
'ip'
]
};
String
bodies
=
jsonEncode
(
data
);
dynamic
jsonObject
=
...
...
@@ -201,6 +205,8 @@ class Api {
String
apiUrl
=
"
$baseUrl${endPoint}
clock_out"
;
Position
position
=
await
Geolocator
.
getCurrentPosition
();
IpAddress
ipAddress
=
IpAddress
(
type:
RequestType
.
json
);
dynamic
dataIp
=
await
ipAddress
.
getIpAddress
();
try
{
Map
<
String
,
dynamic
>
data
=
{
"branch_id"
:
branchId
,
...
...
@@ -209,6 +215,7 @@ class Api {
"user_lat"
:
position
.
latitude
,
"user_long"
:
position
.
longitude
,
"photo_base64"
:
photoBase64
,
"ip"
:
dataIp
[
'ip'
],
};
String
bodies
=
jsonEncode
(
data
);
dynamic
jsonObject
=
...
...
lib/main.dart
View file @
3de480a8
import
'dart:convert'
;
import
'package:excelso_attendance/resource/routes.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_easyloading/flutter_easyloading.dart'
;
import
'package:shared_preferences/shared_preferences.dart'
;
import
'package:url_strategy/url_strategy.dart'
;
import
'package:flutter/services.dart'
as
bundle_root
;
// all config here
bool
debug
=
true
;
late
bool
debug
;
late
SharedPreferences
prefs
;
String
titleApp
=
'Excelso Attendance'
;
late
String
titleApp
;
String
brandCode
=
"EXC"
;
late
String
brandCode
;
String
baseUrl
=
"https://hibiscus-dev.ravku.com/"
;
String
endPoint
=
"rav/attendance/"
;
late
String
baseUrl
;
late
String
endPoint
;
// final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
...
...
@@ -21,6 +24,7 @@ void main() async {
setPathUrlStrategy
();
configLoading
();
await
loadConfigFile
();
SharedPreferences
.
getInstance
().
then
((
value
)
{
prefs
=
value
;
runApp
(
const
MyApp
());
...
...
@@ -44,6 +48,16 @@ void configLoading() {
..
dismissOnTap
=
false
;
}
Future
<
void
>
loadConfigFile
()
async
{
String
datas
=
await
bundle_root
.
rootBundle
.
loadString
(
'config.json'
);
var
decodeJson
=
jsonDecode
(
datas
);
titleApp
=
decodeJson
[
'title'
].
toString
();
brandCode
=
decodeJson
[
'brand'
].
toString
();
baseUrl
=
decodeJson
[
'base_url'
].
toString
();
endPoint
=
decodeJson
[
'end_point'
].
toString
();
debug
=
decodeJson
[
'debug'
];
}
class
MyApp
extends
StatelessWidget
{
const
MyApp
({
super
.
key
});
...
...
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