2022-10-10 14:57:42 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
class OptionBox extends StatelessWidget {
|
|
|
|
final dynamic optionsValue;
|
|
|
|
final dynamic itemValue;
|
|
|
|
final void Function(dynamic) onTap;
|
2023-10-08 00:26:48 +02:00
|
|
|
final String label;
|
2022-10-10 14:57:42 +02:00
|
|
|
|
|
|
|
const OptionBox({
|
2024-09-11 18:13:26 +02:00
|
|
|
super.key,
|
2022-10-10 14:57:42 +02:00
|
|
|
required this.optionsValue,
|
|
|
|
required this.itemValue,
|
|
|
|
required this.onTap,
|
2023-10-08 00:26:48 +02:00
|
|
|
required this.label,
|
2024-09-11 18:13:26 +02:00
|
|
|
});
|
2022-10-10 14:57:42 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Material(
|
|
|
|
color: Colors.transparent,
|
|
|
|
borderRadius: BorderRadius.circular(50),
|
|
|
|
child: InkWell(
|
|
|
|
borderRadius: BorderRadius.circular(50),
|
|
|
|
onTap: () => onTap(itemValue),
|
|
|
|
child: AnimatedContainer(
|
|
|
|
duration: const Duration(milliseconds: 250),
|
|
|
|
curve: Curves.easeInOut,
|
2023-10-08 00:26:48 +02:00
|
|
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
2022-10-10 14:57:42 +02:00
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.circular(50),
|
|
|
|
color: optionsValue == itemValue
|
2023-01-25 20:51:23 +01:00
|
|
|
? Theme.of(context).colorScheme.primary
|
2023-10-08 00:26:48 +02:00
|
|
|
: Theme.of(context).colorScheme.primaryContainer,
|
|
|
|
),
|
|
|
|
child: AnimatedDefaultTextStyle(
|
|
|
|
duration: const Duration(milliseconds: 250),
|
|
|
|
style: TextStyle(
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
fontSize: 14,
|
|
|
|
color: optionsValue == itemValue
|
|
|
|
? Theme.of(context).colorScheme.onInverseSurface
|
|
|
|
: Theme.of(context).colorScheme.onSurface
|
|
|
|
),
|
|
|
|
child: Text(
|
|
|
|
label,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
),
|
2022-10-10 14:57:42 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|