mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-09 17:39:42 +00:00
chore: segmented_buttons rewrite
This commit is contained in:
parent
8684a2a48a
commit
40f4f8822f
|
@ -46,41 +46,55 @@ class SegmentedButtons extends StatelessWidget {
|
||||||
color: Theme.of(context).colorScheme.onSurface,
|
color: Theme.of(context).colorScheme.onSurface,
|
||||||
isSelected: isSelected,
|
isSelected: isSelected,
|
||||||
onPressed: onPressed,
|
onPressed: onPressed,
|
||||||
children: titles.asMap().entries.map((final entry) {
|
children: [
|
||||||
final index = entry.key;
|
for (int i = 0; i < titles.length; i++)
|
||||||
final title = entry.value;
|
_ButtonSegment(
|
||||||
return Stack(
|
isSelected: isSelected[i],
|
||||||
alignment: Alignment.centerLeft,
|
title: titles[i],
|
||||||
children: [
|
),
|
||||||
AnimatedOpacity(
|
],
|
||||||
duration: const Duration(milliseconds: 200),
|
|
||||||
opacity: isSelected[index] ? 1 : 0,
|
|
||||||
child: AnimatedScale(
|
|
||||||
duration: const Duration(milliseconds: 200),
|
|
||||||
curve: Curves.easeInOutCubicEmphasized,
|
|
||||||
alignment: Alignment.centerLeft,
|
|
||||||
scale: isSelected[index] ? 1 : 0,
|
|
||||||
child: Icon(
|
|
||||||
Icons.check,
|
|
||||||
size: 18,
|
|
||||||
color: Theme.of(context).colorScheme.onSecondaryContainer,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
AnimatedPadding(
|
|
||||||
padding: isSelected[index]
|
|
||||||
? const EdgeInsets.only(left: 24)
|
|
||||||
: EdgeInsets.zero,
|
|
||||||
duration: const Duration(milliseconds: 200),
|
|
||||||
curve: Curves.easeInOutCubicEmphasized,
|
|
||||||
child: Text(
|
|
||||||
title,
|
|
||||||
style: Theme.of(context).textTheme.labelLarge,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}).toList(),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _ButtonSegment extends StatelessWidget {
|
||||||
|
const _ButtonSegment({
|
||||||
|
required this.isSelected,
|
||||||
|
required this.title,
|
||||||
|
});
|
||||||
|
|
||||||
|
final bool isSelected;
|
||||||
|
final String title;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(final BuildContext context) => Stack(
|
||||||
|
alignment: Alignment.centerLeft,
|
||||||
|
children: [
|
||||||
|
AnimatedOpacity(
|
||||||
|
duration: const Duration(milliseconds: 200),
|
||||||
|
opacity: isSelected ? 1 : 0,
|
||||||
|
child: AnimatedScale(
|
||||||
|
duration: const Duration(milliseconds: 200),
|
||||||
|
curve: Curves.easeInOutCubicEmphasized,
|
||||||
|
alignment: Alignment.centerLeft,
|
||||||
|
scale: isSelected ? 1 : 0,
|
||||||
|
child: Icon(
|
||||||
|
Icons.check,
|
||||||
|
size: 18,
|
||||||
|
color: Theme.of(context).colorScheme.onSecondaryContainer,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
AnimatedPadding(
|
||||||
|
padding:
|
||||||
|
isSelected ? const EdgeInsets.only(left: 24) : EdgeInsets.zero,
|
||||||
|
duration: const Duration(milliseconds: 200),
|
||||||
|
curve: Curves.easeInOutCubicEmphasized,
|
||||||
|
child: Text(
|
||||||
|
title,
|
||||||
|
style: Theme.of(context).textTheme.labelLarge,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue