import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import '../../../app.dart';

class ProductNameWidget extends StatelessWidget {
  final ProductModel model;

  ProductNameWidget({required this.model});

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: EdgeInsets.symmetric(horizontal: 16.w),
      child: Text(
        model.name,
        style: TextStyle(
          fontWeight: FontWeight.w600,
          fontSize: 14.sp,
          color: ThemeColor.color3A3A3A,
        ),
        maxLines: 2,
        overflow: TextOverflow.ellipsis,
      ),
    );
  }
}

class ProductPriceWidget extends StatelessWidget {
  final ProductModel model;

  ProductPriceWidget({required this.model});

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: EdgeInsets.symmetric(horizontal: 16.w),
      child: model.hasDiscount
          ? Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Row(
                  children: [
                    Text(
                      model.formattedSpecialPrice ?? '',
                      style: TextStyle(
                        fontSize: 14.sp,
                        fontWeight: FontWeight.bold,
                        color: ThemeColor.mainColor,
                      ),
                      overflow: TextOverflow.ellipsis,
                    ),
                    SizedBox(width: 16),
                    // discount box
                    Container(
                      padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 6),
                      decoration: new BoxDecoration(
                        borderRadius: BorderRadius.circular(4),
                        color: Color(0xFFFFE500),
                      ),
                      child: Text(
                        model.discountRate ?? '',
                        style: TextStyle(fontSize: 13.sp),
                      ),
                    ),
                  ],
                ),
                // SizedBox(width: 2.w),
                Text(
                  model.formattedRegularPrice ?? '',
                  style: new TextStyle(
                    fontSize: 14.sp,
                    fontWeight: FontWeight.w400,
                    color: ThemeColor.color3A3A3A,
                    decoration: TextDecoration.lineThrough,
                  ),
                  overflow: TextOverflow.ellipsis,
                )
              ],
            )
          : Text(
              model.formattedPrice,
              style: new TextStyle(
                fontSize: 14.sp,
                fontWeight: FontWeight.bold,
                color: ThemeColor.color3A3A3A,
              ),
              overflow: TextOverflow.ellipsis,
            ),
    );
  }
}
