Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
medapp_eksad
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
qorri_di
medapp_eksad
Commits
8c93b59a
Commit
8c93b59a
authored
Sep 14, 2022
by
Fikri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
menambahkan get api pada halaman dashboard contact us
parent
580c14bb
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
162 additions
and
130 deletions
+162
-130
contact_api.dart
lib/api/contact_api.dart
+5
-9
admin_contact.dart
lib/dashboard/admin/admin_contact.dart
+156
-117
login.dart
lib/login.dart
+1
-4
No files found.
lib/api/contact_api.dart
View file @
8c93b59a
...
...
@@ -6,6 +6,11 @@ import 'package:medapp_eksad/model/contact_model.dart';
var
cmd
=
'https://dmsdev-api.eksad.com/gateway/medapp/v1/cmd'
;
var
qry
=
'https://dmsdev-api.eksad.com/gateway/medapp/v1/qry'
;
Future
<
List
<
dynamic
>>
getcontact
()
async
{
var
response
=
await
http
.
get
(
Uri
.
parse
(
'
$qry
/contact/get'
));
return
jsonDecode
(
response
.
body
)[
'data'
];
}
Future
<
bool
>
savecontact
(
nama
,
email
,
nohp
,
message
)
async
{
final
response
=
await
http
.
post
(
Uri
.
parse
(
'
$cmd
/contact/save'
),
...
...
@@ -25,12 +30,3 @@ Future<bool> savecontact(nama, email, nohp, message) async {
// return response.statusCode;
}
Future
<
List
<
contact
>>
showcontact
()
async
{
var
response
=
await
http
.
get
(
Uri
.
parse
(
'
$qry
/contact/get'
));
var
resultJson
=
jsonDecode
(
response
.
body
)[
'data'
];
List
<
contact
>
contactlist
=
await
resultJson
.
map
<
contact
>((
json
)
=>
contact
.
fromJson
(
json
))
.
toList
();
return
contactlist
;
}
\ No newline at end of file
lib/dashboard/admin/admin_contact.dart
View file @
8c93b59a
import
'package:flutter/material.dart'
;
import
'package:google_fonts/google_fonts.dart'
;
import
'package:medapp_eksad/api/contact_api.dart'
;
class
Dashboard4
extends
StatefulWidget
{
const
Dashboard4
({
Key
?
key
})
:
super
(
key:
key
);
...
...
@@ -9,45 +9,14 @@ class Dashboard4 extends StatefulWidget {
State
<
Dashboard4
>
createState
()
=>
_Dashboard4State
();
}
class
MessageUser
{
String
date
;
String
name
;
String
email
;
String
message
;
String
number
;
MessageUser
(
this
.
date
,
this
.
name
,
this
.
email
,
this
.
message
,
this
.
number
);
}
class
_Dashboard4State
extends
State
<
Dashboard4
>
{
List
<
MessageUser
>
ListMessage
=
<
MessageUser
>[
MessageUser
(
"1"
,
"Jay"
,
'email'
,
'message'
,
'number'
),
MessageUser
(
'2'
,
'Rizky'
,
'email'
,
'message'
,
'nomer'
),
MessageUser
(
'1'
,
"Arham"
,
'email'
,
'message'
,
'number'
),
MessageUser
(
'2'
,
'Faid'
,
'email'
,
'message'
,
'nomer'
),
MessageUser
(
'1'
,
"Bagas"
,
'email'
,
'message'
,
'number'
),
MessageUser
(
'2'
,
'Fikri'
,
'email'
,
'message'
,
'nomer'
),
MessageUser
(
'1'
,
"Budi"
,
'email'
,
'message'
,
'number'
),
MessageUser
(
'2'
,
'Fahrur'
,
'email'
,
'message'
,
'nomer'
),
];
@override
void
initState
()
{
super
.
initState
();
}
refreshList
()
{
setState
(()
{
ListMessage
=
ListMessage
;
});
}
final
formKey
=
GlobalKey
<
FormState
>();
int
id
=
0
;
String
name
=
''
;
String
email
=
''
;
String
massage
=
''
;
String
number
=
''
;
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -61,8 +30,7 @@ class _Dashboard4State extends State<Dashboard4> {
borderRadius:
BorderRadius
.
circular
(
20
),
boxShadow:
[
BoxShadow
(
color:
const
Color
.
fromARGB
(
255
,
10
,
116
,
255
)
.
withAlpha
(
60
),
color:
const
Color
.
fromARGB
(
255
,
10
,
116
,
255
).
withAlpha
(
60
),
blurRadius:
5.0
,
spreadRadius:
5.0
,
offset:
const
Offset
(
...
...
@@ -75,90 +43,161 @@ class _Dashboard4State extends State<Dashboard4> {
children:
[
Container
(
height:
screenSize
.
height
*
0.15
,
child:
Center
(
child:
Text
(
'Data Messages from User'
,
style:
GoogleFonts
.
poppins
(
child:
Text
(
'Data Messages from User'
,
style:
GoogleFonts
.
poppins
(
height:
1.5
,
fontSize:
31
,
fontWeight:
FontWeight
.
bold
,
color:
Colors
.
blueAccent
[
200
]),
),
color:
Colors
.
blueAccent
[
200
]
),
),
),
),
// Container(
// height: screenSize.height * 0.63,
// width: screenSize.width * 0.95,
// decoration:
// BoxDecoration(borderRadius: BorderRadius.circular(40)),
// //color: Colors.white,
// child: PaginatedDataTable(
// rowsPerPage: 5,
// // header :Text("Data Message User"),
// columnSpacing: 150,
// columns: [
// DataColumn(label: Text("ID")),
// DataColumn(label: Text("Name")),
// DataColumn(label: Text("Email")),
// DataColumn(label: Text("Message")),
// DataColumn(label: Text("Number")),
// ], source: ,
// ),
// ),
Container
(
// height: screenSize.height*0.63,
width:
screenSize
.
width
*
0.95
,
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
40
)),
//color: Colors.white,
child:
PaginatedDataTable
(
rowsPerPage:
5
,
// header :Text("Data Message User"),
columnSpacing:
150
,
columns:
[
DataColumn
(
label:
Text
(
"Date"
),),
DataColumn
(
label:
Text
(
"Name"
),),
DataColumn
(
label:
Text
(
"Email"
),),
DataColumn
(
label:
Text
(
"Message"
),),
DataColumn
(
label:
Text
(
"Number"
),),
],
source
:
UserDataTableSource
(
userData:
ListMessage
)),
)
height:
screenSize
.
height
*
0.65
,
child:
ListView
(
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
(
"ID"
)),
DataColumn
(
label:
Text
(
"Date"
)),
DataColumn
(
label:
Text
(
"Name"
)),
DataColumn
(
label:
Text
(
"Email"
)),
DataColumn
(
label:
Text
(
"Message"
)),
DataColumn
(
label:
Text
(
"Number"
)),
],
rows:
List
.
generate
(
snapshot
.
data
.
length
,
(
index
)
{
var
pgm
=
snapshot
.
data
[
index
];
return
DataRow
(
cells:
[
DataCell
(
Text
(
pgm
[
'idContact'
].
toString
()),
),
DataCell
(
Text
(
pgm
[
'namaContact'
]),
),
DataCell
(
Text
(
pgm
[
'dateContact'
]),
),
DataCell
(
Text
(
pgm
[
'emailContact'
]),
),
DataCell
(
Text
(
pgm
[
'messageContact'
]),
),
DataCell
(
Text
(
pgm
[
'noHp'
]),
),
// DataCell(
// Row(
// 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 page ${pgm['title']}?"),
// actions: <Widget>[
// TextButton(
// child: const Text("Yes"),
// onPressed: () {
// Navigator.pop(context);
// deletePage(pgm['idpage'])
// .then((isSuccess) {
// if (isSuccess) {
// setState(() {});
// Scaffold.of(
// this.context)
// .showSnackBar(
// const SnackBar(
// content: Text(
// "Delete data success")));
// } else {
// Scaffold.of(
// this.context)
// .showSnackBar(
// const SnackBar(
// content: Text(
// "Delete data failed")));
// }
// });
// },
// ),
// TextButton(
// child: const Text("No"),
// onPressed: () {
// Navigator.pop(context);
// },
// ),
// ],
// );
// },
// );
// },
// child: const Text("Delete"),
// ),
// ],
// ),
// ),
],
);
},
).
toList
(),
);
},
),
],
),
),
}
}
class
UserDataTableSource
extends
DataTableSource
{
UserDataTableSource
({
required
List
<
MessageUser
>
userData
,
})
:
_userData
=
userData
,
assert
(
userData
!=
null
);
final
List
<
MessageUser
>
_userData
;
@override
DataRow
?
getRow
(
int
index
)
{
assert
(
index
>=
0
);
if
(
index
>=
_userData
.
length
)
{
return
null
;
}
final
_user
=
_userData
[
index
];
return
DataRow
.
byIndex
(
index:
index
,
cells:
<
DataCell
>[
DataCell
(
Text
(
'
${_user.date}
'
)),
DataCell
(
Text
(
'
${_user.name}
'
)),
DataCell
(
Text
(
'
${_user.email}
'
)),
DataCell
(
Text
(
'
${_user.message}
'
)),
DataCell
(
Text
(
'
${_user.number}
'
)),
],
),
),
);
}
@override
bool
get
isRowCountApproximate
=>
false
;
@override
int
get
rowCount
=>
_userData
.
length
;
@override
int
get
selectedRowCount
=>
0
;
void
sort
<
T
>(
Comparable
<
T
>
Function
(
MessageUser
d
)
getField
,
bool
ascending
)
{
_userData
.
sort
((
a
,
b
)
{
final
aValue
=
getField
(
a
);
final
bValue
=
getField
(
b
);
return
ascending
?
Comparable
.
compare
(
aValue
,
bValue
)
:
Comparable
.
compare
(
bValue
,
aValue
);
});
notifyListeners
();
}
}
lib/login.dart
View file @
8c93b59a
...
...
@@ -259,10 +259,7 @@ class _SignInState extends State<SignIn> {
);
}
else
if
(
_usernamecontroller
.
value
.
text
==
'admin@admin.com'
&&
_passwordcontroller
.
value
.
text
==
'administrator'
)
{
Navigator
.
pushNamed
(
context
,
'/admin'
);
}
else
if
(
_usernamecontroller
.
value
.
text
==
'client@client.com'
&&
_passwordcontroller
.
value
.
text
==
'clientpage'
)
{
Navigator
.
pushNamed
(
context
,
'/client'
);
Navigator
.
pushNamed
(
context
,
'/dashboard'
);
}
else
{
showDialog
<
String
>(
context:
context
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment