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
fda33894
Commit
fda33894
authored
Jun 06, 2025
by
DatHV
Browse files
cap nhat giao dien
parent
75178f29
Changes
86
Show whitespace changes
Inline
Side-by-side
lib/screen/home/models/brand_model.dart
0 → 100644
View file @
fda33894
import
'package:json_annotation/json_annotation.dart'
;
import
'brand_category_model.dart'
;
import
'image_model.dart'
;
part
'brand_model.g.dart'
;
@JsonSerializable
()
class
BrandModel
{
@JsonKey
(
name:
'organization_id'
)
final
String
?
organizationId
;
@JsonKey
(
name:
'organization_code'
)
final
String
?
organizationCode
;
@JsonKey
(
name:
'organization_name'
)
final
String
?
organizationName
;
@JsonKey
(
name:
'brand_id'
)
final
String
?
brandId
;
@JsonKey
(
name:
'brand_code'
)
final
String
?
brandCode
;
@JsonKey
(
name:
'brand_name'
)
final
String
?
brandName
;
@JsonKey
(
name:
'contact_name'
)
final
String
?
contactName
;
final
String
?
phone
;
final
String
?
mobile
;
final
String
?
fax
;
final
String
?
email
;
final
String
?
address1
;
final
String
?
address2
;
final
String
?
address3
;
final
String
?
city
;
final
String
?
country
;
final
String
?
website
;
@JsonKey
(
name:
'point_accumulation_rate'
)
final
String
?
pointAccumulationRate
;
final
BrandCategoryModel
?
category
;
final
String
?
logo
;
final
List
<
ImageModel
>?
images
;
const
BrandModel
({
this
.
organizationId
,
this
.
organizationCode
,
this
.
organizationName
,
this
.
brandId
,
this
.
brandCode
,
this
.
brandName
,
this
.
contactName
,
this
.
phone
,
this
.
mobile
,
this
.
fax
,
this
.
email
,
this
.
address1
,
this
.
address2
,
this
.
address3
,
this
.
city
,
this
.
country
,
this
.
website
,
this
.
pointAccumulationRate
,
this
.
category
,
this
.
logo
,
this
.
images
,
});
factory
BrandModel
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
=>
_$BrandModelFromJson
(
json
);
Map
<
String
,
dynamic
>
toJson
()
=>
_$BrandModelToJson
(
this
);
String
get
displayPointAccumulationRate
{
final
value
=
pointAccumulationRate
?.
replaceAll
(
'%'
,
''
)
??
'0'
;
final
doubleValue
=
double
.
tryParse
(
value
)
??
0
;
return
doubleValue
.
toInt
().
toString
();
}
}
lib/screen/home/models/brand_model.g.dart
0 → 100644
View file @
fda33894
// GENERATED CODE - DO NOT MODIFY BY HAND
part of
'brand_model.dart'
;
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
BrandModel
_$BrandModelFromJson
(
Map
<
String
,
dynamic
>
json
)
=>
BrandModel
(
organizationId:
json
[
'organization_id'
]
as
String
?,
organizationCode:
json
[
'organization_code'
]
as
String
?,
organizationName:
json
[
'organization_name'
]
as
String
?,
brandId:
json
[
'brand_id'
]
as
String
?,
brandCode:
json
[
'brand_code'
]
as
String
?,
brandName:
json
[
'brand_name'
]
as
String
?,
contactName:
json
[
'contact_name'
]
as
String
?,
phone:
json
[
'phone'
]
as
String
?,
mobile:
json
[
'mobile'
]
as
String
?,
fax:
json
[
'fax'
]
as
String
?,
email:
json
[
'email'
]
as
String
?,
address1:
json
[
'address1'
]
as
String
?,
address2:
json
[
'address2'
]
as
String
?,
address3:
json
[
'address3'
]
as
String
?,
city:
json
[
'city'
]
as
String
?,
country:
json
[
'country'
]
as
String
?,
website:
json
[
'website'
]
as
String
?,
pointAccumulationRate:
json
[
'point_accumulation_rate'
]
as
String
?,
category:
json
[
'category'
]
==
null
?
null
:
BrandCategoryModel
.
fromJson
(
json
[
'category'
]
as
Map
<
String
,
dynamic
>,
),
logo:
json
[
'logo'
]
as
String
?,
images:
(
json
[
'images'
]
as
List
<
dynamic
>?)
?.
map
((
e
)
=>
ImageModel
.
fromJson
(
e
as
Map
<
String
,
dynamic
>))
.
toList
(),
);
Map
<
String
,
dynamic
>
_$BrandModelToJson
(
BrandModel
instance
)
=>
<
String
,
dynamic
>{
'organization_id'
:
instance
.
organizationId
,
'organization_code'
:
instance
.
organizationCode
,
'organization_name'
:
instance
.
organizationName
,
'brand_id'
:
instance
.
brandId
,
'brand_code'
:
instance
.
brandCode
,
'brand_name'
:
instance
.
brandName
,
'contact_name'
:
instance
.
contactName
,
'phone'
:
instance
.
phone
,
'mobile'
:
instance
.
mobile
,
'fax'
:
instance
.
fax
,
'email'
:
instance
.
email
,
'address1'
:
instance
.
address1
,
'address2'
:
instance
.
address2
,
'address3'
:
instance
.
address3
,
'city'
:
instance
.
city
,
'country'
:
instance
.
country
,
'website'
:
instance
.
website
,
'point_accumulation_rate'
:
instance
.
pointAccumulationRate
,
'category'
:
instance
.
category
,
'logo'
:
instance
.
logo
,
'images'
:
instance
.
images
,
};
lib/screen/home/models/flash_sale_model.dart
0 → 100644
View file @
fda33894
import
'package:json_annotation/json_annotation.dart'
;
import
'../../flash_sale/preview_flash_sale_model.dart'
;
import
'../../voucher/models/product_model.dart'
;
part
'flash_sale_model.g.dart'
;
@JsonSerializable
()
class
FlashSaleModel
{
final
int
id
;
final
String
?
name
;
@JsonKey
(
name:
'start_time'
)
final
String
?
startTime
;
@JsonKey
(
name:
'end_time'
)
final
String
?
endTime
;
@JsonKey
(
name:
'header_img'
)
final
String
?
headerImg
;
@JsonKey
(
name:
'countdown_second'
)
final
int
?
countdownSecond
;
final
List
<
ProductModel
>?
products
;
const
FlashSaleModel
({
required
this
.
id
,
this
.
name
,
this
.
startTime
,
this
.
endTime
,
this
.
headerImg
,
this
.
countdownSecond
,
this
.
products
,
});
factory
FlashSaleModel
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
=>
_$FlashSaleModelFromJson
(
json
);
Map
<
String
,
dynamic
>
toJson
()
=>
_$FlashSaleModelToJson
(
this
);
PreviewFlashSale
get
info
{
final
info
=
products
?.
first
?.
previewFlashSale
??
PreviewFlashSale
(
id:
id
,
countdownSecond:
countdownSecond
,
startTime:
startTime
,
endTime:
endTime
,
name:
name
,
headerImg:
headerImg
,
);
info
.
headerImg
=
headerImg
;
return
info
;
}
}
lib/screen/home/models/flash_sale_model.g.dart
0 → 100644
View file @
fda33894
// GENERATED CODE - DO NOT MODIFY BY HAND
part of
'flash_sale_model.dart'
;
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
FlashSaleModel
_$FlashSaleModelFromJson
(
Map
<
String
,
dynamic
>
json
)
=>
FlashSaleModel
(
id:
(
json
[
'id'
]
as
num
).
toInt
(),
name:
json
[
'name'
]
as
String
?,
startTime:
json
[
'start_time'
]
as
String
?,
endTime:
json
[
'end_time'
]
as
String
?,
headerImg:
json
[
'header_img'
]
as
String
?,
countdownSecond:
(
json
[
'countdown_second'
]
as
num
?)?.
toInt
(),
products:
(
json
[
'products'
]
as
List
<
dynamic
>?)
?.
map
((
e
)
=>
ProductModel
.
fromJson
(
e
as
Map
<
String
,
dynamic
>))
.
toList
(),
);
Map
<
String
,
dynamic
>
_$FlashSaleModelToJson
(
FlashSaleModel
instance
)
=>
<
String
,
dynamic
>{
'id'
:
instance
.
id
,
'name'
:
instance
.
name
,
'start_time'
:
instance
.
startTime
,
'end_time'
:
instance
.
endTime
,
'header_img'
:
instance
.
headerImg
,
'countdown_second'
:
instance
.
countdownSecond
,
'products'
:
instance
.
products
,
};
lib/screen/home/models/header_home_model.dart
0 → 100644
View file @
fda33894
import
'package:json_annotation/json_annotation.dart'
;
part
'header_home_model.g.dart'
;
@JsonSerializable
()
class
HeaderHomeModel
{
final
String
?
background
;
final
String
?
greeting
;
@JsonKey
(
name:
'display_point_active'
)
final
String
?
displayPointActive
;
@JsonKey
(
name:
'total_point_active'
)
final
int
?
totalPointActive
;
@JsonKey
(
name:
'total_voucher'
)
final
int
?
totalVoucher
;
HeaderHomeModel
({
this
.
background
,
this
.
greeting
,
this
.
displayPointActive
,
this
.
totalPointActive
,
this
.
totalVoucher
,
});
factory
HeaderHomeModel
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
=>
_$HeaderHomeModelFromJson
(
json
);
Map
<
String
,
dynamic
>
toJson
()
=>
_$HeaderHomeModelToJson
(
this
);
}
lib/screen/home/models/header_home_model.g.dart
0 → 100644
View file @
fda33894
// GENERATED CODE - DO NOT MODIFY BY HAND
part of
'header_home_model.dart'
;
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
HeaderHomeModel
_$HeaderHomeModelFromJson
(
Map
<
String
,
dynamic
>
json
)
=>
HeaderHomeModel
(
background:
json
[
'background'
]
as
String
?,
greeting:
json
[
'greeting'
]
as
String
?,
displayPointActive:
json
[
'display_point_active'
]
as
String
?,
totalPointActive:
(
json
[
'total_point_active'
]
as
num
?)?.
toInt
(),
totalVoucher:
(
json
[
'total_voucher'
]
as
num
?)?.
toInt
(),
);
Map
<
String
,
dynamic
>
_$HeaderHomeModelToJson
(
HeaderHomeModel
instance
)
=>
<
String
,
dynamic
>{
'background'
:
instance
.
background
,
'greeting'
:
instance
.
greeting
,
'display_point_active'
:
instance
.
displayPointActive
,
'total_point_active'
:
instance
.
totalPointActive
,
'total_voucher'
:
instance
.
totalVoucher
,
};
lib/screen/home/models/header_section_type.dart
0 → 100644
View file @
fda33894
enum
HeaderSectionType
{
profileHeader
,
topButton
,
banner
,
flashSale
,
brand
,
pointPartner
,
campaign
,
product
,
myProduct
,
news
,
}
extension
HeaderSectionTypeExtension
on
HeaderSectionType
{
String
get
key
{
switch
(
this
)
{
case
HeaderSectionType
.
profileHeader
:
return
"LOCAL_PROFILE_HEADER"
;
case
HeaderSectionType
.
topButton
:
return
"QUICK_BUTTONS"
;
case
HeaderSectionType
.
banner
:
return
"BANNERS"
;
case
HeaderSectionType
.
flashSale
:
return
"FLASH_SALE"
;
case
HeaderSectionType
.
brand
:
return
"BRANDS"
;
case
HeaderSectionType
.
pointPartner
:
return
"POINT_PARTNERS"
;
case
HeaderSectionType
.
campaign
:
return
"CAMPAIGNS"
;
case
HeaderSectionType
.
product
:
return
"PRODUCTS"
;
case
HeaderSectionType
.
myProduct
:
return
"MY_VOUCHERS"
;
case
HeaderSectionType
.
news
:
return
"MYPOINT_HOT"
;
}
}
static
HeaderSectionType
?
fromString
(
String
value
)
{
switch
(
value
)
{
case
"LOCAL_PROFILE_HEADER"
:
return
HeaderSectionType
.
profileHeader
;
case
"QUICK_BUTTONS"
:
return
HeaderSectionType
.
topButton
;
case
"BANNERS"
:
return
HeaderSectionType
.
banner
;
case
"FLASH_SALE"
:
return
HeaderSectionType
.
flashSale
;
case
"BRANDS"
:
return
HeaderSectionType
.
brand
;
case
"POINT_PARTNERS"
:
return
HeaderSectionType
.
pointPartner
;
case
"CAMPAIGNS"
:
return
HeaderSectionType
.
campaign
;
case
"PRODUCTS"
:
return
HeaderSectionType
.
product
;
case
"MY_VOUCHERS"
:
return
HeaderSectionType
.
myProduct
;
case
"MYPOINT_HOT"
:
return
HeaderSectionType
.
news
;
default
:
return
null
;
}
}
}
lib/screen/home/models/hover_data_model.dart
0 → 100644
View file @
fda33894
import
'package:json_annotation/json_annotation.dart'
;
import
'package:intl/intl.dart'
;
import
'../../../directional/directional_screen.dart'
;
part
'hover_data_model.g.dart'
;
@JsonSerializable
()
class
HoverDataModel
{
final
String
?
icon
;
@JsonKey
(
name:
'click_action_type'
)
final
String
?
clickActionType
;
@JsonKey
(
name:
'click_action_param'
)
final
String
?
clickActionParam
;
final
int
?
badge
;
final
String
?
countdown
;
HoverDataModel
({
this
.
icon
,
this
.
clickActionType
,
this
.
clickActionParam
,
this
.
badge
,
this
.
countdown
,
});
double
?
get
countDownTime
{
if
(
countdown
==
null
)
return
null
;
try
{
final
date
=
DateFormat
(
"yyyy-MM-dd'T'HH:mm:ss"
).
parseUtc
(
countdown
!);
final
now
=
DateTime
.
now
().
toUtc
();
final
diff
=
date
.
difference
(
now
).
inSeconds
;
return
(
diff
>
0
?
diff
:
0
).
toDouble
();
}
catch
(
_
)
{
return
null
;
}
}
DirectionalScreen
?
get
direction
{
return
DirectionalScreen
.
build
(
clickActionType:
clickActionType
,
clickActionParam:
clickActionParam
,
);
}
factory
HoverDataModel
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
=>
_$HoverDataModelFromJson
(
json
);
Map
<
String
,
dynamic
>
toJson
()
=>
_$HoverDataModelToJson
(
this
);
}
lib/
directional/directional_screen
.g.dart
→
lib/
screen/home/models/hover_data_model
.g.dart
View file @
fda33894
// GENERATED CODE - DO NOT MODIFY BY HAND
part of
'
directional_screen
.dart'
;
part of
'
hover_data_model
.dart'
;
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
DirectionalScreen
_$DirectionalScreenFromJson
(
Map
<
String
,
dynamic
>
json
)
=>
DirectionalScreen
(
HoverDataModel
_$HoverDataModelFromJson
(
Map
<
String
,
dynamic
>
json
)
=>
HoverDataModel
(
icon:
json
[
'icon'
]
as
String
?,
clickActionType:
json
[
'click_action_type'
]
as
String
?,
clickActionParam:
json
[
'click_action_param'
]
as
String
?,
badge:
(
json
[
'badge'
]
as
num
?)?.
toInt
(),
countdown:
json
[
'countdown'
]
as
String
?,
);
Map
<
String
,
dynamic
>
_$
DirectionalScreenToJson
(
DirectionalScreen
instance
)
=>
Map
<
String
,
dynamic
>
_$
HoverDataModelToJson
(
HoverDataModel
instance
)
=>
<
String
,
dynamic
>{
'icon'
:
instance
.
icon
,
'click_action_type'
:
instance
.
clickActionType
,
'click_action_param'
:
instance
.
clickActionParam
,
'badge'
:
instance
.
badge
,
'countdown'
:
instance
.
countdown
,
};
lib/screen/home/models/image_model.dart
0 → 100644
View file @
fda33894
import
'package:json_annotation/json_annotation.dart'
;
part
'image_model.g.dart'
;
@JsonSerializable
()
class
ImageModel
{
final
String
?
id
;
final
String
?
type
;
final
String
?
caption
;
@JsonKey
(
name:
'image_type'
)
final
String
?
imageType
;
@JsonKey
(
name:
'image_url'
)
final
String
?
imageUrl
;
const
ImageModel
({
this
.
id
,
this
.
type
,
this
.
caption
,
this
.
imageType
,
this
.
imageUrl
,
});
factory
ImageModel
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
=>
_$ImageModelFromJson
(
json
);
Map
<
String
,
dynamic
>
toJson
()
=>
_$ImageModelToJson
(
this
);
}
lib/screen/home/models/image_model.g.dart
0 → 100644
View file @
fda33894
// GENERATED CODE - DO NOT MODIFY BY HAND
part of
'image_model.dart'
;
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
ImageModel
_$ImageModelFromJson
(
Map
<
String
,
dynamic
>
json
)
=>
ImageModel
(
id:
json
[
'id'
]
as
String
?,
type:
json
[
'type'
]
as
String
?,
caption:
json
[
'caption'
]
as
String
?,
imageType:
json
[
'image_type'
]
as
String
?,
imageUrl:
json
[
'image_url'
]
as
String
?,
);
Map
<
String
,
dynamic
>
_$ImageModelToJson
(
ImageModel
instance
)
=>
<
String
,
dynamic
>{
'id'
:
instance
.
id
,
'type'
:
instance
.
type
,
'caption'
:
instance
.
caption
,
'image_type'
:
instance
.
imageType
,
'image_url'
:
instance
.
imageUrl
,
};
lib/screen/home/models/main_section_config_model.dart
0 → 100644
View file @
fda33894
import
'package:json_annotation/json_annotation.dart'
;
import
'../../flash_sale/preview_flash_sale_model.dart'
;
import
'header_section_type.dart'
;
part
'main_section_config_model.g.dart'
;
@JsonSerializable
()
class
MainSectionConfigModel
{
final
int
?
id
;
final
String
?
name
;
final
String
?
type
;
final
String
?
layout
;
@JsonKey
(
name:
'slider_speed'
)
final
int
?
sliderSpeed
;
final
int
?
order
;
@JsonKey
(
name:
'api_list'
)
final
String
?
apiList
;
@JsonKey
(
name:
'button_view_all'
)
final
MainHeaderConfigRightButton
?
buttonViewAll
;
@JsonKey
(
name:
'flash_sale'
)
final
PreviewFlashSale
?
flashSale
;
HeaderSectionType
?
get
headerSectionType
{
return
HeaderSectionTypeExtension
.
fromString
(
type
??
""
);
}
MainSectionConfigModel
({
this
.
id
,
this
.
name
,
this
.
type
,
this
.
layout
,
this
.
sliderSpeed
,
this
.
order
,
this
.
apiList
,
this
.
buttonViewAll
,
this
.
flashSale
,
});
factory
MainSectionConfigModel
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
=>
_$MainSectionConfigModelFromJson
(
json
);
Map
<
String
,
dynamic
>
toJson
()
=>
_$MainSectionConfigModelToJson
(
this
);
}
class
MainHeaderConfigRightButton
{
final
String
?
text
;
final
String
?
clickActionType
;
final
String
?
clickActionParam
;
MainHeaderConfigRightButton
({
this
.
text
,
this
.
clickActionType
,
this
.
clickActionParam
,
});
factory
MainHeaderConfigRightButton
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
return
MainHeaderConfigRightButton
(
text:
json
[
'text'
]
as
String
?,
clickActionType:
json
[
'click_action_type'
]
as
String
?,
clickActionParam:
json
[
'click_action_param'
]
as
String
?,
);
}
Map
<
String
,
dynamic
>
toJson
()
{
return
{
'text'
:
text
,
'click_action_type'
:
clickActionType
,
'click_action_param'
:
clickActionParam
,
};
}
}
\ No newline at end of file
lib/screen/home/models/main_section_config_model.g.dart
0 → 100644
View file @
fda33894
// GENERATED CODE - DO NOT MODIFY BY HAND
part of
'main_section_config_model.dart'
;
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
MainSectionConfigModel
_$MainSectionConfigModelFromJson
(
Map
<
String
,
dynamic
>
json
,
)
=>
MainSectionConfigModel
(
id:
(
json
[
'id'
]
as
num
?)?.
toInt
(),
name:
json
[
'name'
]
as
String
?,
type:
json
[
'type'
]
as
String
?,
layout:
json
[
'layout'
]
as
String
?,
sliderSpeed:
(
json
[
'slider_speed'
]
as
num
?)?.
toInt
(),
order:
(
json
[
'order'
]
as
num
?)?.
toInt
(),
apiList:
json
[
'api_list'
]
as
String
?,
buttonViewAll:
json
[
'button_view_all'
]
==
null
?
null
:
MainHeaderConfigRightButton
.
fromJson
(
json
[
'button_view_all'
]
as
Map
<
String
,
dynamic
>,
),
flashSale:
json
[
'flash_sale'
]
==
null
?
null
:
PreviewFlashSale
.
fromJson
(
json
[
'flash_sale'
]
as
Map
<
String
,
dynamic
>,
),
);
Map
<
String
,
dynamic
>
_$MainSectionConfigModelToJson
(
MainSectionConfigModel
instance
,
)
=>
<
String
,
dynamic
>{
'id'
:
instance
.
id
,
'name'
:
instance
.
name
,
'type'
:
instance
.
type
,
'layout'
:
instance
.
layout
,
'slider_speed'
:
instance
.
sliderSpeed
,
'order'
:
instance
.
order
,
'api_list'
:
instance
.
apiList
,
'button_view_all'
:
instance
.
buttonViewAll
,
'flash_sale'
:
instance
.
flashSale
,
};
lib/screen/home/models/main_service_model.dart
0 → 100644
View file @
fda33894
import
'package:json_annotation/json_annotation.dart'
;
import
'package:mypoint_flutter_app/directional/directional_screen.dart'
;
part
'main_service_model.g.dart'
;
@JsonSerializable
()
class
MainServiceModel
{
@JsonKey
(
name:
'service_name'
)
final
String
?
serviceName
;
@JsonKey
(
name:
'service_icon'
)
final
String
?
serviceIcon
;
@JsonKey
(
name:
'image_url'
)
final
String
?
imageUrl
;
@JsonKey
(
name:
'click_action_type'
)
final
String
?
clickActionType
;
@JsonKey
(
name:
'click_action_param'
)
final
String
?
clickActionParam
;
@JsonKey
(
name:
'event_describle'
)
final
String
?
eventDescrible
;
@JsonKey
(
name:
'event_color'
)
final
String
?
eventColor
;
@JsonKey
(
name:
'service_code'
)
final
String
?
serviceCode
;
const
MainServiceModel
({
this
.
serviceName
,
this
.
serviceIcon
,
this
.
imageUrl
,
this
.
clickActionType
,
this
.
clickActionParam
,
this
.
eventDescrible
,
this
.
eventColor
,
this
.
serviceCode
,
});
DirectionalScreen
?
get
directionalScreen
{
return
DirectionalScreen
.
build
(
clickActionType:
clickActionType
,
clickActionParam:
clickActionParam
,
);
}
factory
MainServiceModel
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
=>
_$MainServiceModelFromJson
(
json
);
Map
<
String
,
dynamic
>
toJson
()
=>
_$MainServiceModelToJson
(
this
);
}
lib/screen/home/models/main_service_model.g.dart
0 → 100644
View file @
fda33894
// GENERATED CODE - DO NOT MODIFY BY HAND
part of
'main_service_model.dart'
;
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
MainServiceModel
_$MainServiceModelFromJson
(
Map
<
String
,
dynamic
>
json
)
=>
MainServiceModel
(
serviceName:
json
[
'service_name'
]
as
String
?,
serviceIcon:
json
[
'service_icon'
]
as
String
?,
imageUrl:
json
[
'image_url'
]
as
String
?,
clickActionType:
json
[
'click_action_type'
]
as
String
?,
clickActionParam:
json
[
'click_action_param'
]
as
String
?,
eventDescrible:
json
[
'event_describle'
]
as
String
?,
eventColor:
json
[
'event_color'
]
as
String
?,
serviceCode:
json
[
'service_code'
]
as
String
?,
);
Map
<
String
,
dynamic
>
_$MainServiceModelToJson
(
MainServiceModel
instance
)
=>
<
String
,
dynamic
>{
'service_name'
:
instance
.
serviceName
,
'service_icon'
:
instance
.
serviceIcon
,
'image_url'
:
instance
.
imageUrl
,
'click_action_type'
:
instance
.
clickActionType
,
'click_action_param'
:
instance
.
clickActionParam
,
'event_describle'
:
instance
.
eventDescrible
,
'event_color'
:
instance
.
eventColor
,
'service_code'
:
instance
.
serviceCode
,
};
lib/screen/home/models/my_product_model.dart
0 → 100644
View file @
fda33894
import
'../../voucher/models/my_product_status_type.dart'
;
class
MyProductModel
{
final
int
?
id
;
final
String
?
title
;
final
String
?
logo
;
final
String
?
brandName
;
final
String
?
expireTime
;
final
String
?
createdAt
;
final
String
?
updatedAt
;
final
int
?
rawStatus
;
const
MyProductModel
({
this
.
id
,
this
.
title
,
this
.
logo
,
this
.
brandName
,
this
.
expireTime
,
this
.
createdAt
,
this
.
updatedAt
,
this
.
rawStatus
,
});
factory
MyProductModel
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
return
MyProductModel
(
id:
(
json
[
'id'
]
as
num
).
toInt
(),
title:
json
[
'title'
]
as
String
?,
logo:
json
[
'logo'
]
as
String
?,
brandName:
json
[
'brand_name'
]
as
String
?,
expireTime:
json
[
'expire_time'
]
as
String
?,
createdAt:
json
[
'created_at'
]
as
String
?,
updatedAt:
json
[
'updated_at'
]
as
String
?,
rawStatus:
json
[
'status'
]
as
int
?,
);
}
Map
<
String
,
dynamic
>
toJson
()
=>
{
'id'
:
id
,
'title'
:
title
,
'logo'
:
logo
,
'brand_name'
:
brandName
,
'expire_time'
:
expireTime
,
'created_at'
:
createdAt
,
'updated_at'
:
updatedAt
,
'status'
:
rawStatus
,
};
MyProductStatusType
?
get
status
{
if
(
rawStatus
==
null
)
return
null
;
return
MyProductStatusType
.
fromRaw
(
rawStatus
!);
}
DateTime
?
get
expireDate
{
if
(
expireTime
==
null
)
return
null
;
return
DateTime
.
tryParse
(
expireTime
!);
}
String
get
deadline
{
if
(
expireDate
==
null
)
return
''
;
final
formatted
=
_formatDate
(
expireDate
!);
return
'HSD:
$formatted
'
;
}
String
_formatDate
(
DateTime
date
)
{
return
"
${date.day.toString().padLeft(2, '0')}
/
${date.month.toString().padLeft(2, '0')}
/
${date.year}
"
;
}
}
lib/screen/home/models/notification_unread_model.dart
0 → 100644
View file @
fda33894
class
NotificationUnreadData
{
final
int
?
unread
;
final
bool
?
giftBoxStatus
;
NotificationUnreadData
({
this
.
unread
,
this
.
giftBoxStatus
,
});
factory
NotificationUnreadData
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
return
NotificationUnreadData
(
unread:
json
[
'unread'
]
as
int
?,
giftBoxStatus:
json
[
'giftbox_status'
]
as
bool
?,
);
}
Map
<
String
,
dynamic
>
toJson
()
{
return
{
'unread'
:
unread
,
'giftbox_status'
:
giftBoxStatus
,
};
}
}
lib/screen/home/models/pipi_detail_model.dart
0 → 100644
View file @
fda33894
import
'package:mypoint_flutter_app/directional/directional_screen.dart'
;
class
PipiSupportItemModel
{
final
String
?
id
;
final
String
?
icon
;
final
String
?
title
;
final
String
?
clickActionType
;
final
String
?
clickActionParam
;
PipiSupportItemModel
({
this
.
id
,
this
.
icon
,
this
.
title
,
this
.
clickActionType
,
this
.
clickActionParam
,
});
DirectionalScreen
?
get
directionScreen
{
return
DirectionalScreen
.
build
(
clickActionType:
clickActionType
,
clickActionParam:
clickActionParam
,
);
}
factory
PipiSupportItemModel
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
=>
PipiSupportItemModel
(
id:
json
[
'id'
]
as
String
?,
icon:
json
[
'icon'
]
as
String
?,
title:
json
[
'title'
]
as
String
?,
clickActionType:
json
[
'click_action_type'
]
as
String
?,
clickActionParam:
json
[
'click_action_param'
]
as
String
?,
);
}
class
PipiDetailResponseModel
{
final
List
<
PipiSupportItemModel
>?
items
;
PipiDetailResponseModel
({
this
.
items
,
});
factory
PipiDetailResponseModel
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
=>
PipiDetailResponseModel
(
items:
(
json
[
'list_items'
]
as
List
<
dynamic
>?)
?.
map
((
e
)
=>
PipiSupportItemModel
.
fromJson
(
e
as
Map
<
String
,
dynamic
>))
.
toList
(),
);
}
\ No newline at end of file
lib/screen/home/models/preview_flash_sale_model.dart
0 → 100644
View file @
fda33894
class
PreviewFlashSale
{
final
int
?
id
;
final
int
?
countdownSecond
;
final
String
?
startTime
;
final
String
?
endTime
;
final
int
?
fsQuantityTotal
;
final
int
?
fsQuantitySold
;
final
int
?
percentTag
;
final
String
?
rewardType
;
final
String
?
rewardContent
;
final
String
?
openingContent
;
final
String
?
name
;
final
String
?
rewardPopup
;
final
int
?
price
;
final
bool
?
isFlashSale
;
final
bool
?
isFlashSalePrice
;
final
String
?
headerImg
;
final
int
?
fsQuantityPerPersonTotal
;
final
int
?
fsQuantityPerPersonBought
;
const
PreviewFlashSale
({
this
.
id
,
this
.
countdownSecond
,
this
.
startTime
,
this
.
endTime
,
this
.
fsQuantityTotal
,
this
.
fsQuantitySold
,
this
.
percentTag
,
this
.
rewardType
,
this
.
rewardContent
,
this
.
openingContent
,
this
.
name
,
this
.
rewardPopup
,
this
.
price
,
this
.
isFlashSale
,
this
.
isFlashSalePrice
,
this
.
headerImg
,
this
.
fsQuantityPerPersonTotal
,
this
.
fsQuantityPerPersonBought
,
});
factory
PreviewFlashSale
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
return
PreviewFlashSale
(
id:
json
[
'id'
]
as
int
?,
countdownSecond:
json
[
'countdown_second'
]
as
int
?,
startTime:
json
[
'start_time'
]
as
String
?,
endTime:
json
[
'end_time'
]
as
String
?,
fsQuantityTotal:
json
[
'fs_quantity_total'
]
as
int
?,
fsQuantitySold:
json
[
'fs_quantity_sold'
]
as
int
?,
percentTag:
json
[
'percent_tag'
]
as
int
?,
rewardType:
json
[
'reward_type'
]
as
String
?,
rewardContent:
json
[
'reward_content'
]
as
String
?,
openingContent:
json
[
'opening_content'
]
as
String
?,
name:
json
[
'name'
]
as
String
?,
rewardPopup:
json
[
'reward_popup'
]
as
String
?,
price:
json
[
'price'
]
as
int
?,
isFlashSale:
json
[
'is_flash_sale'
]
as
bool
?,
isFlashSalePrice:
json
[
'is_flash_sale_price'
]
as
bool
?,
headerImg:
json
[
'header_img'
]
as
String
?,
fsQuantityPerPersonTotal:
json
[
'fs_quantity_per_person_total'
]
as
int
?,
fsQuantityPerPersonBought:
json
[
'fs_quantity_per_person_bought'
]
as
int
?,
);
}
Map
<
String
,
dynamic
>
toJson
()
=>
{
'id'
:
id
,
'countdown_second'
:
countdownSecond
,
'start_time'
:
startTime
,
'end_time'
:
endTime
,
'fs_quantity_total'
:
fsQuantityTotal
,
'fs_quantity_sold'
:
fsQuantitySold
,
'percent_tag'
:
percentTag
,
'reward_type'
:
rewardType
,
'reward_content'
:
rewardContent
,
'opening_content'
:
openingContent
,
'name'
:
name
,
'reward_popup'
:
rewardPopup
,
'price'
:
price
,
'is_flash_sale'
:
isFlashSale
,
'is_flash_sale_price'
:
isFlashSalePrice
,
'header_img'
:
headerImg
,
'fs_quantity_per_person_total'
:
fsQuantityPerPersonTotal
,
'fs_quantity_per_person_bought'
:
fsQuantityPerPersonBought
,
};
double
?
get
progress
{
if
(
fsQuantityTotal
!=
null
&&
fsQuantitySold
!=
null
&&
fsQuantityTotal
!
>
0
)
{
return
fsQuantitySold
!
/
fsQuantityTotal
!;
}
return
null
;
}
bool
get
isSoldOut
=>
fsQuantitySold
==
fsQuantityTotal
;
String
get
textQuantitySold
=>
isSoldOut
?
"Đã bán hết"
:
"Đã bán
${fsQuantitySold ?? 0}
"
;
DateTime
?
get
startDate
=>
_parseDate
(
startTime
)?.
subtract
(
Duration
(
seconds:
1
));
DateTime
?
get
endDate
=>
_parseDate
(
endTime
)?.
add
(
Duration
(
seconds:
1
));
bool
?
get
isGoingOn
{
final
now
=
DateTime
.
now
();
if
(
startDate
!=
null
&&
endDate
!=
null
&&
now
.
isBefore
(
endDate
!))
{
return
now
.
isAfter
(
startDate
!);
}
return
null
;
}
String
?
get
desTime
{
final
go
=
isGoingOn
;
if
(
go
==
null
)
return
null
;
return
go
?
"Kết thúc trong"
:
"Bắt đầu sau"
;
}
Duration
?
get
countdownLocal
{
final
now
=
DateTime
.
now
();
if
(
isGoingOn
==
true
)
{
return
endDate
?.
difference
(
now
);
}
else
{
return
startDate
?.
difference
(
now
);
}
}
int
?
get
maximumQuantityPurchased
{
if
(
fsQuantityPerPersonTotal
!=
null
)
{
final
bought
=
fsQuantityPerPersonBought
??
0
;
return
(
fsQuantityPerPersonTotal
!
-
bought
).
clamp
(
0
,
fsQuantityPerPersonTotal
!);
}
return
null
;
}
bool
get
isShowProgressSoldItemCell
=>
isFlashSale
==
true
&&
(
fsQuantityTotal
??
0
)
>
0
;
bool
get
isHidenOpeningContent
=>
openingContent
==
null
||
openingContent
!.
isEmpty
||
isGoingOn
==
true
||
isFlashSalePrice
==
true
;
bool
get
isHasReward
=>
rewardContent
!=
null
&&
rewardContent
!.
isNotEmpty
;
String
?
get
rewardImageAsset
{
return
rewardType
==
"point"
?
"assets/icons/ic_point.png"
:
"assets/icons/ic_gift_flash_sale.png"
;
}
DateTime
?
_parseDate
(
String
?
str
)
{
if
(
str
==
null
)
return
null
;
return
DateTime
.
tryParse
(
str
);
}
}
lib/screen/home/pipi_detail_screen.dart
0 → 100644
View file @
fda33894
import
'package:flutter/material.dart'
;
import
'package:get/get.dart'
;
import
'package:get/get_core/src/get_main.dart'
;
import
'package:mypoint_flutter_app/screen/home/pipi_detail_viewmodel.dart'
;
import
'package:mypoint_flutter_app/widgets/image_loader.dart'
;
import
'models/pipi_detail_model.dart'
;
class
PipiDetailScreen
extends
StatefulWidget
{
const
PipiDetailScreen
({
super
.
key
});
@override
State
<
PipiDetailScreen
>
createState
()
=>
_PipiDetailScreenState
();
}
class
_PipiDetailScreenState
extends
State
<
PipiDetailScreen
>
{
final
PipiDetailViewModel
_viewModel
=
Get
.
put
(
PipiDetailViewModel
());
@override
Widget
build
(
BuildContext
context
)
{
return
Obx
(()
{
return
Container
(
decoration:
const
BoxDecoration
(
color:
Colors
.
white
,
borderRadius:
BorderRadius
.
vertical
(
top:
Radius
.
circular
(
24
)),
),
padding:
const
EdgeInsets
.
fromLTRB
(
16
,
20
,
16
,
24
),
child:
Column
(
mainAxisSize:
MainAxisSize
.
min
,
children:
[
Row
(
crossAxisAlignment:
CrossAxisAlignment
.
center
,
children:
[
const
Spacer
(),
const
Expanded
(
flex:
6
,
child:
Text
(
'Liên hệ'
,
textAlign:
TextAlign
.
center
,
style:
TextStyle
(
fontSize:
18
,
fontWeight:
FontWeight
.
bold
,
color:
Colors
.
black87
,
),
),
),
Expanded
(
child:
IconButton
(
icon:
const
Icon
(
Icons
.
close
),
onPressed:
()
=>
Navigator
.
of
(
context
).
pop
(),
),
)
],
),
const
SizedBox
(
height:
12
),
...
_viewModel
.
items
.
map
((
item
)
=>
_buildItem
(
context
,
item
)),
const
SizedBox
(
height:
100
),
],
),
);
});
}
Widget
_buildItem
(
BuildContext
context
,
PipiSupportItemModel
item
)
{
return
InkWell
(
onTap:
()
{
Navigator
.
of
(
context
).
pop
();
item
.
directionScreen
?.
begin
();
},
child:
Container
(
margin:
const
EdgeInsets
.
only
(
bottom:
12
),
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
12
,
vertical:
14
),
decoration:
BoxDecoration
(
color:
const
Color
(
0xFFF8F8F8
),
borderRadius:
BorderRadius
.
circular
(
16
),
),
child:
Row
(
children:
[
ClipRRect
(
borderRadius:
BorderRadius
.
circular
(
24
),
child:
loadNetworkImage
(
url:
item
.
icon
??
''
,
width:
36
,
height:
36
,
)
),
const
SizedBox
(
width:
12
),
Text
(
item
.
title
??
''
,
style:
const
TextStyle
(
fontSize:
16
)),
],
),
),
);
}
}
Prev
1
2
3
4
5
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