Files
tm_app/lib/views/detail/widgets/tender_detail_header.dart
T
amirrezaghabeli 36f66bfca5 merge branches
2025-08-18 08:28:18 +03:30

87 lines
2.6 KiB
Dart

import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:tm_app/core/theme/colors.dart';
import 'package:tm_app/core/utils/size_config.dart';
import 'package:tm_app/data/services/model/tender_data/tender_data.dart';
import 'package:tm_app/views/detail/widgets/status_tag.dart';
import 'package:tm_app/views/detail/widgets/tender_detail_info_section.dart';
import 'package:tm_app/views/detail/widgets/tender_document_section.dart';
import 'package:tm_app/views/detail/widgets/tender_location_section.dart';
class TenderDetailHeader extends StatelessWidget {
final bool isScreenBig;
final TenderData detail;
const TenderDetailHeader({
required this.isScreenBig,
required this.detail,
super.key,
});
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: AppColors.backgroundColor,
borderRadius: BorderRadius.circular(5),
border: Border.all(width: 0.5, color: AppColors.grey50),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_buildDateAndStatus(),
SizedBox(height: 12.0.h()),
_buildTitle(),
SizedBox(height: 10.0.h()),
Divider(color: AppColors.grey20),
SizedBox(height: 5.0.h()),
TenderDetailInfoSection(isScreenBig: isScreenBig, detail: detail),
TenderLocationSection(detail: detail),
SizedBox(height: 16.0.h()),
TenderDocumentSection(detail: detail),
],
),
);
}
Widget _buildDateAndStatus() => Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
unixToDate(detail.publicationDate),
style: TextStyle(
color: AppColors.grey60,
fontWeight: FontWeight.w400,
fontSize: 12.0.sp(),
),
),
StatusTag(
text: detail.status ?? '',
textColor: AppColors.cyanTeal,
backgroundColor: AppColors.cyanAqua,
),
],
);
Widget _buildTitle() => Text(
detail.title ?? '',
style: TextStyle(
color: AppColors.grey80,
fontWeight: FontWeight.w600,
fontSize: 18.0.sp(),
),
);
}
String unixToDate(int? unixTimestamp, {String format = 'yyyy-MM-dd'}) {
if (unixTimestamp == null) return '';
// Convert seconds to milliseconds if needed
int timestampInMs =
unixTimestamp > 1000000000000 ? unixTimestamp : unixTimestamp * 1000;
final DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(timestampInMs);
return DateFormat(format).format(dateTime);
}