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