mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-03-11 09:14:10 +00:00
Add animations to segmented_buttons.dart
This commit is contained in:
parent
6e9bde827a
commit
3079b4bcc5
1 changed files with 26 additions and 11 deletions
|
@ -30,19 +30,34 @@ class SegmentedButtons extends StatelessWidget {
|
||||||
children: titles.asMap().entries.map((final entry) {
|
children: titles.asMap().entries.map((final entry) {
|
||||||
final index = entry.key;
|
final index = entry.key;
|
||||||
final title = entry.value;
|
final title = entry.value;
|
||||||
return Row(
|
return Stack(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
alignment: Alignment.centerLeft,
|
||||||
children: [
|
children: [
|
||||||
if (isSelected[index])
|
AnimatedOpacity(
|
||||||
Icon(
|
duration: const Duration(milliseconds: 200),
|
||||||
Icons.check,
|
opacity: isSelected[index] ? 1 : 0,
|
||||||
size: 18,
|
child: AnimatedScale(
|
||||||
color: Theme.of(context).colorScheme.onSecondaryContainer,
|
duration: const Duration(milliseconds: 200),
|
||||||
|
curve: Curves.easeInOut,
|
||||||
|
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.easeInOut,
|
||||||
|
child: Text(
|
||||||
|
title,
|
||||||
|
style: Theme.of(context).textTheme.labelLarge,
|
||||||
),
|
),
|
||||||
if (isSelected[index]) const SizedBox(width: 8),
|
|
||||||
Text(
|
|
||||||
title,
|
|
||||||
style: Theme.of(context).textTheme.labelLarge,
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue