TF-2057 Add event hyper link detail widget
(cherry picked from commit 8974e0ab37c2fa0b9097cae638b983e8600db4b2)
This commit is contained in:
@@ -0,0 +1,33 @@
|
|||||||
|
import 'package:core/presentation/extensions/color_extension.dart';
|
||||||
|
import 'package:flutter/gestures.dart';
|
||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
import 'package:url_launcher/url_launcher_string.dart';
|
||||||
|
|
||||||
|
class HyperLinkWidget extends StatelessWidget {
|
||||||
|
|
||||||
|
final String urlString;
|
||||||
|
|
||||||
|
const HyperLinkWidget({Key? key, required this.urlString}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return RichText(
|
||||||
|
text: TextSpan(
|
||||||
|
text: urlString,
|
||||||
|
style: const TextStyle(
|
||||||
|
color: AppColor.primaryColor,
|
||||||
|
fontSize: 16,
|
||||||
|
decoration: TextDecoration.underline
|
||||||
|
),
|
||||||
|
recognizer: TapGestureRecognizer()..onTap = () async {
|
||||||
|
if (await canLaunchUrlString(urlString)) {
|
||||||
|
launchUrlString(
|
||||||
|
urlString,
|
||||||
|
mode: LaunchMode.externalApplication
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -269,4 +269,20 @@ extension CalendarEventExtension on CalendarEvent {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<String> get videoConferences {
|
||||||
|
if (extensionFields != null && extensionFields!.mapFields.isNotEmpty) {
|
||||||
|
final videoConferences = extensionFields!.mapFields['X-OPENPAAS-VIDEOCONFERENCE'];
|
||||||
|
if (videoConferences != null) {
|
||||||
|
final videoConferencesNotEmpty = videoConferences
|
||||||
|
.whereNotNull()
|
||||||
|
.where((link) => link.isNotEmpty)
|
||||||
|
.toList();
|
||||||
|
log('CalendarEventExtension::getListVideoConference: $videoConferencesNotEmpty');
|
||||||
|
return videoConferencesNotEmpty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+6
@@ -6,6 +6,7 @@ import 'package:tmail_ui_user/features/email/presentation/extensions/calendar_ev
|
|||||||
import 'package:tmail_ui_user/features/email/presentation/styles/calendar_event_detail_widget_styles.dart';
|
import 'package:tmail_ui_user/features/email/presentation/styles/calendar_event_detail_widget_styles.dart';
|
||||||
import 'package:tmail_ui_user/features/email/presentation/widgets/calendar_event/event_attendee_detail_widget.dart';
|
import 'package:tmail_ui_user/features/email/presentation/widgets/calendar_event/event_attendee_detail_widget.dart';
|
||||||
import 'package:tmail_ui_user/features/email/presentation/widgets/calendar_event/event_description_detail_widget.dart';
|
import 'package:tmail_ui_user/features/email/presentation/widgets/calendar_event/event_description_detail_widget.dart';
|
||||||
|
import 'package:tmail_ui_user/features/email/presentation/widgets/calendar_event/event_link_detail_widget.dart';
|
||||||
import 'package:tmail_ui_user/features/email/presentation/widgets/calendar_event/event_location_detail_widget.dart';
|
import 'package:tmail_ui_user/features/email/presentation/widgets/calendar_event/event_location_detail_widget.dart';
|
||||||
import 'package:tmail_ui_user/features/email/presentation/widgets/calendar_event/event_time_detail_widget.dart';
|
import 'package:tmail_ui_user/features/email/presentation/widgets/calendar_event/event_time_detail_widget.dart';
|
||||||
import 'package:tmail_ui_user/features/email/presentation/widgets/calendar_event/event_title_widget.dart';
|
import 'package:tmail_ui_user/features/email/presentation/widgets/calendar_event/event_title_widget.dart';
|
||||||
@@ -53,6 +54,11 @@ class CalendarEventDetailWidget extends StatelessWidget {
|
|||||||
padding: const EdgeInsets.only(top: CalendarEventDetailWidgetStyles.fieldTopPadding),
|
padding: const EdgeInsets.only(top: CalendarEventDetailWidgetStyles.fieldTopPadding),
|
||||||
child: EventTimeWidgetWidget(timeEvent: calendarEvent.dateTimeEventAsString),
|
child: EventTimeWidgetWidget(timeEvent: calendarEvent.dateTimeEventAsString),
|
||||||
),
|
),
|
||||||
|
if (calendarEvent.videoConferences.isNotEmpty)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(top: CalendarEventDetailWidgetStyles.fieldTopPadding),
|
||||||
|
child: EventLinkDetailWidget(listHyperLink: calendarEvent.videoConferences),
|
||||||
|
),
|
||||||
if (calendarEvent.location?.isNotEmpty == true)
|
if (calendarEvent.location?.isNotEmpty == true)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(top: CalendarEventDetailWidgetStyles.fieldTopPadding),
|
padding: const EdgeInsets.only(top: CalendarEventDetailWidgetStyles.fieldTopPadding),
|
||||||
|
|||||||
+7
-7
@@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
import 'package:core/presentation/extensions/color_extension.dart';
|
import 'package:core/presentation/extensions/color_extension.dart';
|
||||||
|
import 'package:core/utils/app_logger.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:jmap_dart_client/jmap/mail/calendar/properties/attendee/calendar_attendee.dart';
|
import 'package:jmap_dart_client/jmap/mail/calendar/properties/attendee/calendar_attendee.dart';
|
||||||
import 'package:jmap_dart_client/jmap/mail/calendar/properties/calendar_organizer.dart';
|
import 'package:jmap_dart_client/jmap/mail/calendar/properties/calendar_organizer.dart';
|
||||||
@@ -12,7 +13,7 @@ import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
|||||||
|
|
||||||
class EventAttendeeDetailWidget extends StatefulWidget {
|
class EventAttendeeDetailWidget extends StatefulWidget {
|
||||||
|
|
||||||
static const int _maxAttendeeDisplayed = 6;
|
static const int maxAttendeeDisplayed = 6;
|
||||||
|
|
||||||
final List<CalendarAttendee> attendees;
|
final List<CalendarAttendee> attendees;
|
||||||
final CalendarOrganizer organizer;
|
final CalendarOrganizer organizer;
|
||||||
@@ -30,15 +31,14 @@ class EventAttendeeDetailWidget extends StatefulWidget {
|
|||||||
class _EventAttendeeDetailWidgetState extends State<EventAttendeeDetailWidget> {
|
class _EventAttendeeDetailWidgetState extends State<EventAttendeeDetailWidget> {
|
||||||
|
|
||||||
late List<CalendarAttendee> _attendeesDisplayed;
|
late List<CalendarAttendee> _attendeesDisplayed;
|
||||||
bool _isShowAllAttendee = false;
|
late bool _isShowAllAttendee;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_attendeesDisplayed = _splitAttendees(widget.attendees);
|
_attendeesDisplayed = _splitAttendees(widget.attendees);
|
||||||
if (_attendeesDisplayed.length == widget.attendees.length - 1) {
|
_isShowAllAttendee = widget.attendees.length <= EventAttendeeDetailWidget.maxAttendeeDisplayed;
|
||||||
_isShowAllAttendee = true;
|
log('_EventAttendeeDetailWidgetState::initState:attendees: ${widget.attendees.length} | _isShowAllAttendee: $_isShowAllAttendee');
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -84,8 +84,8 @@ class _EventAttendeeDetailWidgetState extends State<EventAttendeeDetailWidget> {
|
|||||||
|
|
||||||
List<CalendarAttendee> _splitAttendees(List<CalendarAttendee> attendees) {
|
List<CalendarAttendee> _splitAttendees(List<CalendarAttendee> attendees) {
|
||||||
final attendeesWithoutOrganizer = attendees.withoutOrganizer(widget.organizer);
|
final attendeesWithoutOrganizer = attendees.withoutOrganizer(widget.organizer);
|
||||||
return attendeesWithoutOrganizer.length > EventAttendeeDetailWidget._maxAttendeeDisplayed
|
return attendeesWithoutOrganizer.length > EventAttendeeDetailWidget.maxAttendeeDisplayed
|
||||||
? attendeesWithoutOrganizer.sublist(0, EventAttendeeDetailWidget._maxAttendeeDisplayed - 1)
|
? attendeesWithoutOrganizer.sublist(0, EventAttendeeDetailWidget.maxAttendeeDisplayed - 1)
|
||||||
: attendeesWithoutOrganizer;
|
: attendeesWithoutOrganizer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
|
||||||
|
import 'package:core/presentation/extensions/color_extension.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:tmail_ui_user/features/base/widget/hyper_link_widget.dart';
|
||||||
|
import 'package:tmail_ui_user/features/email/presentation/styles/event_location_detail_widget_styles.dart';
|
||||||
|
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||||
|
|
||||||
|
class EventLinkDetailWidget extends StatelessWidget {
|
||||||
|
|
||||||
|
final List<String> listHyperLink;
|
||||||
|
|
||||||
|
const EventLinkDetailWidget({
|
||||||
|
super.key,
|
||||||
|
required this.listHyperLink
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
width: EventLocationDetailWidgetStyles.maxWidth,
|
||||||
|
child: Text(
|
||||||
|
AppLocalizations.of(context).link,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: EventLocationDetailWidgetStyles.textSize,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
color: AppColor.colorSubTitleEventActionText
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: listHyperLink.map((link) => HyperLinkWidget(urlString: link)).toList(),
|
||||||
|
))
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"@@last_modified": "2023-07-28T02:01:26.243299",
|
"@@last_modified": "2023-07-28T02:46:38.430701",
|
||||||
"initializing_data": "Initializing data...",
|
"initializing_data": "Initializing data...",
|
||||||
"@initializing_data": {
|
"@initializing_data": {
|
||||||
"type": "text",
|
"type": "text",
|
||||||
@@ -3101,5 +3101,11 @@
|
|||||||
"type": "text",
|
"type": "text",
|
||||||
"placeholders_order": [],
|
"placeholders_order": [],
|
||||||
"placeholders": {}
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"link": "Link",
|
||||||
|
"@link": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders_order": [],
|
||||||
|
"placeholders": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3198,4 +3198,10 @@ class AppLocalizations {
|
|||||||
'See all attendees',
|
'See all attendees',
|
||||||
name: 'seeAllAttendees');
|
name: 'seeAllAttendees');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String get link {
|
||||||
|
return Intl.message(
|
||||||
|
'Link',
|
||||||
|
name: 'link');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user