一次大的提交
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import '../../../../../core/consts/workorder_consts.dart';
|
||||
import '../../domain/entities/workorder_entity.dart';
|
||||
|
||||
/// 工单标签栏组件
|
||||
/// 展示待处理/执行中/已完成/全部四个静态标签
|
||||
class WorkOrderTabBar extends StatelessWidget {
|
||||
final WorkOrderStatus currentStatus;
|
||||
final Function(WorkOrderStatus) onTabChanged;
|
||||
@@ -15,25 +17,40 @@ class WorkOrderTabBar extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final tabs = [
|
||||
return Container(
|
||||
height: 44,
|
||||
child: ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: 4,
|
||||
itemBuilder: (context, index) {
|
||||
final tabs = _getStaticTabs(context);
|
||||
final tab = tabs[index];
|
||||
return _buildTabItem(
|
||||
context,
|
||||
label: tab['label'] as String,
|
||||
isSelected: currentStatus == tab['status'],
|
||||
showBadge: tab['badge'] as bool,
|
||||
onTap: () => onTabChanged(tab['status'] as WorkOrderStatus),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<Map<String, dynamic>> _getStaticTabs(BuildContext context) {
|
||||
return [
|
||||
{
|
||||
'label': AppLocalizations.of(
|
||||
context,
|
||||
).translate('work_order_v2.pending'),
|
||||
'label': AppLocalizations.of(context).translate('work_order_v2.pending'),
|
||||
'status': WorkOrderStatus.pending,
|
||||
'badge': false,
|
||||
},
|
||||
{
|
||||
'label': AppLocalizations.of(
|
||||
context,
|
||||
).translate('work_order_v2.executing'),
|
||||
'label': AppLocalizations.of(context).translate('work_order_v2.executing'),
|
||||
'status': WorkOrderStatus.executing,
|
||||
'badge': true,
|
||||
},
|
||||
{
|
||||
'label': AppLocalizations.of(
|
||||
context,
|
||||
).translate('work_order_v2.completed'),
|
||||
'label': AppLocalizations.of(context).translate('work_order_v2.completed'),
|
||||
'status': WorkOrderStatus.completed,
|
||||
'badge': false,
|
||||
},
|
||||
@@ -43,69 +60,64 @@ class WorkOrderTabBar extends StatelessWidget {
|
||||
'badge': true,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
return Container(
|
||||
height: 44,
|
||||
child: ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: tabs.length,
|
||||
itemBuilder: (context, index) {
|
||||
final tab = tabs[index];
|
||||
final isSelected = currentStatus == tab['status'];
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () => onTabChanged(tab['status'] as WorkOrderStatus),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
Text(
|
||||
tab['label'] as String,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: isSelected
|
||||
? FontWeight.bold
|
||||
: FontWeight.normal,
|
||||
color: isSelected
|
||||
? AppConstants.primaryColor
|
||||
: AppConstants.secondaryTextColor,
|
||||
),
|
||||
),
|
||||
if (tab['badge'] as bool)
|
||||
Positioned(
|
||||
right: -8,
|
||||
top: -4,
|
||||
child: Container(
|
||||
width: 6,
|
||||
height: 6,
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.red,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
Widget _buildTabItem(
|
||||
BuildContext context, {
|
||||
required String label,
|
||||
required bool isSelected,
|
||||
required VoidCallback onTap,
|
||||
bool showBadge = false,
|
||||
}) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight:
|
||||
isSelected ? FontWeight.bold : FontWeight.normal,
|
||||
color: isSelected
|
||||
? AppConstants.primaryColor
|
||||
: AppConstants.secondaryTextColor,
|
||||
),
|
||||
if (isSelected)
|
||||
Container(
|
||||
margin: const EdgeInsets.only(top: 4),
|
||||
width: 24,
|
||||
height: 3,
|
||||
decoration: BoxDecoration(
|
||||
color: AppConstants.primaryColor,
|
||||
borderRadius: BorderRadius.circular(1.5),
|
||||
),
|
||||
if (showBadge)
|
||||
Positioned(
|
||||
right: -8,
|
||||
top: -4,
|
||||
child: Container(
|
||||
width: 6,
|
||||
height: 6,
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.red,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
if (isSelected)
|
||||
Container(
|
||||
margin: const EdgeInsets.only(top: 4),
|
||||
width: 24,
|
||||
height: 3,
|
||||
decoration: BoxDecoration(
|
||||
color: AppConstants.primaryColor,
|
||||
borderRadius: BorderRadius.circular(1.5),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user