65 lines
1.8 KiB
Dart
65 lines
1.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:tm_app/core/theme/colors.dart';
|
|
import 'package:tm_app/core/utils/size_config.dart';
|
|
|
|
import '../strings/tenders_strings.dart';
|
|
|
|
/// Segmented control for the tenders list.
|
|
class TendersTabBar extends StatelessWidget {
|
|
const TendersTabBar({
|
|
required this.selectedIndex,
|
|
required this.onChanged,
|
|
super.key,
|
|
});
|
|
|
|
/// 1 = Recommended. The former All tab is intentionally hidden.
|
|
final int selectedIndex;
|
|
final ValueChanged<int> onChanged;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
height: 44.0.h(),
|
|
padding: EdgeInsets.all(4.0.h()),
|
|
decoration: BoxDecoration(
|
|
color: AppColors.grey0,
|
|
borderRadius: BorderRadius.circular(12.0.w()),
|
|
border: Border.all(color: AppColors.grey30),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
// All tenders is hidden for now.
|
|
// _segment(TendersStrings.allTab, 0),
|
|
_segment(TendersStrings.recommendedTab, 1),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _segment(String label, int index) {
|
|
final bool isActive = selectedIndex == index;
|
|
return Expanded(
|
|
child: GestureDetector(
|
|
behavior: HitTestBehavior.opaque,
|
|
onTap: () => onChanged(index),
|
|
child: AnimatedContainer(
|
|
duration: const Duration(milliseconds: 200),
|
|
alignment: Alignment.center,
|
|
decoration: BoxDecoration(
|
|
color: isActive ? AppColors.mainBlue : Colors.transparent,
|
|
borderRadius: BorderRadius.circular(8.0.w()),
|
|
),
|
|
child: Text(
|
|
label,
|
|
style: TextStyle(
|
|
fontSize: 14.0.sp(),
|
|
fontWeight: FontWeight.w600,
|
|
color: isActive ? AppColors.grey0 : AppColors.grey60,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|