2022-09-26 16:08:56 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
class CustomRadioToggle extends StatelessWidget {
|
|
|
|
final String groupSelected;
|
|
|
|
final String value;
|
|
|
|
final String label;
|
|
|
|
final void Function(String) onTap;
|
|
|
|
|
|
|
|
const CustomRadioToggle({
|
|
|
|
Key? key,
|
|
|
|
required this.groupSelected,
|
|
|
|
required this.value,
|
|
|
|
required this.label,
|
|
|
|
required this.onTap,
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Material(
|
|
|
|
borderRadius: BorderRadius.circular(30),
|
|
|
|
color: Colors.transparent,
|
|
|
|
child: InkWell(
|
|
|
|
onTap: () => onTap(value),
|
|
|
|
borderRadius: BorderRadius.circular(30),
|
2022-10-02 19:39:41 +02:00
|
|
|
child: AnimatedContainer(
|
|
|
|
duration: const Duration(milliseconds: 200),
|
|
|
|
curve: Curves.easeInOut,
|
2022-09-26 16:08:56 +02:00
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
horizontal: 15,
|
|
|
|
vertical: 5
|
|
|
|
),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: groupSelected == value
|
2023-01-25 20:51:23 +01:00
|
|
|
? Theme.of(context).colorScheme.primary
|
|
|
|
: Theme.of(context).colorScheme.primary.withOpacity(0.05),
|
2022-09-26 16:08:56 +02:00
|
|
|
border: Border.all(
|
2023-01-25 20:51:23 +01:00
|
|
|
color: Theme.of(context).colorScheme.primary
|
2022-09-26 16:08:56 +02:00
|
|
|
),
|
|
|
|
borderRadius: BorderRadius.circular(30)
|
|
|
|
),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
label,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 14,
|
2022-10-02 19:39:41 +02:00
|
|
|
fontWeight: FontWeight.w500,
|
2022-09-26 16:08:56 +02:00
|
|
|
color: groupSelected == value
|
|
|
|
? Colors.white
|
2023-01-25 20:51:23 +01:00
|
|
|
: Theme.of(context).colorScheme.primary
|
2022-09-26 16:08:56 +02:00
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|