Fakultas Ilmu Komputer UI

Commit 719e66ac authored by Usman Sidiq's avatar Usman Sidiq
Browse files

[CHORES] fix conflict

parents 083d08e0 a2da6e68
Pipeline #41898 passed with stages
in 51 minutes and 11 seconds
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"google_maps_flutter","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_maps_flutter-0.5.24+1\\\\","dependencies":[]},{"name":"location","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location-2.5.3\\\\","dependencies":[]},{"name":"path_provider","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.5\\\\","dependencies":[]},{"name":"sqflite","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.3.0\\\\","dependencies":[]}],"android":[{"name":"flutter_plugin_android_lifecycle","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_plugin_android_lifecycle-1.0.6\\\\","dependencies":[]},{"name":"google_maps_flutter","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_maps_flutter-0.5.24+1\\\\","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"location","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location-2.5.3\\\\","dependencies":[]},{"name":"path_provider","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.5\\\\","dependencies":[]},{"name":"sqflite","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.3.0\\\\","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_macos-0.0.4\\\\","dependencies":[]},{"name":"sqflite","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.3.0\\\\","dependencies":[]}],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"google_maps_flutter","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"location","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos"]},{"name":"path_provider_macos","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2020-04-20 14:48:37.594917","version":"1.15.17"}
\ No newline at end of file
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"google_maps_flutter","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_maps_flutter-0.5.24+1\\\\","dependencies":[]},{"name":"location","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location-2.5.3\\\\","dependencies":[]},{"name":"path_provider","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.5\\\\","dependencies":[]},{"name":"sqflite","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.3.0\\\\","dependencies":[]}],"android":[{"name":"flutter_plugin_android_lifecycle","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_plugin_android_lifecycle-1.0.6\\\\","dependencies":[]},{"name":"google_maps_flutter","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_maps_flutter-0.5.24+1\\\\","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"location","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location-2.5.3\\\\","dependencies":[]},{"name":"path_provider","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.5\\\\","dependencies":[]},{"name":"sqflite","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.3.0\\\\","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_macos-0.0.4\\\\","dependencies":[]},{"name":"sqflite","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.3.0\\\\","dependencies":[]}],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"google_maps_flutter","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"location","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos"]},{"name":"path_provider_macos","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2020-04-20 14:48:37.594917","version":"1.15.17"}
......@@ -79,7 +79,7 @@ class BisaGoDrawer extends StatelessWidget {
),
),
onTap: () {
Navigator.pop(context);
Navigator.pushNamed(context, '/login');
},
),
decoration: BoxDecoration(
......
import 'package:flutter/material.dart';
import 'package:ppl_disabilitas/app.dart';
import 'flavor/flavor.dart';
import 'page/login/landing.dart';
void main() {
ApiFlavor.flavor = BuildFlavor.production.toString();
......
import 'package:json_annotation/json_annotation.dart';
part 'pengguna.g.dart';
@JsonSerializable()
class UserListResponse {
List<User> listUser;
UserListResponse();
factory UserListResponse.fromJson(Map<String, dynamic> json) => _$UserListResponseFromJson(json);
Map<String, dynamic> toJson() => _$UserListResponseToJson(this);
}
@JsonSerializable(nullable: true)
class User {
String username;
String phonenumber;
String email;
String password;
User();
factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(json);
Map<String, dynamic> toJson() => _$UserToJson(this);
}
\ No newline at end of file
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'pengguna.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
UserListResponse _$UserListResponseFromJson(Map<String, dynamic> json) {
return UserListResponse()
..listUser = (json['listUser'] as List)
?.map(
(e) => e == null ? null : User.fromJson(e as Map<String, dynamic>))
?.toList();
}
Map<String, dynamic> _$UserListResponseToJson(UserListResponse instance) =>
<String, dynamic>{
'listUser': instance.listUser,
};
User _$UserFromJson(Map<String, dynamic> json) {
return User()
..username = json['username'] as String
..phonenumber = json['phonenumber'] as String
..email = json['email'] as String
..password = json['password'] as String;
}
Map<String, dynamic> _$UserToJson(User instance) => <String, dynamic>{
'username': instance.username,
'phonenumber': instance.phonenumber,
'email': instance.email,
'password': instance.password,
};
import 'dart:convert';
class User {
String username;
String phonenumber;
String email;
String password;
User({this.username, this.phonenumber, this.email, this.password});
factory User.fromJson(Map<String, dynamic> map) {
return User(
username: map["username"], phonenumber: map["phonenumber"], email: map["email"], password: map["password"]);
}
Map<String, dynamic> toJson() {
return {"username": username, "phonenumber": phonenumber, "email": email, "password": password};
}
@override
String toString() {
return 'User{"username": $username, "phonenumber": $phonenumber, "email": $email, "password": $password}';
}
}
List<User> userFromJson(String jsonData) {
final data = json.decode(jsonData);
return List<User>.from(data.map((item) => User.fromJson(item)));
}
String userToJson(User data) {
final jsonData = data.toJson();
return json.encode(jsonData);
}
\ No newline at end of file
import 'package:flutter/material.dart';
import 'package:ppl_disabilitas/page/login/login.dart';
import 'package:ppl_disabilitas/page/registrasi/registrasi.dart';
import 'package:ppl_disabilitas/utils/customButton.dart';
class Landing extends StatelessWidget {
const Landing({Key key}) : super(key: key);
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Color(0xff3A903A),
),
backgroundColor: Color(0xff3A903A),
body: Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Container(
margin: EdgeInsets.fromLTRB(20, 30, 20, 10),
alignment: Alignment.center,
child: ButtonTheme(
minWidth: double.infinity,
height: 60,
child: RaisedButton(
color: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: new BorderRadius.all(Radius.circular(10)),
),
child: Text(
'Masuk',
style: TextStyle(fontSize: 25, color: Color(0xff3A903A), fontWeight: FontWeight.bold),
),
onPressed: () => _navigateToLogin(context),
),
)
),
Container(
child: separator('ATAU', 20, 0xffFFFFFF, 2, 0xffFFFFFF),
),
Container(
margin: EdgeInsets.fromLTRB(20, 10, 20, 30),
alignment: Alignment.center,
child: ButtonTheme(
minWidth: double.infinity,
height: 60,
child: RaisedButton(
color: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: new BorderRadius.all(Radius.circular(10)),
),
child: Text(
'Daftar',
style: TextStyle(fontSize: 25, color: Color(0xff3A903A), fontWeight: FontWeight.bold),
),
onPressed: () => _navigateToRegistrasi(context),
),
)
),
],
),
),
);
}
void _navigateToLogin(BuildContext context) {
final route = MaterialPageRoute(builder: (_) => Login());
Navigator.of(context).push(route);
}
void _navigateToRegistrasi(BuildContext context) {
final route = MaterialPageRoute(builder: (_) => Registrasi());
Navigator.of(context).push(route);
}
}
\ No newline at end of file
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:ppl_disabilitas/config/styles.dart';
import 'package:ppl_disabilitas/utils/customButton.dart';
import 'package:ppl_disabilitas/utils/customTextField.dart';
import 'package:ppl_disabilitas/utils/validator.dart';
import 'package:http/http.dart' as http;
class Login extends StatefulWidget{
......@@ -13,15 +13,43 @@ class Login extends StatefulWidget{
class LoginState extends State<Login> {
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
String _accountCredential;
String _password;
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('bisaGO'),
elevation: 15,
centerTitle: true,
backgroundColor: Color(0xff3A903A),
backgroundColor: greenPrimary,
title: Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Padding(padding: EdgeInsets.all(doubleSpace),
child: Text(
"bisaGo",
style: TextStyle(
fontSize: 25,
fontFamily: 'Comfortaa',
fontWeight: FontWeight.w800),
),
)
],
),
actions: <Widget>[
Padding(
padding: EdgeInsets.all(doubleSpace),
child: InkWell(
child: Text(
'Daftar',
style: TextStyle(fontSize: 15),
),
onTap: () {
Navigator.pushNamed(context, '/register');
},
),
)
],
),
body: SingleChildScrollView(
child: Form(
......@@ -45,19 +73,15 @@ class LoginState extends State<Login> {
CustomTextField(
title: 'Nomor Telepon atau Email',
key: Key('Text Field Akun'),
onSaved: (input) {
_accountCredential = input;
},
validator: FieldValidator.validateEmail,
controller: emailController,
),
CustomTextField(
title: 'Password',
key: Key('Text Field Password'),
obsecure: true,
onSaved: (input) {
_password = input;
},
validator: FieldValidator.validatePassword,
controller: passwordController,
),
Container(
margin: EdgeInsets.fromLTRB(0, 30, 0, 10),
......@@ -91,6 +115,26 @@ class LoginState extends State<Login> {
final FormState form = _formKey.currentState;
if(_formKey.currentState.validate()) {
form.save();
login(emailController.text, passwordController.text);
}
}
TextEditingController emailController = TextEditingController();
TextEditingController passwordController = TextEditingController();
login(String email, String password) async {
Map data = {
'email' : email,
'password' : password
};
// var jsonData;
var response = await http.post('https://my.api.mockaroo.com/register.json?key=095ee610', body: data);
if(response.statusCode == 200) {
// jsonData = json.decode(response.body);
await Navigator.pushNamed(context, '/');
}
else {
print(response.body);
}
}
}
\ No newline at end of file
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:ppl_disabilitas/config/styles.dart';
import 'package:ppl_disabilitas/utils/customButton.dart';
import 'package:ppl_disabilitas/utils/customTextField.dart';
//import 'package:ppl_disabilitas/network/network_interface.dart';
import 'package:ppl_disabilitas/model/user.dart';
import 'package:ppl_disabilitas/utils/validator.dart';
import 'package:http/http.dart' as http;
class Registrasi extends StatefulWidget {
RegistrasiState createState() => RegistrasiState();
......@@ -15,9 +18,38 @@ class RegistrasiState extends State<Registrasi> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('bisaGO'),
elevation: 15,
centerTitle: true,
backgroundColor: Color(0xff3A903A),
backgroundColor: greenPrimary,
title: Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Padding(padding: EdgeInsets.all(doubleSpace),
child: Text(
"bisaGo",
style: TextStyle(
fontSize: 25,
fontFamily: 'Comfortaa',
fontWeight: FontWeight.w800),
),
)
],
),
actions: <Widget>[
Padding(
padding: EdgeInsets.all(doubleSpace),
child: InkWell(
child: Text(
'Login',
style: TextStyle(fontSize: 15),
),
onTap: () {
Navigator.pop(context);
},
),
)
],
),
body: SingleChildScrollView(
child: Form(
......@@ -41,26 +73,38 @@ class RegistrasiState extends State<Registrasi> {
CustomTextField(
title: 'Nama Lengkap',
key: Key('Text Field Nama'),
validator: (input) => input.isEmpty ? "*Wajib diisi" : null,
validator: FieldValidator.validateName,
controller: nameController,
),
CustomTextField(
title: 'Nomor Telepon',
key: Key('Text Field Nomor Telepon'),
validator: (input) => input.isEmpty ? "*Wajib diisi" : null,
validator: FieldValidator.validatePhoneNumber,
controller: phoneController,
),
CustomTextField(
title: 'Email (Opsional)',
title: 'Email',
key: Key('Text Field Email'),
controller: emailController,
validator: FieldValidator.validateEmail,
),
CustomTextField(
title: 'Password',
key: Key('Text Field Password'),
validator: (input) => input.isEmpty ? "*Wajib diisi" : null,
obsecure: true,
validator: FieldValidator.validatePassword,
controller: passwordController,
),
CustomTextField(
title: 'Konfirmasi Password',
key: Key('Text Field Konfirmasi Password'),
validator: (input) => input.isEmpty ? "*Wajib diisi" : null,
obsecure: true,
validator: (input) {
if (input != passwordController.text) {
return '*Password tidak sesuai. Coba lagi';
}
return null;
},
),
Container(
margin: EdgeInsets.fromLTRB(0, 30, 0, 10),
......@@ -88,10 +132,53 @@ class RegistrasiState extends State<Registrasi> {
),
);
}
void _validateLoginInput() async {
final FormState form = _formKey.currentState;
if (_formKey.currentState.validate()) {
form.save();
User user = User(
username: nameController.text.toString(),
phonenumber: phoneController.text.toString(),
email: emailController.text.toString(),
password: passwordController.text.toString()
);
await createUser(user);
}
}
}
\ No newline at end of file
TextEditingController nameController = TextEditingController();
TextEditingController phoneController = TextEditingController();
TextEditingController emailController = TextEditingController();
TextEditingController passwordController = TextEditingController();
// static Future<bool> register(User data) async {
// final response = await http.post(
// 'https://my.api.mockaroo.com/register.json?key=095ee610&__method=POST',
// body: data);
// if (response.statusCode == 200) {
// return true;
// }
// else {
// return false;
// }
// }
// var response = NetworkInterface().post(
// url: 'https://my.api.mockaroo.com/register.json?key=095ee610',
// bodyParams: data,
// isLogin: false
// );
}
Future<bool> createUser(User data) async {
final response = await http.post(
"https://my.api.mockaroo.com/register.json?key=095ee610&__method=POST",
headers: {"content-type": "application/json"},
body: userToJson(data),
);
if (response.statusCode == 200) {
return true;
} else {
return false;
}
}
......@@ -11,7 +11,7 @@ Color fillColor, Color textColor, void function()) {
elevation: 0.0,
color: fillColor,
shape: RoundedRectangleBorder(
borderRadius: new BorderRadius.all(Radius.circular(10)),
borderRadius: BorderRadius.all(Radius.circular(10)),
),
child: Text(
text,
......@@ -71,36 +71,30 @@ Widget googleButton() {
],
color: Colors.white,
),
child: Row(
child: Stack(
children: <Widget>[
Expanded(
flex: 1,
child: Container(
padding: EdgeInsets.all(15),
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(10),
topLeft: Radius.circular(10)),
),
alignment: Alignment.center,
child: Image(
image: NetworkImage('https://upload.wikimedia.org/wikipedia/commons/thumb/5/53/Google_%22G%22_Logo.svg/512px-Google_%22G%22_Logo.svg.png'),
),
Container(
padding: EdgeInsets.all(15),
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(10),
topLeft: Radius.circular(10)),
),
child: Image(
image: AssetImage('assets/logo/google.png'),
width: 20.0,
),
),
Expanded(
flex: 6,
child: Container(
padding: EdgeInsets.symmetric(vertical: 15),
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
bottomRight: Radius.circular(10),
topRight: Radius.circular(10)),
),
alignment: Alignment.center,
child: Text('Akun Google',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold)
),
Container(
padding: EdgeInsets.symmetric(vertical: 15),
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
bottomRight: Radius.circular(10),
topRight: Radius.circular(10)),
),
alignment: Alignment.center,
child: Text('Akun Google',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold)
),
),
],
......
......@@ -8,6 +8,7 @@ class CustomTextField extends StatelessWidget {
this.obsecure = false,
this.key,
this.validator,
this.controller,
this.onSaved});
final String title;
final Key key;
......@@ -15,10 +16,10 @@ class CustomTextField extends StatelessWidget {
final String hint;
final bool obsecure;
final FormFieldValidator<String> validator;
final TextEditingController controller;
@override
Widget build(BuildContext context) {
key: key;
return Container(
margin: EdgeInsets.symmetric(vertical: 10),
child: Column(
......@@ -34,6 +35,7 @@ class CustomTextField extends StatelessWidget {
TextFormField(
onSaved: onSaved,
validator: validator,
controller: controller,
autofocus: true,
obscureText: obsecure,
style: TextStyle(
......
......@@ -2,19 +2,43 @@ class FieldValidator {
static String validateEmail(String value) {
Pattern pattern =
r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$';
RegExp regex = new RegExp(pattern);
RegExp regex = RegExp(pattern);
if (value.isEmpty) return '*Wajib diisi';
if (!regex.hasMatch(value))
if (!regex.hasMatch(value)) {
return '*Masukkan email yang valid';
else
} else {
return null;
}
}
static String validatePassword(String value) {
if (value.isEmpty) return '*Wajib diisi';
if (value.length < 7) return '*Password harus lebih dari 6 karakter';
else
if (value.length < 7) {
return '*Password harus lebih dari 6 karakter';
} else {
return null;
}
}
static String validatePhoneNumber(String value) {
String pattern = r'(^(?:[+0]9)?[0-9]{11,12}$)';
RegExp regExp = RegExp(pattern);
if (value.isEmpty) {
return '*Wajib diisi';
}
else if (!regExp.hasMatch(value)) {
return '*Masukkan nomor telepon yang valid';
}
return null;
}
static String validateName(String value) {
if (value.isEmpty) {
return '*Wajib diisi';
}