Skip to content

Commit d1685e5

Browse files
committed
Update: awesome_message
1 parent 86d5232 commit d1685e5

File tree

5 files changed

+80
-112
lines changed

5 files changed

+80
-112
lines changed

lib/common/helper/tip_helper.dart

+24-82
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import 'package:ai_awesome_message/ai_awesome_message.dart' as awesome_message;
2+
import 'package:airoute/airoute.dart';
13
import 'package:flutter/material.dart';
2-
import 'package:flushbar/flushbar.dart';
3-
import 'tip_type.dart';
4+
5+
import 'tip_type.dart' as tip_type;
46

57
///
68
/// TipHelper
@@ -15,90 +17,30 @@ class TipHelper {
1517
@required BuildContext context,
1618
String title,
1719
String message = '',
18-
TipType tipType = TipType.INFO,
20+
tip_type.TipType tipType = tip_type.TipType.INFO,
1921
}) {
20-
List<Color> _tipStyleColorsSample = [
21-
Colors.blue[100],
22-
Colors.orange[100],
23-
Colors.red[100],
24-
Colors.green[200]
25-
];
26-
List<Color> _tipIndicatorColorsSample = [
27-
Colors.blue[300],
28-
Colors.orange[300],
29-
Colors.red[300],
30-
Colors.blue[300]
31-
];
32-
List<Color> _tipIconColorsSample = [
33-
Colors.blue[500],
34-
Colors.orange[500],
35-
Colors.red[500],
36-
Colors.blue[500]
37-
];
38-
39-
IconData _tipIcon;
40-
Color _tipStyleColor;
41-
Color _tipStyleIconColor;
42-
Color _tipStyleBorderColor;
43-
if (tipType == TipType.INFO) {
44-
title = title ?? "提示";
45-
_tipIcon = Icons.info_outline;
46-
_tipStyleColor = Colors.blue[100];
47-
_tipStyleIconColor = Colors.blue[500];
48-
_tipStyleBorderColor = Colors.blue[300];
49-
} else if (tipType == TipType.WARN) {
50-
title = title ?? "警告";
51-
_tipIcon = Icons.error_outline;
52-
_tipStyleColor = Colors.orange[100];
53-
_tipStyleIconColor = Colors.orange[500];
54-
_tipStyleBorderColor = Colors.orange[300];
55-
} else if (tipType == TipType.ERROR) {
56-
title = title ?? "错误";
57-
_tipIcon = Icons.cancel;
58-
_tipStyleColor = Colors.red[100];
59-
_tipStyleIconColor = Colors.red[500];
60-
_tipStyleBorderColor = Colors.red[300];
61-
} else if (tipType == TipType.COMPLETE) {
62-
title = title ?? "完成";
63-
_tipIcon = Icons.check_circle;
64-
_tipStyleColor = Colors.green[100];
65-
_tipStyleIconColor = Colors.green[500];
66-
_tipStyleBorderColor = Colors.green[300];
22+
awesome_message.TipType awesomeTipType;
23+
if (tipType == tip_type.TipType.INFO) {
24+
awesomeTipType = awesome_message.TipType.INFO;
25+
} else if (tipType == tip_type.TipType.WARN) {
26+
awesomeTipType = awesome_message.TipType.WARN;
27+
} else if (tipType == tip_type.TipType.ERROR) {
28+
awesomeTipType = awesome_message.TipType.ERROR;
29+
} else if (tipType == tip_type.TipType.COMPLETE) {
30+
awesomeTipType = awesome_message.TipType.COMPLETE;
6731
} else {
68-
title = title ?? "默认";
69-
_tipIcon = Icons.info_outline;
70-
_tipStyleColor = Colors.blue[100];
71-
_tipStyleIconColor = Colors.blue[500];
72-
_tipStyleBorderColor = Colors.blue[300];
32+
awesomeTipType = awesome_message.TipType.INFO;
7333
}
74-
75-
Flushbar(
76-
titleText: Text(
77-
"${title ?? '提示'}",
78-
style: TextStyle(
79-
color: Colors.black87,
34+
Airoute.push(
35+
route: awesome_message.AwesomeMessageRoute(
36+
theme: null,
37+
settings: RouteSettings(name: "/ai_awesome_message"),
38+
awesomeMessage: awesome_message.AwesomeHelper.createAwesome(
39+
title: "$title",
40+
message: "$message",
41+
tipType: awesomeTipType,
8042
),
8143
),
82-
messageText: Text(
83-
"${message ?? '提示'}",
84-
style: TextStyle(
85-
color: Colors.black54,
86-
),
87-
),
88-
icon: Icon(
89-
_tipIcon,
90-
size: 28.0,
91-
color: _tipStyleIconColor,
92-
),
93-
duration: Duration(
94-
seconds: 2,
95-
),
96-
flushbarPosition: FlushbarPosition.TOP,
97-
shouldIconPulse: true,
98-
showProgressIndicator: false,
99-
flushbarStyle: FlushbarStyle.GROUNDED,
100-
backgroundColor: _tipStyleColor,
101-
borderColor: _tipStyleBorderColor,
102-
)..show(context);
44+
);
10345
}
10446
}

lib/sample/chart/bar_chart/samples/bar_chart_sample5.dart

+9-8
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ class BarChartSample5State extends State<BarChartSample5> {
9898
checkToShowHorizontalLine: (value) => value % 5 == 0,
9999
getDrawingHorizontalLine: (value) {
100100
if (value == 0) {
101-
return const FlLine(color: Color(0xff363753), strokeWidth: 3);
101+
return const FlLine(
102+
color: Color(0xff363753), strokeWidth: 3);
102103
}
103104
return const FlLine(
104105
color: Color(0xff2a2747),
@@ -110,7 +111,7 @@ class BarChartSample5State extends State<BarChartSample5> {
110111
show: false,
111112
),
112113
barGroups: [
113-
const BarChartGroupData(
114+
BarChartGroupData(
114115
x: 0,
115116
barRods: [
116117
BarChartRodData(
@@ -128,7 +129,7 @@ class BarChartSample5State extends State<BarChartSample5> {
128129
),
129130
],
130131
),
131-
const BarChartGroupData(
132+
BarChartGroupData(
132133
x: 1,
133134
barRods: [
134135
BarChartRodData(
@@ -146,7 +147,7 @@ class BarChartSample5State extends State<BarChartSample5> {
146147
),
147148
],
148149
),
149-
const BarChartGroupData(
150+
BarChartGroupData(
150151
x: 2,
151152
barRods: [
152153
BarChartRodData(
@@ -164,7 +165,7 @@ class BarChartSample5State extends State<BarChartSample5> {
164165
),
165166
],
166167
),
167-
const BarChartGroupData(
168+
BarChartGroupData(
168169
x: 3,
169170
barRods: [
170171
BarChartRodData(
@@ -182,7 +183,7 @@ class BarChartSample5State extends State<BarChartSample5> {
182183
),
183184
],
184185
),
185-
const BarChartGroupData(
186+
BarChartGroupData(
186187
x: 4,
187188
barRods: [
188189
BarChartRodData(
@@ -200,7 +201,7 @@ class BarChartSample5State extends State<BarChartSample5> {
200201
),
201202
],
202203
),
203-
const BarChartGroupData(
204+
BarChartGroupData(
204205
x: 5,
205206
barRods: [
206207
BarChartRodData(
@@ -218,7 +219,7 @@ class BarChartSample5State extends State<BarChartSample5> {
218219
),
219220
],
220221
),
221-
const BarChartGroupData(
222+
BarChartGroupData(
222223
x: 6,
223224
barRods: [
224225
BarChartRodData(

lib/sample/text/input_text_page.dart

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import 'package:flutter/material.dart';
2+
3+
///
4+
/// InputTextPage
5+
class InputTextPage extends StatefulWidget {
6+
@override
7+
State<StatefulWidget> createState() {
8+
return _InputTextState();
9+
}
10+
}
11+
12+
///
13+
/// _InputTextState
14+
class _InputTextState extends State<InputTextPage> {
15+
@override
16+
Widget build(BuildContext context) {
17+
return Scaffold(
18+
appBar: AppBar(
19+
title: Text("InputText"),
20+
),
21+
);
22+
}
23+
}

lib/sample/tip/flushbar_page.dart

+22-18
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import 'package:ai_awesome_message/ai_awesome_message.dart';
2+
import 'package:airoute/airoute.dart';
13
import 'package:flutter/material.dart';
2-
import 'package:flushbar/flushbar.dart';
34

45
import '../../common/helper/tip_helper.dart';
5-
import '../../common/helper/tip_type.dart';
6+
import '../../common/helper/tip_type.dart' as tip_type;
67

78
///
89
/// FlushBarPage
@@ -116,14 +117,14 @@ class _FlushBarToolState extends State<FlushBarToolPage> {
116117
IconData _tipIconData = Icons.info_outline;
117118

118119
List<bool> _tipStyleSelected = [true, false];
119-
List<FlushbarStyle> _tipStyleValues = [
120-
FlushbarStyle.GROUNDED,
121-
FlushbarStyle.FLOATING
120+
List<AwesomeMessageStyle> _tipStyleValues = [
121+
AwesomeMessageStyle.GROUNDED,
122+
AwesomeMessageStyle.FLOATING
122123
];
123-
FlushbarStyle _tipStyleValue = FlushbarStyle.GROUNDED;
124+
AwesomeMessageStyle _tipStyleValue = AwesomeMessageStyle.GROUNDED;
124125

125-
Widget _getFlushBar() {
126-
return Flushbar(
126+
Widget _getAwesomeMessage() {
127+
return AwesomeMessage(
127128
title: "${_tipTitle ?? 'title'}",
128129
titleText: Text(
129130
"${_tipTitle ?? '提示'}",
@@ -151,10 +152,10 @@ class _FlushBarToolState extends State<FlushBarToolPage> {
151152
: _tipSecondDuration),
152153
borderRadius: _tipBorderRadius,
153154
margin: EdgeInsets.all(_tipMargin),
154-
flushbarPosition: FlushbarPosition.TOP,
155+
awesomeMessagePosition: AwesomeMessagePosition.TOP,
155156
shouldIconPulse: _tipIconPulse,
156157
showProgressIndicator: _tipShowProgress,
157-
flushbarStyle: _tipStyleValue,
158+
awesomeMessageStyle: _tipStyleValue,
158159
backgroundColor: _tipStyleBackgroundColor,
159160
borderColor: _tipStyleBorderColor,
160161
progressIndicatorBackgroundColor: _tipIndicatorColor,
@@ -257,7 +258,7 @@ class _FlushBarToolState extends State<FlushBarToolPage> {
257258
),
258259
],
259260
),
260-
_getFlushBar(),
261+
_getAwesomeMessage(),
261262
],
262263
),
263264
),
@@ -415,9 +416,12 @@ class _FlushBarToolState extends State<FlushBarToolPage> {
415416
),
416417
floatingActionButton: FloatingActionButton(
417418
onPressed: () {
418-
Widget flushBarWidget = _getFlushBar();
419-
if (flushBarWidget is Flushbar) {
420-
flushBarWidget..show(context);
419+
Widget awesomeMessageWidget = _getAwesomeMessage();
420+
if (awesomeMessageWidget is AwesomeMessage) {
421+
Airoute.push(
422+
route: AwesomeMessageRoute(
423+
theme: null, awesomeMessage: awesomeMessageWidget),
424+
);
421425
}
422426
},
423427
child: Icon(Icons.slideshow),
@@ -504,31 +508,31 @@ class _FlushBarStyleState extends State<FlushBarStylePage> {
504508
context: context,
505509
title: "Info",
506510
message: "message",
507-
tipType: TipType.INFO,
511+
tipType: tip_type.TipType.INFO,
508512
);
509513
break;
510514
case 1:
511515
TipHelper.showTip(
512516
context: context,
513517
title: "Warn",
514518
message: "message",
515-
tipType: TipType.WARN,
519+
tipType: tip_type.TipType.WARN,
516520
);
517521
break;
518522
case 2:
519523
TipHelper.showTip(
520524
context: context,
521525
title: "Error",
522526
message: "message",
523-
tipType: TipType.ERROR,
527+
tipType: tip_type.TipType.ERROR,
524528
);
525529
break;
526530
case 3:
527531
TipHelper.showTip(
528532
context: context,
529533
title: "Done",
530534
message: "message",
531-
tipType: TipType.COMPLETE,
535+
tipType: tip_type.TipType.COMPLETE,
532536
);
533537
break;
534538
}

pubspec.yaml

+2-4
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ dependencies:
3636

3737
# Barcode package.
3838
# ai_barcode: ^0.2.7
39-
ai_barcode:
40-
git:
41-
url: https://github.com/pdliuw/ai_barcode.git
39+
ai_barcode: ^1.0.3
4240

4341
# Http package.
4442
# ai_http: ^0.1.1
@@ -55,7 +53,7 @@ dependencies:
5553
snappable: ^1.0.1
5654

5755
# tip
58-
flushbar: ^1.9.1
56+
ai_awesome_message: ^0.1.0-pre
5957

6058
# drawing
6159
drawing_animation: ^0.1.3

0 commit comments

Comments
 (0)