From aec558f54cfbd17d3176c7e7b65729a818de5d06 Mon Sep 17 00:00:00 2001 From: zhangmeng <494089941@qq.com> Date: Mon, 9 Aug 2021 14:37:28 +0800 Subject: [PATCH] =?UTF-8?q?=20as=20radio=20butoon=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=A4=9A=E9=80=89=20as=20edit=20tile=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E9=9A=90=E8=97=8F=E8=BE=93=E5=85=A5=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/buttons/as_radio_button.dart | 25 +++++++++++++++++++++---- lib/list_tile/as_edit_tile.dart | 6 ++++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/lib/buttons/as_radio_button.dart b/lib/buttons/as_radio_button.dart index 361496c..6d909a5 100644 --- a/lib/buttons/as_radio_button.dart +++ b/lib/buttons/as_radio_button.dart @@ -5,7 +5,7 @@ import 'package:ansu_ui/extension/num_extension.dart'; class ASRadioButton extends StatefulWidget { /// 选中的值 - final T? groupValue; + final dynamic groupValue; ///按钮标题 final String? title; @@ -15,20 +15,37 @@ class ASRadioButton extends StatefulWidget { ///按钮回调 final Function(T value)? onTap; + + /// 是否多选 + final bool mulitpleChoice; ASRadioButton({ Key? key, this.groupValue, this.title, this.value, this.onTap, - }) : super(key: key); - + }) : this.mulitpleChoice = false, + super(key: key); + ASRadioButton.mult({ + Key? key, + this.groupValue, + this.title, + this.value, + this.onTap, + }) : this.mulitpleChoice = true, + super(key: key); @override _ASRadioButtonState createState() => _ASRadioButtonState(); } class _ASRadioButtonState extends State { - bool get _selected => widget.value == widget.groupValue; + bool get _selected { + if (widget.mulitpleChoice) { + return (widget.groupValue as List).contains(widget.value); + } else { + return widget.value == widget.groupValue; + } + } @override Widget build(BuildContext context) { return InkWell( diff --git a/lib/list_tile/as_edit_tile.dart b/lib/list_tile/as_edit_tile.dart index 417dd1a..19969a9 100644 --- a/lib/list_tile/as_edit_tile.dart +++ b/lib/list_tile/as_edit_tile.dart @@ -15,6 +15,8 @@ class ASEditTile extends StatelessWidget { final TextInputType? keyBoardType; final TextStyle? hintTextStyle; final Widget? suffix; + final bool? obscureText; + final String? obscuringCharacter; ASEditTile({ Key? key, this.title, @@ -27,6 +29,8 @@ class ASEditTile extends StatelessWidget { this.keyBoardType, this.hintTextStyle, this.suffix, + this.obscureText, + this.obscuringCharacter, }) : super(key: key); @override Widget build(BuildContext context) { @@ -55,6 +59,8 @@ class ASEditTile extends StatelessWidget { onChanged: onChange, inputFormatters: inputFormatters, keyboardType: keyBoardType, + obscureText: obscureText ?? false, + obscuringCharacter: obscuringCharacter ?? '*', onSubmitted: onSubmitted, textAlign: TextAlign.end, style: TextStyle(