detail refactor
This commit is contained in:
@@ -1,21 +1,18 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:tm_app/core/theme/colors.dart';
|
||||
import 'package:tm_app/core/utils/date_utils.dart';
|
||||
import 'package:tm_app/core/utils/size_config.dart';
|
||||
|
||||
import '../../../core/constants/strings.dart';
|
||||
import '../../../data/services/model/tender_data/tender_data.dart';
|
||||
|
||||
class DeadlineItem extends StatelessWidget {
|
||||
final String title;
|
||||
final String approvalText;
|
||||
final String approvalDate;
|
||||
final String submissionText;
|
||||
final String submissionDate;
|
||||
final TenderData detail;
|
||||
final bool isScreenBig;
|
||||
|
||||
const DeadlineItem({
|
||||
required this.title,
|
||||
required this.approvalText,
|
||||
required this.approvalDate,
|
||||
required this.submissionText,
|
||||
required this.submissionDate,
|
||||
required this.detail,
|
||||
|
||||
required this.isScreenBig,
|
||||
super.key,
|
||||
});
|
||||
@@ -31,7 +28,7 @@ class DeadlineItem extends StatelessWidget {
|
||||
SizedBox(
|
||||
height: 45.0.h(),
|
||||
child: Text(
|
||||
title,
|
||||
detail.title ?? '',
|
||||
style: TextStyle(
|
||||
color: AppColors.grey80,
|
||||
fontWeight: FontWeight.w600,
|
||||
@@ -47,7 +44,7 @@ class DeadlineItem extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
approvalText,
|
||||
AppStrings.tenderApprovalText,
|
||||
style: TextStyle(
|
||||
color: AppColors.grey70,
|
||||
fontWeight: FontWeight.w400,
|
||||
@@ -56,7 +53,7 @@ class DeadlineItem extends StatelessWidget {
|
||||
),
|
||||
SizedBox(height: 4.0.h()),
|
||||
Text(
|
||||
approvalDate,
|
||||
unixToDate(detail.submissionDeadline),
|
||||
style: TextStyle(
|
||||
color: AppColors.grey80,
|
||||
fontWeight: FontWeight.w400,
|
||||
@@ -76,7 +73,7 @@ class DeadlineItem extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
submissionText,
|
||||
AppStrings.tenderSubmissionText,
|
||||
style: TextStyle(
|
||||
color: AppColors.grey70,
|
||||
fontWeight: FontWeight.w400,
|
||||
@@ -85,7 +82,7 @@ class DeadlineItem extends StatelessWidget {
|
||||
),
|
||||
SizedBox(height: 4.0.h()),
|
||||
Text(
|
||||
submissionDate,
|
||||
unixToDate(detail.applicationDeadline),
|
||||
style: TextStyle(
|
||||
color: AppColors.grey80,
|
||||
fontWeight: FontWeight.w400,
|
||||
@@ -99,7 +96,7 @@ class DeadlineItem extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
SizedBox(height: 8.0.h()),
|
||||
Divider(color: AppColors.grey20,),
|
||||
Divider(color: AppColors.grey20),
|
||||
],
|
||||
),
|
||||
)
|
||||
@@ -111,7 +108,7 @@ class DeadlineItem extends StatelessWidget {
|
||||
SizedBox(
|
||||
height: 45.0.h(),
|
||||
child: Text(
|
||||
title,
|
||||
detail.title ?? '',
|
||||
style: TextStyle(
|
||||
color: AppColors.grey80,
|
||||
fontWeight: FontWeight.w600,
|
||||
@@ -123,7 +120,7 @@ class DeadlineItem extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
approvalText,
|
||||
AppStrings.tenderApprovalText,
|
||||
style: TextStyle(
|
||||
color: AppColors.grey70,
|
||||
fontWeight: FontWeight.w400,
|
||||
@@ -131,7 +128,7 @@ class DeadlineItem extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
Text(
|
||||
approvalDate,
|
||||
unixToDate(detail.submissionDeadline),
|
||||
style: TextStyle(
|
||||
color: AppColors.grey70,
|
||||
fontWeight: FontWeight.w400,
|
||||
@@ -145,7 +142,7 @@ class DeadlineItem extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
submissionText,
|
||||
AppStrings.tenderSubmissionText,
|
||||
style: TextStyle(
|
||||
color: AppColors.grey70,
|
||||
fontWeight: FontWeight.w400,
|
||||
@@ -153,7 +150,7 @@ class DeadlineItem extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
Text(
|
||||
submissionDate,
|
||||
unixToDate(detail.applicationDeadline),
|
||||
style: TextStyle(
|
||||
color: AppColors.grey70,
|
||||
fontWeight: FontWeight.w400,
|
||||
@@ -163,7 +160,7 @@ class DeadlineItem extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
SizedBox(height: 8.0.h()),
|
||||
Divider(color: AppColors.grey20,),
|
||||
Divider(color: AppColors.grey20),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:tm_app/core/theme/colors.dart';
|
||||
import 'package:tm_app/core/utils/date_utils.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';
|
||||
@@ -73,16 +73,3 @@ class TenderDetailHeader extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:tm_app/core/constants/strings.dart';
|
||||
import 'package:tm_app/data/services/model/tender_data/tender_data.dart';
|
||||
import 'package:tm_app/views/detail/widgets/deadline_item.dart';
|
||||
@@ -21,14 +20,7 @@ class TenderDetailInfoSection extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
InfoItem(title: AppStrings.tenderIdLabel, value: detail.tenderId ?? ''),
|
||||
DeadlineItem(
|
||||
title: AppStrings.tenderDeadlineLabel,
|
||||
approvalText: AppStrings.tenderApprovalText,
|
||||
approvalDate: unixToDate(detail.submissionDeadline),
|
||||
submissionText: AppStrings.tenderSubmissionText,
|
||||
submissionDate: unixToDate(detail.applicationDeadline),
|
||||
isScreenBig: isScreenBig,
|
||||
),
|
||||
DeadlineItem(detail: detail, isScreenBig: isScreenBig),
|
||||
InfoItem(
|
||||
title: AppStrings.tenderClientLabel,
|
||||
value: detail.buyerOrganization!.name ?? '',
|
||||
@@ -49,16 +41,3 @@ class TenderDetailInfoSection extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user