as radio butoon 支持多选

as edit tile 支持隐藏输入内容
master
张萌 4 years ago
parent f2aceb5c55
commit aec558f54c

@ -5,7 +5,7 @@ import 'package:ansu_ui/extension/num_extension.dart';
class ASRadioButton<T> extends StatefulWidget { class ASRadioButton<T> extends StatefulWidget {
/// ///
final T? groupValue; final dynamic groupValue;
/// ///
final String? title; final String? title;
@ -15,20 +15,37 @@ class ASRadioButton<T> extends StatefulWidget {
/// ///
final Function(T value)? onTap; final Function(T value)? onTap;
///
final bool mulitpleChoice;
ASRadioButton({ ASRadioButton({
Key? key, Key? key,
this.groupValue, this.groupValue,
this.title, this.title,
this.value, this.value,
this.onTap, 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 @override
_ASRadioButtonState createState() => _ASRadioButtonState(); _ASRadioButtonState createState() => _ASRadioButtonState();
} }
class _ASRadioButtonState extends State<ASRadioButton> { class _ASRadioButtonState extends State<ASRadioButton> {
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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return InkWell( return InkWell(

@ -15,6 +15,8 @@ class ASEditTile extends StatelessWidget {
final TextInputType? keyBoardType; final TextInputType? keyBoardType;
final TextStyle? hintTextStyle; final TextStyle? hintTextStyle;
final Widget? suffix; final Widget? suffix;
final bool? obscureText;
final String? obscuringCharacter;
ASEditTile({ ASEditTile({
Key? key, Key? key,
this.title, this.title,
@ -27,6 +29,8 @@ class ASEditTile extends StatelessWidget {
this.keyBoardType, this.keyBoardType,
this.hintTextStyle, this.hintTextStyle,
this.suffix, this.suffix,
this.obscureText,
this.obscuringCharacter,
}) : super(key: key); }) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -55,6 +59,8 @@ class ASEditTile extends StatelessWidget {
onChanged: onChange, onChanged: onChange,
inputFormatters: inputFormatters, inputFormatters: inputFormatters,
keyboardType: keyBoardType, keyboardType: keyBoardType,
obscureText: obscureText ?? false,
obscuringCharacter: obscuringCharacter ?? '*',
onSubmitted: onSubmitted, onSubmitted: onSubmitted,
textAlign: TextAlign.end, textAlign: TextAlign.end,
style: TextStyle( style: TextStyle(

Loading…
Cancel
Save