Commit 41df0161 authored by Tohap Maruli Pasaribu's avatar Tohap Maruli Pasaribu

Merge branch 'master' of http://103.44.149.204/qorridi/medapp_eksad into develop

parents 1ecf54e9 dfc1191d
...@@ -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 (id, wa, ln, tw, ig, yt) async {
final response = await http final response = await http
.put(Uri.parse('$cmd/settingsosmed/updateSettingSosmed'), .post(Uri.parse('$cmd/settingsosmed/saveSettingSosmed'),
body: jsonEncode({ body: jsonEncode({
'idSettingSosmed': id,
'whatsapp': wa, 'whatsapp': wa,
'linkedin': ln, 'linkedin': ln,
'twitter': tw, 'twitter': tw,
...@@ -52,4 +53,141 @@ Future<List<dynamic>> getSosmedDesc() async { ...@@ -52,4 +53,141 @@ Future<List<dynamic>> getSosmedDesc() async {
//Uri.parse('$qry/settingsosmed/getSettingSosmedById')); //Uri.parse('$qry/settingsosmed/getSettingSosmedById'));
Uri.parse('$qry/settingsosmed/getSettingSosmedByIdDesc')); Uri.parse('$qry/settingsosmed/getSettingSosmedByIdDesc'));
return jsonDecode(response.body)['data']; return jsonDecode(response.body)['data'];
}
Future<bool> createWA (wa) async{
final response = await http.post(
Uri.parse('$cmd/settingsosmed/saveWhatsapp'),
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> createLN (ln) async{
final response = await http.post(
Uri.parse('$cmd/settingsosmed/saveLinkedin'),
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> createTW (tw) async{
final response = await http.post(
Uri.parse('$cmd/settingsosmed/saveTwitter'),
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> createIG (ig) async{
final response = await http.post(
Uri.parse('$cmd/settingsosmed/saveInstagram'),
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> createYT (yt) async{
final response = await http.post(
Uri.parse('$cmd/settingsosmed/saveYoutube'),
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>> getWaDesc() async {
var response = await http.get(
Uri.parse('$qry/settingsosmed/getWhatsappByIdDesc'));
return jsonDecode(response.body)['data'];
}
Future<List<dynamic>> getLnDesc() async {
var response = await http.get(
Uri.parse('$qry/settingsosmed/getLinkedinByIdDesc'));
return jsonDecode(response.body)['data'];
}
Future<List<dynamic>> getTwDesc() async {
var response = await http.get(
Uri.parse('$qry/settingsosmed/getTwitterByIdDesc'));
return jsonDecode(response.body)['data'];
}
Future<List<dynamic>> getIgDesc() async {
var response = await http.get(
Uri.parse('$qry/settingsosmed/getInstagramByIdDesc'));
return jsonDecode(response.body)['data'];
}
Future<List<dynamic>> getYtDesc() async {
var response = await http.get(
Uri.parse('$qry/settingsosmed/getYoutubeByIdDesc'));
return jsonDecode(response.body)['data'];
} }
\ No newline at end of file
...@@ -29,6 +29,7 @@ Future<bool> signUp(namars,nors,alamatrs,namapic,nopic,email, password)async{ ...@@ -29,6 +29,7 @@ Future<bool> signUp(namars,nors,alamatrs,namapic,nopic,email, password)async{
} }
// return response.statusCode; // return response.statusCode;
} }
Future<bool> signIn(username, password)async{ Future<bool> signIn(username, password)async{
final response = await http.post( final response = await http.post(
Uri.parse('$cmd/user/signin'), Uri.parse('$cmd/user/signin'),
......
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:medapp_eksad/firebase/firebase_auth_methods.dart';
import 'package:medapp_eksad/widget/button_appbar.dart'; import 'package:medapp_eksad/widget/button_appbar.dart';
import 'package:medapp_eksad/register.dart'; import 'package:medapp_eksad/register.dart';
import 'package:provider/provider.dart';
AppBar AppbarHomeLarge(Size screenSize, BuildContext context, Color home, AppBar AppbarHomeLarge(Size screenSize, BuildContext context, Color home,
...@@ -144,6 +146,7 @@ AppBar AppbarHomeLargeUser(Size screenSize, BuildContext context, Color home, ...@@ -144,6 +146,7 @@ AppBar AppbarHomeLargeUser(Size screenSize, BuildContext context, Color home,
), ),
ElevatedButton( ElevatedButton(
onPressed: () { onPressed: () {
context.read<FirebaseAuthMethods>().signOut(context);
Navigator.pushNamed(context, '/'); Navigator.pushNamed(context, '/');
}, },
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
......
...@@ -15,27 +15,30 @@ class _SosmedDashboardState extends State<SosmedDashboard> { ...@@ -15,27 +15,30 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
var enb = true; var enb = true;
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();
final youtubeController = TextEditingController(); final youtubeController = TextEditingController();
String wa = ''; String wa = '';
String ln = ''; String ln = '';
String tw = ''; String tw ='';
String ig = ''; String ig = '';
String yt = ''; String yt = '';
String pattern = r'(\62)(\d{2,3})?\)?[ .-]?\d{2,4}[ .-]?\d{2,4}[ .-]?\d{2,4}';
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var screenSize = MediaQuery.of(context).size; var screenSize = MediaQuery.of(context).size;
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.04),
child: Container( child: Container(
width: screenSize.width, width: screenSize.width,
height: screenSize.height * 0.8, height: screenSize.height * 0.8,
...@@ -62,15 +65,37 @@ class _SosmedDashboardState extends State<SosmedDashboard> { ...@@ -62,15 +65,37 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
), ),
primary: const Color.fromARGB(255, 0, 67, 192), primary: const Color.fromARGB(255, 0, 67, 192),
), ),
onPressed: () { onPressed: () async {
switch (btnText) { switch (btnText) {
case 'Save Setting': case 'Save Setting':
createSosmed(wa, ln, tw, ig, yt);
{ if (formKey.currentState!.validate()) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar( // await updateSosmed(wa, ln, tw, ig, yt);
content: Text('Save Data Success'), // await createSosmed(wa, ln, tw, ig, yt);
)); await createWA(wa);
await createLN(ln);
await createTW(tw);
await createIG(ig);
await createYT(yt);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Data Saved'),
backgroundColor: Colors.green)
);
}else if(formKey.currentState!.validate()){}
else {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Failed to save data, please edit all field'),
backgroundColor: Colors.red)
);
} }
// waController.clear(); // waController.clear();
// linkedController.clear(); // linkedController.clear();
// twitterController.clear(); // twitterController.clear();
...@@ -81,34 +106,51 @@ class _SosmedDashboardState extends State<SosmedDashboard> { ...@@ -81,34 +106,51 @@ 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';
}); });
break; break;
case 'Save Update': case 'Save Update':
createSosmed(wa, ln, tw, ig, yt); if (formKey.currentState!.validate()) {
{ // await updateSosmed(wa, ln, tw, ig, yt);
ScaffoldMessenger.of(context).showSnackBar(SnackBar( // await createSosmed(wa, ln, tw, ig, yt);
content: Text('Save Data Success'), await createWA(wa);
)); await createLN(ln);
await createTW(tw);
await createIG(ig);
await createYT(yt);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Data Saved'),
backgroundColor: Colors.green)
);
}else if(formKey.currentState!.validate()){}
else {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Failed to save data, please edit all field'),
backgroundColor: Colors.red)
);
} }
break; break;
default: default:
createSosmed(wa, ln, tw, ig, yt);
{
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text('Save Data Success'),
));
}
} }
}, },
child: Text( child: Text(
...@@ -126,303 +168,266 @@ class _SosmedDashboardState extends State<SosmedDashboard> { ...@@ -126,303 +168,266 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
// endIndent: 0, // endIndent: 0,
color: Colors.grey, color: Colors.grey,
), ),
SizedBox( // Text('Data Must Be Edited'),
height: 25, // Text('For data that is not modified, Please copy last data , delete then paste again'),
const SizedBox(
height: 10,
), ),
FutureBuilder( // FutureBuilder<List<dynamic>>(
future: getSosmedDesc(), // future: getSosmedDesc(),
builder: (BuildContext context, AsyncSnapshot snapshot) { // builder: (BuildContext context, AsyncSnapshot snapshot) {
var pgm = snapshot.data[0]; // var pgm = snapshot.data[0];
final waController = TextEditingController(); //
final linkedController = TextEditingController(); // if (snapshot.hasError ||
final twitterController = TextEditingController(); // snapshot.data == null ||
final igController = TextEditingController(); // snapshot.connectionState == ConnectionState.waiting) {
final youtubeController = TextEditingController(); // return const CircularProgressIndicator();
if (snapshot.hasError || // }
snapshot.data == null || // return
snapshot.connectionState == ConnectionState.waiting) { // },
return const CircularProgressIndicator(); // ),
}
Column(
return Column( mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
children: [ FutureBuilder<List<dynamic>>(
listsosmed( future: getWaDesc(),
Icon( builder: (BuildContext context, AsyncSnapshot snapshot) {
Icons.whatsapp, var pgm = snapshot.data[0];
color: Colors.green,
), if (snapshot.hasError ||
TextFormField( snapshot.data == null ||
// controller: waController, snapshot.connectionState == ConnectionState.waiting) {
initialValue: pgm['whatsapp'], return const CircularProgressIndicator();
decoration: InputDecoration( }
hintText: return listsosmed(
'Enter WhatsApp number without +, Ex : 6280000000000 '), const Icon(
onChanged: (value) => wa = value, Icons.whatsapp,
enabled: enb, color: Colors.green,
),
// 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(
onPressed: () {
showDialog(
context: context,
builder: (BuildContext context) => AlertDialog(
content: Text(
'Active WA : ' + pgm['whatsapp'],
),
), ),
); TextFormField(
}, controller: waController..text = pgm['whatsapp'],
child: Text('View Active'),
), //initialValue: pgm['whatsapp'],
),
SizedBox( decoration: const InputDecoration(
height: 10, errorStyle: TextStyle(color: Colors.red),
), hintText:
listsosmed( 'Enter WhatsApp number without +, Ex : 6280000000000 ',
Icon( helperText: 'Enter WhatsApp number without +, Ex : 6280000000000 ',
FontAwesomeIcons.linkedin,
color: Colors.blue,
),
TextFormField(
// controller: linkedController,
initialValue: pgm['linkedin'],
decoration: InputDecoration(
hintText: 'Enter a new Linkedin link address'),
onChanged: (value) => ln = 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 Linkedin : ' +
// pgm['linkedin']);
// },
// ),
// ),
// );
// },
// child: Text('View Active'),
// ),
ElevatedButton(
onPressed: () {
showDialog(
context: context,
builder: (BuildContext context) => AlertDialog(
content: Text(
'Active Linkedin : ' + pgm['linkedin'],
), ),
onChanged: (value) => wa = value,
enabled: enb,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter your phone number';
}else if(!RegExp(pattern).hasMatch(value)){
return 'Please enter with 628 only';
}
return null;
},
), ),
); ElevatedButton(
}, onPressed: () {
child: Text('View Active'), showDialog(
), context: context,
), builder: (BuildContext context)=>
SizedBox( AlertDialog(
height: 10, content:Text('Active WA : '+pgm['whatsapp'])
), ) ,
listsosmed( );
Icon( }, child: const Text('View Active')));
FontAwesomeIcons.twitterSquare, },
color: Colors.blueAccent, ),
),
TextFormField( const SizedBox(
// controller: twitterController, height: 10,
initialValue: pgm['twitter'], ),
decoration: InputDecoration( FutureBuilder<List<dynamic>>(
hintText: 'Enter a new Twitter link address'), future: getLnDesc(),
onChanged: (value) => tw = value, builder: (BuildContext context, AsyncSnapshot snapshot) {
enabled: enb, var pgm = snapshot.data[0];
),
// ElevatedButton( if (snapshot.hasError ||
// onPressed: () { snapshot.data == null ||
// showDialog( snapshot.connectionState == ConnectionState.waiting) {
// context: context, return const CircularProgressIndicator();
// builder: (BuildContext context) => AlertDialog( }
// content: FutureBuilder<List<dynamic>>( return listsosmed(
// future: getSosmedDesc(), const Icon(
// builder: (BuildContext context, FontAwesomeIcons.linkedin,
// AsyncSnapshot snapshot) { color: Colors.blue,
// 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(
onPressed: () {
showDialog(
context: context,
builder: (BuildContext context) => AlertDialog(
content: Text(
'Active Twitter : ' + pgm['twitter'],
),
), ),
); TextFormField(
}, controller: linkedController..text = pgm['linkedin'],
child: Text('View Active'), //initialValue: pgm['linkedin'],
), decoration: const InputDecoration(
), errorStyle: TextStyle(color: Colors.red),
SizedBox( hintText: 'Enter a new Linkedin link address'),
height: 10, onChanged: (value) => ln = value,
), enabled: enb,
listsosmed( validator: (value) {
Icon( if (value == null || value.isEmpty) {
FontAwesomeIcons.instagramSquare, return 'Please enter linkedin link';
color: Colors.pink, }
), return null;
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'],
),
), ),
); ElevatedButton(
}, onPressed: () {
child: Text('View Active'), showDialog(
), context: context,
), builder: (BuildContext context)=>
SizedBox( AlertDialog(
height: 10, content:Text('Active Linkedin : '+pgm['linkedin'])
), ) ,
listsosmed( );
Icon( }, child: const Text('View Active')));
FontAwesomeIcons.youtube, },
color: Colors.red, ),
),
TextFormField( const SizedBox(
// controller: youtubeController, height: 10,
initialValue: pgm['youtube'], ),
decoration: InputDecoration( FutureBuilder<List<dynamic>>(
hintText: 'Enter a new Youtube link address'), future: getTwDesc(),
onChanged: (value) => yt = value, builder: (BuildContext context, AsyncSnapshot snapshot) {
enabled: enb, var pgm = snapshot.data[0];
),
// ElevatedButton( if (snapshot.hasError ||
// onPressed: () { snapshot.data == null ||
// showDialog( snapshot.connectionState == ConnectionState.waiting) {
// context: context, return const CircularProgressIndicator();
// builder: (BuildContext context) => AlertDialog( }
// content: FutureBuilder<List<dynamic>>( return listsosmed(
// future: getSosmedDesc(), const Icon(
// builder: (BuildContext context, FontAwesomeIcons.twitterSquare,
// AsyncSnapshot snapshot) { color: Colors.blueAccent,
// var pgm = snapshot.data[0]; ),
// if (snapshot.hasError ||
// snapshot.data == null || TextFormField(
// snapshot.connectionState == controller: twitterController..text = pgm['twitter'],
// ConnectionState.waiting) { //initialValue: pgm['twitter'],
// return const CircularProgressIndicator(); decoration: const InputDecoration(
// } errorStyle: TextStyle(color: Colors.red),
// return Text( hintText: 'Enter a new Twitter link address'),
// 'Active Youtube : ' + pgm['youtube']); onChanged: (value) => tw = value,
// }, enabled: enb,
// ), validator: (value) {
// ), if (value == null || value.isEmpty) {
// ); return 'Please enter twitter link';
// }, }
// child: Text('View Active'), return null;
// ), },
ElevatedButton(
onPressed: () {
showDialog(
context: context,
builder: (BuildContext context) => AlertDialog(
content: Text(
'Active Youtube : ' + pgm['youtube'],
),
), ),
); ElevatedButton(
}, onPressed: () {
child: Text('View Active'), showDialog(
), context: context,
), builder: (BuildContext context)=>
], AlertDialog(
); content:Text('Active Twitter : '+pgm['twitter'])
}), ) ,
);
}, child: const Text('View Active')));
},
),
const SizedBox(
height: 10,
),
FutureBuilder<List<dynamic>>(
future: getIgDesc(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
var pgm = snapshot.data[0];
if (snapshot.hasError ||
snapshot.data == null ||
snapshot.connectionState == ConnectionState.waiting) {
return const CircularProgressIndicator();
}
return listsosmed(
const Icon(
FontAwesomeIcons.instagramSquare,
color: Colors.pink,
),
TextFormField(
controller: igController..text = pgm['instagram'],
// initialValue: pgm['instagram'],
decoration: const InputDecoration(
errorStyle: TextStyle(color: Colors.red),
hintText: 'Enter a new Instagram link address'),
onChanged: (value) => ig = value,
enabled: enb,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter instagram link';
}
return null;
},
),
ElevatedButton(
onPressed: () {
showDialog(
context: context,
builder: (BuildContext context)=>
AlertDialog(
content:Text('Active Instagram : '+pgm['instagram'])
) ,
);
}, child: const Text('View Active')));
},
),
const SizedBox(
height: 10,
),
FutureBuilder<List<dynamic>>(
future: getYtDesc(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
var pgm = snapshot.data[0];
if (snapshot.hasError ||
snapshot.data == null ||
snapshot.connectionState == ConnectionState.waiting) {
return const CircularProgressIndicator();
}
return listsosmed(
const Icon(
FontAwesomeIcons.youtube,
color: Colors.red,
),
TextFormField(
controller: youtubeController..text = pgm['youtube'],
//initialValue: pgm['youtube'],
decoration: const InputDecoration(
errorStyle: TextStyle(color: Colors.red),
hintText: 'Enter a new Youtube link address'),
onChanged: (value) => yt = value,
enabled: enb,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter youtube link';
}
return null;
},
),
ElevatedButton(
onPressed: () {
showDialog(
context: context,
builder: (BuildContext context)=>
AlertDialog(
content:Text('Active Youtube : '+pgm['youtube'])
) ,
);
}, child: const 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