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

retrieve data on Action="View" in Data User

parent a99c1728
......@@ -11,382 +11,22 @@ class UserControl extends StatefulWidget {
}
class _UserControlState extends State<UserControl> {
final formKey = GlobalKey<FormState>();
final nameRSController = TextEditingController();
final phoneRSController = TextEditingController();
final addressRSController = TextEditingController();
final namePICController = TextEditingController();
final phonePICController = TextEditingController();
final addressPICController = TextEditingController();
final emailPICController = TextEditingController();
final passwordController = TextEditingController();
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();
}
void viewUser(BuildContext context) {
var screenSize = MediaQuery.of(context).size;
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
// title: Text("Alert!!!"),
// content: Text("Your are awesome!"),
content: Form(
child: Container(
padding: EdgeInsets.only(
left: screenSize.width * 0.045,
top: screenSize.height * 0.01),
width: screenSize.width * 0.50,
height: screenSize.height * 0.55,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
const Spacer(),
Container(
padding: EdgeInsets.only(left: screenSize.width * 0.15),
height: screenSize.width * 0.03,
child: Image.asset("assets/logo/medapp-logo.png"),
),
const SizedBox(height: 20),
Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Row(
children: [
Icon(Icons.drive_file_rename_outline,
color: Colors.grey[500],
size: screenSize.width * 0.01),
const SizedBox(width: 10),
const Text("Nama Rumah Sakit",
style: TextStyle(fontSize: 13))
],
),
const SizedBox(height: 5),
Row(
children: [
SizedBox(
height: 60,
width: screenSize.width * 0.2,
child: TextFormField(
controller: nameRSController,
textAlign: TextAlign.start,
decoration: InputDecoration(
labelText: "Nama Rumah Sakit",
labelStyle: TextStyle(fontSize: 13),
border: OutlineInputBorder(
borderRadius:
BorderRadius.circular(5.0))),
validator: (value) {
if (value == null || value.isEmpty) {
return "Nama Rumah Sakit tidak boleh kosong";
} else {
return null;
}
},
),
)
],
)
],
),
const SizedBox(width: 30),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
// ===============nama pic=============
Row(
children: [
Icon(
Icons.drive_file_rename_outline,
color: Colors.grey[500],
size: screenSize.width * 0.01,
),
const SizedBox(
width: 10,
),
const Text(
"Nama PIC",
style: TextStyle(fontSize: 13),
),
],
),
const SizedBox(
height: 5,
),
Row(
children: [
SizedBox(
height: 60,
width: screenSize.width * 0.2,
child: TextFormField(
controller: namePICController,
textAlign: TextAlign.start,
decoration: InputDecoration(
labelText: "Nama PIC",
labelStyle: TextStyle(fontSize: 13),
border: OutlineInputBorder(
borderRadius:
BorderRadius.circular(5.0),
)),
validator: (value) {
if (value == null || value.isEmpty) {
return "Nama PIC tidak boleh kosong";
}
return null;
},
),
)
],
),
// ===============akhir nama pic=============
],
)
],
),
Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
// ===============alamat rs==========
Row(
children: [
Icon(
Icons.add_home_work_sharp,
color: Colors.grey[500],
size: screenSize.width * 0.01,
),
const SizedBox(
width: 10,
),
const Text(
"Alamat Rumah Sakit",
style: TextStyle(fontSize: 13),
),
],
),
const SizedBox(
height: 5,
),
Row(
children: [
SizedBox(
height: 60,
width: screenSize.width * 0.2,
child: TextFormField(
controller: addressRSController,
textAlign: TextAlign.start,
validator: (value) {
if (value == null || value.isEmpty) {
return "Nomor Alamat Rumah Sakit tidak boleh kosong";
}
return null;
},
decoration: InputDecoration(
labelText: "Nomor Alamat Rumah Sakit",
labelStyle: TextStyle(fontSize: 13),
hintStyle: const TextStyle(),
border: OutlineInputBorder(
borderRadius:
BorderRadius.circular(5.0),
)),
),
)
],
),
// ===============akhir alamat rs==========
],
),
const SizedBox(
width: 30,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
// ===============email pic==========
Row(
children: [
Icon(
Icons.email_outlined,
color: Colors.grey[500],
size: screenSize.width * 0.01,
),
const SizedBox(
width: 10,
),
const Text(
"Email PIC",
style: TextStyle(fontSize: 13),
),
],
),
const SizedBox(
height: 5,
),
Row(
children: [
SizedBox(
height: 60,
width: screenSize.width * 0.2,
child: TextFormField(
controller: emailPICController,
textAlign: TextAlign.start,
validator: (value) {
if (value == null || value.isEmpty) {
return "Email PIC tidak boleh kosong";
}
return null;
},
decoration: InputDecoration(
labelText: "Email PIC",
labelStyle: TextStyle(fontSize: 13),
hintStyle: const TextStyle(),
border: OutlineInputBorder(
borderRadius:
BorderRadius.circular(5.0),
)),
),
)
],
),
// ===============akhir email pic==========
],
),
],
),
Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
// ===============telepon rs==========
Row(
children: [
Icon(
Icons.phone_android,
color: Colors.grey[500],
size: screenSize.width * 0.01,
),
const SizedBox(
width: 10,
),
const Text(
"No Telepon Rumah Sakit",
style: TextStyle(fontSize: 13),
),
],
),
const SizedBox(
height: 5,
),
Row(
children: [
SizedBox(
height: 60,
width: screenSize.width * 0.2,
child: TextFormField(
controller: phoneRSController,
textAlign: TextAlign.start,
validator: (value) {
if (value == null || value.isEmpty) {
return "Nomor Telepon Rumah Sakit tidak boleh kosong";
}
return null;
},
decoration: InputDecoration(
labelText: "Nomor Telepon Rumah Sakit",
labelStyle: TextStyle(fontSize: 13),
hintStyle: const TextStyle(),
border: OutlineInputBorder(
borderRadius:
BorderRadius.circular(5.0),
)),
),
)
],
),
// ===============akhir telepon rs==========
],
),
const SizedBox(
width: 30,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
// ===============telepon pic==========
Row(
children: [
Icon(
Icons.phone_android,
color: Colors.grey[500],
size: screenSize.width * 0.01,
),
const SizedBox(
width: 10,
),
const Text(
"No Telepon PIC",
style: TextStyle(fontSize: 13),
),
],
),
const SizedBox(
height: 5,
),
Row(
children: [
SizedBox(
height: 60,
width: screenSize.width * 0.2,
child: TextFormField(
controller: phonePICController,
textAlign: TextAlign.start,
validator: (value) {
if (value == null || value.isEmpty) {
return "Nomor Telepon PIC tidak boleh kosong";
}
return null;
},
decoration: InputDecoration(
labelText: "Nomor Telepon PIC",
labelStyle: TextStyle(fontSize: 13),
hintStyle: const TextStyle(),
border: OutlineInputBorder(
borderRadius:
BorderRadius.circular(5.0),
)),
),
)
],
),
// ===============akhir telepon pic==========
],
),
],
),
],
),
)),
actions: [
MaterialButton(
child: Text("OK"),
onPressed: () {
Navigator.of(context).pop();
})
],
);
return snapshot.data;
});
}
final formKey = GlobalKey<FormState>();
@override
Widget build(BuildContext context) {
var screenSize = MediaQuery.of(context).size;
......@@ -471,6 +111,547 @@ class _UserControlState extends State<UserControl> {
rows: List.generate(snapshot.data.length, (index) {
var pgm = snapshot.data[index];
final nameRSController = TextEditingController()
..text = pgm['namaRs'].toString();
final phoneRSController = TextEditingController();
final addressRSController =
TextEditingController();
final namePICController = TextEditingController();
final phonePICController =
TextEditingController();
final addressPICController =
TextEditingController();
final emailPICController =
TextEditingController();
final passwordController =
TextEditingController();
void viewUser(BuildContext context) {
var screenSize = MediaQuery.of(context).size;
showDialog(
context: 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(
content: Form(
child: Container(
padding: EdgeInsets.only(
left: screenSize.width * 0.045,
top: screenSize.height * 0.01),
width: screenSize.width * 0.50,
height: screenSize.height * 0.55,
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: [
const Spacer(),
Container(
padding: EdgeInsets.only(
left: screenSize.width *
0.15),
height: screenSize.width * 0.03,
child: Image.asset(
"assets/logo/medapp-logo.png"),
),
const SizedBox(height: 20),
Row(
children: [
Column(
crossAxisAlignment:
CrossAxisAlignment
.start,
mainAxisAlignment:
MainAxisAlignment
.spaceEvenly,
children: [
Row(
children: [
Icon(
Icons
.drive_file_rename_outline,
color: Colors
.grey[500],
size: screenSize
.width *
0.01),
const SizedBox(
width: 10),
const Text(
"Nama Rumah Sakit",
style: TextStyle(
fontSize: 13))
],
),
const SizedBox(height: 5),
Row(
children: [
SizedBox(
height: 60,
width: screenSize
.width *
0.2,
child:
TextFormField(
controller:
nameRSController,
textAlign:
TextAlign
.start,
decoration: InputDecoration(
labelText:
"Nama Rumah Sakit",
labelStyle:
TextStyle(
fontSize:
13),
border: OutlineInputBorder(
borderRadius:
BorderRadius.circular(
5.0))),
readOnly: true,
validator:
(value) {
if (value ==
null ||
value
.isEmpty) {
return "Nama Rumah Sakit tidak boleh kosong";
} else {
return null;
}
},
),
)
],
)
],
),
const SizedBox(width: 30),
Column(
crossAxisAlignment:
CrossAxisAlignment
.start,
mainAxisAlignment:
MainAxisAlignment
.spaceEvenly,
children: [
// ===============nama pic=============
Row(
children: [
Icon(
Icons
.drive_file_rename_outline,
color: Colors
.grey[500],
size: screenSize
.width *
0.01,
),
const SizedBox(
width: 10,
),
const Text(
"Nama PIC",
style: TextStyle(
fontSize: 13),
),
],
),
const SizedBox(
height: 5,
),
Row(
children: [
SizedBox(
height: 60,
width: screenSize
.width *
0.2,
child:
TextFormField(
controller:
namePICController,
textAlign:
TextAlign
.start,
decoration:
InputDecoration(
labelText:
"Nama PIC",
labelStyle: TextStyle(
fontSize:
13),
border:
OutlineInputBorder(
borderRadius:
BorderRadius.circular(5.0),
)),
validator:
(value) {
if (value ==
null ||
value
.isEmpty) {
return "Nama PIC tidak boleh kosong";
}
return null;
},
),
)
],
),
// ===============akhir nama pic=============
],
)
],
),
Row(
children: [
Column(
crossAxisAlignment:
CrossAxisAlignment
.start,
mainAxisAlignment:
MainAxisAlignment
.spaceEvenly,
children: [
// ===============alamat rs==========
Row(
children: [
Icon(
Icons
.add_home_work_sharp,
color: Colors
.grey[500],
size: screenSize
.width *
0.01,
),
const SizedBox(
width: 10,
),
const Text(
"Alamat Rumah Sakit",
style: TextStyle(
fontSize: 13),
),
],
),
const SizedBox(
height: 5,
),
Row(
children: [
SizedBox(
height: 60,
width: screenSize
.width *
0.2,
child:
TextFormField(
controller:
addressRSController,
textAlign:
TextAlign
.start,
validator:
(value) {
if (value ==
null ||
value
.isEmpty) {
return "Nomor Alamat Rumah Sakit tidak boleh kosong";
}
return null;
},
decoration:
InputDecoration(
labelText:
"Nomor Alamat Rumah Sakit",
labelStyle: TextStyle(
fontSize:
13),
hintStyle:
const TextStyle(),
border:
OutlineInputBorder(
borderRadius:
BorderRadius.circular(5.0),
)),
),
)
],
),
// ===============akhir alamat rs==========
],
),
const SizedBox(
width: 30,
),
Column(
crossAxisAlignment:
CrossAxisAlignment
.start,
mainAxisAlignment:
MainAxisAlignment
.spaceEvenly,
children: [
// ===============email pic==========
Row(
children: [
Icon(
Icons
.email_outlined,
color: Colors
.grey[500],
size: screenSize
.width *
0.01,
),
const SizedBox(
width: 10,
),
const Text(
"Email PIC",
style: TextStyle(
fontSize: 13),
),
],
),
const SizedBox(
height: 5,
),
Row(
children: [
SizedBox(
height: 60,
width: screenSize
.width *
0.2,
child:
TextFormField(
controller:
emailPICController,
textAlign:
TextAlign
.start,
validator:
(value) {
if (value ==
null ||
value
.isEmpty) {
return "Email PIC tidak boleh kosong";
}
return null;
},
decoration:
InputDecoration(
labelText:
"Email PIC",
labelStyle: TextStyle(
fontSize:
13),
hintStyle:
const TextStyle(),
border:
OutlineInputBorder(
borderRadius:
BorderRadius.circular(5.0),
)),
),
)
],
),
// ===============akhir email pic==========
],
),
],
),
Row(
children: [
Column(
crossAxisAlignment:
CrossAxisAlignment
.start,
mainAxisAlignment:
MainAxisAlignment
.spaceEvenly,
children: [
// ===============telepon rs==========
Row(
children: [
Icon(
Icons.phone_android,
color: Colors
.grey[500],
size: screenSize
.width *
0.01,
),
const SizedBox(
width: 10,
),
const Text(
"No Telepon Rumah Sakit",
style: TextStyle(
fontSize: 13),
),
],
),
const SizedBox(
height: 5,
),
Row(
children: [
SizedBox(
height: 60,
width: screenSize
.width *
0.2,
child:
TextFormField(
controller:
phoneRSController,
textAlign:
TextAlign
.start,
validator:
(value) {
if (value ==
null ||
value
.isEmpty) {
return "Nomor Telepon Rumah Sakit tidak boleh kosong";
}
return null;
},
decoration:
InputDecoration(
labelText:
"Nomor Telepon Rumah Sakit",
labelStyle: TextStyle(
fontSize:
13),
hintStyle:
const TextStyle(),
border:
OutlineInputBorder(
borderRadius:
BorderRadius.circular(5.0),
)),
),
)
],
),
// ===============akhir telepon rs==========
],
),
const SizedBox(
width: 30,
),
Column(
crossAxisAlignment:
CrossAxisAlignment
.start,
mainAxisAlignment:
MainAxisAlignment
.spaceEvenly,
children: [
// ===============telepon pic==========
Row(
children: [
Icon(
Icons.phone_android,
color: Colors
.grey[500],
size: screenSize
.width *
0.01,
),
const SizedBox(
width: 10,
),
const Text(
"No Telepon PIC",
style: TextStyle(
fontSize: 13),
),
],
),
const SizedBox(
height: 5,
),
Row(
children: [
SizedBox(
height: 60,
width: screenSize
.width *
0.2,
child:
TextFormField(
controller:
phonePICController,
textAlign:
TextAlign
.start,
validator:
(value) {
if (value ==
null ||
value
.isEmpty) {
return "Nomor Telepon PIC tidak boleh kosong";
}
return null;
},
decoration:
InputDecoration(
labelText:
"Nomor Telepon PIC",
labelStyle: TextStyle(
fontSize:
13),
hintStyle:
const TextStyle(),
border:
OutlineInputBorder(
borderRadius:
BorderRadius.circular(5.0),
)),
),
)
],
),
// ===============akhir telepon pic==========
],
),
],
),
],
),
)),
actions: [
MaterialButton(
child: Text("OK"),
onPressed: () {
Navigator.of(context).pop();
})
],
);
});
}
return DataRow(cells: [
DataCell(Text(pgm['idUser'].toString())),
DataCell(Text(pgm['namaRs'].toString())),
......@@ -492,7 +673,7 @@ class _UserControlState extends State<UserControl> {
onSelected: (value) {
if (value == 1) {
print("you choose Edit...");
// viewUser(context);
viewUser(context);
} else if (value == 2) {
print("you choose Delete...");
} 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