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,
......
...@@ -16,7 +16,7 @@ class _SosmedDashboardState extends State<SosmedDashboard> { ...@@ -16,7 +16,7 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
final formKey = GlobalKey<FormState>(); final formKey = GlobalKey<FormState>();
TextEditingController waController = new TextEditingController(); TextEditingController waController = new TextEditingController();
// final waController = TextEditingController(); // final waController = TextEditingController();
final linkedController = TextEditingController(); final linkedController = TextEditingController();
final twitterController = TextEditingController(); final twitterController = TextEditingController();
final igController = TextEditingController(); final igController = TextEditingController();
...@@ -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,14 +80,16 @@ class _SosmedDashboardState extends State<SosmedDashboard> { ...@@ -81,14 +80,16 @@ 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();
// linkedController.clear(); // linkedController.clear();
// twitterController.clear(); // twitterController.clear();
// igController.clear(); // igController.clear();
// youtubeController.clear(); // youtubeController.clear();
setState(() { setState(() {
enb = true; enb = true;
btnText = 'Save Update'; btnText = 'Save Update';
...@@ -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,300 +126,189 @@ class _SosmedDashboardState extends State<SosmedDashboard> { ...@@ -129,300 +126,189 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
SizedBox( SizedBox(
height: 25, height: 25,
), ),
FutureBuilder( Column(
future: getSosmedDesc(), mainAxisAlignment: MainAxisAlignment.spaceBetween,
builder: (BuildContext context, AsyncSnapshot snapshot) { children: [
var pgm = snapshot.data[0]; listsosmed(
final waController = TextEditingController(); Icon(
final linkedController = TextEditingController(); Icons.whatsapp,
final twitterController = TextEditingController(); color: Colors.green,
final igController = TextEditingController(); ),
final youtubeController = TextEditingController(); TextFormField(
if (snapshot.hasError || controller: waController,
snapshot.data == null || decoration: InputDecoration(
snapshot.connectionState == ConnectionState.waiting) { hintText:
return const CircularProgressIndicator(); 'Enter WhatsApp number without +, Ex : 6280000000000 '),
} onChanged: (value) => wa = value,
enabled: enb,
return Column( ),
mainAxisAlignment: MainAxisAlignment.spaceBetween, ElevatedButton(
children: [ onPressed: () {
listsosmed( showDialog(
Icon( context: context,
Icons.whatsapp, builder: (BuildContext context)=>
color: Colors.green, AlertDialog(
), content:FutureBuilder<List<dynamic>>(
TextFormField( future: getSosmedDesc(),
// controller: waController, builder: (BuildContext context, AsyncSnapshot snapshot) {
initialValue: pgm['whatsapp'], var pgm = snapshot.data[0];
decoration: InputDecoration( if (snapshot.hasError ||
hintText: snapshot.data == null ||
'Enter WhatsApp number without +, Ex : 6280000000000 '), snapshot.connectionState == ConnectionState.waiting) {
onChanged: (value) => wa = value, return const CircularProgressIndicator();
enabled: enb, }
), return Text('Active WA : '+pgm['whatsapp']);
// ElevatedButton( },
// onPressed: () { ),
// showDialog( ) ,
// context: context, );
// builder: (BuildContext context) => AlertDialog( }, child: Text('View Active'))),
// content: FutureBuilder<List<dynamic>>( SizedBox(
// future: getSosmedDesc(), height: 10,
// builder: (BuildContext context, ),
// AsyncSnapshot snapshot) { listsosmed(
// var pgm = snapshot.data[0]; Icon(
// if (snapshot.hasError || FontAwesomeIcons.linkedin,
// snapshot.data == null || color: Colors.blue,
// snapshot.connectionState == ),
// ConnectionState.waiting) { TextFormField(
// return const CircularProgressIndicator(); controller: linkedController,
// } decoration: InputDecoration(
// return Text( hintText: 'Enter a new Linkedin link address'),
// 'Active WA : ' + pgm['whatsapp']); onChanged: (value) => ln = value,
// }, enabled: enb,
// ), ),
// ), ElevatedButton(
// ); onPressed: () {
// }, showDialog(
// child: Text('View Active'), context: context,
// ), builder: (BuildContext context)=>
ElevatedButton( AlertDialog(
onPressed: () { content:FutureBuilder<List<dynamic>>(
showDialog( future: getSosmedDesc(),
context: context, builder: (BuildContext context, AsyncSnapshot snapshot) {
builder: (BuildContext context) => AlertDialog( var pgm = snapshot.data[0];
content: Text( if (snapshot.hasError ||
'Active WA : ' + pgm['whatsapp'], snapshot.data == null ||
), snapshot.connectionState == ConnectionState.waiting) {
), return const CircularProgressIndicator();
); }
}, return Text('Active Linkedin : '+pgm['linkedin']);
child: Text('View Active'), },
), ),
), ) ,
SizedBox( );
height: 10, }, child: Text('View Active'))),
), SizedBox(
listsosmed( height: 10,
Icon( ),
FontAwesomeIcons.linkedin, listsosmed(
color: Colors.blue, Icon(
), FontAwesomeIcons.twitterSquare,
TextFormField( color: Colors.blueAccent,
// controller: linkedController, ),
initialValue: pgm['linkedin'], TextFormField(
decoration: InputDecoration( controller: twitterController,
hintText: 'Enter a new Linkedin link address'), decoration: InputDecoration(
onChanged: (value) => ln = value, hintText: 'Enter a new Twitter link address'),
enabled: enb, onChanged: (value) => tw = value,
), enabled: enb,
// ElevatedButton( ),
// onPressed: () { ElevatedButton(
// showDialog( onPressed: () {
// context: context, showDialog(
// builder: (BuildContext context) => AlertDialog( context: context,
// content: FutureBuilder<List<dynamic>>( builder: (BuildContext context)=>
// future: getSosmedDesc(), AlertDialog(
// builder: (BuildContext context, content:FutureBuilder<List<dynamic>>(
// AsyncSnapshot snapshot) { future: getSosmedDesc(),
// var pgm = snapshot.data[0]; builder: (BuildContext context, AsyncSnapshot snapshot) {
// if (snapshot.hasError || var pgm = snapshot.data[0];
// snapshot.data == null || if (snapshot.hasError ||
// snapshot.connectionState == snapshot.data == null ||
// ConnectionState.waiting) { snapshot.connectionState == ConnectionState.waiting) {
// return const CircularProgressIndicator(); return const CircularProgressIndicator();
// } }
// return Text('Active Linkedin : ' + return Text('Active Twitter : '+pgm['twitter']);
// pgm['linkedin']); },
// }, ),
// ), ) ,
// ), );
// ); }, child: Text('View Active'))),
// }, SizedBox(
// child: Text('View Active'), height: 10,
// ), ),
ElevatedButton( listsosmed(
onPressed: () { Icon(
showDialog( FontAwesomeIcons.instagramSquare,
context: context, color: Colors.pink,
builder: (BuildContext context) => AlertDialog( ),
content: Text( TextFormField(
'Active Linkedin : ' + pgm['linkedin'], controller: igController,
), decoration: InputDecoration(
), hintText: 'Enter a new Instagram link address'),
); onChanged: (value) => ig = value,
}, enabled: enb,
child: Text('View Active'), ),
), ElevatedButton(
), onPressed: () {
SizedBox( showDialog(
height: 10, context: context,
), builder: (BuildContext context)=>
listsosmed( AlertDialog(
Icon( content:FutureBuilder<List<dynamic>>(
FontAwesomeIcons.twitterSquare, future: getSosmedDesc(),
color: Colors.blueAccent, builder: (BuildContext context, AsyncSnapshot snapshot) {
), var pgm = snapshot.data[0];
TextFormField( if (snapshot.hasError ||
// controller: twitterController, snapshot.data == null ||
initialValue: pgm['twitter'], snapshot.connectionState == ConnectionState.waiting) {
decoration: InputDecoration( return const CircularProgressIndicator();
hintText: 'Enter a new Twitter link address'), }
onChanged: (value) => tw = value, return Text('Active Instagram : '+pgm['instagram']);
enabled: enb, },
), ),
// ElevatedButton( ) ,
// onPressed: () { );
// showDialog( }, child: Text('View Active'))),
// context: context, SizedBox(
// builder: (BuildContext context) => AlertDialog( height: 10,
// content: FutureBuilder<List<dynamic>>( ),
// future: getSosmedDesc(), listsosmed(
// builder: (BuildContext context, Icon(
// AsyncSnapshot snapshot) { FontAwesomeIcons.youtube,
// var pgm = snapshot.data[0]; color: Colors.red,
// if (snapshot.hasError || ),
// snapshot.data == null || TextFormField(
// snapshot.connectionState == controller: youtubeController,
// ConnectionState.waiting) { decoration: InputDecoration(
// return const CircularProgressIndicator(); hintText: 'Enter a new Youtube link address'),
// } onChanged: (value) => yt = value,
// return Text( enabled: enb,
// 'Active Twitter : ' + pgm['twitter']); ),
// }, ElevatedButton(
// ), onPressed: () {
// ), showDialog(
// ); context: context,
// }, builder: (BuildContext context)=>
// child: Text('View Active'), AlertDialog(
// ), content:FutureBuilder<List<dynamic>>(
ElevatedButton( future: getSosmedDesc(),
onPressed: () { builder: (BuildContext context, AsyncSnapshot snapshot) {
showDialog( var pgm = snapshot.data[0];
context: context, if (snapshot.hasError ||
builder: (BuildContext context) => AlertDialog( snapshot.data == null ||
content: Text( snapshot.connectionState == ConnectionState.waiting) {
'Active Twitter : ' + pgm['twitter'], return const CircularProgressIndicator();
), }
), return Text('Active Youtube : '+pgm['youtube']);
); },
}, ),
child: Text('View Active'), ) ,
), );
), }, child: Text('View Active'))),
SizedBox( ],
height: 10, ),
),
listsosmed(
Icon(
FontAwesomeIcons.instagramSquare,
color: Colors.pink,
),
TextFormField(
// controller: igController,
initialValue: pgm['instagram'],
decoration: InputDecoration(
hintText: 'Enter a new Instagram link address'),
onChanged: (value) => ig = value,
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(
onPressed: () {
showDialog(
context: context,
builder: (BuildContext context) => AlertDialog(
content: Text(
'Active Instagram : ' + pgm['instagram'],
),
),
);
},
child: Text('View Active'),
),
),
SizedBox(
height: 10,
),
listsosmed(
Icon(
FontAwesomeIcons.youtube,
color: Colors.red,
),
TextFormField(
// controller: youtubeController,
initialValue: pgm['youtube'],
decoration: InputDecoration(
hintText: 'Enter a new Youtube link address'),
onChanged: (value) => yt = value,
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(
onPressed: () {
showDialog(
context: context,
builder: (BuildContext context) => AlertDialog(
content: Text(
'Active Youtube : ' + pgm['youtube'],
),
),
);
},
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() {
...@@ -21,32 +22,47 @@ class WAChat extends StatelessWidget { ...@@ -21,32 +22,47 @@ 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>>(
springController.play( future: getSosmedDesc(),
motion: Motion.reverse, builder: (BuildContext context, AsyncSnapshot snapshot) {
animDuration: const Duration(milliseconds: 1000), var pgm = snapshot.data[0];
curve: Curves.easeInBack, if (snapshot.hasError ||
delay: const Duration(milliseconds: 100)); snapshot.data == null ||
launchWhatsApp( snapshot.connectionState == ConnectionState.waiting) {
phone: 6287701892981, return const CircularProgressIndicator();
message: }
'Hallo, saya tertarik dan saya ingin tahu lebih lanjut tentang program Medapp dari EKSAD'); return GestureDetector(
}, onTap: () {
child: Spring.rotate( wa = pgm['whatsapp'];
endAngle: 360 * 10, springController.play(
animDuration: const Duration(seconds: 3 * 10), motion: Motion.reverse,
springController: springController, animDuration: const Duration(milliseconds: 1000),
alignment: Alignment.center, curve: Curves.easeInBack,
animStatus: (AnimStatus status) {}, delay: const Duration(milliseconds: 100));
child: const Icon(Icons.whatsapp, size: 40,color: Colors.white,), launchWhatsApp(
phone: wa,
message:
'Hallo, saya tertarik dan saya ingin tahu lebih lanjut tentang program Medapp dari EKSAD');
},
child: Spring.rotate(
endAngle: 360 * 10,
animDuration: const Duration(seconds: 3 * 10),
springController: springController,
alignment: Alignment.center,
animStatus: (AnimStatus status) {},
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