TF-934 Add link for item list emails
This commit is contained in:
@@ -19,11 +19,15 @@ extension ServicePathExtension on ServicePath {
|
||||
.map((query) => '${query.queryName}=${query.queryValue}').join('&')}');
|
||||
}
|
||||
|
||||
ServicePath withPathParameter([String? pathParameter]) {
|
||||
ServicePath withPathParameter(String? pathParameter) {
|
||||
if (pathParameter == null || pathParameter.isEmpty) {
|
||||
return this;
|
||||
}
|
||||
|
||||
return ServicePath('$path/$pathParameter');
|
||||
if (path.lastIndexOf('/') == path.length - 1) {
|
||||
return ServicePath('$path$pathParameter');
|
||||
} else {
|
||||
return ServicePath('$path/$pathParameter');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,10 @@ import 'package:model/mailbox/select_mode.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/model/search_query.dart';
|
||||
import 'package:tmail_ui_user/features/thread/presentation/mixin/base_email_item_tile.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
import 'package:tmail_ui_user/main/routes/app_routes.dart';
|
||||
import 'package:tmail_ui_user/main/routes/browser_route_utils.dart';
|
||||
import 'package:tmail_ui_user/main/routes/navigation_router.dart';
|
||||
import 'package:url_launcher/link.dart';
|
||||
|
||||
class EmailTileBuilder with BaseEmailItemTile {
|
||||
|
||||
@@ -86,7 +90,19 @@ class EmailTileBuilder with BaseEmailItemTile {
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
color: AppColor.colorItemEmailSelectedDesktop)
|
||||
: null,
|
||||
child: tile,
|
||||
child: Link(
|
||||
uri: BrowserRouteUtils.generateRoutePathBrowser(
|
||||
AppRoutes.dashboard,
|
||||
NavigationRouter(
|
||||
emailId: _presentationEmail.id,
|
||||
mailboxId: mailboxCurrent?.id,
|
||||
dashboardType: isSearchEmailRunning
|
||||
? DashboardType.search
|
||||
: DashboardType.normal
|
||||
)
|
||||
),
|
||||
builder: (_, __) => tile
|
||||
)
|
||||
);
|
||||
} else {
|
||||
return Container(
|
||||
@@ -101,7 +117,19 @@ class EmailTileBuilder with BaseEmailItemTile {
|
||||
borderRadius: BorderRadius.circular(0),
|
||||
color: Colors.white),
|
||||
alignment: Alignment.center,
|
||||
child: tile);
|
||||
child: Link(
|
||||
uri: BrowserRouteUtils.generateRoutePathBrowser(
|
||||
AppRoutes.dashboard,
|
||||
NavigationRouter(
|
||||
emailId: _presentationEmail.id,
|
||||
mailboxId: mailboxCurrent?.id,
|
||||
dashboardType: isSearchEmailRunning
|
||||
? DashboardType.search
|
||||
: DashboardType.normal
|
||||
)
|
||||
),
|
||||
builder: (_, __) => tile
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,12 @@ class AppPages {
|
||||
mailbox_dashboard.loadLibrary,
|
||||
() => mailbox_dashboard.MailboxDashBoardView()),
|
||||
binding: MailboxDashBoardBindings()),
|
||||
GetPage(
|
||||
name: AppRoutes.dashboardWithParameter,
|
||||
page: () => DeferredWidget(
|
||||
mailbox_dashboard.loadLibrary,
|
||||
() => mailbox_dashboard.MailboxDashBoardView()),
|
||||
binding: MailboxDashBoardBindings()),
|
||||
GetPage(
|
||||
name: AppRoutes.settings,
|
||||
page: () => DeferredWidget(
|
||||
|
||||
@@ -2,7 +2,8 @@ abstract class AppRoutes {
|
||||
static const home = '/';
|
||||
static const login = '/login';
|
||||
static const session = '/session';
|
||||
static const dashboard = '/dashboard';
|
||||
static const dashboard = '/dashboard/';
|
||||
static const dashboardWithParameter = '/dashboard/:id';
|
||||
static const settings = '/settings';
|
||||
static const composer = '/composer';
|
||||
static const destinationPicker = '/destination_picker';
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
|
||||
import 'package:core/data/model/query/query_parameter.dart';
|
||||
import 'package:core/data/network/config/service_path.dart';
|
||||
import 'package:core/utils/app_logger.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/id.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/extensions/service_path_extension.dart';
|
||||
import 'package:tmail_ui_user/main/routes/navigation_router.dart';
|
||||
|
||||
class BrowserRouteUtils {
|
||||
|
||||
static String get baseOriginUrl => Uri.base.origin;
|
||||
|
||||
static Uri generateRoutePathBrowser(String route, NavigationRouter router) {
|
||||
final baseRoutePath = '$baseOriginUrl/#$route';
|
||||
ServicePath servicePath = ServicePath(baseRoutePath);
|
||||
if (router.emailId != null) {
|
||||
servicePath = servicePath.withPathParameter(router.emailId!.id.value);
|
||||
}
|
||||
servicePath = servicePath.withQueryParameters([
|
||||
StringQueryParameter('type', router.dashboardType.name),
|
||||
if (router.mailboxId != null)
|
||||
StringQueryParameter('context', router.mailboxId!.id.value),
|
||||
]);
|
||||
|
||||
log('BrowserRouteUtils::generateRoutePathForBrowser(): routePath: ${servicePath.path}');
|
||||
return Uri.parse(servicePath.path);
|
||||
}
|
||||
|
||||
static NavigationRouter parsingRouteParametersToNavigationRouter(Map<String, String?> parameters) {
|
||||
final idParam = parameters['id'];
|
||||
final typeParam = parameters['type'];
|
||||
final contextPram = parameters['context'];
|
||||
|
||||
log('BrowserRouteUtils::parsingRouteParametersToNavigationRouter(): idParam: $idParam');
|
||||
log('BrowserRouteUtils::parsingRouteParametersToNavigationRouter(): typeParam: $typeParam');
|
||||
log('BrowserRouteUtils::parsingRouteParametersToNavigationRouter(): contextPram: $contextPram');
|
||||
|
||||
final emailId = idParam != null ? EmailId(Id(idParam)) : null;
|
||||
final mailboxId = contextPram != null ? MailboxId(Id(contextPram)) : null;
|
||||
final dashboardType = typeParam == DashboardType.search.name
|
||||
? DashboardType.search
|
||||
: DashboardType.normal;
|
||||
|
||||
return NavigationRouter(
|
||||
emailId: emailId,
|
||||
mailboxId: mailboxId,
|
||||
dashboardType: dashboardType,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
|
||||
enum DashboardType {
|
||||
normal,
|
||||
search;
|
||||
}
|
||||
|
||||
class NavigationRouter with EquatableMixin {
|
||||
final EmailId? emailId;
|
||||
final MailboxId? mailboxId;
|
||||
final DashboardType dashboardType;
|
||||
|
||||
NavigationRouter({
|
||||
this.emailId,
|
||||
this.mailboxId,
|
||||
this.dashboardType = DashboardType.normal
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [emailId, mailboxId, dashboardType];
|
||||
}
|
||||
+1
-1
@@ -1352,7 +1352,7 @@ packages:
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
url_launcher:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: url_launcher
|
||||
url: "https://pub.dartlang.org"
|
||||
|
||||
@@ -192,6 +192,8 @@ dependencies:
|
||||
url: https://github.com/linagora/flutter-date-range-picker.git
|
||||
ref: master
|
||||
|
||||
url_launcher: 6.1.5
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
Reference in New Issue
Block a user