import 'dart:convert';

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

///
/// 通用模块的AppBar Widget
///
class CustomAppBarWidget extends StatelessWidget {
  final Map<String, dynamic> data;
  Map<String, dynamic> model;

  CustomAppBarWidget(this.data, {Key key}) : super(key: key) {
    try {
      var dataItem = data['data'];
      if (!EmptyUtil.isEmpty(dataItem)) {
        model = dataItem is Map ? dataItem : dataItem is String ? jsonDecode(dataItem) : null;
      }
    } catch (e, s) {
      Logger.error(e, s);
    }
  }

  @override
  Widget build(BuildContext context) {
    return SliverAppBar(
      leading: IconButton(
        icon: Icon(
          Icons.arrow_back_ios,
          size: 22,
          color: HexColor.fromHex( '#333333'),
        ),
        onPressed: () => Navigator.maybePop(context),
      ),
      title: Text(
        '自定义页面',
        style: TextStyle(
          fontSize: 15,
          color: HexColor.fromHex('#333333'),
          fontWeight: FontWeight.bold,
        ),
      ),
    );
  }
}
