import 'dart:convert' as convert;

import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:zhiying_base_widget/widgets/mine/mine_header/model/mine_header_model.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

// 未登录状态个人中心头部
class MineStaticContainer extends StatefulWidget {
  final Map<String, dynamic> data;
  Map<String, dynamic> json;
  MineHeaderModel staticModel;

  MineStaticContainer(this.data, {Key key}) : super(key: key) {
    String d = data['data'];
    json = convert.jsonDecode(d);
    staticModel = MineHeaderModel.fromJson(json);
  }

  @override
  _MineStaticContainerState createState() => _MineStaticContainerState();
}

class _MineStaticContainerState extends State<MineStaticContainer> {
  @override
  Widget build(BuildContext context) {
    return Container(
      child: Row(
        children: <Widget>[
          GestureDetector(
            child: Container(
              margin: EdgeInsets.only(left: 20, top: 20, bottom: 20, right: 12),
              width: 56,
              height: 56,
              child: ClipRRect(
                  borderRadius: BorderRadius.circular(28),
                  child: CachedNetworkImage(
                      imageUrl: widget.staticModel.nonLoginAvatar,
                      fit: BoxFit.cover)),
            ),
            onTap: () {
              RouterUtil.route(
                  SkipModel.fromJson(widget.json), widget.json, context);
            },
          ),
          Expanded(
              child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              Container(
                width: 120,
                height: 20,
                child: Text(
                  widget.staticModel.loginName,
                  style: TextStyle(
                      color: HexColor.fromHex(
                          widget.staticModel?.loginColor ?? '#ffffff'),
                      fontSize: 17),
                ),
              ),
              Container(
                  margin: EdgeInsets.only(top: 8),
                  width: 80,
                  child: Text(
                    widget.staticModel.loginNameHelpText,
                    style: TextStyle(
                        color: HexColor.fromHex(
                            widget.staticModel?.loginColor ?? '#ffffff'),
                        fontSize: 13),
                  )),
            ],
          ))
        ],
      ),
    );
  }
}
