Skip to content

Commit c1a728b

Browse files
committed
feat(WeuiIcon): add WeuiIcon widget
1 parent 7ac75ba commit c1a728b

File tree

2 files changed

+97
-0
lines changed

2 files changed

+97
-0
lines changed

lib/flutter_weui.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ export 'action_sheet.dart';
77
export 'picker.dart';
88
export 'slider.dart';
99
export 'switch.dart';
10+
export 'weui_icon.dart';
1011

lib/weui_icon.dart

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:smart_color/smart_color.dart';
3+
4+
enum WeuiIconType {
5+
success,
6+
warn,
7+
info,
8+
waiting,
9+
success_no_circle,
10+
circle,
11+
download,
12+
info_circle,
13+
cancel,
14+
search,
15+
}
16+
17+
class WeuiIcon extends StatelessWidget {
18+
WeuiIcon({Key key, this.type, this.msg, this.color = const Color(0xFF09BB07)}) : super(key: key);
19+
20+
final WeuiIconType type;
21+
final bool msg;
22+
final Color color;
23+
Map<WeuiIconType, String> iconMap = const {
24+
WeuiIconType.success: "\u{EA06}",
25+
WeuiIconType.warn: "\u{EA0B}",
26+
WeuiIconType.info: "\u{EA03}",
27+
WeuiIconType.waiting: "\u{EA09}",
28+
WeuiIconType.success_no_circle: "\u{EA08}",
29+
WeuiIconType.circle: "\u{EA01}",
30+
WeuiIconType.download: "\u{EA02}",
31+
WeuiIconType.info_circle: "\u{EA0C}",
32+
WeuiIconType.cancel: "\u{EA0D}",
33+
WeuiIconType.search: "\u{EA0E}",
34+
};
35+
@override
36+
Widget build(BuildContext context) {
37+
// TODO: implement build
38+
return Text(
39+
iconMap[type],
40+
style: TextStyle(
41+
fontSize: msg ? 93 : 23,
42+
package: "flutter_weui",
43+
fontFamily: "WeuiIcon",
44+
color: color,
45+
),
46+
);
47+
}
48+
}
49+
50+
class SuccessIcon extends StatelessWidget {
51+
SuccessIcon({Key key, this.msg = true}) : super(key: key);
52+
53+
final bool msg;
54+
@override
55+
Widget build(BuildContext context) {
56+
return WeuiIcon(
57+
type: WeuiIconType.success,
58+
msg: msg,
59+
);
60+
}
61+
}
62+
63+
class WarnIcon extends StatelessWidget {
64+
WarnIcon({Key key, this.primary = true}) : super(key: key);
65+
final bool primary;
66+
@override
67+
Widget build(BuildContext context) {
68+
return WeuiIcon(
69+
type: WeuiIconType.warn,
70+
msg: true,
71+
color: SmartColor.parse(primary == true ? "FFBE00" : "#F76260"),
72+
);
73+
}
74+
}
75+
76+
class InfoIcon extends StatelessWidget {
77+
@override
78+
Widget build(BuildContext context) {
79+
return WeuiIcon(
80+
type: WeuiIconType.info,
81+
msg: true,
82+
color: SmartColor.parse("10AEFF"),
83+
);
84+
}
85+
}
86+
87+
class WaitingIcon extends StatelessWidget {
88+
@override
89+
Widget build(BuildContext context) {
90+
return WeuiIcon(
91+
type: WeuiIconType.waiting,
92+
msg: true,
93+
color: SmartColor.parse("10AEFF"),
94+
);
95+
}
96+
}

0 commit comments

Comments
 (0)