diff --git a/example/lib/main_home.dart b/example/lib/main_home.dart index 91679c4..45cb367 100644 --- a/example/lib/main_home.dart +++ b/example/lib/main_home.dart @@ -13,6 +13,7 @@ import 'package:example/widgets/example_style_color.dart'; import 'package:example/widgets/example_tab_bar.dart'; import 'package:example/widgets/example_tag.dart'; import 'package:example/widgets/example_text_field.dart'; +import 'package:example/widgets/example_toast.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -104,6 +105,10 @@ class _MainHomeState extends State { title: 'Pop Up Menu', onPressed: () => Get.to(ExamplePopUpMenu()), ), + _innerButton( + title: 'Toast', + onPressed: () => Get.to(ExampleToast()), + ), ], ); } diff --git a/example/lib/widgets/example_tag.dart b/example/lib/widgets/example_tag.dart index 7cde185..a861eb9 100644 --- a/example/lib/widgets/example_tag.dart +++ b/example/lib/widgets/example_tag.dart @@ -1,9 +1,8 @@ import 'package:ansu_ui/ansu_ui.dart'; import 'package:example/codeviewer/code_segments.dart'; -import 'package:example/common/code_view.dart'; +import 'package:example/component/example_scaffold.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:get/get.dart'; import 'package:velocity_x/velocity_x.dart'; class ExampleTag extends StatefulWidget { @@ -17,75 +16,62 @@ class _ExampaleTagState extends State { bool _checked = false; @override Widget build(BuildContext context) { - return ASScaffold( - title: 'ASTag', - actions: [ - IconButton( - icon: Icon( - Icons.code, - color: Colors.black54, - ), - onPressed: () => Get.to( - CodeView( - text: (context) => CodeSegments.tag(context), - ), - ), - ) - ], - body: Column( - children: [ - // BEGIN tag - ListTile( - title: Text('yellowSolid'), - trailing: ASTag.yellowSolid( - '带电', - width: 36.w, - ), - ), - ListTile( - title: Text('redHollow'), - trailing: ASTag.redHollow( - '带磁', - width: 36.w, - ), - ), - ListTile( - title: Text('yellowHollow'), - trailing: ASTag.yellowHollow( - '选填', - width: 36.w, - ), - ), - ListTile( - title: Text('redHollow'), - subtitle: Text('width:45.w'), - trailing: ASTag.redHollow( - '未付款', - width: 45.w, - ), - ), - ListTile( - title: Text('yellowHollowS'), - subtitle: Text('width:45.w'), - trailing: ASTag.yellowHollowS( - '已付款', - width: 45.w, - ), - ), - ListTile( - title: Text('transport'), - trailing: ASTag.transport('海运'), - ), - ListTile( - onTap: () => setState(() => _checked = !_checked), - title: Text('ASCheckedTag'), - trailing: ASCheckTag( - checked: _checked, - text: 'TAG'.text.make(), - ), - ), - // END - ], - )); + return ExampleScaffold( + title: 'ASTag', + text: (context) => CodeSegments.tag(context), + children: [ + // BEGIN tag + ListTile( + title: Text('yellowSolid'), + trailing: ASTag.yellowSolid( + '带电', + width: 36.w, + ), + ), + ListTile( + title: Text('redHollow'), + trailing: ASTag.redHollow( + '带磁', + width: 36.w, + ), + ), + ListTile( + title: Text('yellowHollow'), + trailing: ASTag.yellowHollow( + '选填', + width: 36.w, + ), + ), + ListTile( + title: Text('redHollow'), + subtitle: Text('width:45.w'), + trailing: ASTag.redHollow( + '未付款', + width: 45.w, + ), + ), + ListTile( + title: Text('yellowHollowS'), + subtitle: Text('width:45.w'), + trailing: ASTag.yellowHollowS( + '已付款', + width: 45.w, + ), + ), + ListTile( + title: Text('transport'), + trailing: ASTag.transport('海运'), + ), + ListTile( + onTap: () => setState(() => _checked = !_checked), + title: Text('ASCheckedTag'), + trailing: ASCheckTag( + checked: _checked, + text: 'TAG'.text.make(), + ), + ), + ], + // END + ); } } diff --git a/example/lib/widgets/example_toast.dart b/example/lib/widgets/example_toast.dart new file mode 100644 index 0000000..72ec95e --- /dev/null +++ b/example/lib/widgets/example_toast.dart @@ -0,0 +1,32 @@ +import 'package:ansu_ui/toast/as_toast.dart'; +import 'package:example/codeviewer/code_segments.dart'; +import 'package:example/component/example_scaffold.dart'; +import 'package:flutter/material.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class ExampleToast extends StatelessWidget { + const ExampleToast({Key key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return ExampleScaffold( + title: 'Toast', + text: (context) => CodeSegments.toast(context), + children: [ + // BEGIN toast + ListTile( + title: 'Toast'.text.make(), + onTap: () => ASToast.show('Toast!'), + ), + ListTile( + title: 'Toast'.text.make(), + onTap: () { + Function cancel = ASToast.loading; + Future.delayed(Duration(seconds: 2), () => cancel()); + }, + ), + // END + ], + ); + } +} diff --git a/lib/pop_up_menu/pop_up_menu.dart b/lib/pop_up_menu/pop_up_menu.dart index 225ab89..03ff631 100644 --- a/lib/pop_up_menu/pop_up_menu.dart +++ b/lib/pop_up_menu/pop_up_menu.dart @@ -3,12 +3,12 @@ import 'package:flutter/material.dart'; /// ## 弹框菜单 ///```dart -/// showASPopUpMenu( +/// int result = await showASPopUpMenu( /// context: context, /// items: [ -/// PopupMenuItem(child: 'test'.text, value: 1), +/// PopupMenuItem(child: Text('test'), value: 1), /// ], -/// ).then((value) {}); +/// ); /// ``` Future showASPopUpMenu({ @required BuildContext context, diff --git a/lib/toast/as_toast.dart b/lib/toast/as_toast.dart index ba34d10..2107651 100644 --- a/lib/toast/as_toast.dart +++ b/lib/toast/as_toast.dart @@ -1,7 +1,30 @@ +import 'dart:ui'; + import 'package:bot_toast/bot_toast.dart'; +import 'package:flutter/material.dart'; class ASToast { static show(String text) { - BotToast.showText(text: text); + BotToast.showText( + text: text, + borderRadius: BorderRadius.circular(20), + ); + } + + static Function get loading { + return BotToast.showCustomLoading( + toastBuilder: (cancel) { + return Center( + child: Material( + clipBehavior: Clip.antiAlias, + shape: StadiumBorder(), + child: Padding( + padding: const EdgeInsets.all(8.0), + child: CircularProgressIndicator(), + ), + ), + ); + }, + ); } }