update tag example, add loading toast

null_safety
小赖 4 years ago
parent 7d688b08ac
commit 1c52272ec0

@ -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<MainHome> {
title: 'Pop Up Menu',
onPressed: () => Get.to(ExamplePopUpMenu()),
),
_innerButton(
title: 'Toast',
onPressed: () => Get.to(ExampleToast()),
),
],
);
}

@ -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<ExampleTag> {
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
);
}
}

@ -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
/// showASPopUpMenu<int>(
/// int result = await showASPopUpMenu<int>(
/// context: context,
/// items: [
/// PopupMenuItem(child: 'test'.text, value: 1),
/// PopupMenuItem(child: Text('test'), value: 1),
/// ],
/// ).then((value) {});
/// );
/// ```
Future<T> showASPopUpMenu<T>({
@required BuildContext context,

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

Loading…
Cancel
Save