Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Hoàng Văn Đạt
mypoint_flutter_app
Commits
d86c3328
Commit
d86c3328
authored
Apr 23, 2025
by
DatHV
Browse files
update auth logic
parent
5fb93f2d
Changes
3
Hide whitespace changes
Inline
Side-by-side
lib/screen/delete_account/delete_account_dialog.dart
View file @
d86c3328
...
...
@@ -9,6 +9,7 @@ import '../../resouce/text_style.dart';
import
'../../shared/router_gage.dart'
;
import
'../pageDetail/campaign_detail_screen.dart'
;
import
'../pageDetail/model/detail_page_rule_type.dart'
;
import
'delete_account_viewmodel.dart'
;
class
DeleteAccountDialog
extends
StatefulWidget
{
const
DeleteAccountDialog
({
super
.
key
});
...
...
@@ -18,7 +19,7 @@ class DeleteAccountDialog extends StatefulWidget {
}
class
_DeleteAccountDialogState
extends
State
<
DeleteAccountDialog
>
{
bool
agreed
=
false
;
final
DeleteAccountViewModel
_viewModel
=
DeleteAccountViewModel
()
;
late
TapGestureRecognizer
_termConditionRecognizer
;
@override
...
...
@@ -60,7 +61,11 @@ class _DeleteAccountDialogState extends State<DeleteAccountDialog> {
onTap:
_onUnUsedVoucherPressed
,
child:
Text
(
"Ưu đãi chưa sử dụng "
,
style:
AppTextStyle
.
link
.
copyWith
(
color:
Colors
.
blue
,
decoration:
TextDecoration
.
underline
),
style:
AppTextStyle
.
link
.
copyWith
(
color:
Colors
.
blue
,
// ✅ Màu chữ
decoration:
TextDecoration
.
underline
,
// ✅ Gạch chân
decorationColor:
Colors
.
blue
,
// ✅ Gạch chân màu xanh
),
),
),
),
...
...
@@ -88,8 +93,8 @@ class _DeleteAccountDialogState extends State<DeleteAccountDialog> {
),
),
child:
Checkbox
(
value:
agreed
,
onChanged:
(
value
)
=>
setState
(()
=>
agreed
=
value
??
false
),
value:
_viewModel
.
agreed
.
value
,
onChanged:
(
value
)
=>
setState
(()
=>
_viewModel
.
agreed
.
value
=
value
??
false
),
visualDensity:
const
VisualDensity
(
horizontal:
-
4
,
vertical:
-
4
),
),
),
...
...
@@ -116,7 +121,7 @@ class _DeleteAccountDialogState extends State<DeleteAccountDialog> {
width:
double
.
infinity
,
height:
40
,
child:
ElevatedButton
(
onPressed:
agreed
?
_onConfirmDelete
:
null
,
onPressed:
_viewModel
.
agreed
.
value
?
_onConfirmDelete
:
null
,
style:
AppButtonStyle
.
secondary
,
child:
const
Text
(
"Xác nhận xoá"
),
),
...
...
@@ -138,7 +143,7 @@ class _DeleteAccountDialogState extends State<DeleteAccountDialog> {
void
_onConfirmDelete
()
{
if
(
DataPreference
.
instance
.
profile
?.
userAgreements
?.
hideDeleteAccount
==
false
)
{
_viewModel
.
confirmDelete
();
}
else
{
DataPreference
.
instance
.
clearData
();
Get
.
offAllNamed
(
onboardingScreen
);
...
...
lib/screen/delete_account/delete_account_viewmodel.dart
View file @
d86c3328
...
...
@@ -18,7 +18,7 @@ class DeleteAccountViewModel extends RestfulApiViewModel {
if
(
value
.
isSuccess
)
{
final
phone
=
DataPreference
.
instance
.
phone
??
""
;
Get
.
to
(
()
=>
OtpScreen
(
repository:
DeleteAccountOtpRepository
(
phone
,
value
.
data
?.
resendAfterSecond
??
0
)),
()
=>
OtpScreen
(
repository:
DeleteAccountOtpRepository
(
phone
,
value
.
data
?.
resendAfterSecond
??
Constants
.
otpTtl
)),
);
}
else
{
final
mgs
=
value
.
errorMessage
??
Constants
.
commonError
;
...
...
lib/screen/otp/delete_account_otp_repository.dart
View file @
d86c3328
...
...
@@ -4,7 +4,9 @@ import 'package:mypoint_flutter_app/networking/restful_api_request.dart';
import
'package:mypoint_flutter_app/shared/router_gage.dart'
;
import
'../../base/base_response_model.dart'
;
import
'../../base/restful_api_viewmodel.dart'
;
import
'../../configs/constants.dart'
;
import
'../../preference/data_preference.dart'
;
import
'../../widgets/custom_toast_message.dart'
;
import
'../splash/splash_screen_viewmodel.dart'
;
import
'otp_viewmodel.dart'
;
...
...
@@ -25,6 +27,7 @@ class DeleteAccountOtpRepository extends RestfulApiViewModel implements IOtpRepo
return
client
.
verifyDeleteAccount
(
otpCode
).
then
((
value
)
{
hideLoading
();
if
(
value
.
isSuccess
)
{
showToastMessage
(
"Xóa tài khoản thành công"
);
DataPreference
.
instance
.
clearData
();
Get
.
offAllNamed
(
onboardingScreen
);
}
...
...
@@ -34,10 +37,15 @@ class DeleteAccountOtpRepository extends RestfulApiViewModel implements IOtpRepo
@override
Future
<
int
?>
resendOtp
()
async
{
// showLoading();
// return client.resendOTP(mfaToken).then((value) {
// hideLoading();
// return value.data?.otpTtl;
// });
showLoading
();
client
.
requestOtpDeleteAccount
().
then
((
value
)
{
hideLoading
();
if
(
value
.
isSuccess
)
{
otpTtl
=
value
.
data
?.
resendAfterSecond
??
Constants
.
otpTtl
;
}
else
{
final
mgs
=
value
.
errorMessage
??
Constants
.
commonError
;
Get
.
snackbar
(
"Thông báo"
,
mgs
);
}
});
}
}
Write
Preview
Supports
Markdown
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