detail refactor

This commit is contained in:
amirrezaghabeli
2025-08-27 13:59:47 +03:30
parent 8794627e7f
commit e7950cd3fc
9 changed files with 171 additions and 137 deletions
+9 -3
View File
@@ -74,7 +74,6 @@ class AppStrings {
static const String tenderDeliveryLocationsLabel = 'Delivery Locations';
static const String tenderReferenceNumberLabel = 'Reference Number';
static const String tenderLocationLabel = 'Locations';
static const String tenderLocationCountry = 'UK';
static const String tenderPdfDocument = 'PDF , Document';
static const String tenderMatchProfile = 'Match with your profile';
static const String tenderIncompleteResume = 'Incomplete Resume Information';
@@ -82,10 +81,17 @@ class AppStrings {
'No experience in e-platform development';
static const String tenderSubmitButton = 'Submit';
static const String tenderRejectButton = 'Reject';
static const String tenderClientExample =
'Procurement Notice Procurement Notice';
static const String estimatedValue = 'Estimated Value ';
static const String duration = 'Duration';
static const String tenderSubmittedSuccessfully =
'tender submitted successfully!';
static const String tenderRejectedSuccessfully =
'tender rejected successfully!';
static const String tenderUnrejectedSuccessfully =
'tender unrejected successfully!';
static const String tenderUnsubmittedSuccessfully =
'tender unsubmitted successfully!';
static const String tenderNoData = 'No tender details available';
}
+86 -25
View File
@@ -1,15 +1,15 @@
import 'package:intl/intl.dart';
class DateUtils {
/// Extension on int to provide date formatting utilities for Unix timestamps
extension UnixTimestampExtension on int? {
/// Converts Unix timestamp (seconds since epoch) to a formatted date string
static String unixToDate(int? unixTimestamp, {String format = 'yyyy-MM-dd'}) {
if (unixTimestamp == null) {
String toDate({String format = 'yyyy-MM-dd'}) {
if (this == null) {
return '';
}
// Convert seconds to milliseconds if needed
int timestampInMs =
unixTimestamp > 1000000000000 ? unixTimestamp : unixTimestamp * 1000;
int timestampInMs = this! > 1000000000000 ? this! : this! * 1000;
final DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(
timestampInMs,
@@ -18,13 +18,12 @@ class DateUtils {
}
/// Converts Unix timestamp to a readable date string
static String unixToReadableDate(int? unixTimestamp) {
if (unixTimestamp == null) {
String toReadableDate() {
if (this == null) {
return '';
}
int timestampInMs =
unixTimestamp > 1000000000000 ? unixTimestamp : unixTimestamp * 1000;
int timestampInMs = this! > 1000000000000 ? this! : this! * 1000;
final DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(
timestampInMs,
@@ -44,13 +43,12 @@ class DateUtils {
}
/// Converts Unix timestamp to a short date format
static String unixToShortDate(int? unixTimestamp) {
if (unixTimestamp == null) {
String toShortDate() {
if (this == null) {
return '';
}
int timestampInMs =
unixTimestamp > 1000000000000 ? unixTimestamp : unixTimestamp * 1000;
int timestampInMs = this! > 1000000000000 ? this! : this! * 1000;
final DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(
timestampInMs,
@@ -59,13 +57,12 @@ class DateUtils {
}
/// Converts Unix timestamp to a full date and time format
static String unixToDateTime(int? unixTimestamp) {
if (unixTimestamp == null) {
String toDateTime() {
if (this == null) {
return '';
}
int timestampInMs =
unixTimestamp > 1000000000000 ? unixTimestamp : unixTimestamp * 1000;
int timestampInMs = this! > 1000000000000 ? this! : this! * 1000;
final DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(
timestampInMs,
@@ -74,13 +71,12 @@ class DateUtils {
}
/// Checks if a Unix timestamp is in the past
static bool isPast(int? unixTimestamp) {
if (unixTimestamp == null) {
bool get isPast {
if (this == null) {
return false;
}
int timestampInMs =
unixTimestamp > 1000000000000 ? unixTimestamp : unixTimestamp * 1000;
int timestampInMs = this! > 1000000000000 ? this! : this! * 1000;
final DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(
timestampInMs,
@@ -89,13 +85,12 @@ class DateUtils {
}
/// Gets the number of days remaining until a Unix timestamp
static int daysRemaining(int? unixTimestamp) {
if (unixTimestamp == null) {
int get daysRemaining {
if (this == null) {
return 0;
}
int timestampInMs =
unixTimestamp > 1000000000000 ? unixTimestamp : unixTimestamp * 1000;
int timestampInMs = this! > 1000000000000 ? this! : this! * 1000;
final DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(
timestampInMs,
@@ -106,3 +101,69 @@ class DateUtils {
return difference.inDays;
}
}
/// Extension on DateTime to provide additional formatting utilities
extension DateTimeExtension on DateTime {
/// Formats the DateTime to a readable string
String toReadableString() {
final DateTime now = DateTime.now();
final Duration difference = now.difference(this);
if (difference.inDays == 0) {
return 'Today';
} else if (difference.inDays == 1) {
return 'Yesterday';
} else if (difference.inDays < 7) {
return '${difference.inDays} days ago';
} else {
return DateFormat('MMM dd, yyyy').format(this);
}
}
/// Formats the DateTime to a short date string
String toShortDate() {
return DateFormat('MMM dd').format(this);
}
/// Formats the DateTime to a full date and time string
String toDateTimeString() {
return DateFormat('MMM dd, yyyy HH:mm').format(this);
}
/// Checks if the DateTime is in the past
bool get isPast {
return isBefore(DateTime.now());
}
/// Gets the number of days remaining until this DateTime
int get daysRemaining {
final DateTime now = DateTime.now();
final Duration difference = this.difference(now);
return difference.inDays;
}
}
/// Utility class for date operations
class DateUtils {
/// Converts Unix timestamp to a formatted date string
static String unixToDate(int? timestamp) {
if (timestamp == null) {
return '';
}
// Convert seconds to milliseconds if needed
int timestampInMs =
timestamp > 1000000000000 ? timestamp : timestamp * 1000;
final DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(
timestampInMs,
);
return DateFormat('MMM dd, yyyy').format(dateTime);
}
}
/// Global function for backward compatibility
String unixToDate(int? timestamp) {
return DateUtils.unixToDate(timestamp);
}