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

///
/// 商品详情标题
///
class GoodsDetailsTitleWidget extends StatelessWidget {
  final Map<String, dynamic> model;

  const GoodsDetailsTitleWidget(this.model);

  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      margin: const EdgeInsets.only(left: 12.5, right: 12.5),
      child: _getMaiWidget(),
    );
  }

  /// 主widget
  Widget _getMaiWidget() {
    return RichText(
      maxLines: 2,
      overflow: TextOverflow.ellipsis,
      text: TextSpan(children: [
        WidgetSpan(
          child: _getGoodsTypeIcon(),
        ),
        _getGoodsTitle(),
      ]),
    );
  }

  /// 商品类型图标
  Widget _getGoodsTypeIcon() {
    return Container(
      height: 15,
      width: 32,
      color: Colors.red,
    );
  }

  /// 商品标题
  InlineSpan _getGoodsTitle() {
    return TextSpan(text: '品胜（PISEN）苹果数据线1.5米 适用于苹果手机所有机型 MFI认证安全稳定一年换新1.5米2米', style: TextStyle(fontSize: 14, color: HexColor.fromHex('#FF333333')));
  }
}
