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

///
/// 商品详情价格widget
///
class GoodsDetailsPriceWidget extends StatelessWidget {
  final Map<String, dynamic> model;

  const GoodsDetailsPriceWidget(this.model);

  @override
  Widget build(BuildContext context) {
    return Container(margin: const EdgeInsets.symmetric(horizontal: 12.5), child: _getMainWidget());
  }

  /// 主体视图
  Widget _getMainWidget() {
    return Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: <Widget>[
        _getLeftWidget(),

        /// 右边widget
        _getBuyNumberWidget(),
      ],
    );
  }

  /// 左边的wiget 包括价格等
  Widget _getLeftWidget() {
    return Row(
      mainAxisAlignment: MainAxisAlignment.start,
      crossAxisAlignment: CrossAxisAlignment.center,
      children: <Widget>[
        /// 价格
        _getPriceWidget(),
        const SizedBox(width: 5),

        /// 券后
        _getQhPriceWidget(),
        const SizedBox(width: 5),

        /// 积分
        _getPointsWidget()
      ],
    );
  }

  /// 价格
  Widget _getPriceWidget() {
    return Row(
      children: <Widget>[
        Text('￥', style: TextStyle(color: HexColor.fromHex('#FF4242'), fontSize: 15)),
        Text('99', style: TextStyle(color: HexColor.fromHex('#FF4242'), fontSize: 30)),
      ],
    );
  }

  /// 积分
  Widget _getPointsWidget() {
    return Container(
      decoration: BoxDecoration(color: HexColor.fromHex('#FFEFDA'), borderRadius: BorderRadius.circular(5)),
      padding: const EdgeInsets.only(left: 4, right: 7.5, top: 4, bottom: 4),
      child: Text('', style: TextStyle(color: HexColor.fromHex('#B78107'), fontSize: 9)),
    );
  }

  /// 券后价格
  Widget _getQhPriceWidget() {
    return Column(
      children: <Widget>[
        Text('券后', style: TextStyle(color: HexColor.fromHex('#FF4242'), fontSize: 11)),
        Text('¥ 199', style: TextStyle(color: HexColor.fromHex('#FF4242'), fontSize: 10)),
      ],
    );
  }

  /// 购买人数
  Widget _getBuyNumberWidget() {
    return Text('99999人已购买', style: TextStyle(color: HexColor.fromHex('#999999'), fontSize: 12.5));
  }
}
