add asCheckTag

null_safety
小赖 4 years ago
parent 93d6b1883f
commit 784f153b55

@ -10,6 +10,7 @@ class ExampleTag extends StatefulWidget {
} }
class _ExampaleTagState extends State<ExampleTag> { class _ExampaleTagState extends State<ExampleTag> {
bool _checked = false;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ASScaffold( return ASScaffold(
@ -56,6 +57,14 @@ class _ExampaleTagState extends State<ExampleTag> {
title: Text('transport'), title: Text('transport'),
trailing: ASTag.transport('海运'), trailing: ASTag.transport('海运'),
), ),
ListTile(
onTap: () => setState(() => _checked = !_checked),
title: Text('ASCheckedTag'),
trailing: ASCheckTag(
checked: _checked,
text: 'TAG'.text,
),
),
], ],
)); ));
} }

@ -53,6 +53,8 @@ export 'box/as_check_box.dart';
export 'pop_up_menu/pop_up_menu.dart'; export 'pop_up_menu/pop_up_menu.dart';
export 'tag/as_tag.dart'; export 'tag/as_tag.dart';
export 'tag/as_check_tag.dart';
export 'divider/as_divider.dart'; export 'divider/as_divider.dart';
export 'text_field/as_search_text_field.dart'; export 'text_field/as_search_text_field.dart';
export 'badge/as_badge.dart'; export 'badge/as_badge.dart';

@ -0,0 +1,54 @@
import 'package:ansu_ui/ansu_ui.dart';
import 'package:flutter/material.dart';
import 'package:ansu_ui/extension/num_extension.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class ASCheckTag extends StatelessWidget {
final bool checked;
final Widget text;
const ASCheckTag({
Key key,
this.checked = false,
@required this.text,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
AnimatedContainer(
duration: Duration(milliseconds: 300),
curve: Curves.easeInOutCubic,
height: 14.w,
width: 14.w,
decoration: BoxDecoration(
color: checked ? Color(0xFF00BF44) : Color(0xFFFF0000),
borderRadius: 7.radius,
),
alignment: Alignment.center,
child: AnimatedSwitcher(
duration: Duration(milliseconds: 300),
switchInCurve: Curves.easeInOutCubic,
switchOutCurve: Curves.easeInOutCubic,
child: Icon(
checked ? Icons.check : Icons.clear,
key: ValueKey(checked),
size: 10.w,
color: kForegroundColor,
),
),
),
6.wb,
AnimatedDefaultTextStyle(
duration: Duration(milliseconds: 300),
curve: Curves.easeInOutCubic,
style: TextStyle(
color: checked ? Color(0xFF00BF44) : Color(0xFFFF0000),
),
child: text,
),
],
);
}
}
Loading…
Cancel
Save