Commit d65976f2 authored by Budi Prasetyo's avatar Budi Prasetyo
parents 34fbd5f8 697b8c40
......@@ -19,6 +19,7 @@ Future savecontact(nama, email, nohp, message) async {
// } else {
// return false;
// }
return response.statusCode;
}
Future<List<contact>> showcontact() async {
......
import 'dart:convert';
import 'package:http/http.dart' as http;
Future<bool> signup(nama, email, nohp, username, password)async{
final response = await http.post(
Uri.parse('http://10.3.4.250:8081/medapp/v1/api/user/save'),
body: jsonEncode({
"namaUser": nama,
"emailUser": email,
"noHp": nohp,
"username": username,
"password": password}),
headers: {
'Content-type' : 'application/json; charset=UTF-8',
}
);
if (response.statusCode == 200) {
return true;
} else {
return false;
}
// return response.statusCode;
}
\ No newline at end of file
import 'package:flutter/material.dart';
import 'package:medapp_eksad/api/user_api.dart';
class Register extends StatefulWidget {
const Register({Key? key}) : super(key: key);
......@@ -10,6 +11,15 @@ class Register extends StatefulWidget {
class _RegisterState extends State<Register> {
bool _isObscure = true;
final _formKey = GlobalKey<FormState>();
final nameController = TextEditingController();
final emailController = TextEditingController();
final phoneController = TextEditingController();
final usernameController = TextEditingController();
final pwController = TextEditingController();
@override
Widget build(BuildContext context) {
var screenize = MediaQuery.of(context).size;
......@@ -17,7 +27,7 @@ class _RegisterState extends State<Register> {
body: Container(
height: screenize.height,
width: screenize.width,
decoration: BoxDecoration(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/register.jpg"),
fit: BoxFit.fill,
......@@ -32,7 +42,7 @@ class _RegisterState extends State<Register> {
children: [
Container(
decoration: BoxDecoration(
color: Color.fromARGB(255, 10, 116, 255),
color: const Color.fromARGB(255, 10, 116, 255),
borderRadius: BorderRadius.circular(20),
),
width: screenize.width * 0.36,
......@@ -54,27 +64,28 @@ class _RegisterState extends State<Register> {
borderRadius: BorderRadius.circular(20),
border: Border.all(
width: 5,
color: Color.fromARGB(255, 10, 116, 255),
color: const Color.fromARGB(255, 10, 116, 255),
),
boxShadow: [
BoxShadow(
color: Color.fromARGB(255, 10, 116, 255).withAlpha(60),
color: const Color.fromARGB(255, 10, 116, 255).withAlpha(60),
blurRadius: 15.0,
spreadRadius: 20.0,
offset: Offset(
offset: const Offset(
0.0,
3.0,
),
),],
),
child: Form(
key: _formKey,
child: Container(
padding: EdgeInsets.only(
left: screenize.width * 0.045,
top: screenize.height * 0.05
top: screenize.height * 0.02
),
width: screenize.width * 0.36,
height: screenize.height * 0.9,
height: screenize.height * 0.8,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
......@@ -85,7 +96,7 @@ class _RegisterState extends State<Register> {
height: screenize.width * 0.02,
child: Image.asset("assets/logo/medapp-logo.png"),
),
SizedBox(height: 20,),
const SizedBox(height: 20,),
Row(
children: [
Icon(
......@@ -93,34 +104,34 @@ class _RegisterState extends State<Register> {
color: Colors.grey[500],
size: screenize.width * 0.01,
),
SizedBox(
const SizedBox(
width: 10,
),
Text("Nama"),
const Text("Nama"),
],
),
SizedBox(height: 5,),
const SizedBox(height: 5,),
Row(
children: [
Container(
SizedBox(
height: 40,
width: screenize.width * 0.2,
child: TextFormField(
controller: nameController,
textAlign: TextAlign.start,
decoration: InputDecoration(
labelText: "Nama Lengkap",
hintStyle: TextStyle(),
hintStyle: const TextStyle(),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5.0),
)
),
onChanged: null,
),
)
],
),
SizedBox(height: 10,),
const SizedBox(height: 10,),
Row(
children: [
Icon(
......@@ -128,34 +139,34 @@ class _RegisterState extends State<Register> {
color: Colors.grey[500],
size: screenize.width * 0.01,
),
SizedBox(
const SizedBox(
width: 10,
),
Text("Email"),
const Text("Email"),
],
),
SizedBox(height: 5,),
const SizedBox(height: 5,),
Row(
children: [
Container(
SizedBox(
height: 40,
width: screenize.width * 0.2,
child: TextFormField(
controller: emailController,
textAlign: TextAlign.start,
decoration: InputDecoration(
labelText: "Email Valid",
hintStyle: TextStyle(),
hintStyle: const TextStyle(),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5.0),
)
),
onChanged: null,
),
)
],
),
SizedBox(height: 10,),
const SizedBox(height: 10,),
Row(
children: [
Icon(
......@@ -163,34 +174,33 @@ class _RegisterState extends State<Register> {
color: Colors.grey[500],
size: screenize.width * 0.01,
),
SizedBox(
const SizedBox(
width: 10,
),
Text("No Hp"),
const Text("No Hp"),
],
),
SizedBox(height: 5,),
const SizedBox(height: 5,),
Row(
children: [
Container(
SizedBox(
height: 40,
width: screenize.width * 0.2,
child: TextFormField(
controller: phoneController,
textAlign: TextAlign.start,
decoration: InputDecoration(
labelText: "Nomor Handphone",
hintStyle: TextStyle(),
hintStyle: const TextStyle(),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5.0),
)
),
onChanged: null,
),
)
],
),
SizedBox(height: 10,),
const SizedBox(height: 10,),
Row(
children: [
Icon(
......@@ -198,17 +208,53 @@ class _RegisterState extends State<Register> {
color: Colors.grey[500],
size: screenize.width * 0.01,
),
const SizedBox(
width: 10,
),
const Text("Username"),
],
),
const SizedBox(height: 5,),
Row(
children: [
SizedBox(
height: 40,
width: screenize.width * 0.2,
child: TextFormField(
controller: usernameController,
textAlign: TextAlign.start,
decoration: InputDecoration(
labelText: "Username",
hintStyle: const TextStyle(),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5.0),
)
),
),
)
],
),
const SizedBox(height: 10,),
Row(
children: [
Icon(
Icons.email_outlined,
color: Colors.grey[500],
size: screenize.width * 0.01,
),
const SizedBox(
width: 10,
),
Text("Username"),
const Text("Password"),
],
),
SizedBox(height: 5,),
Container(
const SizedBox(height: 5,),
SizedBox(
height: 40,
width: screenize.width * 0.2,
child: TextFormField(
controller: pwController,
textAlign: TextAlign.start,
obscureText: _isObscure,
decoration: InputDecoration(
......@@ -224,43 +270,69 @@ class _RegisterState extends State<Register> {
});
},
),
hintStyle: TextStyle(),
hintStyle: const TextStyle(),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5.0)
),
),
),
),
Spacer(
const Spacer(
flex: 4,
),
Row(
children: [
Container(
SizedBox(
height: 30,
width: screenize.width * 0.09,
child: ElevatedButton(
onPressed: (){
},
child: Text("LOGIN"),
child: const Text("LOGIN"),
),
),
SizedBox(
width: screenize.width * 0.02,
),
Container(
SizedBox(
height: 30,
width: screenize.width * 0.09,
child: ElevatedButton(
onPressed: (){
onPressed: ()async{
if (_formKey.currentState!.validate()){
final response = await signup(
nameController.value.text,
emailController.value.text,
phoneController.value.text,
usernameController.value.text,
pwController.value.text);
ScaffoldMessenger.of(context).showSnackBar(
response == true
? const SnackBar(
content: Text("Registrasi berhasil ! cek email untuk validasi"),
backgroundColor: Colors.green,)
: const SnackBar(
content: Text("Registrasi gagal"),
backgroundColor: Colors.red,)
);
print(
nameController.value.text+ emailController.value.text+phoneController.value.text+usernameController.value.text+pwController.value.text
);
nameController.clear();
emailController.clear();
phoneController.clear();
usernameController.clear();
pwController.clear();
}
},
child: Text("REGISTER"),
child: const Text("REGISTER"),
),
)
],
),
Spacer(
const Spacer(
flex: 7,
)
],
......
......@@ -249,7 +249,6 @@ class _ContactUs2_smallState extends State<ContactUs2_small> {
Text('Failed to send message!'),
backgroundColor: Colors.red),
);
nameController.clear();
phoneController.clear();
emailController.clear();
......
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