37 lines
1.2 KiB
Dart
37 lines
1.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class PeriodSelector extends StatelessWidget {
|
|
final List<String> periods;
|
|
final int currentIndex;
|
|
final Function(int) onSelect;
|
|
|
|
PeriodSelector({required this.currentIndex, required this.onSelect, required this.periods});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
children: List.generate(periods.length, (index) {
|
|
bool isSelected = currentIndex == index;
|
|
return GestureDetector(
|
|
onTap: () => onSelect(index),
|
|
child: AnimatedContainer(
|
|
duration: const Duration(milliseconds: 200),
|
|
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
|
decoration: BoxDecoration(
|
|
color: isSelected ? const Color(0xFF80FFD1) : const Color(0xFF1E2652),
|
|
borderRadius: BorderRadius.circular(20),
|
|
),
|
|
child: Text(
|
|
periods[index],
|
|
style: TextStyle(
|
|
color: isSelected ? Colors.black : Colors.white.withOpacity(0.5),
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}),
|
|
);
|
|
}
|
|
} |