Commit f6f3af4a authored by Fikri's avatar Fikri

menampilkan hasil get setting di public

parent 00648504
...@@ -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,13 +34,13 @@ class _SosmedDashboardState extends State<SosmedDashboard> { ...@@ -34,13 +34,13 @@ 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.05, horizontal: screenSize.width * 0.15,
vertical: screenSize.height * 0.05), vertical: screenSize.height * 0.15),
child: Container( child: Container(
width: screenSize.width, width: screenSize.width,
height: screenSize.height * 0.8, height: screenSize.height * 0.8,
padding: padding:
const EdgeInsets.only(left: 30, top: 15, right: 30, bottom: 15), const EdgeInsets.only(left: 30, top: 15, right: 30, bottom: 15),
color: Colors.white, color: Colors.white,
child: Form( child: Form(
key: formKey, key: formKey,
...@@ -65,10 +65,11 @@ class _SosmedDashboardState extends State<SosmedDashboard> { ...@@ -65,10 +65,11 @@ 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(content: Text('Save Data Success'),)); ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text('Save Data Success'),
));
} }
// waController.clear(); // waController.clear();
// linkedController.clear(); // linkedController.clear();
...@@ -80,16 +81,14 @@ class _SosmedDashboardState extends State<SosmedDashboard> { ...@@ -80,16 +81,14 @@ 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';
...@@ -98,13 +97,17 @@ class _SosmedDashboardState extends State<SosmedDashboard> { ...@@ -98,13 +97,17 @@ 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(content: Text('Save Data Success'),)); ScaffoldMessenger.of(context).showSnackBar(SnackBar(
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(content: Text('Save Data Success'),)); ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text('Save Data Success'),
));
} }
} }
}, },
...@@ -126,189 +129,300 @@ class _SosmedDashboardState extends State<SosmedDashboard> { ...@@ -126,189 +129,300 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
SizedBox( SizedBox(
height: 25, height: 25,
), ),
Column( FutureBuilder(
mainAxisAlignment: MainAxisAlignment.spaceBetween, future: getSosmedDesc(),
children: [ builder: (BuildContext context, AsyncSnapshot snapshot) {
listsosmed( var pgm = snapshot.data[0];
Icon( final waController = TextEditingController();
Icons.whatsapp, final linkedController = TextEditingController();
color: Colors.green, final twitterController = TextEditingController();
), final igController = TextEditingController();
TextFormField( final youtubeController = TextEditingController();
controller: waController, if (snapshot.hasError ||
decoration: InputDecoration( snapshot.data == null ||
hintText: snapshot.connectionState == ConnectionState.waiting) {
'Enter WhatsApp number without +, Ex : 6280000000000 '), return const CircularProgressIndicator();
onChanged: (value) => wa = value, }
enabled: enb,
), return Column(
ElevatedButton( mainAxisAlignment: MainAxisAlignment.spaceBetween,
onPressed: () { children: [
showDialog( listsosmed(
context: context, Icon(
builder: (BuildContext context)=> Icons.whatsapp,
AlertDialog( color: Colors.green,
content:FutureBuilder<List<dynamic>>( ),
future: getSosmedDesc(), TextFormField(
builder: (BuildContext context, AsyncSnapshot snapshot) { // controller: waController,
var pgm = snapshot.data[0]; initialValue: pgm['whatsapp'],
if (snapshot.hasError || decoration: InputDecoration(
snapshot.data == null || hintText:
snapshot.connectionState == ConnectionState.waiting) { 'Enter WhatsApp number without +, Ex : 6280000000000 '),
return const CircularProgressIndicator(); onChanged: (value) => wa = value,
} enabled: enb,
return Text('Active WA : '+pgm['whatsapp']); ),
}, // ElevatedButton(
), // onPressed: () {
) , // showDialog(
); // context: context,
}, child: Text('View Active'))), // builder: (BuildContext context) => AlertDialog(
SizedBox( // content: FutureBuilder<List<dynamic>>(
height: 10, // future: getSosmedDesc(),
), // builder: (BuildContext context,
listsosmed( // AsyncSnapshot snapshot) {
Icon( // var pgm = snapshot.data[0];
FontAwesomeIcons.linkedin, // if (snapshot.hasError ||
color: Colors.blue, // snapshot.data == null ||
), // snapshot.connectionState ==
TextFormField( // ConnectionState.waiting) {
controller: linkedController, // return const CircularProgressIndicator();
decoration: InputDecoration( // }
hintText: 'Enter a new Linkedin link address'), // return Text(
onChanged: (value) => ln = value, // 'Active WA : ' + pgm['whatsapp']);
enabled: enb, // },
), // ),
ElevatedButton( // ),
onPressed: () { // );
showDialog( // },
context: context, // child: Text('View Active'),
builder: (BuildContext context)=> // ),
AlertDialog( ElevatedButton(
content:FutureBuilder<List<dynamic>>( onPressed: () {
future: getSosmedDesc(), showDialog(
builder: (BuildContext context, AsyncSnapshot snapshot) { context: context,
var pgm = snapshot.data[0]; builder: (BuildContext context) => AlertDialog(
if (snapshot.hasError || content: Text(
snapshot.data == null || 'Active WA : ' + pgm['whatsapp'],
snapshot.connectionState == ConnectionState.waiting) { ),
return const CircularProgressIndicator(); ),
} );
return Text('Active Linkedin : '+pgm['linkedin']); },
}, child: Text('View Active'),
), ),
) , ),
); SizedBox(
}, child: Text('View Active'))), height: 10,
SizedBox( ),
height: 10, listsosmed(
), Icon(
listsosmed( FontAwesomeIcons.linkedin,
Icon( color: Colors.blue,
FontAwesomeIcons.twitterSquare, ),
color: Colors.blueAccent, TextFormField(
), // controller: linkedController,
TextFormField( initialValue: pgm['linkedin'],
controller: twitterController, decoration: InputDecoration(
decoration: InputDecoration( hintText: 'Enter a new Linkedin link address'),
hintText: 'Enter a new Twitter link address'), onChanged: (value) => ln = value,
onChanged: (value) => tw = value, enabled: enb,
enabled: enb, ),
), // ElevatedButton(
ElevatedButton( // onPressed: () {
onPressed: () { // showDialog(
showDialog( // context: context,
context: context, // builder: (BuildContext context) => AlertDialog(
builder: (BuildContext context)=> // content: FutureBuilder<List<dynamic>>(
AlertDialog( // future: getSosmedDesc(),
content:FutureBuilder<List<dynamic>>( // builder: (BuildContext context,
future: getSosmedDesc(), // AsyncSnapshot snapshot) {
builder: (BuildContext context, AsyncSnapshot snapshot) { // var pgm = snapshot.data[0];
var pgm = snapshot.data[0]; // if (snapshot.hasError ||
if (snapshot.hasError || // snapshot.data == null ||
snapshot.data == null || // snapshot.connectionState ==
snapshot.connectionState == ConnectionState.waiting) { // ConnectionState.waiting) {
return const CircularProgressIndicator(); // return const CircularProgressIndicator();
} // }
return Text('Active Twitter : '+pgm['twitter']); // return Text('Active Linkedin : ' +
}, // pgm['linkedin']);
), // },
) , // ),
); // ),
}, child: Text('View Active'))), // );
SizedBox( // },
height: 10, // child: Text('View Active'),
), // ),
listsosmed( ElevatedButton(
Icon( onPressed: () {
FontAwesomeIcons.instagramSquare, showDialog(
color: Colors.pink, context: context,
), builder: (BuildContext context) => AlertDialog(
TextFormField( content: Text(
controller: igController, 'Active Linkedin : ' + pgm['linkedin'],
decoration: InputDecoration( ),
hintText: 'Enter a new Instagram link address'), ),
onChanged: (value) => ig = value, );
enabled: enb, },
), child: Text('View Active'),
ElevatedButton( ),
onPressed: () { ),
showDialog( SizedBox(
context: context, height: 10,
builder: (BuildContext context)=> ),
AlertDialog( listsosmed(
content:FutureBuilder<List<dynamic>>( Icon(
future: getSosmedDesc(), FontAwesomeIcons.twitterSquare,
builder: (BuildContext context, AsyncSnapshot snapshot) { color: Colors.blueAccent,
var pgm = snapshot.data[0]; ),
if (snapshot.hasError || TextFormField(
snapshot.data == null || // controller: twitterController,
snapshot.connectionState == ConnectionState.waiting) { initialValue: pgm['twitter'],
return const CircularProgressIndicator(); decoration: InputDecoration(
} hintText: 'Enter a new Twitter link address'),
return Text('Active Instagram : '+pgm['instagram']); onChanged: (value) => tw = value,
}, enabled: enb,
), ),
) , // ElevatedButton(
); // onPressed: () {
}, child: Text('View Active'))), // showDialog(
SizedBox( // context: context,
height: 10, // builder: (BuildContext context) => AlertDialog(
), // content: FutureBuilder<List<dynamic>>(
listsosmed( // future: getSosmedDesc(),
Icon( // builder: (BuildContext context,
FontAwesomeIcons.youtube, // AsyncSnapshot snapshot) {
color: Colors.red, // var pgm = snapshot.data[0];
), // if (snapshot.hasError ||
TextFormField( // snapshot.data == null ||
controller: youtubeController, // snapshot.connectionState ==
decoration: InputDecoration( // ConnectionState.waiting) {
hintText: 'Enter a new Youtube link address'), // return const CircularProgressIndicator();
onChanged: (value) => yt = value, // }
enabled: enb, // return Text(
), // 'Active Twitter : ' + pgm['twitter']);
ElevatedButton( // },
onPressed: () { // ),
showDialog( // ),
context: context, // );
builder: (BuildContext context)=> // },
AlertDialog( // child: Text('View Active'),
content:FutureBuilder<List<dynamic>>( // ),
future: getSosmedDesc(), ElevatedButton(
builder: (BuildContext context, AsyncSnapshot snapshot) { onPressed: () {
var pgm = snapshot.data[0]; showDialog(
if (snapshot.hasError || context: context,
snapshot.data == null || builder: (BuildContext context) => AlertDialog(
snapshot.connectionState == ConnectionState.waiting) { content: Text(
return const CircularProgressIndicator(); 'Active Twitter : ' + pgm['twitter'],
} ),
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:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:google_fonts/google_fonts.dart'; import 'package:google_fonts/google_fonts.dart';
import 'package:medapp_eksad/api/setting_api.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
class Footer extends StatelessWidget { class Footer extends StatelessWidget {
...@@ -268,53 +269,8 @@ class Footer extends StatelessWidget { ...@@ -268,53 +269,8 @@ class Footer extends StatelessWidget {
), ),
), ),
const SizedBox(height: 8), const SizedBox(height: 8),
Container( TelphoneApi(),
width: screenSize.width * 0.2, EmailAPI(),
child: ListTile(
leading: const Icon(
Icons.phone,
size: 22,
),
title: TextButton(
onPressed: () {
launch('tel:02157958040');
},
child: Container(
height: screenSize.height * 0.04,
child: Text(
'(021) 5795 - 8040',
style: GoogleFonts.poppins(
fontSize: 16,
color: Colors.black87,
),
),
),
),
),
),
Container(
width: screenSize.width * 0.2,
child: ListTile(
leading: const Icon(
Icons.mail,
size: 22,
),
title: TextButton(
onPressed: () {
launch(
'mailto:Hello@eksad.com?subject=Hello saya ingin bertanya tentang Medapp');
},
child: Container(
height: screenSize.height * 0.04,
child: Text(
'Hello@eksad.com',
style: GoogleFonts.poppins(
fontSize: 16, color: Colors.black87),
),
),
),
),
),
Container( Container(
width: screenSize.width * 0.25, width: screenSize.width * 0.25,
height: screenSize.height * 0.29, height: screenSize.height * 0.29,
...@@ -385,3 +341,97 @@ class itemBawah extends StatelessWidget { ...@@ -385,3 +341,97 @@ class itemBawah extends StatelessWidget {
)); ));
} }
} }
class TelphoneApi extends StatefulWidget {
const TelphoneApi({Key? key}) : super(key: key);
@override
State<TelphoneApi> createState() => _TelphoneApiState();
}
class _TelphoneApiState extends State<TelphoneApi> {
String no = '';
@override
Widget build(BuildContext context) {
var screenSize = MediaQuery.of(context).size;
return FutureBuilder<List<dynamic>>(
future: getSettingDesc(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
var pgm = snapshot.data[0];
if (snapshot.hasError ||
snapshot.data == null ||
snapshot.connectionState == ConnectionState.waiting) {
return const CircularProgressIndicator();
}
return Container(
width: screenSize.width * 0.19,
child: ListTile(
leading: const Icon(
Icons.phone,
size: 23,
color: Colors.black,
),
title: TextButton(
onPressed: () {
no = pgm['no'];
//02157958040
launch('tel:$no');
},
child: Text(
pgm['no'],
style: GoogleFonts.poppins(
fontSize: 16, color: Colors.black87, letterSpacing: 1.5),
)),
),
);
},
);
}
}
class EmailAPI extends StatefulWidget {
const EmailAPI({Key? key}) : super(key: key);
@override
State<EmailAPI> createState() => _EmailAPIState();
}
class _EmailAPIState extends State<EmailAPI> {
String email = '';
@override
Widget build(BuildContext context) {
var screenSize = MediaQuery.of(context).size;
return FutureBuilder<List<dynamic>>(
future: getSettingDesc(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
var pgm = snapshot.data[0];
if (snapshot.hasError ||
snapshot.data == null ||
snapshot.connectionState == ConnectionState.waiting) {
return const CircularProgressIndicator();
}
return Container(
width: screenSize.width * 0.2,
child: ListTile(
leading: const Icon(
Icons.mail,
size: 23,
color: Colors.black,
),
title: TextButton(
onPressed: () {
email = pgm['email'];
launch('mailto:$email?subject=Info MCS');
},
// child: SettingAPI(),
child: Text(
pgm['email'],
style: GoogleFonts.poppins(
fontSize: 16, color: Colors.black87, letterSpacing: 1.1),
)),
),
);
},
);
}
}
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