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,22 +16,9 @@ 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: [
IconButton(
icon: Icon(
Icons.code,
color: Colors.black54,
),
onPressed: () => Get.to(
CodeView(
text: (context) => CodeSegments.tag(context), text: (context) => CodeSegments.tag(context),
),
),
)
],
body: Column(
children: [ children: [
// BEGIN tag // BEGIN tag
ListTile( ListTile(
@ -84,8 +70,8 @@ class _ExampaleTagState extends State<ExampleTag> {
text: 'TAG'.text.make(), text: 'TAG'.text.make(),
), ),
), ),
// END
], ],
)); // 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