Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
medapp_eksad
Project
Project
Details
Activity
Releases
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
qorri_di
medapp_eksad
Commits
04723573
Commit
04723573
authored
Sep 21, 2022
by
Budi Prasetyo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
push
parent
56fc8238
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
164 additions
and
13 deletions
+164
-13
sosmed_api.dart
lib/api/sosmed_api.dart
+55
-0
admin_sosmed.dart
lib/dashboard/admin/admin_sosmed.dart
+109
-13
No files found.
lib/api/sosmed_api.dart
0 → 100644
View file @
04723573
import
'dart:convert'
;
import
'package:http/http.dart'
as
http
;
var
cmd
=
'https://dmsdev-api.eksad.com/gateway/medapp/v1/cmd'
;
var
qry
=
'https://dmsdev-api.eksad.com/gateway/medapp/v1/qry'
;
Future
<
bool
>
createSosmed
(
wa
,
ln
,
tw
,
ig
,
yt
)
async
{
final
response
=
await
http
.
post
(
Uri
.
parse
(
'
$cmd
/settingsosmed/saveSettingSosmed'
),
body:
jsonEncode
(
{
"whatsapp"
:
wa
,
"linkedin"
:
ln
,
"twitter"
:
tw
,
"instagram"
:
ig
,
"youtube"
:
yt
}),
headers:
{
'Content-type'
:
'application/json; charset=UTF-8'
,
});
if
(
response
.
statusCode
==
200
)
{
return
true
;
}
else
{
return
false
;
}
}
Future
<
bool
>
updateSosmed
(
wa
,
ln
,
tw
,
ig
,
yt
)
async
{
final
response
=
await
http
.
put
(
Uri
.
parse
(
'
$cmd
/settingsosmed/updateSettingSosmed'
),
body:
jsonEncode
({
'whatsapp'
:
wa
,
'linkedin'
:
ln
,
'twitter'
:
tw
,
'instagram'
:
ig
,
'youtube'
:
yt
}),
headers:
{
'Content-type'
:
'application/json; charset=UTF-8'
,
});
if
(
response
.
statusCode
==
200
)
{
return
true
;
}
else
{
return
false
;
}
}
Future
<
List
<
dynamic
>>
getSosmedDesc
()
async
{
var
response
=
await
http
.
get
(
Uri
.
parse
(
'
$qry
/settingsosmed/getSettingSosmedById'
));
// Uri.parse('$qry/settingsosmed/getSettingSosmedByIdDesc'));
return
jsonDecode
(
response
.
body
)[
'data'
];
}
\ No newline at end of file
lib/dashboard/admin/admin_sosmed.dart
View file @
04723573
import
'package:flutter/material.dart'
;
import
'package:font_awesome_flutter/font_awesome_flutter.dart'
;
import
'package:google_fonts/google_fonts.dart'
;
import
'package:medapp_eksad/api/sosmed_api.dart'
;
class
SosmedDashboard
extends
StatefulWidget
{
const
SosmedDashboard
({
Key
?
key
})
:
super
(
key:
key
);
...
...
@@ -13,12 +14,20 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
var
btnText
=
'Save Setting'
;
var
enb
=
true
;
final
formKey
=
GlobalKey
<
FormState
>();
final
waController
=
TextEditingController
();
TextEditingController
waController
=
new
TextEditingController
();
// final waController = TextEditingController();
final
linkedController
=
TextEditingController
();
final
twitterController
=
TextEditingController
();
final
igController
=
TextEditingController
();
final
youtubeController
=
TextEditingController
();
String
wa
=
''
;
String
ln
=
''
;
String
tw
=
''
;
String
ig
=
''
;
String
yt
=
''
;
@override
Widget
build
(
BuildContext
context
)
{
var
screenSize
=
MediaQuery
.
of
(
context
).
size
;
...
...
@@ -34,6 +43,7 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
const
EdgeInsets
.
only
(
left:
30
,
top:
15
,
right:
30
,
bottom:
15
),
color:
Colors
.
white
,
child:
Form
(
key:
formKey
,
child:
Column
(
children:
[
Row
(
...
...
@@ -45,10 +55,6 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
fontSize:
25
,
fontWeight:
FontWeight
.
w600
,
letterSpacing:
1.1
)),
// SizedBox(
// height: 0,
// width: 820,
// ),
ElevatedButton
(
style:
ElevatedButton
.
styleFrom
(
shape:
RoundedRectangleBorder
(
...
...
@@ -59,22 +65,47 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
onPressed:
()
{
switch
(
btnText
)
{
case
'Save Setting'
:
// createSetting(im.toString(), tt.toString(),
// tl.toString(), em.toString(), no.toString());
createSosmed
(
wa
,
ln
,
tw
,
ig
,
yt
);
{
ScaffoldMessenger
.
of
(
context
).
showSnackBar
(
SnackBar
(
content:
Text
(
'Save Data Success'
),));
}
// waController.clear();
// linkedController.clear();
// twitterController.clear();
// igController.clear();
// youtubeController.clear();
// createSetting(im.toString(), tt.toString(),
// tl.toString(), em.toString(), no.toString());
setState
(()
{
btnText
=
'Update Setting'
;
enb
=
false
;
});
}
);
break
;
case
'Update Setting'
:
// waController.clear();
// linkedController.clear();
// twitterController.clear();
// igController.clear();
// youtubeController.clear();
setState
(()
{
enb
=
true
;
btnText
=
'Save Update'
;
});
break
;
case
'Save Update'
:
createSosmed
(
wa
,
ln
,
tw
,
ig
,
yt
);
{
ScaffoldMessenger
.
of
(
context
).
showSnackBar
(
SnackBar
(
content:
Text
(
'Save Data Success'
),));
}
break
;
default
:
createSosmed
(
wa
,
ln
,
tw
,
ig
,
yt
);
{
ScaffoldMessenger
.
of
(
context
).
showSnackBar
(
SnackBar
(
content:
Text
(
'Save Data Success'
),));
}
}
},
child:
Text
(
...
...
@@ -108,6 +139,8 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
decoration:
InputDecoration
(
hintText:
'Enter WhatsApp number without +, Ex : 6280000000000 '
),
onChanged:
(
value
)
=>
wa
=
value
,
enabled:
enb
,
),
ElevatedButton
(
onPressed:
()
{
...
...
@@ -115,7 +148,18 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
context:
context
,
builder:
(
BuildContext
context
)=>
AlertDialog
(
content:
Text
(
'Nomer'
),
content:
FutureBuilder
<
List
<
dynamic
>>(
future:
getSosmedDesc
(),
builder:
(
BuildContext
context
,
AsyncSnapshot
snapshot
)
{
var
pgm
=
snapshot
.
data
[
0
];
if
(
snapshot
.
hasError
||
snapshot
.
data
==
null
||
snapshot
.
connectionState
==
ConnectionState
.
waiting
)
{
return
const
CircularProgressIndicator
();
}
return
Text
(
'Active WA : '
+
pgm
[
'whatsapp'
]);
},
),
)
,
);
},
child:
Text
(
'View Active'
))),
...
...
@@ -131,6 +175,8 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
controller:
linkedController
,
decoration:
InputDecoration
(
hintText:
'Enter a new Linkedin link address'
),
onChanged:
(
value
)
=>
ln
=
value
,
enabled:
enb
,
),
ElevatedButton
(
onPressed:
()
{
...
...
@@ -138,7 +184,18 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
context:
context
,
builder:
(
BuildContext
context
)=>
AlertDialog
(
content:
Text
(
'Linkedin'
),
content:
FutureBuilder
<
List
<
dynamic
>>(
future:
getSosmedDesc
(),
builder:
(
BuildContext
context
,
AsyncSnapshot
snapshot
)
{
var
pgm
=
snapshot
.
data
[
0
];
if
(
snapshot
.
hasError
||
snapshot
.
data
==
null
||
snapshot
.
connectionState
==
ConnectionState
.
waiting
)
{
return
const
CircularProgressIndicator
();
}
return
Text
(
'Active Linkedin : '
+
pgm
[
'linkedin'
]);
},
),
)
,
);
},
child:
Text
(
'View Active'
))),
...
...
@@ -154,6 +211,8 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
controller:
twitterController
,
decoration:
InputDecoration
(
hintText:
'Enter a new Twitter link address'
),
onChanged:
(
value
)
=>
tw
=
value
,
enabled:
enb
,
),
ElevatedButton
(
onPressed:
()
{
...
...
@@ -161,7 +220,18 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
context:
context
,
builder:
(
BuildContext
context
)=>
AlertDialog
(
content:
Text
(
'Twitter'
),
content:
FutureBuilder
<
List
<
dynamic
>>(
future:
getSosmedDesc
(),
builder:
(
BuildContext
context
,
AsyncSnapshot
snapshot
)
{
var
pgm
=
snapshot
.
data
[
0
];
if
(
snapshot
.
hasError
||
snapshot
.
data
==
null
||
snapshot
.
connectionState
==
ConnectionState
.
waiting
)
{
return
const
CircularProgressIndicator
();
}
return
Text
(
'Active Twitter : '
+
pgm
[
'twitter'
]);
},
),
)
,
);
},
child:
Text
(
'View Active'
))),
...
...
@@ -177,6 +247,8 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
controller:
igController
,
decoration:
InputDecoration
(
hintText:
'Enter a new Instagram link address'
),
onChanged:
(
value
)
=>
ig
=
value
,
enabled:
enb
,
),
ElevatedButton
(
onPressed:
()
{
...
...
@@ -184,7 +256,18 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
context:
context
,
builder:
(
BuildContext
context
)=>
AlertDialog
(
content:
Text
(
'Instagram'
),
content:
FutureBuilder
<
List
<
dynamic
>>(
future:
getSosmedDesc
(),
builder:
(
BuildContext
context
,
AsyncSnapshot
snapshot
)
{
var
pgm
=
snapshot
.
data
[
0
];
if
(
snapshot
.
hasError
||
snapshot
.
data
==
null
||
snapshot
.
connectionState
==
ConnectionState
.
waiting
)
{
return
const
CircularProgressIndicator
();
}
return
Text
(
'Active Instagram : '
+
pgm
[
'instagram'
]);
},
),
)
,
);
},
child:
Text
(
'View Active'
))),
...
...
@@ -200,6 +283,8 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
controller:
youtubeController
,
decoration:
InputDecoration
(
hintText:
'Enter a new Youtube link address'
),
onChanged:
(
value
)
=>
yt
=
value
,
enabled:
enb
,
),
ElevatedButton
(
onPressed:
()
{
...
...
@@ -207,7 +292,18 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
context:
context
,
builder:
(
BuildContext
context
)=>
AlertDialog
(
content:
Text
(
'Youtube'
),
content:
FutureBuilder
<
List
<
dynamic
>>(
future:
getSosmedDesc
(),
builder:
(
BuildContext
context
,
AsyncSnapshot
snapshot
)
{
var
pgm
=
snapshot
.
data
[
0
];
if
(
snapshot
.
hasError
||
snapshot
.
data
==
null
||
snapshot
.
connectionState
==
ConnectionState
.
waiting
)
{
return
const
CircularProgressIndicator
();
}
return
Text
(
'Active Youtube : '
+
pgm
[
'youtube'
]);
},
),
)
,
);
},
child:
Text
(
'View Active'
))),
...
...
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