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
4438b883
Commit
4438b883
authored
Jul 31, 2020
by
Mobile : Jetrin Phuekkaew (N'new)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update edit profile and getpro file(not finish yet waiting for api fix about user profile photo).
parent
f29f2aad
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
195 additions
and
112 deletions
+195
-112
android/app/src/main/AndroidManifest.xml
+4
-0
lib/service/api.dart
+21
-1
lib/ui/edit_profile/edit_profile.dart
+16
-1
lib/ui/edit_profile/editprofile_presenter.dart
+154
-110
No files found.
android/app/src/main/AndroidManifest.xml
View file @
4438b883
...
...
@@ -22,6 +22,10 @@
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
<activity
android:name=
"com.yalantis.ucrop.UCropActivity"
android:screenOrientation=
"portrait"
android:theme=
"@style/Theme.AppCompat.Light.NoActionBar"
/>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
...
...
lib/service/api.dart
View file @
4438b883
...
...
@@ -19,7 +19,7 @@ class Api<T> {
final
_headerApi
=
{
"Authorization"
:
"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvYmFja2VuZC11YXQuZmVlbHZlci5jb21cL2FwaVwvbG9naW4iLCJpYXQiOjE1OT
Q5NzIzMjYsImV4cCI6MTYwMjE3MjMyNiwibmJmIjoxNTk0OTcyMzI2LCJqdGkiOiJsM1BldUJVcTdDNldSbzVGIiwic3ViIjo1LCJwcnYiOiI4N2UwYWYxZWY5ZmQxNTgxMmZkZWM5NzE1M2ExNGUwYjA0NzU0NmFhIn0.fwFqcbzG2T_ZHtIcGF13Ek7nIxxwbnaE9ZXGomo-nzY
"
,
"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvYmFja2VuZC11YXQuZmVlbHZlci5jb21cL2FwaVwvbG9naW4iLCJpYXQiOjE1OT
YxMDAzNTgsImV4cCI6MTYwMzMwMDM1OCwibmJmIjoxNTk2MTAwMzU4LCJqdGkiOiJ2YjA2S0FHR1JtZDFseEw1Iiwic3ViIjozNzMsInBydiI6Ijg3ZTBhZjFlZjlmZDE1ODEyZmRlYzk3MTUzYTE0ZTBiMDQ3NTQ2YWEifQ.UkY70AshvW5O4M63XY_Iv2IPBohSUUwnRF1oi46p2zs
"
,
};
Future
<
Response
<
T
>>
getprofile
(
Object
body
)
async
{
...
...
@@ -41,6 +41,26 @@ class Api<T> {
});
return
result
;
}
Future
<
Response
<
T
>>
editProfile
(
Object
body
)
async
{
var
_model
;
var
_fail
;
var
result
;
print
(
"This is body "
+
body
.
toString
());
await
_httpConnection
(
"
${this._baseApi}
/customer/edit"
,
this
.
_headerApi
,
body
)
.
then
((
response
)
{
print
(
"ผลลัพ เท่ากับบบบ "
+
"
${response.body}
"
);
if
(
response
.
statusCode
==
200
)
{
_model
=
FogetPasswordModel
.
fromJson
(
json
.
decode
(
response
.
body
));
}
else
{
_fail
=
FailModel
.
fromJson
(
json
.
decode
(
response
.
body
));
}
result
=
new
Response
<
T
>(
_model
,
_fail
);
});
return
result
;
}
Future
<
Response
<
T
>>
forgetPassword
(
Object
body
)
async
{
var
_model
;
var
_fail
;
...
...
lib/ui/edit_profile/edit_profile.dart
View file @
4438b883
...
...
@@ -28,6 +28,7 @@ class _EditProfileState extends State<EditProfile> {
ImagePickerUtil
(
context
,
(
img
)
{
setState
(()
{
image
=
img
;
presenter
.
imageFile
=
img
;
});
});
}
...
...
@@ -75,7 +76,7 @@ class _EditProfileState extends State<EditProfile> {
height:
SizeConfig
.
getWidth
(
100
),
),
)
:
Stack
(
:
presenter
.
getmodel
.
result
[
0
].
image
==
null
?
Stack
(
children:
<
Widget
>[
Container
(
height:
SizeConfig
.
getWidth
(
80
),
...
...
@@ -108,7 +109,19 @@ class _EditProfileState extends State<EditProfile> {
),
)
],
):
ClipRRect
(
borderRadius:
BorderRadius
.
all
(
Radius
.
circular
(
SizeConfig
.
getWidth
(
56
))),
child:
Image
.
network
(
presenter
.
getmodel
.
result
[
0
].
image
,
fit:
BoxFit
.
contain
,
width:
SizeConfig
.
getWidth
(
100
),
height:
SizeConfig
.
getWidth
(
100
),
),
),
),
Container
(
alignment:
Alignment
.
topLeft
,
...
...
@@ -317,6 +330,8 @@ class _EditProfileState extends State<EditProfile> {
padding:
EdgeInsets
.
all
(
0.0
),
splashColor:
Colors
.
blueAccent
,
onPressed:
()
{
presenter
.
letCheckData
();
print
(
'name=
${presenter.nameCtrl.text}
'
);
print
(
'lastname=
${presenter.lnameCtrl.text}
'
);
print
(
'email=
${presenter.emailCtrl.text}
'
);
...
...
lib/ui/edit_profile/editprofile_presenter.dart
View file @
4438b883
import
'dart:async'
;
import
'dart:convert'
;
import
'dart:developer'
;
import
'dart:io'
;
import
'package:feelverapp/model/Login/login_model.dart'
;
import
'package:feelverapp/model/editprofile/getprofilemodel.dart'
;
import
'package:feelverapp/model/forgetpassword/forgetpassModel.dart'
;
import
'package:feelverapp/service/Loading.dart'
;
import
'package:feelverapp/service/api.dart'
;
...
...
@@ -20,135 +21,178 @@ import 'package:rflutter_alert/rflutter_alert.dart';
import
'edit_profile.dart'
;
class
EditprofilePresenter
extends
BasePresenter
<
EditProfile
>
{
Api
_api
;
File
imageFile
;
String
uid
=
"16"
;
final
formKey
=
GlobalKey
<
FormState
>();
String
age
,
lastname
,
firstname
,
sex
,
address
,
email
,
phone
;
GetprofileModel
getmodel
;
TextEditingController
addresCtrl
=
TextEditingController
()
;
TextEditingController
ageCtrl
=
TextEditingController
()
;
TextEditingController
selectedSex
=
TextEditingController
()
;
TextEditingController
nameCtrl
=
TextEditingController
();
String
age
,
lastname
,
firstname
,
sex
,
address
,
email
,
phone
;
GetprofileModel
getmodel
;
TextEditingController
addresCtrl
=
TextEditingController
()
;
TextEditingController
ageCtrl
=
TextEditingController
()
;
TextEditingController
selectedSex
=
TextEditingController
()
;
TextEditingController
nameCtrl
=
TextEditingController
();
TextEditingController
phoneCtrl
=
TextEditingController
();
TextEditingController
emailCtrl
=
TextEditingController
();
TextEditingController
lnameCtrl
=
TextEditingController
();
EditprofilePresenter
(
State
<
EditProfile
>
state
)
:
super
(
state
);
letCheckData
()
async
{
try
{
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
ไม่ถูกต้อง'
);
Pattern
pattern2
=
r'(^(?:[+0]9)?[0-9]{10,12}$)'
;
RegExp
regex2
=
new
RegExp
(
pattern2
);
if
(!
regex2
.
hasMatch
(
phoneCtrl
.
text
))
throw
(
'รูปแบบเบอร์โทรศัพท์
\n
ไม่ถูกต้อง'
);
if
(
selectedSex
.
text
!=
"ชาย"
)
{
if
(
selectedSex
.
text
!=
"หญิง"
)
throw
(
'กรุณาระบุเพศ
\n
ชาย/หญิง'
);
else
{
await
letedit
();
print
(
"completeee"
);
}
}
else
{
await
letedit
();
print
(
"completeee"
);
}
}
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
();
}
}
letedit
()
async
{
_api
=
Api
<
FogetPasswordModel
>();
LoadingView
(
state
.
context
).
show
();
var
res
=
await
_api
.
editProfile
({
'id'
:
getmodel
.
result
[
0
].
id
.
toString
(),
'name'
:
nameCtrl
.
text
,
'lastname'
:
lnameCtrl
.
text
,
'phone'
:
phoneCtrl
.
text
,
'email'
:
emailCtrl
.
text
,
'sex'
:
selectedSex
.
text
==
"ชาย"
?
'm'
:
'w'
,
'image'
:
imageFile
!=
null
?
_getImageBase64
()
:
" "
,
});
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
();
}
else
{
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
();
}
}
letCheckData
()
async
{
try
{
if
(
emailCtrl
.
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
getprofile
();
}
}
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
();
}
}
_getImageBase64
()
{
return
base64
.
encode
(
imageFile
.
readAsBytesSync
());
}
getprofile
()
async
{
_api
=
Api
<
GetprofileModel
>();
var
res
=
await
_api
.
getprofile
({
"id"
:
"16"
});
var
res
=
await
_api
.
getprofile
({
"id"
:
"16"
});
if
(
res
.
fail
==
null
)
{
setState
((){
getmodel
=
res
.
success
;
ageCtrl
.
text
=
getmodel
.
result
[
0
].
age
.
toString
();
nameCtrl
.
text
=
getmodel
.
result
[
0
].
name
;
lnameCtrl
.
text
=
getmodel
.
result
[
0
].
lastname
;
selectedSex
.
text
=
getmodel
.
result
[
0
].
sex
==
'm'
?
"ชาย"
:
"หญิง"
;
addresCtrl
.
text
=
getmodel
.
result
[
0
].
address
.
toString
();
emailCtrl
.
text
=
getmodel
.
result
[
0
].
email
;
phoneCtrl
.
text
=
getmodel
.
result
[
0
].
phone
.
toString
();
});
}
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
();
setState
(()
{
getmodel
=
res
.
success
;
ageCtrl
.
text
=
getmodel
.
result
[
0
].
age
.
toString
();
nameCtrl
.
text
=
getmodel
.
result
[
0
].
name
;
lnameCtrl
.
text
=
getmodel
.
result
[
0
].
lastname
;
selectedSex
.
text
=
getmodel
.
result
[
0
].
sex
==
'm'
?
"ชาย"
:
"หญิง"
;
addresCtrl
.
text
=
getmodel
.
result
[
0
].
address
.
toString
();
emailCtrl
.
text
=
getmodel
.
result
[
0
].
email
;
phoneCtrl
.
text
=
getmodel
.
result
[
0
].
phone
.
toString
();
});
}
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
();
}
}
}
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