diff --git a/example/lib/example_box.dart b/example/lib/example_box.dart new file mode 100644 index 0000000..568b4c2 --- /dev/null +++ b/example/lib/example_box.dart @@ -0,0 +1,32 @@ +import 'package:ansu_ui/ansu_ui.dart'; +import 'package:flutter/material.dart'; + +class ExampleBox extends StatefulWidget { + ExampleBox({Key key}) : super(key: key); + + @override + _ExampleBoxState createState() => _ExampleBoxState(); +} + +class _ExampleBoxState extends State { + bool _state = false; + @override + Widget build(BuildContext context) { + return ASScaffold( + title: '选框', + body: ListView( + children: [ + ListTile( + leading: ASCheckBox(value: _state), + title: Text('CheckBox'), + onTap: () { + setState(() { + _state = !_state; + }); + }, + ), + ], + ), + ); + } +} diff --git a/example/lib/main.dart b/example/lib/main.dart index 6eff1ec..d0f3341 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,5 +1,6 @@ import 'package:ansu_ui/ansu_ui.dart'; import 'package:example/example_bottom_button.dart'; +import 'package:example/example_box.dart'; import 'package:example/example_dialog.dart'; import 'package:example/example_drawer.dart'; import 'package:example/example_listtile.dart'; @@ -122,6 +123,10 @@ class _MyHomePageState extends State { title: '刷新组件 Refresh', onPressed: () => Get.to(ExampleRefresh()), ), + ASButton.info( + title: '选框 Box', + onPressed: () => Get.to(ExampleBox()), + ), ], ), ); diff --git a/lib/ansu_ui.dart b/lib/ansu_ui.dart index 6dfd527..4ed0d75 100644 --- a/lib/ansu_ui.dart +++ b/lib/ansu_ui.dart @@ -25,6 +25,8 @@ export 'list_tile/as_vertical_tile_item.dart'; export 'refresh/as_refresh.dart'; +export 'box/as_check_box.dart'; + export 'tag/as_tag.dart'; export 'divider/as_divider.dart'; export 'text_field/as_search_text_field.dart'; diff --git a/lib/box/as_check_box.dart b/lib/box/as_check_box.dart new file mode 100644 index 0000000..490876d --- /dev/null +++ b/lib/box/as_check_box.dart @@ -0,0 +1,38 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +class ASCheckBox extends StatefulWidget { + final bool value; + ASCheckBox({Key key, this.value = false}) : super(key: key); + + @override + _ASCheckBoxState createState() => _ASCheckBoxState(); +} + +class _ASCheckBoxState extends State { + @override + Widget build(BuildContext context) { + return Container( + height: 17.w, + width: 17.w, + alignment: Alignment.center, + decoration: BoxDecoration( + border: Border.all( + color: Color(0xFFD5D5D5), + width: 1.w, + ), + borderRadius: BorderRadius.circular(17.w), + ), + child: AnimatedContainer( + duration: Duration(milliseconds: 300), + curve: Curves.fastOutSlowIn, + height: widget.value ? 13.w : 5.w, + width: widget.value ? 13.w : 5.w, + decoration: BoxDecoration( + color: Color(0xFFF69A2D).withOpacity(widget.value ? 1 : 0), + borderRadius: BorderRadius.circular(13.w), + ), + ), + ); + } +}