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

class imageIcon extends StatelessWidget {
  final String icon; // icon名称
  final double size; // 大小，默认20
  final EdgeInsetsGeometry margin;

  const imageIcon({Key key, this.icon, this.size = 20, this.margin})
      : super(key: key); // 外边距

  @override
  Widget build(BuildContext context) {
    return Container(
        margin: margin ?? EdgeInsets.all(10),
        child: Image(
            image: AssetImage('assets/icons/$icon.png'),
            width: size,
            height: size));
  }
}

// iconfont的icon的Widget
class IconfontIcon extends StatelessWidget {
  final int code; // 16进制编码
  final IconData iconData; // iiconData格式
  final double size; // 大小，默认20
  final Color color; // 颜色，默认黑色
  final EdgeInsetsGeometry margin; // 外边距

  const IconfontIcon(
      {Key key,
      this.code,
      this.iconData,
      this.size = 20,
      this.margin,
      this.color = Colors.black})
      : super(key: key);

  @override
  Widget build(Object context) {
    if (iconData != null) {
      return Container(
          margin: margin ?? EdgeInsets.all(10),
          child: Icon(iconData, size: size, color: color));
    } else {
      return Container(
          margin: margin ?? EdgeInsets.all(10),
          child: Icon(IconData(code, fontFamily: 'IconFont'),
              size: size, color: color));
    }
  }
}

// iconFont字典
class IconfontIcons {
  static const IconData icon_add = IconData(0xeb8f, fontFamily: 'iconfont');
  static const IconData icon_addmessage =
      IconData(0xeb90, fontFamily: 'iconfont');
  static const IconData icon_addresslist =
      IconData(0xeb91, fontFamily: 'iconfont');
  static const IconData icon_affiliations_li =
      IconData(0xeb92, fontFamily: 'iconfont');
  static const IconData icon_addperson =
      IconData(0xeb93, fontFamily: 'iconfont');
  static const IconData icon_boss = IconData(0xeb94, fontFamily: 'iconfont');
  static const IconData icon_airplay = IconData(0xeb95, fontFamily: 'iconfont');
  static const IconData icon_calendar =
      IconData(0xeb96, fontFamily: 'iconfont');
  static const IconData icon_attestation =
      IconData(0xeb97, fontFamily: 'iconfont');
  static const IconData icon_camera = IconData(0xeb98, fontFamily: 'iconfont');
  static const IconData icon_certificate_fil =
      IconData(0xeb99, fontFamily: 'iconfont');
  static const IconData icon_coinpurse_line =
      IconData(0xeb9a, fontFamily: 'iconfont');
  static const IconData icon_collect = IconData(0xeb9b, fontFamily: 'iconfont');
  static const IconData icon_compile = IconData(0xeb9c, fontFamily: 'iconfont');
}
