Commit c708746e authored by Fikri's avatar Fikri

mengubah design contact

parent e170bfe7
......@@ -80,225 +80,549 @@ class _Dashboard4State extends State<Dashboard4> {
controller: ScrollController(),
children: [
FutureBuilder<List<dynamic>>(
future: getcontact(),
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: 105,
columns: const [
DataColumn(label: Text("Date")),
DataColumn(label: Text("Name")),
DataColumn(label: Text("Number")),
DataColumn(label: Text("Email")),
DataColumn(label: Text("Action")),
],
rows: List.generate(
snapshot.data.length,
(index) {
var pgm = snapshot.data[index];
return DataRow(
cells: [
DataCell(
Text(pgm['dateContact']),
),
DataCell(
Text(pgm['namaContact']),
),
DataCell(
Text(pgm['noHp']),
),
DataCell(
Text(pgm['emailContact']),
),
DataCell(
Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
Column(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
TextButton(
style: TextButton.styleFrom(
padding:
const EdgeInsets.all(16.0),
primary: Colors.white,
backgroundColor: Color.fromARGB(
255, 15, 102, 223),
textStyle:
const TextStyle(fontSize: 15),
),
onPressed: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(
"Information",
style: GoogleFonts.poppins(
fontSize: 16,
fontWeight: FontWeight.bold,
future: getcontact(),
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(
"Date",
style: TextStyle(fontWeight: FontWeight.bold),
)),
DataColumn(
label: Text(
"Name",
style: TextStyle(fontWeight: FontWeight.bold),
)),
// DataColumn(label: Text("Telp Rumah Sakit")),
DataColumn(
label: Text(
"Number",
style: TextStyle(fontWeight: FontWeight.bold),
)),
// DataColumn(label: Text("Nama PIC")),
// DataColumn(label: Text("Telp PIC")),
// DataColumn(label: Text("Email PIC")),
DataColumn(
label: Text(
"Email",
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 dateController = TextEditingController()
..text = pgm['dateContact'].toString();
final nameController = TextEditingController(
text: pgm['namaContact'].toString());
final nohpController = TextEditingController(
text: pgm['noHp'].toString());
final emailController = TextEditingController(
text: pgm['emailContact'].toString());
final messageController = TextEditingController(
text: pgm['messageContact'].toString());
void viewUser(BuildContext context) {
var screenSize = MediaQuery.of(context).size;
showDialog(
context: context,
builder: (BuildContext context) {
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.50,
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",
style: TextStyle(
fontSize: 13))
],
),
),
content: Container(
height:
screenSize.height *
0.3,
width: screenSize.width *
0.33,
child: Column(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
crossAxisAlignment:
CrossAxisAlignment
.start,
const SizedBox(height: 5),
Row(
children: [
Text(
"Date : ${pgm['dateContact']}"),
Text(
"Nama : ${pgm['namaContact']}"),
Text(
"No.Telp : ${pgm['noHp']}"),
Text(
"Email : ${pgm['emailContact']}"),
Text(
"Message : ${pgm['messageContact']}"),
SizedBox(
height: 60,
width: screenSize
.width *
0.2,
child:
TextFormField(
controller:
nameController,
textAlign:
TextAlign
.start,
decoration: InputDecoration(
labelText:
"Nama",
labelStyle:
TextStyle(
fontSize:
13),
border: OutlineInputBorder(
borderRadius:
BorderRadius.circular(
5.0))),
readOnly: true,
validator:
(value) {
if (value ==
null ||
value
.isEmpty) {
return "Nama";
} else {
return null;
}
},
),
)
],
)
],
),
const SizedBox(width: 30),
Column(
crossAxisAlignment:
CrossAxisAlignment
.start,
mainAxisAlignment:
MainAxisAlignment
.spaceEvenly,
children: [
// ===============nama pic=============
Row(
children: [
Icon(
Icons
.calendar_month,
color: Colors
.grey[500],
size: screenSize
.width *
0.01,
),
const SizedBox(
width: 10,
),
const Text(
"Date",
style: TextStyle(
fontSize: 13),
),
],
),
),
actions: <Widget>[
TextButton(
style: TextButton
.styleFrom(
padding:
const EdgeInsets
.all(16.0),
primary: Colors.white,
backgroundColor:
Color.fromARGB(
255,
15,
102,
223),
textStyle:
const TextStyle(
fontSize: 15),
),
child:
const Text("Back"),
onPressed: () {
Navigator.pop(
context);
},
const SizedBox(
height: 5,
),
Row(
children: [
SizedBox(
height: 60,
width: screenSize
.width *
0.2,
child:
TextFormField(
controller:
dateController,
textAlign:
TextAlign
.start,
decoration:
InputDecoration(
labelText:
"date",
labelStyle: TextStyle(
fontSize:
13),
border:
OutlineInputBorder(
borderRadius:
BorderRadius.circular(5.0),
)),
readOnly: true,
validator:
(value) {
if (value ==
null ||
value
.isEmpty) {
return "Date";
}
return null;
},
),
)
],
),
// ===============akhir nama pic=============
],
);
},
);
},
child: const Text("View"),
),
],
),
SizedBox(
width: 3,
),
Column(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
TextButton(
style: TextButton.styleFrom(
padding:
const EdgeInsets.all(16.0),
primary: Colors.white,
backgroundColor:
const Color.fromARGB(
255, 245, 27, 27),
textStyle:
const TextStyle(fontSize: 15),
),
onPressed: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title:
const Text("Warning"),
content: Text(
"Are you sure want to delete data user ${pgm['namaContact']}?"),
actions: <Widget>[
TextButton(
child:
const Text("Yes"),
onPressed: () {
Navigator.pop(
context);
deleteContact(pgm[
'idContact'])
.then(
(isSuccess) {
if (isSuccess) {
setState(() {});
ScaffoldMessenger.of(this
.context)
.showSnackBar(
const SnackBar(
content:
Text("Delete data success")));
} else {
ScaffoldMessenger.of(this
.context)
.showSnackBar(
const SnackBar(
content:
Text("Delete data failed")));
}
});
},
)
],
),
Row(
children: [
Column(
crossAxisAlignment:
CrossAxisAlignment
.start,
mainAxisAlignment:
MainAxisAlignment
.spaceEvenly,
children: [
// ===============alamat rs==========
Row(
children: [
Icon(
Icons.email,
color: Colors
.grey[500],
size: screenSize
.width *
0.01,
),
const SizedBox(
width: 10,
),
const Text(
"Email",
style: TextStyle(
fontSize: 13),
),
],
),
TextButton(
child: const Text("No"),
onPressed: () {
Navigator.pop(
context);
},
const SizedBox(
height: 5,
),
Row(
children: [
SizedBox(
height: 60,
width: screenSize
.width *
0.2,
child:
TextFormField(
controller:
emailController,
textAlign:
TextAlign
.start,
readOnly: true,
validator:
(value) {
if (value ==
null ||
value
.isEmpty) {
return "Email";
}
return null;
},
decoration:
InputDecoration(
labelText:
"Email",
labelStyle: TextStyle(
fontSize:
13),
hintStyle:
const TextStyle(),
border:
OutlineInputBorder(
borderRadius:
BorderRadius.circular(5.0),
)),
),
)
],
),
// ===============akhir alamat rs==========
],
);
},
);
},
child: const Text("Delete"),
),
const SizedBox(
width: 30,
),
Column(
crossAxisAlignment:
CrossAxisAlignment
.start,
mainAxisAlignment:
MainAxisAlignment
.spaceEvenly,
children: [
// ===============email pic==========
Row(
children: [
Icon(
Icons.phone_android,
color: Colors
.grey[500],
size: screenSize
.width *
0.01,
),
const SizedBox(
width: 10,
),
const Text(
"No HP",
style: TextStyle(
fontSize: 13),
),
],
),
const SizedBox(
height: 5,
),
Row(
children: [
SizedBox(
height: 60,
width: screenSize
.width *
0.2,
child:
TextFormField(
controller:
nohpController,
textAlign:
TextAlign
.start,
readOnly: true,
validator:
(value) {
if (value ==
null ||
value
.isEmpty) {
return "No Hp";
}
return null;
},
decoration:
InputDecoration(
labelText:
"No Hp",
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: [
// ===============email pic==========
Row(
children: [
Icon(
Icons.message,
color: Colors
.grey[500],
size: screenSize
.width *
0.01,
),
const SizedBox(
width: 10,
),
const Text(
"Message",
style: TextStyle(
fontSize: 13),
),
],
),
const SizedBox(
height: 5,
),
Row(
children: [
Container(
height: 90,
width: screenSize
.width *
0.42,
child: Column(
crossAxisAlignment:
CrossAxisAlignment
.start,
mainAxisAlignment:
MainAxisAlignment
.spaceEvenly,
children: [
TextFormField(
keyboardType:
TextInputType
.multiline,
textInputAction:
TextInputAction
.newline,
minLines: 1,
maxLines: 5,
controller:
messageController,
textAlign:
TextAlign
.start,
readOnly:
true,
validator:
(value) {
if (value ==
null ||
value
.isEmpty) {
return "Message";
}
return null;
},
decoration:
InputDecoration(
labelText:
"Message",
labelStyle: TextStyle(
fontSize:
13),
hintStyle:
const TextStyle(),
border:
OutlineInputBorder(
borderRadius:
BorderRadius.circular(5.0),
)),
),
],
),
)
],
),
// ===============akhir email pic==========
],
),
],
),
],
),
)),
actions: [
MaterialButton(
child: Text("OK"),
onPressed: () {
Navigator.of(context).pop();
})
],
),
],
),
),
],
);
},
).toList(),
);
},
),
);
});
}
return DataRow(cells: [
DataCell(Text(pgm['dateContact'].toString())),
DataCell(Text(pgm['namaContact'].toString())),
DataCell(Text(pgm['noHp'].toString())),
DataCell(Text(pgm['emailContact'].toString())),
DataCell(PopupMenuButton(
icon: Icon(Icons.more_vert_outlined),
itemBuilder: (context) => [
PopupMenuItem(
child: Text("View"), value: 1),
PopupMenuItem(
child: Text("Delete"), value: 2),
],
onSelected: (value) {
if (value == 1) {
print("you choose View...");
viewUser(context);
} else if (value == 2) {
print("you choose Delete...");
viewUser(context);
}
},
))
]);
}).toList());
})
],
),
),
)
],
),
),
......
......@@ -687,12 +687,14 @@ class _UserControlState extends State<UserControl> {
}
},
))
]);
}).toList());
})
],
),
)
],
),
),
......
......@@ -128,6 +128,12 @@ class ContactUs2 extends StatelessWidget {
borderSide: BorderSide(width: 1, color: Colors.white),
),
),
validator: (value) {
if (value == null || value.isEmpty) {
return 'Name cannot be empty!!!';
}
return null;
},
),
),
const SizedBox(
......@@ -175,6 +181,12 @@ class ContactUs2 extends StatelessWidget {
BorderSide(width: 1, color: Colors.white),
),
),
validator: (value) {
if (value == null || value.isEmpty) {
return 'Phone cannot be empty!!!';
}
return null;
},
),
),
const SizedBox(
......@@ -199,6 +211,12 @@ class ContactUs2 extends StatelessWidget {
BorderSide(width: 1, color: Colors.white),
),
),
validator: (value) {
if (value == null || value.isEmpty) {
return 'Email cannot be empty!!!';
}
return null;
},
),
),
const SizedBox(
......@@ -237,7 +255,7 @@ class ContactUs2 extends StatelessWidget {
maxLines: 5,
validator: (value) {
if (value == null || value.isEmpty) {
return '*Required';
return 'Message cannot be empty!!!';
}
return null;
},
......
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