TF-2042 Add event time information widget
(cherry picked from commit 5bfa21a8c426a794dfc5f1036c00c31f3069f77f)
This commit is contained in:
@@ -180,6 +180,8 @@ extension CalendarEventExtension on CalendarEvent {
|
||||
|
||||
DateTime? get localStartDate => startUtcDate?.value.toLocal();
|
||||
|
||||
DateTime? get localEndDate => endUtcDate?.value.toLocal();
|
||||
|
||||
String get monthStartDateAsString {
|
||||
if (localStartDate != null) {
|
||||
return date_format.formatDate(
|
||||
@@ -215,4 +217,56 @@ extension CalendarEventExtension on CalendarEvent {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
String formatDateTime(DateTime dateTime) {
|
||||
return date_format.formatDate(
|
||||
dateTime,
|
||||
[
|
||||
date_format.DD,
|
||||
', ',
|
||||
date_format.MM,
|
||||
' ',
|
||||
date_format.dd,
|
||||
', ',
|
||||
date_format.yyyy,
|
||||
' ',
|
||||
date_format.hh,
|
||||
':',
|
||||
date_format.ss,
|
||||
' ',
|
||||
date_format.am
|
||||
],
|
||||
locale: AppUtils.getCurrentDateLocale()
|
||||
);
|
||||
}
|
||||
|
||||
String formatTime(DateTime dateTime) {
|
||||
return date_format.formatDate(
|
||||
dateTime,
|
||||
[
|
||||
date_format.hh,
|
||||
':',
|
||||
date_format.ss,
|
||||
' ',
|
||||
date_format.am
|
||||
],
|
||||
locale: AppUtils.getCurrentDateLocale()
|
||||
);
|
||||
}
|
||||
|
||||
String get dateTimeEventAsString {
|
||||
if (localStartDate != null && localEndDate != null) {
|
||||
final timeStart = formatDateTime(localStartDate!);
|
||||
final timeEnd = DateUtils.isSameDay(localStartDate, localEndDate)
|
||||
? formatTime(localEndDate!)
|
||||
: formatDateTime(localEndDate!);
|
||||
return '$timeStart - $timeEnd';
|
||||
} else if (localStartDate != null) {
|
||||
return formatDateTime(localStartDate!);
|
||||
} else if (localEndDate != null) {
|
||||
return formatDateTime(localEndDate!);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
class EventTimeInformationWidgetStyles {
|
||||
static const double maxWidth = 100;
|
||||
static const double textSize = 16;
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
|
||||
import 'package:core/presentation/extensions/color_extension.dart';
|
||||
import 'package:core/presentation/utils/style_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/styles/event_time_information_widget_styles.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
|
||||
class EventTimeInformationWidget extends StatelessWidget {
|
||||
|
||||
final String timeEvent;
|
||||
|
||||
const EventTimeInformationWidget({
|
||||
super.key,
|
||||
required this.timeEvent
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: EventTimeInformationWidgetStyles.maxWidth,
|
||||
child: Text(
|
||||
AppLocalizations.of(context).when,
|
||||
style: const TextStyle(
|
||||
fontSize: EventTimeInformationWidgetStyles.textSize,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColor.colorSubTitleEventActionText
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(child: Text(
|
||||
timeEvent,
|
||||
overflow: CommonTextStyle.defaultTextOverFlow,
|
||||
softWrap: CommonTextStyle.defaultSoftWrap,
|
||||
style: const TextStyle(
|
||||
fontSize: EventTimeInformationWidgetStyles.textSize,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.black
|
||||
),
|
||||
))
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user