Skip to content

Commit

Permalink
Update: awesome_message
Browse files Browse the repository at this point in the history
  • Loading branch information
pdliuw committed Apr 6, 2020
1 parent 86d5232 commit d1685e5
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 112 deletions.
106 changes: 24 additions & 82 deletions lib/common/helper/tip_helper.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'package:ai_awesome_message/ai_awesome_message.dart' as awesome_message;
import 'package:airoute/airoute.dart';
import 'package:flutter/material.dart';
import 'package:flushbar/flushbar.dart';
import 'tip_type.dart';

import 'tip_type.dart' as tip_type;

///
/// TipHelper
Expand All @@ -15,90 +17,30 @@ class TipHelper {
@required BuildContext context,
String title,
String message = '',
TipType tipType = TipType.INFO,
tip_type.TipType tipType = tip_type.TipType.INFO,
}) {
List<Color> _tipStyleColorsSample = [
Colors.blue[100],
Colors.orange[100],
Colors.red[100],
Colors.green[200]
];
List<Color> _tipIndicatorColorsSample = [
Colors.blue[300],
Colors.orange[300],
Colors.red[300],
Colors.blue[300]
];
List<Color> _tipIconColorsSample = [
Colors.blue[500],
Colors.orange[500],
Colors.red[500],
Colors.blue[500]
];

IconData _tipIcon;
Color _tipStyleColor;
Color _tipStyleIconColor;
Color _tipStyleBorderColor;
if (tipType == TipType.INFO) {
title = title ?? "提示";
_tipIcon = Icons.info_outline;
_tipStyleColor = Colors.blue[100];
_tipStyleIconColor = Colors.blue[500];
_tipStyleBorderColor = Colors.blue[300];
} else if (tipType == TipType.WARN) {
title = title ?? "警告";
_tipIcon = Icons.error_outline;
_tipStyleColor = Colors.orange[100];
_tipStyleIconColor = Colors.orange[500];
_tipStyleBorderColor = Colors.orange[300];
} else if (tipType == TipType.ERROR) {
title = title ?? "错误";
_tipIcon = Icons.cancel;
_tipStyleColor = Colors.red[100];
_tipStyleIconColor = Colors.red[500];
_tipStyleBorderColor = Colors.red[300];
} else if (tipType == TipType.COMPLETE) {
title = title ?? "完成";
_tipIcon = Icons.check_circle;
_tipStyleColor = Colors.green[100];
_tipStyleIconColor = Colors.green[500];
_tipStyleBorderColor = Colors.green[300];
awesome_message.TipType awesomeTipType;
if (tipType == tip_type.TipType.INFO) {
awesomeTipType = awesome_message.TipType.INFO;
} else if (tipType == tip_type.TipType.WARN) {
awesomeTipType = awesome_message.TipType.WARN;
} else if (tipType == tip_type.TipType.ERROR) {
awesomeTipType = awesome_message.TipType.ERROR;
} else if (tipType == tip_type.TipType.COMPLETE) {
awesomeTipType = awesome_message.TipType.COMPLETE;
} else {
title = title ?? "默认";
_tipIcon = Icons.info_outline;
_tipStyleColor = Colors.blue[100];
_tipStyleIconColor = Colors.blue[500];
_tipStyleBorderColor = Colors.blue[300];
awesomeTipType = awesome_message.TipType.INFO;
}

Flushbar(
titleText: Text(
"${title ?? '提示'}",
style: TextStyle(
color: Colors.black87,
Airoute.push(
route: awesome_message.AwesomeMessageRoute(
theme: null,
settings: RouteSettings(name: "/ai_awesome_message"),
awesomeMessage: awesome_message.AwesomeHelper.createAwesome(
title: "$title",
message: "$message",
tipType: awesomeTipType,
),
),
messageText: Text(
"${message ?? '提示'}",
style: TextStyle(
color: Colors.black54,
),
),
icon: Icon(
_tipIcon,
size: 28.0,
color: _tipStyleIconColor,
),
duration: Duration(
seconds: 2,
),
flushbarPosition: FlushbarPosition.TOP,
shouldIconPulse: true,
showProgressIndicator: false,
flushbarStyle: FlushbarStyle.GROUNDED,
backgroundColor: _tipStyleColor,
borderColor: _tipStyleBorderColor,
)..show(context);
);
}
}
17 changes: 9 additions & 8 deletions lib/sample/chart/bar_chart/samples/bar_chart_sample5.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ class BarChartSample5State extends State<BarChartSample5> {
checkToShowHorizontalLine: (value) => value % 5 == 0,
getDrawingHorizontalLine: (value) {
if (value == 0) {
return const FlLine(color: Color(0xff363753), strokeWidth: 3);
return const FlLine(
color: Color(0xff363753), strokeWidth: 3);
}
return const FlLine(
color: Color(0xff2a2747),
Expand All @@ -110,7 +111,7 @@ class BarChartSample5State extends State<BarChartSample5> {
show: false,
),
barGroups: [
const BarChartGroupData(
BarChartGroupData(
x: 0,
barRods: [
BarChartRodData(
Expand All @@ -128,7 +129,7 @@ class BarChartSample5State extends State<BarChartSample5> {
),
],
),
const BarChartGroupData(
BarChartGroupData(
x: 1,
barRods: [
BarChartRodData(
Expand All @@ -146,7 +147,7 @@ class BarChartSample5State extends State<BarChartSample5> {
),
],
),
const BarChartGroupData(
BarChartGroupData(
x: 2,
barRods: [
BarChartRodData(
Expand All @@ -164,7 +165,7 @@ class BarChartSample5State extends State<BarChartSample5> {
),
],
),
const BarChartGroupData(
BarChartGroupData(
x: 3,
barRods: [
BarChartRodData(
Expand All @@ -182,7 +183,7 @@ class BarChartSample5State extends State<BarChartSample5> {
),
],
),
const BarChartGroupData(
BarChartGroupData(
x: 4,
barRods: [
BarChartRodData(
Expand All @@ -200,7 +201,7 @@ class BarChartSample5State extends State<BarChartSample5> {
),
],
),
const BarChartGroupData(
BarChartGroupData(
x: 5,
barRods: [
BarChartRodData(
Expand All @@ -218,7 +219,7 @@ class BarChartSample5State extends State<BarChartSample5> {
),
],
),
const BarChartGroupData(
BarChartGroupData(
x: 6,
barRods: [
BarChartRodData(
Expand Down
23 changes: 23 additions & 0 deletions lib/sample/text/input_text_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:flutter/material.dart';

///
/// InputTextPage
class InputTextPage extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return _InputTextState();
}
}

///
/// _InputTextState
class _InputTextState extends State<InputTextPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("InputText"),
),
);
}
}
40 changes: 22 additions & 18 deletions lib/sample/tip/flushbar_page.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import 'package:ai_awesome_message/ai_awesome_message.dart';
import 'package:airoute/airoute.dart';
import 'package:flutter/material.dart';
import 'package:flushbar/flushbar.dart';

import '../../common/helper/tip_helper.dart';
import '../../common/helper/tip_type.dart';
import '../../common/helper/tip_type.dart' as tip_type;

///
/// FlushBarPage
Expand Down Expand Up @@ -116,14 +117,14 @@ class _FlushBarToolState extends State<FlushBarToolPage> {
IconData _tipIconData = Icons.info_outline;

List<bool> _tipStyleSelected = [true, false];
List<FlushbarStyle> _tipStyleValues = [
FlushbarStyle.GROUNDED,
FlushbarStyle.FLOATING
List<AwesomeMessageStyle> _tipStyleValues = [
AwesomeMessageStyle.GROUNDED,
AwesomeMessageStyle.FLOATING
];
FlushbarStyle _tipStyleValue = FlushbarStyle.GROUNDED;
AwesomeMessageStyle _tipStyleValue = AwesomeMessageStyle.GROUNDED;

Widget _getFlushBar() {
return Flushbar(
Widget _getAwesomeMessage() {
return AwesomeMessage(
title: "${_tipTitle ?? 'title'}",
titleText: Text(
"${_tipTitle ?? '提示'}",
Expand Down Expand Up @@ -151,10 +152,10 @@ class _FlushBarToolState extends State<FlushBarToolPage> {
: _tipSecondDuration),
borderRadius: _tipBorderRadius,
margin: EdgeInsets.all(_tipMargin),
flushbarPosition: FlushbarPosition.TOP,
awesomeMessagePosition: AwesomeMessagePosition.TOP,
shouldIconPulse: _tipIconPulse,
showProgressIndicator: _tipShowProgress,
flushbarStyle: _tipStyleValue,
awesomeMessageStyle: _tipStyleValue,
backgroundColor: _tipStyleBackgroundColor,
borderColor: _tipStyleBorderColor,
progressIndicatorBackgroundColor: _tipIndicatorColor,
Expand Down Expand Up @@ -257,7 +258,7 @@ class _FlushBarToolState extends State<FlushBarToolPage> {
),
],
),
_getFlushBar(),
_getAwesomeMessage(),
],
),
),
Expand Down Expand Up @@ -415,9 +416,12 @@ class _FlushBarToolState extends State<FlushBarToolPage> {
),
floatingActionButton: FloatingActionButton(
onPressed: () {
Widget flushBarWidget = _getFlushBar();
if (flushBarWidget is Flushbar) {
flushBarWidget..show(context);
Widget awesomeMessageWidget = _getAwesomeMessage();
if (awesomeMessageWidget is AwesomeMessage) {
Airoute.push(
route: AwesomeMessageRoute(
theme: null, awesomeMessage: awesomeMessageWidget),
);
}
},
child: Icon(Icons.slideshow),
Expand Down Expand Up @@ -504,31 +508,31 @@ class _FlushBarStyleState extends State<FlushBarStylePage> {
context: context,
title: "Info",
message: "message",
tipType: TipType.INFO,
tipType: tip_type.TipType.INFO,
);
break;
case 1:
TipHelper.showTip(
context: context,
title: "Warn",
message: "message",
tipType: TipType.WARN,
tipType: tip_type.TipType.WARN,
);
break;
case 2:
TipHelper.showTip(
context: context,
title: "Error",
message: "message",
tipType: TipType.ERROR,
tipType: tip_type.TipType.ERROR,
);
break;
case 3:
TipHelper.showTip(
context: context,
title: "Done",
message: "message",
tipType: TipType.COMPLETE,
tipType: tip_type.TipType.COMPLETE,
);
break;
}
Expand Down
6 changes: 2 additions & 4 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ dependencies:

# Barcode package.
# ai_barcode: ^0.2.7
ai_barcode:
git:
url: https://github.com/pdliuw/ai_barcode.git
ai_barcode: ^1.0.3

# Http package.
# ai_http: ^0.1.1
Expand All @@ -55,7 +53,7 @@ dependencies:
snappable: ^1.0.1

# tip
flushbar: ^1.9.1
ai_awesome_message: ^0.1.0-pre

# drawing
drawing_animation: ^0.1.3
Expand Down

0 comments on commit d1685e5

Please sign in to comment.