Commit 799c82c4 authored by Ade Fikriatul  Ilmi's avatar Ade Fikriatul Ilmi

menambahkan get public and post

parent afdcae7d
...@@ -26,10 +26,11 @@ Future<bool> createSosmed (wa, ln, tw, ig, yt) async{ ...@@ -26,10 +26,11 @@ Future<bool> createSosmed (wa, ln, tw, ig, yt) async{
} }
} }
Future<bool> updateSosmed (wa,ln,tw,ig,yt) async { Future<bool> updateSosmed (wa, ln, tw, ig, yt) async {
final response = await http final response = await http
.put(Uri.parse('$cmd/settingsosmed/updateSettingSosmed'), .put(Uri.parse('$cmd/settingsosmed/saveSettingSosmed'),
body: jsonEncode({ body: jsonEncode({
// 'idSettingSosmed': id,
'whatsapp': wa, 'whatsapp': wa,
'linkedin': ln, 'linkedin': ln,
'twitter': tw, 'twitter': tw,
......
...@@ -24,7 +24,7 @@ class _SosmedDashboardState extends State<SosmedDashboard> { ...@@ -24,7 +24,7 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
String wa = ''; String wa = '';
String ln = ''; String ln = '';
String tw = ''; String tw ='';
String ig = ''; String ig = '';
String yt = ''; String yt = '';
...@@ -34,8 +34,8 @@ class _SosmedDashboardState extends State<SosmedDashboard> { ...@@ -34,8 +34,8 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
return Container( return Container(
color: const Color.fromRGBO(238, 224, 224, 1), color: const Color.fromRGBO(238, 224, 224, 1),
padding: EdgeInsets.symmetric( padding: EdgeInsets.symmetric(
horizontal: screenSize.width * 0.15, horizontal: screenSize.width * 0.05,
vertical: screenSize.height * 0.15), vertical: screenSize.height * 0.05),
child: Container( child: Container(
width: screenSize.width, width: screenSize.width,
height: screenSize.height * 0.8, height: screenSize.height * 0.8,
...@@ -65,11 +65,10 @@ class _SosmedDashboardState extends State<SosmedDashboard> { ...@@ -65,11 +65,10 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
onPressed: () { onPressed: () {
switch (btnText) { switch (btnText) {
case 'Save Setting': case 'Save Setting':
createSosmed(wa, ln, tw, ig, yt); createSosmed(wa, ln, tw, ig, yt);
{ {
ScaffoldMessenger.of(context).showSnackBar(SnackBar( ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('Save Data Success'),));
content: Text('Save Data Success'),
));
} }
// waController.clear(); // waController.clear();
// linkedController.clear(); // linkedController.clear();
...@@ -81,7 +80,9 @@ class _SosmedDashboardState extends State<SosmedDashboard> { ...@@ -81,7 +80,9 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
setState(() { setState(() {
btnText = 'Update Setting'; btnText = 'Update Setting';
enb = false; enb = false;
}); }
);
break; break;
case 'Update Setting': case 'Update Setting':
// waController.clear(); // waController.clear();
...@@ -97,17 +98,13 @@ class _SosmedDashboardState extends State<SosmedDashboard> { ...@@ -97,17 +98,13 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
case 'Save Update': case 'Save Update':
createSosmed(wa, ln, tw, ig, yt); createSosmed(wa, ln, tw, ig, yt);
{ {
ScaffoldMessenger.of(context).showSnackBar(SnackBar( ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('Save Data Success'),));
content: Text('Save Data Success'),
));
} }
break; break;
default: default:
createSosmed(wa, ln, tw, ig, yt); createSosmed(wa, ln, tw, ig, yt);
{ {
ScaffoldMessenger.of(context).showSnackBar(SnackBar( ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('Save Data Success'),));
content: Text('Save Data Success'),
));
} }
} }
}, },
...@@ -129,22 +126,7 @@ class _SosmedDashboardState extends State<SosmedDashboard> { ...@@ -129,22 +126,7 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
SizedBox( SizedBox(
height: 25, height: 25,
), ),
FutureBuilder( Column(
future: getSosmedDesc(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
var pgm = snapshot.data[0];
final waController = TextEditingController();
final linkedController = TextEditingController();
final twitterController = TextEditingController();
final igController = TextEditingController();
final youtubeController = TextEditingController();
if (snapshot.hasError ||
snapshot.data == null ||
snapshot.connectionState == ConnectionState.waiting) {
return const CircularProgressIndicator();
}
return Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
listsosmed( listsosmed(
...@@ -153,53 +135,34 @@ class _SosmedDashboardState extends State<SosmedDashboard> { ...@@ -153,53 +135,34 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
color: Colors.green, color: Colors.green,
), ),
TextFormField( TextFormField(
// controller: waController, controller: waController,
initialValue: pgm['whatsapp'],
decoration: InputDecoration( decoration: InputDecoration(
hintText: hintText:
'Enter WhatsApp number without +, Ex : 6280000000000 '), 'Enter WhatsApp number without +, Ex : 6280000000000 '),
onChanged: (value) => wa = value, onChanged: (value) => wa = value,
enabled: enb, enabled: enb,
), ),
// ElevatedButton(
// onPressed: () {
// showDialog(
// context: context,
// builder: (BuildContext context) => AlertDialog(
// 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'),
// ),
ElevatedButton( ElevatedButton(
onPressed: () { onPressed: () {
showDialog( showDialog(
context: context, context: context,
builder: (BuildContext context) => AlertDialog( builder: (BuildContext context)=>
content: Text( AlertDialog(
'Active WA : ' + pgm['whatsapp'], 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'),
),
), ),
) ,
);
}, child: Text('View Active'))),
SizedBox( SizedBox(
height: 10, height: 10,
), ),
...@@ -209,52 +172,33 @@ class _SosmedDashboardState extends State<SosmedDashboard> { ...@@ -209,52 +172,33 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
color: Colors.blue, color: Colors.blue,
), ),
TextFormField( TextFormField(
// controller: linkedController, controller: linkedController,
initialValue: pgm['linkedin'],
decoration: InputDecoration( decoration: InputDecoration(
hintText: 'Enter a new Linkedin link address'), hintText: 'Enter a new Linkedin link address'),
onChanged: (value) => ln = value, onChanged: (value) => ln = value,
enabled: enb, enabled: enb,
), ),
// ElevatedButton(
// onPressed: () {
// showDialog(
// context: context,
// builder: (BuildContext context) => AlertDialog(
// 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'),
// ),
ElevatedButton( ElevatedButton(
onPressed: () { onPressed: () {
showDialog( showDialog(
context: context, context: context,
builder: (BuildContext context) => AlertDialog( builder: (BuildContext context)=>
content: Text( AlertDialog(
'Active Linkedin : ' + pgm['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'),
),
), ),
) ,
);
}, child: Text('View Active'))),
SizedBox( SizedBox(
height: 10, height: 10,
), ),
...@@ -264,52 +208,33 @@ class _SosmedDashboardState extends State<SosmedDashboard> { ...@@ -264,52 +208,33 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
color: Colors.blueAccent, color: Colors.blueAccent,
), ),
TextFormField( TextFormField(
// controller: twitterController, controller: twitterController,
initialValue: pgm['twitter'],
decoration: InputDecoration( decoration: InputDecoration(
hintText: 'Enter a new Twitter link address'), hintText: 'Enter a new Twitter link address'),
onChanged: (value) => tw = value, onChanged: (value) => tw = value,
enabled: enb, enabled: enb,
), ),
// ElevatedButton(
// onPressed: () {
// showDialog(
// context: context,
// builder: (BuildContext context) => AlertDialog(
// 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'),
// ),
ElevatedButton( ElevatedButton(
onPressed: () { onPressed: () {
showDialog( showDialog(
context: context, context: context,
builder: (BuildContext context) => AlertDialog( builder: (BuildContext context)=>
content: Text( AlertDialog(
'Active Twitter : ' + pgm['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'),
),
), ),
) ,
);
}, child: Text('View Active'))),
SizedBox( SizedBox(
height: 10, height: 10,
), ),
...@@ -319,52 +244,33 @@ class _SosmedDashboardState extends State<SosmedDashboard> { ...@@ -319,52 +244,33 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
color: Colors.pink, color: Colors.pink,
), ),
TextFormField( TextFormField(
// controller: igController, controller: igController,
initialValue: pgm['instagram'],
decoration: InputDecoration( decoration: InputDecoration(
hintText: 'Enter a new Instagram link address'), hintText: 'Enter a new Instagram link address'),
onChanged: (value) => ig = value, onChanged: (value) => ig = value,
enabled: enb, enabled: enb,
), ),
// ElevatedButton(
// onPressed: () {
// showDialog(
// context: context,
// builder: (BuildContext context) => AlertDialog(
// 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'),
// ),
ElevatedButton( ElevatedButton(
onPressed: () { onPressed: () {
showDialog( showDialog(
context: context, context: context,
builder: (BuildContext context) => AlertDialog( builder: (BuildContext context)=>
content: Text( AlertDialog(
'Active Instagram : ' + pgm['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'),
),
), ),
) ,
);
}, child: Text('View Active'))),
SizedBox( SizedBox(
height: 10, height: 10,
), ),
...@@ -374,55 +280,35 @@ class _SosmedDashboardState extends State<SosmedDashboard> { ...@@ -374,55 +280,35 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
color: Colors.red, color: Colors.red,
), ),
TextFormField( TextFormField(
// controller: youtubeController, controller: youtubeController,
initialValue: pgm['youtube'],
decoration: InputDecoration( decoration: InputDecoration(
hintText: 'Enter a new Youtube link address'), hintText: 'Enter a new Youtube link address'),
onChanged: (value) => yt = value, onChanged: (value) => yt = value,
enabled: enb, enabled: enb,
), ),
// ElevatedButton(
// onPressed: () {
// showDialog(
// context: context,
// builder: (BuildContext context) => AlertDialog(
// 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'),
// ),
ElevatedButton( ElevatedButton(
onPressed: () { onPressed: () {
showDialog( showDialog(
context: context, context: context,
builder: (BuildContext context) => AlertDialog( builder: (BuildContext context)=>
content: Text( AlertDialog(
'Active Youtube : ' + pgm['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'),
),
), ),
], ) ,
); );
}), }, child: Text('View Active'))),
],
),
], ],
), ),
), ),
......
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:medapp_eksad/api/sosmed_api.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
import 'package:spring/spring.dart'; import 'package:spring/spring.dart';
...@@ -6,7 +7,7 @@ class WAChat extends StatelessWidget { ...@@ -6,7 +7,7 @@ class WAChat extends StatelessWidget {
WAChat({Key? key}) : super(key: key); WAChat({Key? key}) : super(key: key);
void launchWhatsApp({ void launchWhatsApp({
required final int phone, required final String phone,
required String message, required String message,
}) async { }) async {
String url() { String url() {
...@@ -22,19 +23,32 @@ class WAChat extends StatelessWidget { ...@@ -22,19 +23,32 @@ class WAChat extends StatelessWidget {
final SpringController springController = final SpringController springController =
SpringController(initialAnim: Motion.play); SpringController(initialAnim: Motion.play);
String wa = '';
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return FloatingActionButton( return FloatingActionButton(
onPressed: () {},
backgroundColor: Colors.green, backgroundColor: Colors.green,
onPressed: (){ child: 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 GestureDetector(
onTap: () {
wa = pgm['whatsapp'];
springController.play( springController.play(
motion: Motion.reverse, motion: Motion.reverse,
animDuration: const Duration(milliseconds: 1000), animDuration: const Duration(milliseconds: 1000),
curve: Curves.easeInBack, curve: Curves.easeInBack,
delay: const Duration(milliseconds: 100)); delay: const Duration(milliseconds: 100));
launchWhatsApp( launchWhatsApp(
phone: 6287701892981, phone: wa,
message: message:
'Hallo, saya tertarik dan saya ingin tahu lebih lanjut tentang program Medapp dari EKSAD'); 'Hallo, saya tertarik dan saya ingin tahu lebih lanjut tentang program Medapp dari EKSAD');
}, },
...@@ -44,9 +58,11 @@ class WAChat extends StatelessWidget { ...@@ -44,9 +58,11 @@ class WAChat extends StatelessWidget {
springController: springController, springController: springController,
alignment: Alignment.center, alignment: Alignment.center,
animStatus: (AnimStatus status) {}, animStatus: (AnimStatus status) {},
child: const Icon(Icons.whatsapp, size: 40,color: Colors.white,), child: const Icon(Icons.whatsapp, size: 30),
),
);
},
), ),
); );
} }
} }
//phone: 81807890777,
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment