Commit 611fe657 authored by Tohap Maruli Pasaribu's avatar Tohap Maruli Pasaribu

retrieve data on Action="View" in Data User

parent a99c1728
...@@ -11,25 +11,135 @@ class UserControl extends StatefulWidget { ...@@ -11,25 +11,135 @@ class UserControl extends StatefulWidget {
} }
class _UserControlState extends State<UserControl> { class _UserControlState extends State<UserControl> {
void apiService(BuildContext context) {
FutureBuilder<List<dynamic>>(
future: getUserControl(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.hasError ||
snapshot.data == null ||
snapshot.connectionState == ConnectionState.waiting) {
return const CircularProgressIndicator();
}
return snapshot.data;
});
}
final formKey = GlobalKey<FormState>(); final formKey = GlobalKey<FormState>();
final nameRSController = TextEditingController(); @override
Widget build(BuildContext context) {
var screenSize = MediaQuery.of(context).size;
return Padding(
padding: const EdgeInsets.all(30.0),
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 10),
decoration: BoxDecoration(
color: Colors.white60,
borderRadius: BorderRadius.circular(20),
boxShadow: [
BoxShadow(
color: const Color.fromARGB(255, 10, 116, 255).withAlpha(60),
blurRadius: 5.0,
spreadRadius: 5.0,
offset: const Offset(0.0, 3.0))
]),
child: Column(
children: [
Container(
height: screenSize.height * 0.15,
child: Center(
child: Text(
'Data User',
style: GoogleFonts.poppins(
height: 1.5,
fontSize: 31,
fontWeight: FontWeight.bold,
color: Colors.blueAccent[200]),
),
),
),
Container(
height: screenSize.height * 0.65,
child: ListView(
controller: ScrollController(),
children: [
FutureBuilder<List<dynamic>>(
future: getUserControl(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.hasError ||
snapshot.data == null ||
snapshot.connectionState ==
ConnectionState.waiting) {
return const CircularProgressIndicator();
}
return DataTable(
decoration:
const BoxDecoration(color: Colors.white),
columnSpacing: 55,
columns: const [
DataColumn(
label: Text(
"ID",
style: TextStyle(fontWeight: FontWeight.bold),
)),
DataColumn(
label: Text(
"Nama Rumah Sakit",
style: TextStyle(fontWeight: FontWeight.bold),
)),
// DataColumn(label: Text("Telp Rumah Sakit")),
DataColumn(
label: Text(
"Alamat Rumah Sakit",
style: TextStyle(fontWeight: FontWeight.bold),
)),
// DataColumn(label: Text("Nama PIC")),
// DataColumn(label: Text("Telp PIC")),
// DataColumn(label: Text("Email PIC")),
DataColumn(
label: Text(
"STATUS",
style: TextStyle(fontWeight: FontWeight.bold),
)),
DataColumn(
label: Text(
"ACTION",
style: TextStyle(fontWeight: FontWeight.bold),
))
],
rows: List.generate(snapshot.data.length, (index) {
var pgm = snapshot.data[index];
final nameRSController = TextEditingController()
..text = pgm['namaRs'].toString();
final phoneRSController = TextEditingController(); final phoneRSController = TextEditingController();
final addressRSController = TextEditingController(); final addressRSController =
TextEditingController();
final namePICController = TextEditingController(); final namePICController = TextEditingController();
final phonePICController = TextEditingController(); final phonePICController =
final addressPICController = TextEditingController(); TextEditingController();
final emailPICController = TextEditingController(); final addressPICController =
final passwordController = TextEditingController(); TextEditingController();
final emailPICController =
TextEditingController();
final passwordController =
TextEditingController();
void viewUser(BuildContext context) { void viewUser(BuildContext context) {
var screenSize = MediaQuery.of(context).size; var screenSize = MediaQuery.of(context).size;
showDialog( showDialog(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
// var pgm = snapshot.data;
// print(pgm);
// if (snapshot.hasError ||
// snapshot.data == null ||
// snapshot.connectionState == ConnectionState.waiting) {
// return const CircularProgressIndicator();
// }
return AlertDialog( return AlertDialog(
// title: Text("Alert!!!"),
// content: Text("Your are awesome!"),
content: Form( content: Form(
child: Container( child: Container(
padding: EdgeInsets.only( padding: EdgeInsets.only(
...@@ -38,30 +148,47 @@ class _UserControlState extends State<UserControl> { ...@@ -38,30 +148,47 @@ class _UserControlState extends State<UserControl> {
width: screenSize.width * 0.50, width: screenSize.width * 0.50,
height: screenSize.height * 0.55, height: screenSize.height * 0.55,
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment:
mainAxisAlignment: MainAxisAlignment.spaceEvenly, CrossAxisAlignment.start,
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: [ children: [
const Spacer(), const Spacer(),
Container( Container(
padding: EdgeInsets.only(left: screenSize.width * 0.15), padding: EdgeInsets.only(
left: screenSize.width *
0.15),
height: screenSize.width * 0.03, height: screenSize.width * 0.03,
child: Image.asset("assets/logo/medapp-logo.png"), child: Image.asset(
"assets/logo/medapp-logo.png"),
), ),
const SizedBox(height: 20), const SizedBox(height: 20),
Row( Row(
children: [ children: [
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment:
mainAxisAlignment: MainAxisAlignment.spaceEvenly, CrossAxisAlignment
.start,
mainAxisAlignment:
MainAxisAlignment
.spaceEvenly,
children: [ children: [
Row( Row(
children: [ children: [
Icon(Icons.drive_file_rename_outline, Icon(
color: Colors.grey[500], Icons
size: screenSize.width * 0.01), .drive_file_rename_outline,
const SizedBox(width: 10), color: Colors
const Text("Nama Rumah Sakit", .grey[500],
style: TextStyle(fontSize: 13)) size: screenSize
.width *
0.01),
const SizedBox(
width: 10),
const Text(
"Nama Rumah Sakit",
style: TextStyle(
fontSize: 13))
], ],
), ),
const SizedBox(height: 5), const SizedBox(height: 5),
...@@ -69,18 +196,34 @@ class _UserControlState extends State<UserControl> { ...@@ -69,18 +196,34 @@ class _UserControlState extends State<UserControl> {
children: [ children: [
SizedBox( SizedBox(
height: 60, height: 60,
width: screenSize.width * 0.2, width: screenSize
child: TextFormField( .width *
controller: nameRSController, 0.2,
textAlign: TextAlign.start, child:
TextFormField(
controller:
nameRSController,
textAlign:
TextAlign
.start,
decoration: InputDecoration( decoration: InputDecoration(
labelText: "Nama Rumah Sakit", labelText:
labelStyle: TextStyle(fontSize: 13), "Nama Rumah Sakit",
labelStyle:
TextStyle(
fontSize:
13),
border: OutlineInputBorder( border: OutlineInputBorder(
borderRadius: borderRadius:
BorderRadius.circular(5.0))), BorderRadius.circular(
validator: (value) { 5.0))),
if (value == null || value.isEmpty) { readOnly: true,
validator:
(value) {
if (value ==
null ||
value
.isEmpty) {
return "Nama Rumah Sakit tidak boleh kosong"; return "Nama Rumah Sakit tidak boleh kosong";
} else { } else {
return null; return null;
...@@ -94,23 +237,32 @@ class _UserControlState extends State<UserControl> { ...@@ -94,23 +237,32 @@ class _UserControlState extends State<UserControl> {
), ),
const SizedBox(width: 30), const SizedBox(width: 30),
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment:
mainAxisAlignment: MainAxisAlignment.spaceEvenly, CrossAxisAlignment
.start,
mainAxisAlignment:
MainAxisAlignment
.spaceEvenly,
children: [ children: [
// ===============nama pic============= // ===============nama pic=============
Row( Row(
children: [ children: [
Icon( Icon(
Icons.drive_file_rename_outline, Icons
color: Colors.grey[500], .drive_file_rename_outline,
size: screenSize.width * 0.01, color: Colors
.grey[500],
size: screenSize
.width *
0.01,
), ),
const SizedBox( const SizedBox(
width: 10, width: 10,
), ),
const Text( const Text(
"Nama PIC", "Nama PIC",
style: TextStyle(fontSize: 13), style: TextStyle(
fontSize: 13),
), ),
], ],
), ),
...@@ -121,19 +273,34 @@ class _UserControlState extends State<UserControl> { ...@@ -121,19 +273,34 @@ class _UserControlState extends State<UserControl> {
children: [ children: [
SizedBox( SizedBox(
height: 60, height: 60,
width: screenSize.width * 0.2, width: screenSize
child: TextFormField( .width *
controller: namePICController, 0.2,
textAlign: TextAlign.start, child:
decoration: InputDecoration( TextFormField(
labelText: "Nama PIC", controller:
labelStyle: TextStyle(fontSize: 13), namePICController,
border: OutlineInputBorder( textAlign:
TextAlign
.start,
decoration:
InputDecoration(
labelText:
"Nama PIC",
labelStyle: TextStyle(
fontSize:
13),
border:
OutlineInputBorder(
borderRadius: borderRadius:
BorderRadius.circular(5.0), BorderRadius.circular(5.0),
)), )),
validator: (value) { validator:
if (value == null || value.isEmpty) { (value) {
if (value ==
null ||
value
.isEmpty) {
return "Nama PIC tidak boleh kosong"; return "Nama PIC tidak boleh kosong";
} }
return null; return null;
...@@ -150,23 +317,32 @@ class _UserControlState extends State<UserControl> { ...@@ -150,23 +317,32 @@ class _UserControlState extends State<UserControl> {
Row( Row(
children: [ children: [
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment:
mainAxisAlignment: MainAxisAlignment.spaceEvenly, CrossAxisAlignment
.start,
mainAxisAlignment:
MainAxisAlignment
.spaceEvenly,
children: [ children: [
// ===============alamat rs========== // ===============alamat rs==========
Row( Row(
children: [ children: [
Icon( Icon(
Icons.add_home_work_sharp, Icons
color: Colors.grey[500], .add_home_work_sharp,
size: screenSize.width * 0.01, color: Colors
.grey[500],
size: screenSize
.width *
0.01,
), ),
const SizedBox( const SizedBox(
width: 10, width: 10,
), ),
const Text( const Text(
"Alamat Rumah Sakit", "Alamat Rumah Sakit",
style: TextStyle(fontSize: 13), style: TextStyle(
fontSize: 13),
), ),
], ],
), ),
...@@ -177,21 +353,37 @@ class _UserControlState extends State<UserControl> { ...@@ -177,21 +353,37 @@ class _UserControlState extends State<UserControl> {
children: [ children: [
SizedBox( SizedBox(
height: 60, height: 60,
width: screenSize.width * 0.2, width: screenSize
child: TextFormField( .width *
controller: addressRSController, 0.2,
textAlign: TextAlign.start, child:
validator: (value) { TextFormField(
if (value == null || value.isEmpty) { controller:
addressRSController,
textAlign:
TextAlign
.start,
validator:
(value) {
if (value ==
null ||
value
.isEmpty) {
return "Nomor Alamat Rumah Sakit tidak boleh kosong"; return "Nomor Alamat Rumah Sakit tidak boleh kosong";
} }
return null; return null;
}, },
decoration: InputDecoration( decoration:
labelText: "Nomor Alamat Rumah Sakit", InputDecoration(
labelStyle: TextStyle(fontSize: 13), labelText:
hintStyle: const TextStyle(), "Nomor Alamat Rumah Sakit",
border: OutlineInputBorder( labelStyle: TextStyle(
fontSize:
13),
hintStyle:
const TextStyle(),
border:
OutlineInputBorder(
borderRadius: borderRadius:
BorderRadius.circular(5.0), BorderRadius.circular(5.0),
)), )),
...@@ -206,23 +398,32 @@ class _UserControlState extends State<UserControl> { ...@@ -206,23 +398,32 @@ class _UserControlState extends State<UserControl> {
width: 30, width: 30,
), ),
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment:
mainAxisAlignment: MainAxisAlignment.spaceEvenly, CrossAxisAlignment
.start,
mainAxisAlignment:
MainAxisAlignment
.spaceEvenly,
children: [ children: [
// ===============email pic========== // ===============email pic==========
Row( Row(
children: [ children: [
Icon( Icon(
Icons.email_outlined, Icons
color: Colors.grey[500], .email_outlined,
size: screenSize.width * 0.01, color: Colors
.grey[500],
size: screenSize
.width *
0.01,
), ),
const SizedBox( const SizedBox(
width: 10, width: 10,
), ),
const Text( const Text(
"Email PIC", "Email PIC",
style: TextStyle(fontSize: 13), style: TextStyle(
fontSize: 13),
), ),
], ],
), ),
...@@ -233,21 +434,37 @@ class _UserControlState extends State<UserControl> { ...@@ -233,21 +434,37 @@ class _UserControlState extends State<UserControl> {
children: [ children: [
SizedBox( SizedBox(
height: 60, height: 60,
width: screenSize.width * 0.2, width: screenSize
child: TextFormField( .width *
controller: emailPICController, 0.2,
textAlign: TextAlign.start, child:
validator: (value) { TextFormField(
if (value == null || value.isEmpty) { controller:
emailPICController,
textAlign:
TextAlign
.start,
validator:
(value) {
if (value ==
null ||
value
.isEmpty) {
return "Email PIC tidak boleh kosong"; return "Email PIC tidak boleh kosong";
} }
return null; return null;
}, },
decoration: InputDecoration( decoration:
labelText: "Email PIC", InputDecoration(
labelStyle: TextStyle(fontSize: 13), labelText:
hintStyle: const TextStyle(), "Email PIC",
border: OutlineInputBorder( labelStyle: TextStyle(
fontSize:
13),
hintStyle:
const TextStyle(),
border:
OutlineInputBorder(
borderRadius: borderRadius:
BorderRadius.circular(5.0), BorderRadius.circular(5.0),
)), )),
...@@ -263,23 +480,31 @@ class _UserControlState extends State<UserControl> { ...@@ -263,23 +480,31 @@ class _UserControlState extends State<UserControl> {
Row( Row(
children: [ children: [
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment:
mainAxisAlignment: MainAxisAlignment.spaceEvenly, CrossAxisAlignment
.start,
mainAxisAlignment:
MainAxisAlignment
.spaceEvenly,
children: [ children: [
// ===============telepon rs========== // ===============telepon rs==========
Row( Row(
children: [ children: [
Icon( Icon(
Icons.phone_android, Icons.phone_android,
color: Colors.grey[500], color: Colors
size: screenSize.width * 0.01, .grey[500],
size: screenSize
.width *
0.01,
), ),
const SizedBox( const SizedBox(
width: 10, width: 10,
), ),
const Text( const Text(
"No Telepon Rumah Sakit", "No Telepon Rumah Sakit",
style: TextStyle(fontSize: 13), style: TextStyle(
fontSize: 13),
), ),
], ],
), ),
...@@ -290,21 +515,37 @@ class _UserControlState extends State<UserControl> { ...@@ -290,21 +515,37 @@ class _UserControlState extends State<UserControl> {
children: [ children: [
SizedBox( SizedBox(
height: 60, height: 60,
width: screenSize.width * 0.2, width: screenSize
child: TextFormField( .width *
controller: phoneRSController, 0.2,
textAlign: TextAlign.start, child:
validator: (value) { TextFormField(
if (value == null || value.isEmpty) { controller:
phoneRSController,
textAlign:
TextAlign
.start,
validator:
(value) {
if (value ==
null ||
value
.isEmpty) {
return "Nomor Telepon Rumah Sakit tidak boleh kosong"; return "Nomor Telepon Rumah Sakit tidak boleh kosong";
} }
return null; return null;
}, },
decoration: InputDecoration( decoration:
labelText: "Nomor Telepon Rumah Sakit", InputDecoration(
labelStyle: TextStyle(fontSize: 13), labelText:
hintStyle: const TextStyle(), "Nomor Telepon Rumah Sakit",
border: OutlineInputBorder( labelStyle: TextStyle(
fontSize:
13),
hintStyle:
const TextStyle(),
border:
OutlineInputBorder(
borderRadius: borderRadius:
BorderRadius.circular(5.0), BorderRadius.circular(5.0),
)), )),
...@@ -319,23 +560,31 @@ class _UserControlState extends State<UserControl> { ...@@ -319,23 +560,31 @@ class _UserControlState extends State<UserControl> {
width: 30, width: 30,
), ),
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment:
mainAxisAlignment: MainAxisAlignment.spaceEvenly, CrossAxisAlignment
.start,
mainAxisAlignment:
MainAxisAlignment
.spaceEvenly,
children: [ children: [
// ===============telepon pic========== // ===============telepon pic==========
Row( Row(
children: [ children: [
Icon( Icon(
Icons.phone_android, Icons.phone_android,
color: Colors.grey[500], color: Colors
size: screenSize.width * 0.01, .grey[500],
size: screenSize
.width *
0.01,
), ),
const SizedBox( const SizedBox(
width: 10, width: 10,
), ),
const Text( const Text(
"No Telepon PIC", "No Telepon PIC",
style: TextStyle(fontSize: 13), style: TextStyle(
fontSize: 13),
), ),
], ],
), ),
...@@ -346,21 +595,37 @@ class _UserControlState extends State<UserControl> { ...@@ -346,21 +595,37 @@ class _UserControlState extends State<UserControl> {
children: [ children: [
SizedBox( SizedBox(
height: 60, height: 60,
width: screenSize.width * 0.2, width: screenSize
child: TextFormField( .width *
controller: phonePICController, 0.2,
textAlign: TextAlign.start, child:
validator: (value) { TextFormField(
if (value == null || value.isEmpty) { controller:
phonePICController,
textAlign:
TextAlign
.start,
validator:
(value) {
if (value ==
null ||
value
.isEmpty) {
return "Nomor Telepon PIC tidak boleh kosong"; return "Nomor Telepon PIC tidak boleh kosong";
} }
return null; return null;
}, },
decoration: InputDecoration( decoration:
labelText: "Nomor Telepon PIC", InputDecoration(
labelStyle: TextStyle(fontSize: 13), labelText:
hintStyle: const TextStyle(), "Nomor Telepon PIC",
border: OutlineInputBorder( labelStyle: TextStyle(
fontSize:
13),
hintStyle:
const TextStyle(),
border:
OutlineInputBorder(
borderRadius: borderRadius:
BorderRadius.circular(5.0), BorderRadius.circular(5.0),
)), )),
...@@ -387,90 +652,6 @@ class _UserControlState extends State<UserControl> { ...@@ -387,90 +652,6 @@ class _UserControlState extends State<UserControl> {
}); });
} }
@override
Widget build(BuildContext context) {
var screenSize = MediaQuery.of(context).size;
return Padding(
padding: const EdgeInsets.all(30.0),
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 10),
decoration: BoxDecoration(
color: Colors.white60,
borderRadius: BorderRadius.circular(20),
boxShadow: [
BoxShadow(
color: const Color.fromARGB(255, 10, 116, 255).withAlpha(60),
blurRadius: 5.0,
spreadRadius: 5.0,
offset: const Offset(0.0, 3.0))
]),
child: Column(
children: [
Container(
height: screenSize.height * 0.15,
child: Center(
child: Text(
'Data User',
style: GoogleFonts.poppins(
height: 1.5,
fontSize: 31,
fontWeight: FontWeight.bold,
color: Colors.blueAccent[200]),
),
),
),
Container(
height: screenSize.height * 0.65,
child: ListView(
controller: ScrollController(),
children: [
FutureBuilder<List<dynamic>>(
future: getUserControl(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.hasError ||
snapshot.data == null ||
snapshot.connectionState ==
ConnectionState.waiting) {
return const CircularProgressIndicator();
}
return DataTable(
decoration:
const BoxDecoration(color: Colors.white),
columnSpacing: 55,
columns: const [
DataColumn(
label: Text(
"ID",
style: TextStyle(fontWeight: FontWeight.bold),
)),
DataColumn(
label: Text(
"Nama Rumah Sakit",
style: TextStyle(fontWeight: FontWeight.bold),
)),
// DataColumn(label: Text("Telp Rumah Sakit")),
DataColumn(
label: Text(
"Alamat Rumah Sakit",
style: TextStyle(fontWeight: FontWeight.bold),
)),
// DataColumn(label: Text("Nama PIC")),
// DataColumn(label: Text("Telp PIC")),
// DataColumn(label: Text("Email PIC")),
DataColumn(
label: Text(
"STATUS",
style: TextStyle(fontWeight: FontWeight.bold),
)),
DataColumn(
label: Text(
"ACTION",
style: TextStyle(fontWeight: FontWeight.bold),
))
],
rows: List.generate(snapshot.data.length, (index) {
var pgm = snapshot.data[index];
return DataRow(cells: [ return DataRow(cells: [
DataCell(Text(pgm['idUser'].toString())), DataCell(Text(pgm['idUser'].toString())),
DataCell(Text(pgm['namaRs'].toString())), DataCell(Text(pgm['namaRs'].toString())),
...@@ -492,7 +673,7 @@ class _UserControlState extends State<UserControl> { ...@@ -492,7 +673,7 @@ class _UserControlState extends State<UserControl> {
onSelected: (value) { onSelected: (value) {
if (value == 1) { if (value == 1) {
print("you choose Edit..."); print("you choose Edit...");
// viewUser(context); viewUser(context);
} else if (value == 2) { } else if (value == 2) {
print("you choose Delete..."); print("you choose Delete...");
} else if (value == 3) { } else if (value == 3) {
......
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