import 'dart:convert';

import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:zhiying_base_widget/widgets/hot_ranking/hot_ranking_appbar/model/hot_ranking_appbaar_model.dart';
import 'package:zhiying_comm/util/extension/color.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

class HotRankingAppBar extends StatelessWidget {
  final Map<String, dynamic> data;

  const HotRankingAppBar(this.data, {Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    var model = HotRankingAppbarModel.fromJson(json.decode(data['data']));
    return Container(
      height: MediaQuery.of(context).padding.top + 56,
      child: AppBar(
          elevation: 0,
          leading: Navigator.canPop(context)
              ? IconButton(
                  icon: Icon(Icons.arrow_back_ios),
                  onPressed: () {
                    Navigator.of(context).pop();
                  })
              : Container(),
          backgroundColor: HexColor.fromHex(
              model.appBarBgColor == "" ? "#00000000" : model.appBarBgColor),
          centerTitle: true,
          title: Container(
            child: Stack(
              alignment: Alignment.center,
              children: <Widget>[
                Text(
                  model.appBarName ?? "",
                  style: TextStyle(
                      color: HexColor.fromHex(model?.appBarNameColor ?? "")),
                ),
                CachedNetworkImage(
                  height: 20,
                  width: 72,
                  imageUrl: model.appBarNameImg ?? "",
                  fit: BoxFit.fill,
                )
              ],
            ),
          )),
    );
  }
}
