You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
1.9 KiB
69 lines
1.9 KiB
2 years ago
|
import 'package:flutter/cupertino.dart';
|
||
|
import 'package:flutter/material.dart';
|
||
|
import 'package:project_telephony/base/base_style.dart';
|
||
|
import 'package:project_telephony/utils/headers.dart';
|
||
|
|
||
|
class BeeCheckRadio<T> extends StatefulWidget {
|
||
|
final T? value;
|
||
|
final List<T>? groupValue;
|
||
|
final Widget? indent;
|
||
|
final Color? backColor;
|
||
|
final bool? border;
|
||
|
const BeeCheckRadio({
|
||
|
Key? key,
|
||
|
this.value,
|
||
|
this.groupValue,
|
||
|
this.indent,
|
||
|
this.backColor,
|
||
|
this.border = true,
|
||
|
});
|
||
|
|
||
|
@override
|
||
|
_BeeCheckRadioState createState() => _BeeCheckRadioState();
|
||
|
}
|
||
|
|
||
|
class _BeeCheckRadioState extends State<BeeCheckRadio> {
|
||
|
bool get _selected {
|
||
|
if (widget.groupValue!.contains(widget.value)) {
|
||
|
return true;
|
||
|
} else {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return AnimatedContainer(
|
||
|
height: 40.w,
|
||
|
width: 40.w,
|
||
|
decoration: widget.border!
|
||
|
? BoxDecoration(
|
||
|
color: widget.backColor ??
|
||
|
kPrimaryColor.withOpacity(_selected ? 1 : 0),
|
||
|
border: Border.all(
|
||
|
color: widget.backColor != null
|
||
|
? kForeGroundColor
|
||
|
: (_selected ? kPrimaryColor : const Color(0xFFcccccc)),
|
||
|
width: 2.w,
|
||
|
),
|
||
|
borderRadius: BorderRadius.circular(20.w),
|
||
|
)
|
||
|
: const BoxDecoration(),
|
||
|
duration: const Duration(milliseconds: 300),
|
||
|
curve: Curves.easeInOutCubic,
|
||
|
alignment: Alignment.center,
|
||
|
child: AnimatedOpacity(
|
||
|
duration: const Duration(milliseconds: 500),
|
||
|
curve: Curves.easeInOutCubic,
|
||
|
opacity: _selected ? 1 : 0,
|
||
|
child: widget.indent ??
|
||
|
Icon(
|
||
|
CupertinoIcons.checkmark,
|
||
|
color: widget.border! ? Colors.white : const Color(0xFF027AFF),
|
||
|
size: 28.w,
|
||
|
),
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
}
|