Commit bbd6fddd by art

update

parents 85b4b8fa 14002e85
import 'package:feelverapp/ui/nearme/near_me_list.dart';
import 'package:feelverapp/ui/login/login.dart';
import 'package:feelverapp/ui/shop/shop_main.dart';
import 'package:flutter/material.dart';
......
class LoginModel {
String token;
int expires;
User user;
LoginModel({this.token,
this.expires,
this.user
});
LoginModel.fromJson(Map<String, dynamic> json) {
token = json['token'];
expires = json['expires'];
user = json['user'] != null ? new User.fromJson(json['user']) : null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['token'] = this.token;
data['expires'] = this.expires;
if (this.user != null) {
data['user'] = this.user.toJson();
}
return data;
}
}
class User {
int id;
String roleId;
String name;
String email;
String avatar;
String emailVerifiedAt;
int status;
int fvRoleId;
String settings;
String createdAt;
String updatedAt;
String customerInfo;
User(
{this.id,
this.roleId,
this.name,
this.email,
this.avatar,
this.emailVerifiedAt,
this.status,
this.fvRoleId,
this.settings,
this.createdAt,
this.updatedAt,
this.customerInfo});
User.fromJson(Map<String, dynamic> json) {
id = json['id'];
roleId = json['role_id'];
name = json['name'];
email = json['email'];
avatar = json['avatar'];
emailVerifiedAt = json['email_verified_at'];
status = json['status'];
fvRoleId = json['fv_role_id'];
settings = json['settings'];
createdAt = json['created_at'];
updatedAt = json['updated_at'];
customerInfo = json['customer_info'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id']= this.id;
data['role_id']==null?[]: data['role_id'] = this.roleId;
data['name'] = this.name;
data['email'] = this.email;
data['avatar'] = this.avatar;
data['email_verified_at']==null?[]: data['email_verified_at'] = this.emailVerifiedAt;
data['status'] = this.status;
data['fv_role_id'] = this.fvRoleId;
data['settings']==null?[]: data['settings'] = this.settings;
data['created_at']==null?[]: data['created_at'] = this.createdAt;
data['updated_at']==null?[]: data['updated_at'] = this.updatedAt;
data['customer_info']==null?[]: data['customer_info'] = this.customerInfo;
return data;
}
}
\ No newline at end of file
class LoginModel {
String token;
int expires;
User user;
LoginModel({this.token,
this.expires,
this.user
});
LoginModel.fromJson(Map<String, dynamic> json) {
token = json['token'];
expires = json['expires'];
user = json['user'] != null ? new User.fromJson(json['user']) : null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['token'] = this.token;
data['expires'] = this.expires;
if (this.user != null) {
data['user'] = this.user.toJson();
}
return data;
}
}
class User {
int id;
String roleId;
String name;
String email;
String avatar;
String emailVerifiedAt;
int status;
int fvRoleId;
String settings;
String createdAt;
String updatedAt;
String customerInfo;
User(
{this.id,
this.roleId,
this.name,
this.email,
this.avatar,
this.emailVerifiedAt,
this.status,
this.fvRoleId,
this.settings,
this.createdAt,
this.updatedAt,
this.customerInfo});
User.fromJson(Map<String, dynamic> json) {
id = json['id'];
roleId = json['role_id'];
name = json['name'];
email = json['email'];
avatar = json['avatar'];
emailVerifiedAt = json['email_verified_at'];
status = json['status'];
fvRoleId = json['fv_role_id'];
settings = json['settings'];
createdAt = json['created_at'];
updatedAt = json['updated_at'];
customerInfo = json['customer_info'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id']= this.id;
data['role_id']==null?[]: data['role_id'] = this.roleId;
data['name'] = this.name;
data['email'] = this.email;
data['avatar'] = this.avatar;
data['email_verified_at']==null?[]: data['email_verified_at'] = this.emailVerifiedAt;
data['status'] = this.status;
data['fv_role_id'] = this.fvRoleId;
data['settings']==null?[]: data['settings'] = this.settings;
data['created_at']==null?[]: data['created_at'] = this.createdAt;
data['updated_at']==null?[]: data['updated_at'] = this.updatedAt;
data['customer_info']==null?[]: data['customer_info'] = this.customerInfo;
return data;
}
}
\ No newline at end of file
import 'package:json_annotation/json_annotation.dart';
part 'base.g.dart';
@JsonSerializable()
class BaseModel {
final bool status;
final String message;
BaseModel(this.status, this.message);
factory BaseModel.fromJson(Map<String, dynamic> json) => _$BaseModelFromJson(json);
Map<String, dynamic> toJson() => _$BaseModelToJson(this);
}
@JsonSerializable()
class FailModel {
final bool status;
final String message;
FailModel(this.status, this.message);
factory FailModel.fromJson(Map<String, dynamic> json) =>
_$FailModelFromJson(json);
Map<String, dynamic> toJson() => _$FailModelToJson(this);
}
\ No newline at end of file
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'base.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
BaseModel _$BaseModelFromJson(Map<String, dynamic> json) {
return BaseModel(
json['status'] as bool,
json['message'] as String,
);
}
Map<String, dynamic> _$BaseModelToJson(BaseModel instance) => <String, dynamic>{
'status': instance.status,
'message': instance.message,
};
FailModel _$FailModelFromJson(Map<String, dynamic> json) {
return FailModel(
json['status'] as bool,
json['message'] as String,
);
}
Map<String, dynamic> _$FailModelToJson(FailModel instance) => <String, dynamic>{
'status': instance.status,
'message': instance.message,
};
import 'package:feelverapp/service/MyAlert.dart';
import 'package:flutter/cupertino.dart';
class Alert {
final MyAlertType type;
final BuildContext context;
final String title;
final String message;
final Function onOK;
final Function onCancel;
final String okText;
final String cancelText;
Alert({
this.type = MyAlertType.normal,
@required this.context,
this.title,
@required this.message,
this.onOK,
this.onCancel,
this.okText, this.cancelText,
}){
showCupertinoModalPopup(context: this.context, builder: (context){
return MyAlert(
type: this.type,
title: this.title,
message: this.message,
onOK: this.onOK,
onCancel: this.onCancel,
okText: this.okText ,
cancelText: this.cancelText ,
);
});
}
}
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class LoadingView {
BuildContext context;
LoadingView(this.context);
show() {
showCupertinoModalPopup(
context: this.context,
builder: (context) => Container(
color: Colors.black87.withOpacity(0.3),
alignment: Alignment.center,
child: CircularProgressIndicator(
valueColor: new AlwaysStoppedAnimation<Color>(Colors.greenAccent),)
),
);
}
hide(){
Navigator.pop(context);
}
}
import 'package:feelverapp/util/SizeConfig.dart';
import 'package:flutter/material.dart';
enum MyAlertType {
normal,
confirm,
}
class MyAlert extends StatelessWidget {
final MyAlertType type;
final String title;
final String message;
final Function onOK;
final Function onCancel;
final String okText;
final String cancelText;
MyAlert({
@required this.title,
this.message,
this.type = MyAlertType.normal,
this.onOK,
this.onCancel, this.okText = 'ตกลง', this.cancelText = 'ยกเลิก',
});
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black.withOpacity(.4),
body: Center(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: SizeConfig.getPadding(24)),
child: AspectRatio(
aspectRatio: 4 / 3,
child: ClipRRect(
borderRadius: BorderRadius.circular(10),
child: Container(
color: Colors.white,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
_title(),
_message(),
_actionButton(context),
],
),
),
),
),
),
),
);
}
Widget _title() {
return Container(
padding: EdgeInsets.symmetric(
vertical: SizeConfig.getPadding(30),
horizontal: SizeConfig.getPadding(10),
),
child: Text(
'${this.title}',
style: TextStyle(
fontSize: SizeConfig.getFontSize(22),
fontWeight: FontWeight.bold,
),
),
);
}
Widget _message() {
return Expanded(
child: Container(
padding: EdgeInsets.symmetric(
horizontal: SizeConfig.getPadding(16),
),
child: SingleChildScrollView(
child: Text(
'${this.message}',
style: TextStyle(
fontSize: SizeConfig.getFontSize(18),
),
textAlign: TextAlign.center,
),
),
),
);
}
Widget _actionButton(BuildContext context) {
return Container(
padding: EdgeInsets.only(
// left: SizeConfig.getPadding(8),
// right: SizeConfig.getPadding(8),
// bottom: SizeConfig.getPadding(0),
),
child: Row(
children: <Widget>[
_okButton(context),
this.type != MyAlertType.normal
? _cancelButton(context)
: Container(),
],
),
);
}
Widget _okButton(BuildContext context) {
return Expanded(
child: Container(
padding: EdgeInsets.symmetric(
horizontal: SizeConfig.getPadding(16),
vertical: SizeConfig.getPadding(16)),
child: RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
padding: EdgeInsets.symmetric(vertical: SizeConfig.getPadding(8)),
onPressed: () {
Navigator.pop(context);
if (onOK != null) {
onOK();
}
},
color: Theme.of(context).primaryColor,
child: Text(
this.okText,
style: TextStyle(
color: Colors.white,
fontSize: SizeConfig.getFontSize(18),
),
),
),
),
);
}
Widget _cancelButton(BuildContext context) {
return Expanded(
child: Container(
padding: EdgeInsets.symmetric(
horizontal: SizeConfig.getPadding(16),
vertical: SizeConfig.getPadding(16)),
child: RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
padding: EdgeInsets.symmetric(vertical: SizeConfig.getPadding(8)),
onPressed: () {
Navigator.pop(context);
if (onCancel != null) {
onCancel();
}
},
color: Colors.grey[400],
child: Text(
this.cancelText,
style: TextStyle(
color: Colors.white,
fontSize: SizeConfig.getFontSize(18),
),
),
),
),
);
}
}
import 'dart:convert';
import 'package:feelverapp/model/Login/login_model.dart';
import 'package:feelverapp/model/base/base.dart';
import 'package:http/http.dart' as http;
class Api<T>{
final String _baseApi = "https://backend-uat.feelver.com/api";
final _headerApi = {
"Authorization": "Bearer {{ token }}",
};
Future<Response<T>> login(Object body) async {
var _model;
var _fail;
var result;
// (body as Map)['lang'] = allTranslations.currentLanguage;
await _httpConnection(
"${this._baseApi}/login", this._headerApi, body)
.then((response) {
print("ผลลัพ เท่ากับบบบ "+"${response.body}");
if (response.statusCode == 200 ) {
_model = LoginModel.fromJson(json.decode(response.body));
} else {
_fail = FailModel.fromJson(json.decode(response.body));
}
result = new Response<T>(_model, _fail);
});
return result;
}
///api environment
Future<http.Response> _httpConnection(
String url, Map<String, String> headers, Object body) async {
if (body != null) {
final response = headers != null
? http.post(Uri.encodeFull(url), headers: headers, body: body)
: http.post(Uri.encodeFull(url), body: body);
return response;
} else {
final response = headers != null
? http.get(Uri.encodeFull(url), headers: headers)
: http.get(Uri.encodeFull(url));
return response;
}
}
dynamic _jsonDecode(String json) {
var resJson = jsonDecode(json);
return resJson;
}
}
class Response<T> {
T success;
FailModel fail;
Response(this.success, this.fail);
}
import 'package:flutter/material.dart';
abstract class BasePre{
}
class BasePresenter<T extends StatefulWidget> {
State<T> state;
bool loader = true;
BasePresenter(this.state);
setState(Function v){
state.setState(v);
}
loading(){
setState((){
loader = true;
});
}
dispose() {
state = null;
}
loaded(){
setState((){
loader = false;
});
}
}
\ No newline at end of file
......@@ -105,7 +105,7 @@ class _HomePageState extends State<HomePage> {
'รถเข็นของฉัน',
style: TextStyle(
color: Colors.grey,
fontSize: SizeConfig.getFontSize(12),
fontSize: SizeConfig.getFontSize(11),
fontFamily: "SF_Pro_Text",
fontWeight: FontWeight.w700),
)
......
import 'package:feelverapp/ui/home/home.dart';
import 'package:feelverapp/ui/login/login_presenter.dart';
//import 'package:feelverapp/ui/login/login_presenter.dart';
import 'package:feelverapp/ui/register/register_email.dart';
import 'package:feelverapp/util/SizeConfig.dart';
import 'package:flutter/cupertino.dart';
......@@ -11,26 +14,41 @@ class LoginPage extends StatefulWidget {
class _LoginPageState extends State<LoginPage> with TickerProviderStateMixin {
TabController _tabController;
LoginPresenter presenter;
@override
void initState() {
// TODO: implement initState
super.initState();
presenter = LoginPresenter(this);
presenter.letSignIn();
_tabController = TabController(length: 2, vsync: this);
_tabController.addListener(_handleTabSelection);
// registerBloc = RegisterBloc(this);
// loginBloc = LoginBloc(this);
}
void _handleTabSelection() {
setState(() {});
}
@override
void dispose() {
super.dispose();
_tabController.dispose();
}
@override
Widget build(BuildContext context) {
SizeConfig(context);
return Scaffold(
body: _setupView(),
);
}
_setupView() {
return SingleChildScrollView(
return Container(
child: Column(
children: <Widget>[
Container(
......@@ -72,17 +90,39 @@ class _LoginPageState extends State<LoginPage> with TickerProviderStateMixin {
),
],
),
SizedBox(
height: SizeConfig.getHeight(30),
),
SizedBox(height: SizeConfig.getWidth(30)),
Expanded(
child: new Container(
// height: double.maxFinite,
child: new TabBarView(
controller: _tabController,
children: <Widget>[
_formLogin(),
_phoneLogin()
// Container(
// color: Colors.red,
// ),
// Container(
// color: Colors.green,
// ),
],
),
),
),
// _phoneLogin(),
],
),
);
}
Widget _formLogin() {
return Container(
print("index = " +"${_tabController.index}");
return SingleChildScrollView(
child: Form(
child: Column(
children: <Widget>[
......@@ -112,7 +152,7 @@ class _LoginPageState extends State<LoginPage> with TickerProviderStateMixin {
),
),
child: TextFormField(
// controller: loginBloc.emailCtrl,
controller: presenter.emailCtrl,
// validator: loginBloc.validateField,
decoration: InputDecoration(
contentPadding: EdgeInsets.symmetric(
......@@ -154,7 +194,118 @@ class _LoginPageState extends State<LoginPage> with TickerProviderStateMixin {
),
),
child: TextFormField(
// controller: loginBloc.passCtrl,
controller: presenter.passCtrl,
// validator: loginBloc.validateField,
decoration: InputDecoration(
contentPadding: EdgeInsets.symmetric(
vertical: SizeConfig.getPadding(20),
horizontal: SizeConfig.getPadding(16),
),
// hintText:
// allTranslations.text(key2: 'password', key: 'login'),
border: OutlineInputBorder(borderSide: BorderSide.none),
),
obscureText: true,
),
),
),
SizedBox(
height: SizeConfig.getWidth(24),
),
Container(
alignment: Alignment.topRight,
padding: EdgeInsets.only(right: SizeConfig.getPadding(30)),
child: Text(
'ลืมรหัสผ่าน',
style: TextStyle(
color: Color.fromRGBO(106, 179, 170, 1),
fontSize: SizeConfig.getFontSize(13),
fontFamily: "SF_Pro_Text",
fontWeight: FontWeight.w600),
),
),
_submitLoginButton(),
_policyText(),
SizedBox(
height: SizeConfig.getWidth(20),
),
_facebookLoginButton(),
],
),
),
);
}
Widget _phoneLogin() {
print("index = " +"${_tabController.index}");
return SingleChildScrollView(
child: Form(
child: Column(
children: <Widget>[
Container(
alignment: Alignment.topLeft,
padding: EdgeInsets.only(left: SizeConfig.getPadding(30)),
child: Text(
'เบอร์โทร',
style: TextStyle(
color: Colors.black,
fontSize: SizeConfig.getFontSize(20),
fontFamily: "SF_Pro_Text",
fontWeight: FontWeight.w500),
),
),
Padding(
padding: EdgeInsets.symmetric(
vertical: SizeConfig.getPadding(8.0),
horizontal: SizeConfig.getPadding(24),
),
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
SizeConfig.getPadding(50.0),
),
),
child: TextFormField(
controller: presenter.phonenumberCtrl,
// validator: loginBloc.validateField,
decoration: InputDecoration(
contentPadding: EdgeInsets.symmetric(
vertical: SizeConfig.getPadding(20),
horizontal: SizeConfig.getPadding(16),
),
// hintText:
// allTranslations.text(key2: 'email', key: 'login') +
// ' / ' +
// allTranslations.text(
// key2: 'tel_number', key: 'register'),
border: OutlineInputBorder(borderSide: BorderSide.none),
),
),
),
),
Container(
alignment: Alignment.topLeft,
padding: EdgeInsets.only(left: SizeConfig.getPadding(30)),
child: Text(
'รหัสผ่าน',
style: TextStyle(
color: Colors.black,
fontSize: SizeConfig.getFontSize(20),
fontFamily: "SF_Pro_Text",
fontWeight: FontWeight.w500),
),
),
Padding(
padding: EdgeInsets.symmetric(
vertical: SizeConfig.getPadding(8.0),
horizontal: SizeConfig.getPadding(24)),
child: Card(
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(SizeConfig.getPadding(50.0)),
),
child: TextFormField(
controller: presenter.passCtrl,
// validator: loginBloc.validateField,
decoration: InputDecoration(
contentPadding: EdgeInsets.symmetric(
......@@ -212,12 +363,18 @@ class _LoginPageState extends State<LoginPage> with TickerProviderStateMixin {
Radius.circular(50),
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => HomePage(),
),
);
if (_tabController.index==0){
presenter.letCheckData();}
else{
presenter.letCheckData_phone();
}
// Navigator.push(
// context,
// MaterialPageRoute(builder: (context) => HomePage()),
// );
// if (loginBloc.formKey.currentState.validate()) {
// loginBloc.getLogin();
// }
......@@ -282,7 +439,7 @@ class _LoginPageState extends State<LoginPage> with TickerProviderStateMixin {
Widget _policyText() {
return Column(
children: <Widget>[
Stack(
Column(
children: <Widget>[
Container(
padding: EdgeInsets.only(
......@@ -291,16 +448,31 @@ class _LoginPageState extends State<LoginPage> with TickerProviderStateMixin {
top: SizeConfig.getPadding(30)),
child: Center(
child: Text(
'คุณยอมรับ ข้อกำหนดการใช้งาน และ นโยบายความเป็นส่วนตัว ของอโกด้าเมื่อดำเนินการต่อ',
'คุณยอมรับ ข้อกำหนดการใช้งาน และ นโยบาย',
style: TextStyle(fontSize: SizeConfig.getFontSize(12)),
textAlign: TextAlign.center,
),
),
),
Row(
children: <Widget>[
Container(
margin: EdgeInsets.only(
right: SizeConfig.getPadding(34),
top: SizeConfig.getPadding(47)),
padding: EdgeInsets.only(
left: SizeConfig.getPadding(30),
right: SizeConfig.getPadding(10),
),
child: Center(
child: Text(
'ความเป็นส่วนตัวของอโกด้าเมื่อดำเนินการต่อ',
style: TextStyle(fontSize: SizeConfig.getFontSize(12)),
textAlign: TextAlign.center,
),
),
),
Container(
alignment: Alignment.centerRight,
child: GestureDetector(
onTap: () {
......@@ -322,6 +494,10 @@ class _LoginPageState extends State<LoginPage> with TickerProviderStateMixin {
),
),
)
]),
],
),
Container(
......
import 'dart:async';
import 'dart:developer';
import 'package:feelverapp/model/Login/login_model.dart';
import 'package:feelverapp/service/Loading.dart';
import 'package:feelverapp/service/api.dart';
import 'package:feelverapp/service/base_presenter.dart';
import 'package:feelverapp/ui/home/home.dart';
import 'package:feelverapp/ui/login/login.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:rflutter_alert/rflutter_alert.dart';
class LoginPresenter extends BasePresenter<LoginPage> {
Api _api;
Timer _timer;
final formKey = GlobalKey<FormState>();
TextEditingController emailCtrl = TextEditingController();
TextEditingController passCtrl = TextEditingController();
TextEditingController phonenumberCtrl = TextEditingController();
LoginPresenter(State<LoginPage> state) : super(state);
/////email Login/////////
letCheckData() async {
// if(!verifyPhoneState){
// throw(allTranslations.text(key: 'please_verify_phone'));
// }
try {
if (emailCtrl.text.isEmpty ) throw ('กรุณากรอก\nอีเมล์');
else if (passCtrl.text.isEmpty ) throw('กรุณากรอก\nรหัสผ่าน');
Pattern pattern =
r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+";
RegExp regex = new RegExp(pattern);
if (!regex.hasMatch(emailCtrl.text))
throw ('รูปแบบอีเมล์\nไม่ถูกต้อง');
else {
await letSignIn();
}
} catch (e) {
Alert(
style: AlertStyle(
animationType: AnimationType.fromTop,
isCloseButton: false,
),
context: state.context,
title: '$e',
content: Icon(Icons.warning,color: Colors.orange,size: 80,),
buttons: [
DialogButton(
color: Color.fromRGBO(106, 179, 170, 1),
onPressed: () => Navigator.pop(state.context),
child: Text(
"ตกลง",
style: TextStyle(color: Colors.white, fontSize: 20),
),
)
]).show();
}
}
letSignIn() async {
LoadingView(state.context).show();
_api = Api<LoginModel>();
var res = await _api.login({
"access_type":"portal",
"access_status":"customer",
"email": emailCtrl.text,
'password':passCtrl.text
});
LoadingView(state.context).hide();
if (res.fail == null) {
Alert(
style: AlertStyle(
animationType: AnimationType.fromTop,
isCloseButton: false,
),
context: state.context,
title: "เข้าสู่ระบบสำเร็จ",
content: Icon(Icons.check_circle,color: Color.fromRGBO(106, 179, 170, 1),size: 80,),
buttons: [
DialogButton(
color: Color.fromRGBO(106, 179, 170, 1),
onPressed: () =>
Navigator.pushReplacement(state.context, CupertinoPageRoute(builder: (_) => HomePage())),
child: Text(
"ตกลง",
style: TextStyle(color: Colors.white, fontSize: 20),
),
)
]).show();
LoginModel model = res.success;
// print("Username ="+"${model.user}");
print("Token ="+"${model.token}");
} else {
Alert(
style: AlertStyle(
animationType: AnimationType.fromTop,
isCloseButton: false,
),
context: state.context,
title: "อีเมล์หรือรหัสผ่าน\nไม่ถูกต้อง",
content: Icon(Icons.warning,color: Colors.orange,size: 80,),
buttons: [
DialogButton(
color: Color.fromRGBO(106, 179, 170, 1),
onPressed: () => Navigator.pop(state.context),
child: Text(
"ลองอีกครั้ง",
style: TextStyle(color: Colors.white, fontSize: 20),
),
)
]).show();
}
}
///////phone log in////////////////
letSignIn_phone() async {
LoadingView(state.context).show();
_api = Api<LoginModel>();
var res = await _api.login({
"access_type":"portal",
"access_status":"customer",
"email": phonenumberCtrl.text,
'password':passCtrl.text
});
LoadingView(state.context).hide();
if (res.fail == null) {
Alert(
style: AlertStyle(
animationType: AnimationType.fromTop,
isCloseButton: false,
),
context: state.context,
title: "เข้าสู่ระบบสำเร็จ",
content: Icon(Icons.check_circle,color: Color.fromRGBO(106, 179, 170, 1),size: 80,),
buttons: [
DialogButton(
color: Color.fromRGBO(106, 179, 170, 1),
onPressed: () =>
Navigator.pushReplacement(state.context, CupertinoPageRoute(builder: (_) => HomePage())),
child: Text(
"ตกลง",
style: TextStyle(color: Colors.white, fontSize: 20),
),
)
]).show();
LoginModel model = res.success;
// print("Username ="+"${model.user}");
print("Token ="+"${model.token}");
} else {
Alert(
style: AlertStyle(
animationType: AnimationType.fromTop,
isCloseButton: false,
),
context: state.context,
title: "เบอร์โทรศัพท์หรือรหัสผ่าน\nไม่ถูกต้อง",
content: Icon(Icons.warning,color: Colors.orange,size: 80,),
buttons: [
DialogButton(
color: Color.fromRGBO(106, 179, 170, 1),
onPressed: () => Navigator.pop(state.context),
child: Text(
"ลองอีกครั้ง",
style: TextStyle(color: Colors.white, fontSize: 20),
),
)
]).show();
}
}
letCheckData_phone() async {
// if(!verifyPhoneState){
// throw(allTranslations.text(key: 'please_verify_phone'));
// }
try {
if (phonenumberCtrl.text.isEmpty ) throw ('กรุณากรอก\nเบอร์โทรศัพท์มือถือ');
else if (passCtrl.text.isEmpty ) throw('กรุณากรอก\nรหัสผ่าน');
Pattern pattern =
r'(^(?:[+0]9)?[0-9]{10,12}$)';
RegExp regex = new RegExp(pattern);
if (!regex.hasMatch(phonenumberCtrl.text))
throw ('รูปแบบเบอร์โทรศัพท์\nไม่ถูกต้อง');
else {
await letSignIn_phone();
}
} catch (e) {
Alert(
style: AlertStyle(
animationType: AnimationType.fromTop,
isCloseButton: false,
),
context: state.context,
title: '$e',
content: Icon(Icons.warning,color: Colors.orange,size: 80,),
buttons: [
DialogButton(
color: Color.fromRGBO(106, 179, 170, 1),
onPressed: () => Navigator.pop(state.context),
child: Text(
"ตกลง",
style: TextStyle(color: Colors.white, fontSize: 20),
),
)
]).show();
}
}
// facebookLogin() async {
// try {
// await _facebookLogin.logIn(['email']).then((result) async {
// var fbData = await Api().getFacebookInfo(result.accessToken.token);
// print(fbData);
// await _letSocialSignIn(result.accessToken.userId, 'facebook')
// .then((value) {
// if (value) {
// Navigator.popUntil(state.context, (route) => route.isFirst);
// Navigator.pushReplacement(state.context, CupertinoPageRoute(builder: (_) =>
// NavigatorPage(),
// ));
// } else {
// Navigator.push(
// state.context,
// CupertinoPageRoute(
// builder: (_) => SignUpEmail(
// socialType: SocialType.facebook,
// socialData: new RegisterSocialDataModel(
// socialId: result.accessToken.userId,
// token: result.accessToken.token,
// email: fbData['email'],
// firstName: fbData['first_name'],
// lastName: fbData['last_name'],
// ),
// )));
// }
// });
// });
// } catch (e) {
// print(e);
// }
// }
}
......@@ -397,6 +397,7 @@ class _ShopState extends State<Shop> {
children: <Widget>[
Container(
color: Color.fromRGBO(106, 179, 170, 1),
height: SizeConfig.getHeight(470),
width: MediaQuery.of(context).size.width,
),
......
......@@ -54,9 +54,7 @@ class _MainShopState extends State<MainShop> with SingleTickerProviderStateMixi
Widget build(BuildContext context) {
SizeConfig(context);
// Init the items
for (var i = 0; i < 100; i++) {
items.add('Item $i');
}
return Scaffold(
// backgroundColor: Colors.transparent,
......
import 'dart:async';
import 'package:feelverapp/ui/home/home.dart';
import 'package:feelverapp/ui/login/login.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
......@@ -14,7 +15,7 @@ class _SplashScreenPageState extends State<SplashScreenPage> {
@override
void initState() {
_timer = new Timer(Duration(seconds: 2), () => Navigator.pushReplacement(context, CupertinoPageRoute(builder: (_) => HomePage())));
_timer = new Timer(Duration(seconds: 2), () => Navigator.pushReplacement(context, CupertinoPageRoute(builder: (_) => LoginPage())));
super.initState();
}
......
......@@ -81,6 +81,20 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
http:
dependency: "direct main"
description:
name: http
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.1"
http_parser:
dependency: transitive
description:
name: http_parser
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.4"
image:
dependency: transitive
description:
......@@ -88,6 +102,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
json_annotation:
dependency: "direct main"
description:
name: json_annotation
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
matcher:
dependency: transitive
description:
......@@ -130,6 +151,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
rflutter_alert:
dependency: "direct main"
description:
name: rflutter_alert
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.3"
sky_engine:
dependency: transitive
description: flutter
......
......@@ -24,6 +24,9 @@ dependencies:
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
flutter_screenutil: ^1.0.2
http: ^0.12.0+4
json_annotation: ^3.0.1
rflutter_alert: ^1.0.3
dev_dependencies:
......
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