Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
feelver
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2F-ART
feelver
Commits
5f22bd0b
Commit
5f22bd0b
authored
Jul 16, 2020
by
Mobile : Jetrin Phuekkaew (N'new)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update login
parent
229a58d9
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
156 additions
and
18 deletions
+156
-18
lib/service/Loading.dart
+25
-0
lib/ui/login/login.dart
+35
-8
lib/ui/login/login_presenter.dart
+88
-10
pubspec.lock
+7
-0
pubspec.yaml
+1
-0
No files found.
lib/service/Loading.dart
0 → 100644
View file @
5f22bd0b
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
);
}
}
lib/ui/login/login.dart
View file @
5f22bd0b
import
'package:feelverapp/ui/home/home.dart'
;
import
'package:feelverapp/ui/login/login_presenter.dart'
;
//import 'package:feelverapp/ui/login/login_presenter.dart';
...
...
@@ -21,9 +22,19 @@ class _LoginPageState extends State<LoginPage> with TickerProviderStateMixin {
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
)
{
...
...
@@ -75,14 +86,27 @@ class _LoginPageState extends State<LoginPage> with TickerProviderStateMixin {
],
),
SizedBox
(
height:
SizeConfig
.
getWidth
(
30
)),
_formLogin
(),
_phoneLogin
(),
new
Container
(
height:
double
.
maxFinite
,
child:
new
TabBarView
(
controller:
_tabController
,
children:
<
Widget
>[
_formLogin
(),
_phoneLogin
()
],
),
),
// _phoneLogin(),
],
),
);
}
Widget
_formLogin
()
{
print
(
"index = "
+
"
${_tabController.index}
"
);
return
Container
(
child:
Form
(
child:
Column
(
...
...
@@ -111,7 +135,7 @@ class _LoginPageState extends State<LoginPage> with TickerProviderStateMixin {
),
),
child:
TextFormField
(
// controller: loginBloc
.emailCtrl,
controller:
presenter
.
emailCtrl
,
// validator: loginBloc.validateField,
decoration:
InputDecoration
(
contentPadding:
EdgeInsets
.
symmetric
(
...
...
@@ -150,7 +174,7 @@ class _LoginPageState extends State<LoginPage> with TickerProviderStateMixin {
BorderRadius
.
circular
(
SizeConfig
.
getPadding
(
50.0
)),
),
child:
TextFormField
(
// controller: loginBloc
.passCtrl,
controller:
presenter
.
passCtrl
,
// validator: loginBloc.validateField,
decoration:
InputDecoration
(
contentPadding:
EdgeInsets
.
symmetric
(
...
...
@@ -193,6 +217,7 @@ class _LoginPageState extends State<LoginPage> with TickerProviderStateMixin {
}
Widget
_phoneLogin
()
{
print
(
"index = "
+
"
${_tabController.index}
"
);
return
Container
(
child:
Form
(
child:
Column
(
...
...
@@ -314,10 +339,12 @@ class _LoginPageState extends State<LoginPage> with TickerProviderStateMixin {
padding:
EdgeInsets
.
all
(
0
),
borderRadius:
BorderRadius
.
all
(
Radius
.
circular
(
50
)),
onPressed:
()
{
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)
=>
HomePage
()),
);
presenter
.
onSignIn
();
// Navigator.push(
// context,
// MaterialPageRoute(builder: (context) => HomePage()),
// );
// if (loginBloc.formKey.currentState.validate()) {
// loginBloc.getLogin();
// }
...
...
lib/ui/login/login_presenter.dart
View file @
5f22bd0b
...
...
@@ -2,12 +2,15 @@ import 'dart:developer';
import
'package:feelverapp/model/Login/login_model.dart'
;
import
'package:feelverapp/service/Alert.dart'
;
import
'package:feelverapp/service/Loading.dart'
;
import
'package:feelverapp/service/api.dart'
;
import
'package:feelverapp/service/base_presenter.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'
;
...
...
@@ -25,35 +28,110 @@ class LoginPresenter extends BasePresenter<LoginPage> {
LoginPresenter
(
State
<
LoginPage
>
state
)
:
super
(
state
);
onSignIn
()
async
{
if
(
formKey
.
currentState
.
validate
())
{
await
letSignIn
();
if
(
emailCtrl
.
text
.
isEmpty
)
{
Alert
(
style:
AlertStyle
(
animationType:
AnimationType
.
fromTop
,
isCloseButton:
false
,
),
context:
state
.
context
,
title:
"กรุณากรอกอีเมล์"
,
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
();
}
if
(
passCtrl
.
text
.
isEmpty
)
{
Alert
(
style:
AlertStyle
(
animationType:
AnimationType
.
fromTop
,
isCloseButton:
false
,
),
context:
state
.
context
,
title:
"กรุณากรอกรหัสผ่าน"
,
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
();
}
else
letSignIn
();
}
letSignIn
()
async
{
LoadingView
(
state
.
context
).
show
();
_api
=
Api
<
LoginModel
>();
var
res
=
await
_api
.
login
({
"access_type"
:
"portal"
,
"access_status"
:
"customer"
,
"email"
:
"api@feelver.com"
,
'password'
:
"
\
$J3M
{GfzNW7EhwxP"
,
"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
.
pop
(
state
.
context
),
child:
Text
(
"ตกลง"
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
20
),
),
)
]).
show
();
LoginModel
model
=
res
.
success
;
// print("Username ="+"${model.user}");
print
(
"Token ="
+
"
${model.token}
"
);
}
else
{
Alert
(
Alert
(
style:
AlertStyle
(
animationType:
AnimationType
.
fromTop
,
isCloseButton:
false
,
),
context:
state
.
context
,
message:
'email_or_password_invalid'
);
title:
"อีเมล์หรือรหัสผ่านผิด"
,
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
();
}
}
...
...
pubspec.lock
View file @
5f22bd0b
...
...
@@ -151,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
...
...
pubspec.yaml
View file @
5f22bd0b
...
...
@@ -26,6 +26,7 @@ dependencies:
flutter_screenutil
:
^1.0.2
http
:
^0.12.0+4
json_annotation
:
^3.0.1
rflutter_alert
:
^1.0.3
dev_dependencies
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment