import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:zhiying_base_widget/widgets/others/dotted_line/dotted_line.dart';
import 'package:zhiying_base_widget/widgets/share/models/share_alert_model.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

class ShareAlertContent extends StatelessWidget {
  final ShareAlertModel model;

  const ShareAlertContent(this.model, {Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Center(
        child: UnconstrainedBox(
          child: Container(
            padding: EdgeInsets.all(14),
            width: 220,
            decoration: BoxDecoration(
              color: Colors.white,
              borderRadius: BorderRadius.circular(12),
            ),
            child: Column(
              children: <Widget>[
                Container(
                  width: 92,
                  height: 92,
                  margin: EdgeInsets.only(top: 10),
                  child: CachedNetworkImage(
                    imageUrl: model?.successImg ?? '',
                  ),
                ),
                Padding(
                  padding: const EdgeInsets.only(top: 8.0),
                  child: Text(
                    model?.sucText ?? '',
                    style: TextStyle(
                      color: HexColor.fromHex('#333333'),
                      fontSize: 18,
                      fontWeight: FontWeight.bold,
                    ),
                  ),
                ),
                Padding(
                  padding: const EdgeInsets.only(top: 4, left: 30, right: 30),
                  child: Text(
                    model?.sucTips ?? '',
                    textAlign: TextAlign.center,
                    style: TextStyle(
                      color: HexColor.fromHex('#999999'),
                      fontSize: 11,
                      fontWeight: FontWeight.normal,
                    ),
                  ),
                ),
                Padding(
                  padding: const EdgeInsets.only(top: 10.0),
                  child: _createLine(
                      model?.selectImg ?? '', model?.selectText1 ?? ''),
                ),
                Padding(
                  padding: const EdgeInsets.only(top: 10.0),
                  child: _createLine(
                      model?.selectTextImg ?? '', model?.selectText2 ?? ''),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }

  Widget _createLine(String imgUrl, String text) {
    return Row(
      children: <Widget>[
        Container(
          width: 12,
          height: 12,
          // color: Colors.redAccent,
          child: CachedNetworkImage(
            imageUrl: imgUrl ?? '',
          ),
        ),
        Padding(
          padding: const EdgeInsets.only(left: 4, right: 4),
          child: Text(
            text ?? '',
            style: TextStyle(fontSize: 11, color: HexColor.fromHex('#999999')),
          ),
        ),
        Expanded(
            child: DottedLine(
          width: 2,
          height: 0.5,
          color: HexColor.fromHex('#a8a8a8'),
        )),
        Container(
          margin: EdgeInsets.only(left: 6),
          width: 15,
          height: 15,
          child: CachedNetworkImage(
            imageUrl: model?.selectIcon ?? '',
          ),
        ),
      ],
    );
  }
}
