Merge branch 'master' into null_safety

* master:
  update tag example, add loading toast
null_safety
小赖 4 years ago
commit f42b698ae6

@ -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_tab_bar.dart';
import 'package:example/widgets/example_tag.dart'; import 'package:example/widgets/example_tag.dart';
import 'package:example/widgets/example_text_field.dart'; import 'package:example/widgets/example_text_field.dart';
import 'package:example/widgets/example_toast.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
@ -104,6 +105,10 @@ class _MainHomeState extends State<MainHome> {
title: 'Pop Up Menu', title: 'Pop Up Menu',
onPressed: () => Get.to(ExamplePopUpMenu()), onPressed: () => Get.to(ExamplePopUpMenu()),
), ),
_innerButton(
title: 'Toast',
onPressed: () => Get.to(ExampleToast()),
),
], ],
); );
} }

@ -1,9 +1,8 @@
import 'package:ansu_ui/ansu_ui.dart'; import 'package:ansu_ui/ansu_ui.dart';
import 'package:example/codeviewer/code_segments.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/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:velocity_x/velocity_x.dart'; import 'package:velocity_x/velocity_x.dart';
class ExampleTag extends StatefulWidget { class ExampleTag extends StatefulWidget {
@ -17,75 +16,62 @@ class _ExampaleTagState extends State<ExampleTag> {
bool _checked = false; bool _checked = false;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ASScaffold( return ExampleScaffold(
title: 'ASTag', title: 'ASTag',
actions: [ text: (context) => CodeSegments.tag(context),
IconButton( children: [
icon: Icon( // BEGIN tag
Icons.code, ListTile(
color: Colors.black54, title: Text('yellowSolid'),
), trailing: ASTag.yellowSolid(
onPressed: () => Get.to( '带电',
CodeView( width: 36.w,
text: (context) => CodeSegments.tag(context), ),
), ),
), ListTile(
) title: Text('redHollow'),
], trailing: ASTag.redHollow(
body: Column( '带磁',
children: [ width: 36.w,
// BEGIN tag ),
ListTile( ),
title: Text('yellowSolid'), ListTile(
trailing: ASTag.yellowSolid( title: Text('yellowHollow'),
'带电', trailing: ASTag.yellowHollow(
width: 36.w, '选填',
), width: 36.w,
), ),
ListTile( ),
title: Text('redHollow'), ListTile(
trailing: ASTag.redHollow( title: Text('redHollow'),
'带磁', subtitle: Text('width:45.w'),
width: 36.w, trailing: ASTag.redHollow(
), '未付款',
), width: 45.w,
ListTile( ),
title: Text('yellowHollow'), ),
trailing: ASTag.yellowHollow( ListTile(
'选填', title: Text('yellowHollowS'),
width: 36.w, subtitle: Text('width:45.w'),
), trailing: ASTag.yellowHollowS(
), '已付款',
ListTile( width: 45.w,
title: Text('redHollow'), ),
subtitle: Text('width:45.w'), ),
trailing: ASTag.redHollow( ListTile(
'未付款', title: Text('transport'),
width: 45.w, trailing: ASTag.transport('海运'),
), ),
), ListTile(
ListTile( onTap: () => setState(() => _checked = !_checked),
title: Text('yellowHollowS'), title: Text('ASCheckedTag'),
subtitle: Text('width:45.w'), trailing: ASCheckTag(
trailing: ASTag.yellowHollowS( checked: _checked,
'已付款', text: 'TAG'.text.make(),
width: 45.w, ),
), ),
), ],
ListTile( // END
title: Text('transport'), );
trailing: ASTag.transport('海运'),
),
ListTile(
onTap: () => setState(() => _checked = !_checked),
title: Text('ASCheckedTag'),
trailing: ASCheckTag(
checked: _checked,
text: 'TAG'.text.make(),
),
),
// END
],
));
} }
} }

@ -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
],
);
}
}

@ -3,12 +3,12 @@ import 'package:flutter/material.dart';
/// ## /// ##
///```dart ///```dart
/// showASPopUpMenu<int>( /// int result = await showASPopUpMenu<int>(
/// context: context, /// context: context,
/// items: [ /// items: [
/// PopupMenuItem(child: 'test'.text, value: 1), /// PopupMenuItem(child: Text('test'), value: 1),
/// ], /// ],
/// ).then((value) {}); /// );
/// ``` /// ```
Future<T> showASPopUpMenu<T>({ Future<T> showASPopUpMenu<T>({
@required BuildContext context, @required BuildContext context,

@ -1,7 +1,30 @@
import 'dart:ui';
import 'package:bot_toast/bot_toast.dart'; import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/material.dart';
class ASToast { class ASToast {
static show(String text) { 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(),
),
),
);
},
);
} }
} }

Loading…
Cancel
Save