Updated optionbox styles

This commit is contained in:
Juan Gilsanz Polo 2023-10-08 00:26:48 +02:00
parent 95aec4b3a5
commit bb5cdc13d1
2 changed files with 26 additions and 88 deletions

View file

@ -94,19 +94,7 @@ class _UpdateIntervalListsModalState extends State<UpdateIntervalListsModal> {
optionsValue: selectedOption,
itemValue: 0,
onTap: _updateRadioValue,
child: Center(
child: AnimatedDefaultTextStyle(
duration: const Duration(milliseconds: 250),
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14,
color: selectedOption == 0
? Theme.of(context).colorScheme.onInverseSurface
: Theme.of(context).colorScheme.onSurface
),
child: Text(AppLocalizations.of(context)!.never),
),
),
label: AppLocalizations.of(context)!.never,
),
),
),
@ -118,19 +106,7 @@ class _UpdateIntervalListsModalState extends State<UpdateIntervalListsModal> {
optionsValue: selectedOption,
itemValue: 1,
onTap: _updateRadioValue,
child: Center(
child: AnimatedDefaultTextStyle(
duration: const Duration(milliseconds: 250),
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14,
color: selectedOption == 1
? Theme.of(context).colorScheme.onInverseSurface
: Theme.of(context).colorScheme.onSurface
),
child: Text(AppLocalizations.of(context)!.hour1),
),
),
label: AppLocalizations.of(context)!.hour1,
),
),
),
@ -142,19 +118,7 @@ class _UpdateIntervalListsModalState extends State<UpdateIntervalListsModal> {
optionsValue: selectedOption,
itemValue: 12,
onTap: _updateRadioValue,
child: Center(
child: AnimatedDefaultTextStyle(
duration: const Duration(milliseconds: 250),
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14,
color: selectedOption == 12
? Theme.of(context).colorScheme.onInverseSurface
: Theme.of(context).colorScheme.onSurface
),
child: Text(AppLocalizations.of(context)!.hours12),
),
),
label: AppLocalizations.of(context)!.hours12,
),
),
),
@ -166,19 +130,8 @@ class _UpdateIntervalListsModalState extends State<UpdateIntervalListsModal> {
optionsValue: selectedOption,
itemValue: 24,
onTap: _updateRadioValue,
child: Center(
child: AnimatedDefaultTextStyle(
duration: const Duration(milliseconds: 250),
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14,
color: selectedOption == 24
? Theme.of(context).colorScheme.onInverseSurface
: Theme.of(context).colorScheme.onSurface
),
child: Text(AppLocalizations.of(context)!.hours24),
),
),
label: AppLocalizations.of(context)!.hours24,
),
),
),
@ -190,19 +143,8 @@ class _UpdateIntervalListsModalState extends State<UpdateIntervalListsModal> {
optionsValue: selectedOption,
itemValue: 72,
onTap: _updateRadioValue,
child: Center(
child: AnimatedDefaultTextStyle(
duration: const Duration(milliseconds: 250),
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14,
color: selectedOption == 72
? Theme.of(context).colorScheme.onInverseSurface
: Theme.of(context).colorScheme.onSurface
),
child: Text(AppLocalizations.of(context)!.days3),
),
),
label: AppLocalizations.of(context)!.days3,
),
),
),
@ -214,19 +156,7 @@ class _UpdateIntervalListsModalState extends State<UpdateIntervalListsModal> {
optionsValue: selectedOption,
itemValue: 168,
onTap: _updateRadioValue,
child: Center(
child: AnimatedDefaultTextStyle(
duration: const Duration(milliseconds: 250),
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14,
color: selectedOption == 168
? Theme.of(context).colorScheme.onInverseSurface
: Theme.of(context).colorScheme.onSurface
),
child: Text(AppLocalizations.of(context)!.days7),
),
),
label: AppLocalizations.of(context)!.days7,
),
),
),

View file

@ -1,17 +1,17 @@
import 'package:flutter/material.dart';
class OptionBox extends StatelessWidget {
final Widget child;
final dynamic optionsValue;
final dynamic itemValue;
final void Function(dynamic) onTap;
final String label;
const OptionBox({
Key? key,
required this.child,
required this.optionsValue,
required this.itemValue,
required this.onTap,
required this.label,
}) : super(key: key);
@override
@ -25,19 +25,27 @@ class OptionBox extends StatelessWidget {
child: AnimatedContainer(
duration: const Duration(milliseconds: 250),
curve: Curves.easeInOut,
padding: const EdgeInsets.all(15),
padding: const EdgeInsets.symmetric(vertical: 16),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(50),
border: Border.all(
color: optionsValue == itemValue
? Theme.of(context).colorScheme.primary
: Theme.of(context).colorScheme.onSurfaceVariant
),
color: optionsValue == itemValue
? Theme.of(context).colorScheme.primary
: Colors.transparent,
: 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,
),
),
child: child,
),
),
);