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,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.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,
...@@ -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,9 +81,7 @@ class _SosmedDashboardState extends State<SosmedDashboard> { ...@@ -80,9 +81,7 @@ 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();
...@@ -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,7 +129,22 @@ class _SosmedDashboardState extends State<SosmedDashboard> { ...@@ -126,7 +129,22 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
SizedBox( SizedBox(
height: 25, height: 25,
), ),
Column( FutureBuilder(
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(
...@@ -135,34 +153,53 @@ class _SosmedDashboardState extends State<SosmedDashboard> { ...@@ -135,34 +153,53 @@ 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)=> builder: (BuildContext context) => AlertDialog(
AlertDialog( content: Text(
content:FutureBuilder<List<dynamic>>( 'Active WA : ' + pgm['whatsapp'],
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,
), ),
...@@ -172,33 +209,52 @@ class _SosmedDashboardState extends State<SosmedDashboard> { ...@@ -172,33 +209,52 @@ 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)=> builder: (BuildContext context) => AlertDialog(
AlertDialog( content: Text(
content:FutureBuilder<List<dynamic>>( 'Active Linkedin : ' + pgm['linkedin'],
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,
), ),
...@@ -208,33 +264,52 @@ class _SosmedDashboardState extends State<SosmedDashboard> { ...@@ -208,33 +264,52 @@ 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)=> builder: (BuildContext context) => AlertDialog(
AlertDialog( content: Text(
content:FutureBuilder<List<dynamic>>( 'Active Twitter : ' + pgm['twitter'],
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,
), ),
...@@ -244,33 +319,52 @@ class _SosmedDashboardState extends State<SosmedDashboard> { ...@@ -244,33 +319,52 @@ 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)=> builder: (BuildContext context) => AlertDialog(
AlertDialog( content: Text(
content:FutureBuilder<List<dynamic>>( 'Active Instagram : ' + pgm['instagram'],
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,
), ),
...@@ -280,36 +374,56 @@ class _SosmedDashboardState extends State<SosmedDashboard> { ...@@ -280,36 +374,56 @@ 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)=> builder: (BuildContext context) => AlertDialog(
AlertDialog( content: Text(
content:FutureBuilder<List<dynamic>>( 'Active Youtube : ' + pgm['youtube'],
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: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