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
a6797435
Commit
a6797435
authored
Nov 05, 2025
by
DatHV
Browse files
refactor print, log, request
parent
f0334970
Changes
117
Hide whitespace changes
Inline
Side-by-side
lib/screen/campaign7day/campaign_7day_guide_dialog.dart
View file @
a6797435
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_widget_from_html/flutter_widget_from_html.dart'
;
import
'package:flutter_widget_from_html
_core
/flutter_widget_from_html
_core
.dart'
;
import
'../../resources/base_color.dart'
;
import
'../../resources/base_color.dart'
;
class
Campaign7DayGuideDialog
extends
StatelessWidget
{
class
Campaign7DayGuideDialog
extends
StatelessWidget
{
...
...
lib/screen/campaign7day/campaign_7day_mission_info_dialog.dart
View file @
a6797435
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_widget_from_html/flutter_widget_from_html.dart'
;
import
'package:flutter_widget_from_html
_core
/flutter_widget_from_html
_core
.dart'
;
import
'../../resources/base_color.dart'
;
import
'../../resources/base_color.dart'
;
import
'models/campaign_7day_mission_model.dart'
;
import
'models/campaign_7day_mission_model.dart'
;
...
...
lib/screen/campaign7day/custom_widgets/campaign_7day_reward_item.dart
View file @
a6797435
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_widget_from_html/flutter_widget_from_html.dart'
;
import
'package:flutter_widget_from_html
_core
/flutter_widget_from_html
_core
.dart'
;
import
'package:get/get.dart'
;
import
'package:get/get.dart'
;
import
'../../../resources/base_color.dart'
;
import
'../../../resources/base_color.dart'
;
import
'../models/campaign_7day_reward_model.dart'
;
import
'../models/campaign_7day_reward_model.dart'
;
...
...
lib/screen/campaign7day/models/campaign_7day_info_model.dart
View file @
a6797435
import
'package:flutter/foundation.dart'
;
import
'package:json_annotation/json_annotation.dart'
;
import
'package:json_annotation/json_annotation.dart'
;
import
'campaign_7day_config_model.dart'
;
import
'campaign_7day_config_model.dart'
;
import
'campaign_7day_mission_model.dart'
;
import
'campaign_7day_mission_model.dart'
;
...
@@ -29,14 +30,14 @@ class Campaign7DayInfoModel {
...
@@ -29,14 +30,14 @@ class Campaign7DayInfoModel {
});
});
double
?
get
countDownTime
{
double
?
get
countDownTime
{
p
rint
(
"End time:
$endTime
"
);
debugP
rint
(
"End time:
$endTime
"
);
if
(
endTime
==
null
)
return
null
;
if
(
endTime
==
null
)
return
null
;
try
{
try
{
final
date
=
intl
.
DateFormat
(
"yyyy-MM-dd HH:mm:ss"
).
parseUtc
(
endTime
!);
final
date
=
intl
.
DateFormat
(
"yyyy-MM-dd HH:mm:ss"
).
parseUtc
(
endTime
!);
p
rint
(
"Parsed date:
$date
"
);
debugP
rint
(
"Parsed date:
$date
"
);
final
now
=
DateTime
.
now
().
toUtc
();
final
now
=
DateTime
.
now
().
toUtc
();
final
diff
=
date
.
difference
(
now
).
inSeconds
;
final
diff
=
date
.
difference
(
now
).
inSeconds
;
p
rint
(
"Difference in seconds:
$diff
"
);
debugP
rint
(
"Difference in seconds:
$diff
"
);
return
(
diff
>
0
?
diff
:
0
).
toDouble
();
return
(
diff
>
0
?
diff
:
0
).
toDouble
();
}
catch
(
_
)
{
}
catch
(
_
)
{
return
null
;
return
null
;
...
...
lib/screen/contacts/contacts_list_screen.dart
View file @
a6797435
import
'package:flutter/foundation.dart'
;
import
'package:flutter_contacts/flutter_contacts.dart'
;
import
'package:flutter_contacts/flutter_contacts.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:get/get.dart'
;
import
'package:get/get.dart'
;
...
@@ -78,7 +79,7 @@ class _ContactsListScreenState extends State<ContactsListScreen> {
...
@@ -78,7 +79,7 @@ class _ContactsListScreenState extends State<ContactsListScreen> {
final
contact
=
displayContacts
[
index
];
final
contact
=
displayContacts
[
index
];
return
GestureDetector
(
return
GestureDetector
(
onTap:
()
{
onTap:
()
{
p
rint
(
'contact selected
${contact.phones.firstOrNull}
'
);
debugP
rint
(
'contact selected
${contact.phones.firstOrNull}
'
);
},
},
child:
Column
(
child:
Column
(
children:
[
children:
[
...
...
lib/screen/create_pass/signup_create_password_repository.dart
View file @
a6797435
import
'dart:async'
;
import
'dart:async'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:get/get.dart'
;
import
'package:get/get.dart'
;
import
'package:mypoint_flutter_app/networking/restful_api_client_all_request.dart'
;
import
'package:mypoint_flutter_app/networking/restful_api_client_all_request.dart'
;
...
@@ -29,7 +30,7 @@ class SignUpCreatePasswordRepository extends RestfulApiViewModel implements ICre
...
@@ -29,7 +30,7 @@ class SignUpCreatePasswordRepository extends RestfulApiViewModel implements ICre
return
client
.
signup
(
phoneNumber
,
password
).
then
((
value
)
{
return
client
.
signup
(
phoneNumber
,
password
).
then
((
value
)
{
hideLoading
();
hideLoading
();
if
(
value
.
status
==
"success"
||
value
.
code
==
200
)
{
if
(
value
.
status
==
"success"
||
value
.
code
==
200
)
{
p
rint
(
"signup success"
);
debugP
rint
(
"signup success"
);
_autoLogin
(
password
);
_autoLogin
(
password
);
}
}
return
value
;
return
value
;
...
...
lib/screen/data_network_service/data_network_service_screen.dart
View file @
a6797435
import
'dart:async'
;
import
'dart:async'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:get/get.dart'
;
import
'package:get/get.dart'
;
import
'package:mypoint_flutter_app/extensions/num_extension.dart'
;
import
'package:mypoint_flutter_app/extensions/num_extension.dart'
;
...
@@ -94,7 +95,7 @@ class _DataNetworkServiceScreenState extends BaseState<DataNetworkServiceScreen>
...
@@ -94,7 +95,7 @@ class _DataNetworkServiceScreenState extends BaseState<DataNetworkServiceScreen>
}
}
void
_redeemProductMobileCard
()
{
void
_redeemProductMobileCard
()
{
p
rint
(
"redeem
${UserPointManager().point}
>=
${_viewModel.payPoint}
"
);
debugP
rint
(
"redeem
${UserPointManager().point}
>=
${_viewModel.payPoint}
"
);
final
isValidInput
=
final
isValidInput
=
(
_viewModel
.
phoneNumber
.
value
.
trim
().
length
>=
10
)
&&
(
_viewModel
.
selectedProduct
.
value
!=
null
);
(
_viewModel
.
phoneNumber
.
value
.
trim
().
length
>=
10
)
&&
(
_viewModel
.
selectedProduct
.
value
!=
null
);
if
(!
isValidInput
)
{
if
(!
isValidInput
)
{
...
...
lib/screen/data_network_service/data_network_service_viewmodel.dart
View file @
a6797435
import
'package:get/get.dart'
;
import
'package:get/get.dart'
;
import
'package:get/get_rx/src/rx_types/rx_types.dart'
;
import
'package:get/get_rx/src/rx_types/rx_types.dart'
;
import
'package:mypoint_flutter_app/networking/
restful_api_client_all_request.dart'
;
import
'package:mypoint_flutter_app/networking/
api/product_api.dart'
deferred
as
product_api
;
import
'package:mypoint_flutter_app/preference/data_preference.dart'
;
import
'package:mypoint_flutter_app/preference/data_preference.dart'
;
import
'package:mypoint_flutter_app/screen/data_network_service/product_network_data_model.dart'
;
import
'package:mypoint_flutter_app/screen/data_network_service/product_network_data_model.dart'
;
import
'package:mypoint_flutter_app/widgets/custom_toast_message.dart'
;
import
'package:mypoint_flutter_app/widgets/custom_toast_message.dart'
;
...
@@ -23,6 +23,19 @@ class DataNetworkServiceViewModel extends RestfulApiViewModel {
...
@@ -23,6 +23,19 @@ class DataNetworkServiceViewModel extends RestfulApiViewModel {
final
RxString
phoneNumber
=
''
.
obs
;
final
RxString
phoneNumber
=
''
.
obs
;
void
Function
(
String
message
)?
onShowAlertError
;
void
Function
(
String
message
)?
onShowAlertError
;
void
Function
(
String
message
)?
onShowAlertRedeemSuccess
;
void
Function
(
String
message
)?
onShowAlertRedeemSuccess
;
bool
_productApiLoaded
=
false
;
Future
<
void
>
_ensureProductApiLoaded
()
async
{
if
(
_productApiLoaded
)
return
;
await
product_api
.
loadLibrary
();
_productApiLoaded
=
true
;
}
Future
<
BaseResponseModel
<
T
>>
_callProductApi
<
T
>(
Future
<
BaseResponseModel
<
T
>>
Function
(
dynamic
api
)
fn
)
async
{
await
_ensureProductApiLoaded
();
final
api
=
product_api
.
ProductApi
(
client
);
return
fn
(
api
);
}
int
get
payPoint
{
int
get
payPoint
{
return
(
int
.
tryParse
(
selectedProduct
.
value
?.
prices
?.
firstOrNull
?.
payPoint
??
"0"
)
??
0
);
return
(
int
.
tryParse
(
selectedProduct
.
value
?.
prices
?.
firstOrNull
?.
payPoint
??
"0"
)
??
0
);
...
@@ -55,7 +68,7 @@ class DataNetworkServiceViewModel extends RestfulApiViewModel {
...
@@ -55,7 +68,7 @@ class DataNetworkServiceViewModel extends RestfulApiViewModel {
Future
<
void
>
_getNetworkBrands
()
async
{
Future
<
void
>
_getNetworkBrands
()
async
{
await
callApi
<
List
<
ProductBrandModel
>>(
await
callApi
<
List
<
ProductBrandModel
>>(
request:
()
=>
client
.
productTopUpBrands
(),
request:
()
=>
_callProductApi
((
api
)
=>
api
.
productTopUpBrands
()
)
,
onSuccess:
(
data
,
_
)
{
onSuccess:
(
data
,
_
)
{
topUpBrands
.
assignAll
(
data
);
topUpBrands
.
assignAll
(
data
);
checkMobileNetwork
();
checkMobileNetwork
();
...
@@ -69,7 +82,7 @@ class DataNetworkServiceViewModel extends RestfulApiViewModel {
...
@@ -69,7 +82,7 @@ class DataNetworkServiceViewModel extends RestfulApiViewModel {
Future
<
void
>
checkMobileNetwork
()
async
{
Future
<
void
>
checkMobileNetwork
()
async
{
await
callApi
<
BrandNameCheckResponse
>(
await
callApi
<
BrandNameCheckResponse
>(
request:
()
=>
client
.
checkMobileNetwork
(
phoneNumber
.
value
),
request:
()
=>
_callProductApi
((
api
)
=>
api
.
checkMobileNetwork
(
phoneNumber
.
value
)
)
,
onSuccess:
(
data
,
_
)
{
onSuccess:
(
data
,
_
)
{
final
brandCode
=
data
.
brand
??
''
;
final
brandCode
=
data
.
brand
??
''
;
var
brand
=
topUpBrands
.
isNotEmpty
var
brand
=
topUpBrands
.
isNotEmpty
...
@@ -118,7 +131,7 @@ class DataNetworkServiceViewModel extends RestfulApiViewModel {
...
@@ -118,7 +131,7 @@ class DataNetworkServiceViewModel extends RestfulApiViewModel {
return
;
return
;
}
}
await
callApi
<
List
<
TopUpNetworkDataModel
>>(
await
callApi
<
List
<
TopUpNetworkDataModel
>>(
request:
()
=>
client
.
getNetworkProducts
((
id
??
0
).
toString
()),
request:
()
=>
_callProductApi
((
api
)
=>
api
.
getNetworkProducts
((
id
??
0
).
toString
())
)
,
onSuccess:
(
data
,
_
)
{
onSuccess:
(
data
,
_
)
{
final
filtered
=
(
data
)
final
filtered
=
(
data
)
.
where
((
e
)
=>
e
.
products
?.
isNotEmpty
==
true
)
.
where
((
e
)
=>
e
.
products
?.
isNotEmpty
==
true
)
...
@@ -138,7 +151,7 @@ class DataNetworkServiceViewModel extends RestfulApiViewModel {
...
@@ -138,7 +151,7 @@ class DataNetworkServiceViewModel extends RestfulApiViewModel {
return
;
return
;
}
}
await
callApi
<
EmptyCodable
>(
await
callApi
<
EmptyCodable
>(
request:
()
=>
client
.
redeemProductTopUps
(
id
,
phoneNumber
.
value
),
request:
()
=>
_callProductApi
((
api
)
=>
api
.
redeemProductTopUps
(
id
,
phoneNumber
.
value
)
)
,
onSuccess:
(
data
,
_
)
{
onSuccess:
(
data
,
_
)
{
onShowAlertRedeemSuccess
?.
call
(
"Chúc mừng bạn đã đổi Ưu đãi data thành công"
);
onShowAlertRedeemSuccess
?.
call
(
"Chúc mừng bạn đã đổi Ưu đãi data thành công"
);
},
},
...
@@ -147,4 +160,4 @@ class DataNetworkServiceViewModel extends RestfulApiViewModel {
...
@@ -147,4 +160,4 @@ class DataNetworkServiceViewModel extends RestfulApiViewModel {
},
},
);
);
}
}
}
}
\ No newline at end of file
lib/screen/electric_payment/electric_payment_bill_viewmodel.dart
View file @
a6797435
import
'package:get/get_rx/src/rx_types/rx_types.dart'
;
import
'package:get/get_rx/src/rx_types/rx_types.dart'
;
import
'package:mypoint_flutter_app/extensions/collection_extension.dart'
;
import
'package:mypoint_flutter_app/extensions/collection_extension.dart'
;
import
'package:mypoint_flutter_app/networking/api/product_api.dart'
deferred
as
product_api
;
import
'package:mypoint_flutter_app/networking/restful_api_client_all_request.dart'
;
import
'package:mypoint_flutter_app/networking/restful_api_client_all_request.dart'
;
import
'../../networking/restful_api_viewmodel.dart'
;
import
'../../networking/restful_api_viewmodel.dart'
;
import
'../transaction/model/payment_method_model.dart'
;
import
'../transaction/model/payment_method_model.dart'
;
import
'models/customer_contract_object_model.dart'
;
import
'models/customer_contract_object_model.dart'
;
import
'models/electric_payment_response_model.dart'
;
import
'models/electric_payment_response_model.dart'
;
import
'../../base/base_response_model.dart'
;
class
ElectricPaymentBillViewModel
extends
RestfulApiViewModel
{
class
ElectricPaymentBillViewModel
extends
RestfulApiViewModel
{
final
RxList
<
PaymentMethodModel
>
paymentMethods
=
<
PaymentMethodModel
>[].
obs
;
final
RxList
<
PaymentMethodModel
>
paymentMethods
=
<
PaymentMethodModel
>[].
obs
;
final
RxInt
selectedPaymentMethodIndex
=
0
.
obs
;
final
RxInt
selectedPaymentMethodIndex
=
0
.
obs
;
void
Function
(
ElectricPaymentResponseModel
data
)?
customerEvnPaymentGatewayResponse
;
void
Function
(
ElectricPaymentResponseModel
data
)?
customerEvnPaymentGatewayResponse
;
void
Function
(
String
message
)?
onShowAlertError
;
void
Function
(
String
message
)?
onShowAlertError
;
bool
_productApiLoaded
=
false
;
Future
<
void
>
_ensureProductApiLoaded
()
async
{
if
(
_productApiLoaded
)
return
;
await
product_api
.
loadLibrary
();
_productApiLoaded
=
true
;
}
Future
<
BaseResponseModel
<
T
>>
_callProductApi
<
T
>(
Future
<
BaseResponseModel
<
T
>>
Function
(
dynamic
api
)
fn
)
async
{
await
_ensureProductApiLoaded
();
final
api
=
product_api
.
ProductApi
(
client
);
return
fn
(
api
);
}
Future
<
void
>
getPaymentMethods
()
async
{
Future
<
void
>
getPaymentMethods
()
async
{
await
callApi
<
List
<
PaymentMethodModel
>>(
await
callApi
<
List
<
PaymentMethodModel
>>(
request:
()
=>
client
.
getPreviewPaymentMethods
(),
request:
()
=>
_callProductApi
((
api
)
=>
api
.
getPreviewPaymentMethods
()
)
,
onSuccess:
(
data
,
_
)
{
onSuccess:
(
data
,
_
)
{
selectedPaymentMethodIndex
.
value
=
0
;
selectedPaymentMethodIndex
.
value
=
0
;
paymentMethods
.
assignAll
(
data
);
paymentMethods
.
assignAll
(
data
);
...
...
lib/screen/electric_payment/electric_payment_history_screen.dart
View file @
a6797435
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:get/get.dart'
;
import
'package:get/get.dart'
;
import
'package:mypoint_flutter_app/extensions/num_extension.dart'
;
import
'package:mypoint_flutter_app/extensions/num_extension.dart'
;
...
@@ -189,7 +190,7 @@ class _ElectricPaymentHistoryScreenState extends State<ElectricPaymentHistoryScr
...
@@ -189,7 +190,7 @@ class _ElectricPaymentHistoryScreenState extends State<ElectricPaymentHistoryScr
GestureDetector
(
GestureDetector
(
onTap:
()
{
onTap:
()
{
Get
.
to
(
ElectricPaymentBillScreen
(
bill:
bill
,));
Get
.
to
(
ElectricPaymentBillScreen
(
bill:
bill
,));
p
rint
(
'Thanh toán hoá đơn:
${bill.maKH ?? ''}
'
);
debugP
rint
(
'Thanh toán hoá đơn:
${bill.maKH ?? ''}
'
);
},
},
child:
Container
(
child:
Container
(
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
12
,
vertical:
8
),
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
12
,
vertical:
8
),
...
...
lib/screen/faqs/faqs_viewmodel.dart
View file @
a6797435
import
'package:get/get.dart'
;
import
'package:get/get.dart'
;
import
'package:mypoint_flutter_app/networking/
restful_api_client_all_request.dart'
;
import
'package:mypoint_flutter_app/networking/
api/website_api.dart'
deferred
as
website_api
;
import
'../../networking/restful_api_viewmodel.dart'
;
import
'../../networking/restful_api_viewmodel.dart'
;
import
'faqs_model.dart'
;
import
'faqs_model.dart'
;
class
FAQViewModel
extends
RestfulApiViewModel
{
class
FAQViewModel
extends
RestfulApiViewModel
{
final
RxList
<
PageItemModel
>
faqItems
=
<
PageItemModel
>[].
obs
;
final
RxList
<
PageItemModel
>
faqItems
=
<
PageItemModel
>[].
obs
;
bool
_websiteApiLoaded
=
false
;
Future
<
void
>
_ensureWebsiteApiLoaded
()
async
{
if
(
_websiteApiLoaded
)
return
;
await
website_api
.
loadLibrary
();
_websiteApiLoaded
=
true
;
}
@override
@override
void
onInit
()
{
void
onInit
()
{
super
.
onInit
();
super
.
onInit
();
...
@@ -14,7 +22,11 @@ class FAQViewModel extends RestfulApiViewModel {
...
@@ -14,7 +22,11 @@ class FAQViewModel extends RestfulApiViewModel {
Future
<
void
>
fetchFAQItems
()
async
{
Future
<
void
>
fetchFAQItems
()
async
{
await
callApi
<
FAQItemModelResponse
>(
await
callApi
<
FAQItemModelResponse
>(
request:
()
=>
client
.
websiteFolderGetPageList
({
"folder_uri"
:
"FAQ"
}),
request:
()
async
{
await
_ensureWebsiteApiLoaded
();
final
api
=
website_api
.
WebsiteApi
(
client
);
return
api
.
websiteFolderGetPageList
({
"folder_uri"
:
"FAQ"
});
},
onSuccess:
(
data
,
_
)
{
onSuccess:
(
data
,
_
)
{
faqItems
.
assignAll
(
data
.
items
??
[]);
faqItems
.
assignAll
(
data
.
items
??
[]);
},
},
...
...
lib/screen/game/game_cards/game_card_viewmodel.dart
View file @
a6797435
import
'package:get/get.dart'
;
import
'package:get/get.dart'
;
import
'package:mypoint_flutter_app/networking/
restful_api_client_all_request.dart'
;
import
'package:mypoint_flutter_app/networking/
api/game_api.dart'
deferred
as
game_api
;
import
'../../../configs/constants.dart'
;
import
'../../../configs/constants.dart'
;
import
'../../../networking/restful_api_viewmodel.dart'
;
import
'../../../networking/restful_api_viewmodel.dart'
;
import
'../../../widgets/alert/popup_data_model.dart'
;
import
'../../../widgets/alert/popup_data_model.dart'
;
...
@@ -11,9 +11,21 @@ class GameCardViewModel extends RestfulApiViewModel {
...
@@ -11,9 +11,21 @@ class GameCardViewModel extends RestfulApiViewModel {
void
Function
(
PopupDataModel
popup
)?
submitGameCardSuccess
;
void
Function
(
PopupDataModel
popup
)?
submitGameCardSuccess
;
void
Function
()?
getGameDetailSuccess
;
void
Function
()?
getGameDetailSuccess
;
bool
_gameApiLoaded
=
false
;
Future
<
void
>
_ensureGameApiLoaded
()
async
{
if
(
_gameApiLoaded
)
return
;
await
game_api
.
loadLibrary
();
_gameApiLoaded
=
true
;
}
Future
<
void
>
submitGameCard
(
String
gameId
,
int
itemId
)
async
{
Future
<
void
>
submitGameCard
(
String
gameId
,
int
itemId
)
async
{
await
callApi
<
GameBundleItemModel
>(
await
callApi
<
GameBundleItemModel
>(
request:
()
=>
client
.
submitGameCard
(
gameId
,
itemId
.
toString
()),
request:
()
async
{
await
_ensureGameApiLoaded
();
final
api
=
game_api
.
GameApi
(
client
);
return
api
.
submitGameCard
(
gameId
,
itemId
.
toString
());
},
onSuccess:
(
data
,
_
)
{
onSuccess:
(
data
,
_
)
{
final
popupData
=
data
?.
popup
;
final
popupData
=
data
?.
popup
;
if
(
popupData
!=
null
)
{
if
(
popupData
!=
null
)
{
...
@@ -22,7 +34,7 @@ class GameCardViewModel extends RestfulApiViewModel {
...
@@ -22,7 +34,7 @@ class GameCardViewModel extends RestfulApiViewModel {
onShowAlertError
?.
call
(
Constants
.
commonError
,
false
);
onShowAlertError
?.
call
(
Constants
.
commonError
,
false
);
}
}
},
},
onFailure:
(
msg
,
_
,
_
_
)
async
{
onFailure:
(
msg
,
_
,
_
)
async
{
onShowAlertError
?.
call
(
msg
,
false
);
onShowAlertError
?.
call
(
msg
,
false
);
},
},
);
);
...
@@ -30,7 +42,11 @@ class GameCardViewModel extends RestfulApiViewModel {
...
@@ -30,7 +42,11 @@ class GameCardViewModel extends RestfulApiViewModel {
Future
<
void
>
getGameDetail
({
String
?
id
})
async
{
Future
<
void
>
getGameDetail
({
String
?
id
})
async
{
await
callApi
<
GameBundleItemModel
>(
await
callApi
<
GameBundleItemModel
>(
request:
()
=>
client
.
getGameDetail
(
id
??
data
.
value
?.
id
??
''
),
request:
()
async
{
await
_ensureGameApiLoaded
();
final
api
=
game_api
.
GameApi
(
client
);
return
api
.
getGameDetail
(
id
??
data
.
value
?.
id
??
''
);
},
onSuccess:
(
data
,
_
)
{
onSuccess:
(
data
,
_
)
{
this
.
data
.
value
=
data
;
this
.
data
.
value
=
data
;
getGameDetailSuccess
?.
call
();
getGameDetailSuccess
?.
call
();
...
@@ -40,4 +56,4 @@ class GameCardViewModel extends RestfulApiViewModel {
...
@@ -40,4 +56,4 @@ class GameCardViewModel extends RestfulApiViewModel {
},
},
);
);
}
}
}
}
\ No newline at end of file
lib/screen/game/game_tab_screen.dart
View file @
a6797435
import
'dart:io'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:get/get.dart'
;
import
'package:get/get.dart'
;
import
'package:mypoint_flutter_app/widgets/image_loader.dart'
;
import
'package:mypoint_flutter_app/widgets/image_loader.dart'
;
import
'../../base/base_screen.dart'
;
import
'../../base/base_screen.dart'
;
...
@@ -58,7 +57,7 @@ class _GameTabScreenState extends BaseState<GameTabScreen> with BasicState, Popu
...
@@ -58,7 +57,7 @@ class _GameTabScreenState extends BaseState<GameTabScreen> with BasicState, Popu
title:
"Games"
,
title:
"Games"
,
leftButtons:
_canBackButton
?
[
CustomBackButton
()]
:
[],
leftButtons:
_canBackButton
?
[
CustomBackButton
()]
:
[],
rightButtons:
[
rightButtons:
[
if
(
Platform
.
i
sI
OS
)
if
(
!
kIsWeb
&&
defaultTargetPlatform
==
Target
Platform
.
iOS
)
CompositedTransformTarget
(
CompositedTransformTarget
(
link:
_layerLink
,
link:
_layerLink
,
child:
IconButton
(
child:
IconButton
(
...
...
lib/screen/game/game_tab_viewmodel.dart
View file @
a6797435
import
'package:get/get_rx/src/rx_types/rx_types.dart'
;
import
'package:get/get_rx/src/rx_types/rx_types.dart'
;
import
'package:mypoint_flutter_app/networking/
restful_api_client_all_request.dart'
;
import
'package:mypoint_flutter_app/networking/
api/game_api.dart'
deferred
as
game_api
;
import
'package:mypoint_flutter_app/screen/game/models/game_bundle_item_model.dart'
;
import
'package:mypoint_flutter_app/screen/game/models/game_bundle_item_model.dart'
;
import
'../../networking/restful_api_viewmodel.dart'
;
import
'../../networking/restful_api_viewmodel.dart'
;
import
'models/game_bundle_response.dart'
;
import
'models/game_bundle_response.dart'
;
...
@@ -11,9 +10,21 @@ class GameTabViewModel extends RestfulApiViewModel {
...
@@ -11,9 +10,21 @@ class GameTabViewModel extends RestfulApiViewModel {
void
Function
(
String
message
)?
onShowAlertError
;
void
Function
(
String
message
)?
onShowAlertError
;
void
Function
(
GameBundleItemModel
data
)?
gotoGameDetail
;
void
Function
(
GameBundleItemModel
data
)?
gotoGameDetail
;
bool
_gameApiLoaded
=
false
;
Future
<
void
>
_ensureGameApiLoaded
()
async
{
if
(
_gameApiLoaded
)
return
;
await
game_api
.
loadLibrary
();
_gameApiLoaded
=
true
;
}
Future
<
void
>
getGames
()
{
Future
<
void
>
getGames
()
{
return
callApi
<
GameBundleResponse
>(
return
callApi
<
GameBundleResponse
>(
request:
()
=>
client
.
getGames
(),
request:
()
async
{
await
_ensureGameApiLoaded
();
final
api
=
game_api
.
GameApi
(
client
);
return
api
.
getGames
();
},
onSuccess:
(
data
,
_
)
{
onSuccess:
(
data
,
_
)
{
games
.
assignAll
(
data
.
games
??
[]);
games
.
assignAll
(
data
.
games
??
[]);
turnsNumberText
.
value
=
data
.
turnsNumberText
??
""
;
turnsNumberText
.
value
=
data
.
turnsNumberText
??
""
;
...
@@ -26,7 +37,11 @@ class GameTabViewModel extends RestfulApiViewModel {
...
@@ -26,7 +37,11 @@ class GameTabViewModel extends RestfulApiViewModel {
void
getGameDetail
(
String
gameId
)
{
void
getGameDetail
(
String
gameId
)
{
callApi
<
GameBundleItemModel
>(
callApi
<
GameBundleItemModel
>(
request:
()
=>
client
.
getGameDetail
(
gameId
),
request:
()
async
{
await
_ensureGameApiLoaded
();
final
api
=
game_api
.
GameApi
(
client
);
return
api
.
getGameDetail
(
gameId
);
},
onSuccess:
(
data
,
_
)
{
onSuccess:
(
data
,
_
)
{
gotoGameDetail
?.
call
(
data
);
gotoGameDetail
?.
call
(
data
);
},
},
...
...
lib/screen/health_book/widgets/health_book_item.dart
View file @
a6797435
...
@@ -124,3 +124,6 @@ class HealthBookItem extends StatelessWidget {
...
@@ -124,3 +124,6 @@ class HealthBookItem extends StatelessWidget {
lib/screen/home/custom_widget/hover_view_widget.dart
View file @
a6797435
import
'dart:async'
;
import
'dart:async'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:get/get.dart'
;
import
'package:get/get.dart'
;
import
'package:mypoint_flutter_app/widgets/image_loader.dart'
;
import
'package:mypoint_flutter_app/widgets/image_loader.dart'
;
...
@@ -65,7 +66,7 @@ class _HoverViewState extends State<HoverView> {
...
@@ -65,7 +66,7 @@ class _HoverViewState extends State<HoverView> {
if
(!
mounted
)
return
;
if
(!
mounted
)
return
;
setState
(()
{
setState
(()
{
_remainingSeconds
.
value
--;
_remainingSeconds
.
value
--;
p
rint
(
"Remaining seconds:
${_remainingSeconds.value}
"
);
debugP
rint
(
"Remaining seconds:
${_remainingSeconds.value}
"
);
if
(
_remainingSeconds
.
value
<=
0
)
_timer
?.
cancel
();
if
(
_remainingSeconds
.
value
<=
0
)
_timer
?.
cancel
();
});
});
});
});
...
...
lib/screen/home/header_home_viewmodel.dart
View file @
a6797435
import
'package:get/get.dart'
;
import
'package:get/get.dart'
;
import
'package:mypoint_flutter_app/networking/api/notification_api.dart'
deferred
as
notification_api
;
import
'package:mypoint_flutter_app/networking/restful_api_client_all_request.dart'
;
import
'package:mypoint_flutter_app/networking/restful_api_client_all_request.dart'
;
import
'package:mypoint_flutter_app/preference/data_preference.dart'
;
import
'package:mypoint_flutter_app/preference/data_preference.dart'
;
import
'../../networking/restful_api_viewmodel.dart'
;
import
'../../networking/restful_api_viewmodel.dart'
;
...
@@ -12,10 +14,12 @@ class HeaderHomeRepository extends RestfulApiViewModel {
...
@@ -12,10 +14,12 @@ class HeaderHomeRepository extends RestfulApiViewModel {
factory
HeaderHomeRepository
()
=>
_instance
;
factory
HeaderHomeRepository
()
=>
_instance
;
final
Rx
<
HeaderHomeModel
?>
_headerHome
=
Rx
<
HeaderHomeModel
?>(
null
);
final
Rx
<
HeaderHomeModel
?>
_headerHome
=
Rx
<
HeaderHomeModel
?>(
null
);
final
Rxn
<
NotificationUnreadData
>
_notificationUnread
=
Rxn
<
NotificationUnreadData
>();
final
Rxn
<
NotificationUnreadData
>
_notificationUnread
=
Rxn
<
NotificationUnreadData
>();
int
get
totalPoint
=>
header
.
totalPointActive
??
0
;
int
get
totalPoint
=>
header
.
totalPointActive
??
0
;
HeaderHomeModel
get
header
=>
_headerHome
.
value
??
HeaderHomeModel
get
header
=>
_headerHome
.
value
??
HeaderHomeModel
(
HeaderHomeModel
(
greeting:
'Xin chào!'
,
greeting:
'Xin chào!'
,
totalVoucher:
0
,
totalVoucher:
0
,
...
@@ -47,13 +51,25 @@ class HeaderHomeRepository extends RestfulApiViewModel {
...
@@ -47,13 +51,25 @@ class HeaderHomeRepository extends RestfulApiViewModel {
Future
<
void
>
_fetchNotificationUnread
()
async
{
Future
<
void
>
_fetchNotificationUnread
()
async
{
if
(!
DataPreference
.
instance
.
logged
)
return
;
if
(!
DataPreference
.
instance
.
logged
)
return
;
await
callApi
<
NotificationUnreadData
>(
await
callApi
<
NotificationUnreadData
>(
request:
()
=>
client
.
getNotificationUnread
(),
request:
()
async
{
await
_ensureNotificationApiLoaded
();
final
api
=
notification_api
.
NotificationApi
(
client
);
return
api
.
getNotificationUnread
();
},
onSuccess:
(
data
,
_
)
{
onSuccess:
(
data
,
_
)
{
_notificationUnread
.
value
=
data
;
_notificationUnread
.
value
=
data
;
},
},
withLoading:
false
,
withLoading:
false
,
);
);
}
}
bool
_notificationApiLoaded
=
false
;
Future
<
void
>
_ensureNotificationApiLoaded
()
async
{
if
(
_notificationApiLoaded
)
return
;
await
notification_api
.
loadLibrary
();
_notificationApiLoaded
=
true
;
}
}
}
class
HeaderThemeController
extends
GetxController
{
class
HeaderThemeController
extends
GetxController
{
...
@@ -65,7 +81,8 @@ class HeaderHomeViewModel extends GetxController {
...
@@ -65,7 +81,8 @@ class HeaderHomeViewModel extends GetxController {
final
HeaderHomeRepository
_repository
=
HeaderHomeRepository
();
final
HeaderHomeRepository
_repository
=
HeaderHomeRepository
();
HeaderHomeModel
get
headerData
=>
_repository
.
header
;
HeaderHomeModel
get
headerData
=>
_repository
.
header
;
Rxn
<
NotificationUnreadData
>
get
notificationUnreadData
=>
_repository
.
notificationStream
;
Rxn
<
NotificationUnreadData
>
get
notificationUnreadData
=>
_repository
.
notificationStream
;
@override
@override
void
onInit
()
{
void
onInit
()
{
...
...
lib/screen/home/models/achievement_model.dart
View file @
a6797435
import
'package:flutter/foundation.dart'
;
import
'package:get/get.dart'
;
import
'package:get/get.dart'
;
import
'package:json_annotation/json_annotation.dart'
;
import
'package:json_annotation/json_annotation.dart'
;
import
'package:mypoint_flutter_app/directional/directional_screen.dart'
;
import
'package:mypoint_flutter_app/directional/directional_screen.dart'
;
...
@@ -40,7 +41,7 @@ class AchievementModel {
...
@@ -40,7 +41,7 @@ class AchievementModel {
(
image
)
=>
image
.
imageType
==
'COVER'
,
(
image
)
=>
image
.
imageType
==
'COVER'
,
);
);
final
url
=
coverImage
?.
imageUrl
??
images
?.
firstOrNull
?.
imageUrl
;
final
url
=
coverImage
?.
imageUrl
??
images
?.
firstOrNull
?.
imageUrl
;
p
rint
(
"urlBackground:
$url
"
);
debugP
rint
(
"urlBackground:
$url
"
);
return
url
;
return
url
;
}
}
...
...
lib/screen/home/models/my_product_model.dart
View file @
a6797435
...
@@ -37,9 +37,7 @@ class MyProductModel {
...
@@ -37,9 +37,7 @@ class MyProductModel {
rawStatus:
json
[
'status'
]
as
int
?,
rawStatus:
json
[
'status'
]
as
int
?,
);
);
}
catch
(
e
)
{
}
catch
(
e
)
{
if
(
kDebugMode
)
{
debugPrint
(
'Failed to parse MyProductModel:
$e
'
);
print
(
'Failed to parse MyProductModel:
$e
'
);
}
rethrow
;
rethrow
;
}
}
}
}
...
@@ -65,9 +63,7 @@ class MyProductModel {
...
@@ -65,9 +63,7 @@ class MyProductModel {
try
{
try
{
return
DateTime
.
tryParse
(
expireTime
!);
return
DateTime
.
tryParse
(
expireTime
!);
}
catch
(
e
)
{
}
catch
(
e
)
{
if
(
kDebugMode
)
{
debugPrint
(
'Failed to parse expireTime:
$expireTime
-
$e
'
);
print
(
'Failed to parse expireTime:
$expireTime
-
$e
'
);
}
return
null
;
return
null
;
}
}
}
}
...
@@ -83,9 +79,7 @@ class MyProductModel {
...
@@ -83,9 +79,7 @@ class MyProductModel {
final
formatted
=
_formatDate
(
expireDate
!);
final
formatted
=
_formatDate
(
expireDate
!);
return
'HSD:
$formatted
'
;
return
'HSD:
$formatted
'
;
}
catch
(
e
)
{
}
catch
(
e
)
{
if
(
kDebugMode
)
{
debugPrint
(
'Failed to format deadline:
$e
'
);
print
(
'Failed to format deadline:
$e
'
);
}
return
'HSD: Không xác định'
;
return
'HSD: Không xác định'
;
}
}
}
}
...
...
lib/screen/location_address/location_address_viewmodel.dart
View file @
a6797435
import
'package:get/get.dart'
;
import
'package:get/get.dart'
;
import
'package:mypoint_flutter_app/networking/restful_api_client_all_request.dart'
;
import
'package:mypoint_flutter_app/networking/api/location_api.dart'
deferred
as
location_api
;
import
'../../base/base_response_model.dart'
;
import
'../../networking/restful_api_viewmodel.dart'
;
import
'../../networking/restful_api_viewmodel.dart'
;
import
'location_address_screen.dart'
;
import
'location_address_screen.dart'
;
import
'models/district_address_model.dart'
;
import
'models/district_address_model.dart'
;
...
@@ -18,6 +19,20 @@ class LocationAddressViewModel extends RestfulApiViewModel {
...
@@ -18,6 +19,20 @@ class LocationAddressViewModel extends RestfulApiViewModel {
LocationAddressType
type
=
LocationAddressType
.
province
;
LocationAddressType
type
=
LocationAddressType
.
province
;
String
provinceCode
=
''
;
String
provinceCode
=
''
;
bool
_locationApiLoaded
=
false
;
Future
<
void
>
_ensureLocationApiLoaded
()
async
{
if
(
_locationApiLoaded
)
return
;
await
location_api
.
loadLibrary
();
_locationApiLoaded
=
true
;
}
Future
<
BaseResponseModel
<
T
>>
_callLocationApi
<
T
>(
Future
<
BaseResponseModel
<
T
>>
Function
(
dynamic
api
)
fn
)
async
{
await
_ensureLocationApiLoaded
();
final
api
=
location_api
.
LocationApi
(
client
);
return
fn
(
api
);
}
LocationAddressViewModel
({
this
.
type
=
LocationAddressType
.
province
,
this
.
provinceCode
=
''
});
LocationAddressViewModel
({
this
.
type
=
LocationAddressType
.
province
,
this
.
provinceCode
=
''
});
@override
@override
...
@@ -25,7 +40,7 @@ class LocationAddressViewModel extends RestfulApiViewModel {
...
@@ -25,7 +40,7 @@ class LocationAddressViewModel extends RestfulApiViewModel {
super
.
onInit
();
super
.
onInit
();
if
(
type
==
LocationAddressType
.
province
)
{
if
(
type
==
LocationAddressType
.
province
)
{
callApi
<
ProvinceAddressResponse
>(
callApi
<
ProvinceAddressResponse
>(
request:
()
=>
client
.
locationProvinceGetList
(),
request:
()
=>
_callLocationApi
((
api
)
=>
api
.
locationProvinceGetList
()
)
,
onSuccess:
(
data
,
_
)
{
onSuccess:
(
data
,
_
)
{
_loadFromProvince
(
data
.
items
??
[]);
_loadFromProvince
(
data
.
items
??
[]);
},
},
...
@@ -33,7 +48,7 @@ class LocationAddressViewModel extends RestfulApiViewModel {
...
@@ -33,7 +48,7 @@ class LocationAddressViewModel extends RestfulApiViewModel {
);
);
}
else
{
}
else
{
callApi
<
DistrictAddressResponse
>(
callApi
<
DistrictAddressResponse
>(
request:
()
=>
client
.
locationDistrictGetList
(
provinceCode
),
request:
()
=>
_callLocationApi
((
api
)
=>
api
.
locationDistrictGetList
(
provinceCode
)
)
,
onSuccess:
(
data
,
_
)
{
onSuccess:
(
data
,
_
)
{
_loadFromDistrict
(
data
.
items
??
[]);
_loadFromDistrict
(
data
.
items
??
[]);
},
},
...
@@ -58,11 +73,12 @@ class LocationAddressViewModel extends RestfulApiViewModel {
...
@@ -58,11 +73,12 @@ class LocationAddressViewModel extends RestfulApiViewModel {
return
;
return
;
}
}
final
lowerQuery
=
_removeDiacritics
(
query
).
toLowerCase
();
final
lowerQuery
=
_removeDiacritics
(
query
).
toLowerCase
();
final
filteredItems
=
_allItems
.
where
((
item
)
{
final
filteredItems
=
final
name
=
item
.
name
??
''
;
_allItems
.
where
((
item
)
{
final
normalized
=
_removeDiacritics
(
name
).
toLowerCase
();
final
name
=
item
.
name
??
''
;
return
normalized
.
contains
(
lowerQuery
);
final
normalized
=
_removeDiacritics
(
name
).
toLowerCase
();
}).
toList
();
return
normalized
.
contains
(
lowerQuery
);
}).
toList
();
displayItems
.
assignAll
(
filteredItems
);
displayItems
.
assignAll
(
filteredItems
);
}
}
...
@@ -73,9 +89,11 @@ class LocationAddressViewModel extends RestfulApiViewModel {
...
@@ -73,9 +89,11 @@ class LocationAddressViewModel extends RestfulApiViewModel {
}
}
String
_removeDiacritics
(
String
str
)
{
String
_removeDiacritics
(
String
str
)
{
const
withDiacritics
=
'àáảãạâầấẩẫậăằắẳẵặèéẻẽẹêềếểễệìíỉĩịòóỏõọôồốổỗộơờớởỡợùúủũụưừứửữựỳýỷỹỵđ'
const
withDiacritics
=
'àáảãạâầấẩẫậăằắẳẵặèéẻẽẹêềếểễệìíỉĩịòóỏõọôồốổỗộơờớởỡợùúủũụưừứửữựỳýỷỹỵđ'
'ÀÁẢÃẠÂẦẤẨẪẬĂẰẮẲẴẶÈÉẺẼẸÊỀẾỂỄỆÌÍỈĨỊÒÓỎÕỌÔỒỐỔỖỘƠỜỚỞỠỢÙÚỦŨỤƯỪỨỬỮỰỲÝỶỸỴĐ'
;
'ÀÁẢÃẠÂẦẤẨẪẬĂẰẮẲẴẶÈÉẺẼẸÊỀẾỂỄỆÌÍỈĨỊÒÓỎÕỌÔỒỐỔỖỘƠỜỚỞỠỢÙÚỦŨỤƯỪỨỬỮỰỲÝỶỸỴĐ'
;
const
withoutDiacritics
=
'aaaaaaaaaaaaaaaaaeeeeeeeeeeeiiiiiooooooooooooooooouuuuuuuuuuuyyyyyd'
const
withoutDiacritics
=
'aaaaaaaaaaaaaaaaaeeeeeeeeeeeiiiiiooooooooooooooooouuuuuuuuuuuyyyyyd'
'AAAAAAAAAAAAAAAAAEEEEEEEEEEEIIIIIOOOOOOOOOOOOOOOOOUUUUUUUUUUUYYYYYD'
;
'AAAAAAAAAAAAAAAAAEEEEEEEEEEEIIIIIOOOOOOOOOOOOOOOOOUUUUUUUUUUUYYYYYD'
;
for
(
int
i
=
0
;
i
<
withDiacritics
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
withDiacritics
.
length
;
i
++)
{
...
...
Prev
1
2
3
4
5
6
Next
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