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
d607485f
Commit
d607485f
authored
Sep 13, 2022
by
Fikri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
menambahkan contact us untuk send email
parent
b13e7f74
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
4 deletions
+55
-4
contact_api.dart
lib/api/contact_api.dart
+2
-2
contact_us2.dart
lib/screen/contact_us/contact_us2.dart
+28
-1
small_contact_us2.dart
lib/screen_small/small_contact/small_contact_us2.dart
+25
-1
No files found.
lib/api/contact_api.dart
View file @
d607485f
...
@@ -5,7 +5,7 @@ import 'package:medapp_eksad/model/contact_model.dart';
...
@@ -5,7 +5,7 @@ import 'package:medapp_eksad/model/contact_model.dart';
Future
savecontact
(
nama
,
email
,
nohp
,
message
)
async
{
Future
savecontact
(
nama
,
email
,
nohp
,
message
)
async
{
final
response
=
await
http
.
post
(
final
response
=
await
http
.
post
(
Uri
.
parse
(
'http://10.107.
121.210
:8081/medapp/v1/api/contact/save'
),
Uri
.
parse
(
'http://10.107.
223.156
:8081/medapp/v1/api/contact/save'
),
body:
jsonEncode
({
body:
jsonEncode
({
"nama"
:
nama
,
"nama"
:
nama
,
"email"
:
email
,
"email"
:
email
,
...
@@ -24,7 +24,7 @@ Future savecontact(nama, email, nohp, message) async {
...
@@ -24,7 +24,7 @@ Future savecontact(nama, email, nohp, message) async {
Future
<
List
<
contact
>>
showcontact
()
async
{
Future
<
List
<
contact
>>
showcontact
()
async
{
var
response
=
await
http
var
response
=
await
http
.
get
(
Uri
.
parse
(
'http://10.
3.4.231
:8082/medapp/v1/api/contact/get'
));
.
get
(
Uri
.
parse
(
'http://10.
107.223.156
:8082/medapp/v1/api/contact/get'
));
var
resultJson
=
jsonDecode
(
response
.
body
)[
'data'
];
var
resultJson
=
jsonDecode
(
response
.
body
)[
'data'
];
List
<
contact
>
contactlist
=
await
resultJson
List
<
contact
>
contactlist
=
await
resultJson
.
map
<
contact
>((
json
)
=>
contact
.
fromJson
(
json
))
.
map
<
contact
>((
json
)
=>
contact
.
fromJson
(
json
))
...
...
lib/screen/contact_us/contact_us2.dart
View file @
d607485f
import
'dart:convert'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:google_fonts/google_fonts.dart'
;
import
'package:google_fonts/google_fonts.dart'
;
// import 'package:mcs_flutter/widget/botton.dart';
// import 'package:mcs_flutter/widget/botton.dart';
// import 'package:mcs_flutter/const/conts.dart';
// import 'package:mcs_flutter/const/conts.dart';
import
'package:http/http.dart'
as
http
;
import
'package:medapp_eksad/api/contact_api.dart'
;
import
'package:medapp_eksad/api/contact_api.dart'
;
import
'package:medapp_eksad/widget/button_color.dart'
;
import
'package:medapp_eksad/widget/button_color.dart'
;
...
@@ -250,7 +253,7 @@ class ContactUs2 extends StatelessWidget {
...
@@ -250,7 +253,7 @@ class ContactUs2 extends StatelessWidget {
style:
Btn_Submit
(),
style:
Btn_Submit
(),
onPressed:
()
async
{
onPressed:
()
async
{
if
(
_formKey
.
currentState
!.
validate
())
{
if
(
_formKey
.
currentState
!.
validate
())
{
final
response
=
await
savecontact
(
final
response
=
await
SendEmail
(
nameController
.
value
.
text
,
nameController
.
value
.
text
,
emailController
.
value
.
text
,
emailController
.
value
.
text
,
phoneController
.
value
.
text
,
phoneController
.
value
.
text
,
...
@@ -288,4 +291,28 @@ class ContactUs2 extends StatelessWidget {
...
@@ -288,4 +291,28 @@ class ContactUs2 extends StatelessWidget {
),
),
);
);
}
}
Future
SendEmail
(
String
name
,
String
phone
,
String
email
,
String
message
)
async
{
final
url
=
Uri
.
parse
(
'https://api.emailjs.com/api/v1.0/email/send'
);
const
serviceId
=
'service_7wwup8c'
;
const
templateId
=
'template_4u8rbur'
;
const
userId
=
'bzSFpP9flgDHE1D8dDLOP'
;
final
response
=
await
http
.
post
(
url
,
headers:
{
'Content-Type'
:
'application/json'
},
//This line makes sure it works for all platforms.
body:
json
.
encode
({
'service_id'
:
serviceId
,
'template_id'
:
templateId
,
'user_id'
:
userId
,
'template_params'
:
{
'from_name'
:
name
,
'from_phone'
:
phone
,
'to_email'
:
email
,
'message'
:
message
}
}));
return
response
.
statusCode
;
}
}
}
lib/screen_small/small_contact/small_contact_us2.dart
View file @
d607485f
...
@@ -234,7 +234,7 @@ class _ContactUs2_smallState extends State<ContactUs2_small> {
...
@@ -234,7 +234,7 @@ class _ContactUs2_smallState extends State<ContactUs2_small> {
style:
Btn_Submit
(),
style:
Btn_Submit
(),
onPressed:
()
async
{
onPressed:
()
async
{
if
(
_formKey
.
currentState
!.
validate
())
{
if
(
_formKey
.
currentState
!.
validate
())
{
final
response
=
await
savecontact
(
final
response
=
await
SendEmail
(
nameController
.
value
.
text
,
nameController
.
value
.
text
,
emailController
.
value
.
text
,
emailController
.
value
.
text
,
phoneController
.
value
.
text
,
phoneController
.
value
.
text
,
...
@@ -268,6 +268,30 @@ class _ContactUs2_smallState extends State<ContactUs2_small> {
...
@@ -268,6 +268,30 @@ class _ContactUs2_smallState extends State<ContactUs2_small> {
),
),
);
);
}
}
Future
SendEmail
(
String
name
,
String
phone
,
String
email
,
String
message
)
async
{
final
url
=
Uri
.
parse
(
'https://api.emailjs.com/api/v1.0/email/send'
);
const
serviceId
=
'service_7wwup8c'
;
const
templateId
=
'template_4u8rbur'
;
const
userId
=
'bzSFpP9flgDHE1D8dDLOP'
;
final
response
=
await
http
.
post
(
url
,
headers:
{
'Content-Type'
:
'application/json'
},
//This line makes sure it works for all platforms.
body:
json
.
encode
({
'service_id'
:
serviceId
,
'template_id'
:
templateId
,
'user_id'
:
userId
,
'template_params'
:
{
'from_name'
:
name
,
'from_phone'
:
phone
,
'to_email'
:
email
,
'message'
:
message
}
}));
return
response
.
statusCode
;
}
}
}
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