Commit 51056ab5 authored by Arham Aulia Nugraha's avatar Arham Aulia Nugraha
parents 85d2ba63 d65976f2
......@@ -3,7 +3,7 @@ import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:medapp_eksad/model/wa_model.dart';
Future<bool> savewa(nama, nohp) async {
Future<bool> saveWa(nama, nohp) async {
final response = await http.post(
Uri.parse('http://10.3.4.231:8081/medapp/v1/api/whatapps/save'),
body: jsonEncode({
......@@ -19,7 +19,7 @@ Future<bool> savewa(nama, nohp) async {
return false;
}
}
Future<List<dynamic>> showa() async {
Future<List<dynamic>> getWA () async {
var response = await http
.get(Uri.parse('http://10.3.4.231:8082/medapp/v1/api/whatapps/get'));
var resultJson = jsonDecode(response.body)['data'];
......
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:medapp_eksad/api/wa_api.dart';
class Dashboard3 extends StatefulWidget {
......@@ -40,8 +41,11 @@ class _Dashboard3State extends State<Dashboard3> {
ListWhatsapp=ListWhatsapp;
});
}
final TextEditingController phoneController = TextEditingController();
final TextEditingController nameController = TextEditingController();
final TextEditingController waController = TextEditingController();
final formKey = GlobalKey<FormState>();
String nameWa = '';
String whatsapp = '';
@override
Widget build(BuildContext context) {
......@@ -88,17 +92,47 @@ class _Dashboard3State extends State<Dashboard3> {
),
),
Form(
key: formKey,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
height: 48,
width: 120,
child: TextFormField(
controller: nameController,
//initialValue: '+62',
decoration: const InputDecoration(
labelText: "Enter a name",
hintText: 'Ex: Jaenudin',
fillColor: Colors.white,
filled: true,
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.zero,
borderSide:
BorderSide(width: 1, color: Colors.blue),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.zero,
borderSide:
BorderSide(width: 1, color: Colors.blue),
),
),
onChanged: (value) => nameWa = value,
),
),
SizedBox(width: 15,),
Container(
height: 48,
width: 250,
child: TextFormField(
controller: phoneController,
controller: waController,
//initialValue: '+62',
decoration: const InputDecoration(
hintText: "Enter a whatsapp number",
labelText: "Enter a whatsapp number",
hintText: 'Ex: 62xxxxxxxxxxx',
fillColor: Colors.white,
filled: true,
enabledBorder: OutlineInputBorder(
......@@ -112,6 +146,7 @@ class _Dashboard3State extends State<Dashboard3> {
BorderSide(width: 1, color: Colors.blue),
),
),
onChanged: (value) => whatsapp = value,
),
),
SizedBox(width: 15,),
......@@ -119,7 +154,33 @@ class _Dashboard3State extends State<Dashboard3> {
height : 45,
width : 175,
child: ElevatedButton(
onPressed: (){},
onPressed: (){
if(whatsapp.trim().isEmpty){
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Number Can\'t Be Empty')),
);
}else {
nameController.clear();
waController.clear();
saveWa(nameWa, whatsapp).then(
(isSuccess) {
if (isSuccess) {
setState(() {});
Scaffold.of(this.context).showSnackBar(
const SnackBar(
content: Text("Input Data success")));
} else {
Scaffold.of(this.context).showSnackBar(
const SnackBar(
content: Text("Input Data failed!!!")));
}
},
);
}
},
style: ElevatedButton.styleFrom(
primary: Colors.blueAccent[200],
onSurface: Colors.white,
......
......@@ -10,7 +10,7 @@ class WAChat extends StatelessWidget {
required String message,
}) async {
String url() {
return "https://api.whatsapp.com/send?phone=+62$phone&text=${Uri.parse(message)}";
return "https://api.whatsapp.com/send?phone=$phone&text=${Uri.parse(message)}";
}
if (await canLaunch(url())) {
......@@ -26,25 +26,17 @@ class WAChat extends StatelessWidget {
@override
Widget build(BuildContext context) {
return FloatingActionButton(
onPressed: () {
launchWhatsApp(
//phone: 81807890777,
phone: 87701892981,
message:
'Hallo, saya tertarik dan saya ingin tahu lebih lanjut tentang program Medapp by EKSAD');
},
backgroundColor: Colors.green,
child: GestureDetector(
onTap: () {
onPressed: (){
springController.play(
motion: Motion.reverse,
animDuration: const Duration(milliseconds: 1000),
curve: Curves.easeInBack,
delay: const Duration(milliseconds: 100));
launchWhatsApp(
phone: 6281807890777,
phone: 6287701892981,
message:
'Hallo, saya tertarik dengan produk EKSAD dan saya ingin tahu lebih lanjut tentang program Protalent');
'Hallo, saya tertarik dan saya ingin tahu lebih lanjut tentang program Medapp dari EKSAD');
},
child: Spring.rotate(
endAngle: 360 * 10,
......@@ -52,9 +44,9 @@ class WAChat extends StatelessWidget {
springController: springController,
alignment: Alignment.center,
animStatus: (AnimStatus status) {},
child: const Icon(Icons.whatsapp, size: 30),
),
child: const Icon(Icons.whatsapp, size: 40,color: Colors.white,),
),
);
}
}
//phone: 81807890777,
\ No newline at end of file
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