parent
bff2d19976
commit
378dfe6412
@ -1,64 +1,64 @@
|
|||||||
// Flutter imports:
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
// Project imports:
|
|
||||||
import 'package:akuCommunity/base/base_style.dart';
|
import 'package:akuCommunity/base/base_style.dart';
|
||||||
|
import 'package:akuCommunity/widget/animated/animated_scale.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
import 'package:akuCommunity/utils/headers.dart';
|
import 'package:akuCommunity/utils/headers.dart';
|
||||||
|
|
||||||
class CommonRadio extends StatefulWidget {
|
class CommonRadio<T> extends StatefulWidget {
|
||||||
final List<Map<String, dynamic>> commonlist;
|
final T value;
|
||||||
final Function fun;
|
final T groupValue;
|
||||||
CommonRadio({Key key, this.commonlist, this.fun}) : super(key: key);
|
final Widget text;
|
||||||
|
final double size;
|
||||||
|
CommonRadio({Key key, this.value, this.groupValue, this.text, this.size})
|
||||||
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_CommonRadioState createState() => _CommonRadioState();
|
_CommonRadioState createState() => _CommonRadioState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _CommonRadioState extends State<CommonRadio> {
|
class _CommonRadioState extends State<CommonRadio> {
|
||||||
InkWell _inkWellRadio(String title, bool isCheck,int index, Function fun) {
|
bool get _selected => widget.value == widget.groupValue;
|
||||||
return InkWell(
|
double get smallSize {
|
||||||
onTap: () {
|
return widget.size.isNull ? 24.w : (widget.size * 24 / 40);
|
||||||
fun(index);
|
|
||||||
},
|
|
||||||
child: Container(
|
|
||||||
margin: EdgeInsets.only(left: 20.w),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Icon(
|
|
||||||
isCheck
|
|
||||||
? Icons.radio_button_checked
|
|
||||||
: Icons.radio_button_unchecked,
|
|
||||||
size: 32.w,
|
|
||||||
color: isCheck ? BaseStyle.colorffc40c : BaseStyle.color979797,
|
|
||||||
),
|
|
||||||
SizedBox(width: 10.w),
|
|
||||||
Text(
|
|
||||||
title,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: BaseStyle.fontSize28, color: ktextPrimary),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Row(
|
||||||
child: Row(
|
children: [
|
||||||
children: widget.commonlist
|
AnimatedContainer(
|
||||||
.asMap()
|
height: widget.size ?? 40.w,
|
||||||
.keys
|
width: widget.size ?? 40.w,
|
||||||
.map((index) => _inkWellRadio(
|
decoration: BoxDecoration(
|
||||||
widget.commonlist[index]['title'],
|
border: Border.all(
|
||||||
widget.commonlist[index]['isCheck'],
|
color: _selected ? kPrimaryColor : Color(0xFF979797),
|
||||||
index,
|
width: 3.w,
|
||||||
widget.fun
|
),
|
||||||
))
|
borderRadius: BorderRadius.circular(20.w),
|
||||||
.toList(),
|
),
|
||||||
),
|
duration: Duration(milliseconds: 300),
|
||||||
|
curve: Curves.easeInOutCubic,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: AnimatedOpacity(
|
||||||
|
duration: Duration(milliseconds: 300),
|
||||||
|
curve: Curves.easeInOutCubic,
|
||||||
|
opacity: _selected ? 1 : 0,
|
||||||
|
child: AnimatedScale(
|
||||||
|
scale: _selected ? 1 : 0,
|
||||||
|
child: Container(
|
||||||
|
height: smallSize,
|
||||||
|
width: smallSize,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: kPrimaryColor,
|
||||||
|
borderRadius: BorderRadius.circular(12.w),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
10.w.widthBox,
|
||||||
|
widget.text,
|
||||||
|
10.w.widthBox,
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in new issue