getPromotions method
Implementation
getPromotions(BuildContext context) {
showModalBottomSheet<void>(
context: context,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30.0),
),
backgroundColor: Colors.transparent,
builder: (BuildContext context) {
return Container(
height: SizeConstant.getHeightWithScreen(500),
padding: EdgeInsets.all(SizeConstant.getHeightWithScreen(16)),
decoration: BoxDecoration(
color: ColorConstant.white,
borderRadius: BorderRadius.only(
topLeft:
Radius.circular(SizeConstant.getHeightWithScreen(15.0)),
topRight:
Radius.circular(SizeConstant.getHeightWithScreen(15.0)))),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
localization.translate('promotionsForYou'),
style: TextStyle(
color: ColorConstant.black3,
fontSize: SizeConstant.mediumLargeFont,
fontWeight: FontWeight.w500,
),
),
],
),
SizedBox(
height: SizeConstant.getHeightWithScreen(27),
),
Expanded(
child: ListView.separated(
separatorBuilder: (BuildContext context, int index) =>
SizedBox(
height: SizeConstant.getHeightWithScreen(15),
),
shrinkWrap: false,
itemCount: stockOrderController.discountList.length,
itemBuilder: (ctx, id) => Container(
decoration: BoxDecoration(
color: ColorConstant.dividerColor,
borderRadius: BorderRadius.all(
Radius.circular(SizeConstant.getHeightWithScreen(15)),
),
),
padding: EdgeInsets.symmetric(
horizontal: SizeConstant.getHeightWithScreen(15),
vertical: SizeConstant.getHeightWithScreen(10),
),
child: Container(
padding:
EdgeInsets.all(SizeConstant.getHeightWithScreen(16)),
decoration: BoxDecoration(
color: ColorConstant.dividerColor,
borderRadius: BorderRadius.all(Radius.circular(
SizeConstant.getHeightWithScreen(15.0)))),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text.rich(TextSpan(children: [
WidgetSpan(
child: Container(
width: 13,
height: 13,
margin: EdgeInsets.only(
right: SizeConstant
.getHeightWithScreen(8)),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: ColorConstant.grey5,
),
),
),
TextSpan(
text: stockOrderController
.discountList[id]
.description! ??
'',
style: TextStyle(
color: ColorConstant.black3,
fontSize: SizeConstant.smallFont,
fontWeight: FontWeight.w500,
),
),
])),
SizedBox(
height:
SizeConstant.getHeightWithScreen(4),
),
Text(
'Code: ${stockOrderController.discountList[id].id ?? '0'}',
style: TextStyle(
color: ColorConstant.grey5,
fontSize: SizeConstant.smallXFont,
fontWeight: FontWeight.w500,
),
),
],
),
(stockOrderController.discountId.isNotEmpty &&
stockOrderController
.discountList[id].id ==
stockOrderController
.discountId.value)
? Padding(
padding: EdgeInsets.only(
left: SizeConstant
.getHeightWithScreen(5)),
child: VentasTextButton(
textStyle: TextStyle(
overflow: TextOverflow.visible,
fontSize: SizeConstant.smallFont,
fontWeight: FontWeight.w500,
color: ColorConstant.pink
.withOpacity(0.88),
),
label:
localization.translate("remove"),
onTap: () async {
// pop the bottom sheet first.
await stockOrderController
.removePromotion(
context,
stockOrderController
.discountList[id].id!
.toString(),
stockOrderController
.cart_id.value);
Get.back();
},
))
: Padding(
padding: EdgeInsets.only(
left: SizeConstant
.getHeightWithScreen(5)),
child: GestureDetector(
onTap: () async {
// pop the bottom sheet first.
await stockOrderController
.updatePromotion(
context,
stockOrderController
.discountList[id].id!
.toString(),
stockOrderController
.cart_id.value);
Get.back();
},
child: Card(
shape: const RoundedRectangleBorder(
side: BorderSide(
color: Colors.orange),
borderRadius: BorderRadius.all(
Radius.circular(7.0)),
),
child: Container(
height: SizeConstant
.getHeightWithScreen(28),
// width: SizeConstant
// .getHeightWithScreen(55),
padding: EdgeInsets.symmetric(
horizontal: SizeConstant
.getHeightWithScreen(10),
),
decoration: BoxDecoration(
color: ColorConstant.white,
borderRadius: BorderRadius.all(
Radius.circular(SizeConstant
.getHeightWithScreen(
7.0))),
),
child: Center(
child: Text(
localization
.translate('apply'),
style: TextStyle(
color: ColorConstant
.primaryColor,
fontSize:
SizeConstant.smallFont,
fontWeight: FontWeight.w600,
),
),
),
),
),
),
),
// GestureDetector(
// onTap: () {
// Navigator.of(context).pop();
// stockOrderController.updatePromotion(context, stockOrderController.discountList[id].id!.toString(), stockOrderController.cart_id.value);
// },
// child: Card(
// shape: const RoundedRectangleBorder(
// side: BorderSide(color: Colors.orange),
// borderRadius: BorderRadius.all(
// Radius.circular(7.0)),
// ),
// child: Container(
// height:
// SizeConstant.getHeightWithScreen(28),
// width:
// SizeConstant.getHeightWithScreen(55),
// decoration: BoxDecoration(
// color: ColorConstant.white,
// borderRadius: BorderRadius.all(
// Radius.circular(SizeConstant
// .getHeightWithScreen(7.0))),
// ),
// child: Center(
// child: Text(
// 'apply'.tr,
// style: TextStyle(
// color: ColorConstant.primaryColor,
// fontSize: SizeConstant.smallFont,
// fontWeight: FontWeight.w600,
// ),
// ),
// ),
// ),
// ),
// )
],
),
]),
),
),
),
)
],
),
);
},
);
}