Files

131 lines
5.1 KiB
Dart

import 'package:flutter/material.dart';
import 'package:initial_folder/providers/total_price_provider.dart';
import 'package:initial_folder/size_config.dart';
import 'package:initial_folder/theme.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
class CourseListCoupon extends StatelessWidget {
final String idCourse;
final String title;
final String price;
final String discountPrice;
final String imageUrl;
const CourseListCoupon({
Key? key,
required this.idCourse,
required this.title,
required this.price,
required this.discountPrice,
required this.imageUrl,
}) : super(key: key);
@override
Widget build(BuildContext context) {
final priceCoupon = Provider.of<TotalPriceProvider>(context).priceCoupon;
return Column(
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Flexible(
flex: 10,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: getProportionateScreenWidth(70),
height: getProportionateScreenWidth(39),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
image: DecorationImage(
fit: BoxFit.cover,
image: NetworkImage(imageUrl),
),
),
),
],
)),
SizedBox(width: getProportionateScreenWidth(10)),
Expanded(
flex: 15,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: primaryTextStyle.copyWith(
letterSpacing: 0.5,
fontWeight: reguler,
fontSize: getProportionateScreenWidth(12),
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
],
)),
Spacer(),
Flexible(
flex: 10,
child: Align(
alignment: Alignment.centerRight,
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
discountPrice == "0"
? Text(
'Rp. ${NumberFormat.currency(locale: 'id', symbol: '', decimalDigits: 0).format(double.parse(price))}',
style: primaryTextStyle.copyWith(
letterSpacing: 0.5,
fontWeight: reguler,
fontSize: getProportionateScreenWidth(12),
),
)
: Text(
'Rp. ${NumberFormat.currency(locale: 'id', symbol: '', decimalDigits: 0).format(double.parse(discountPrice))}',
style: primaryTextStyle.copyWith(
letterSpacing: 0.5,
fontWeight: reguler,
fontSize: getProportionateScreenWidth(12),
),
),
// Text(
// 'Rp ${NumberFormat.currency(locale: 'id', symbol: '', decimalDigits: 0).format(double.parse(price))}',
// style: primaryTextStyle.copyWith(
// letterSpacing: 0.5,
// fontWeight: reguler,
// fontSize: getProportionateScreenWidth(12),
// ),
// ),
SizedBox(
height: getProportionateScreenHeight(2),
),
priceCoupon.toString() != "0"
? Text(
'Rp. ${NumberFormat.currency(locale: 'id', symbol: '', decimalDigits: 0).format(double.parse(priceCoupon.toString()))}',
style: primaryTextStyle.copyWith(
decoration: TextDecoration.lineThrough,
color: secondaryColor,
letterSpacing: 0.5,
fontWeight: reguler,
fontSize: getProportionateScreenWidth(10),
),
)
: SizedBox(),
],
),
),
),
],
),
SizedBox(height: getProportionateScreenHeight(10)),
Divider(color: fourthColor),
SizedBox(height: getProportionateScreenHeight(5)),
],
);
}
}