Skip to content

Commit

Permalink
TF-3005 Apply new design app bar contact view
Browse files Browse the repository at this point in the history
  • Loading branch information
dab246 committed Oct 8, 2024
1 parent b510278 commit db8d8d3
Show file tree
Hide file tree
Showing 12 changed files with 344 additions and 292 deletions.
26 changes: 14 additions & 12 deletions lib/features/contact/presentation/contact_controller.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import 'package:core/presentation/utils/keyboard_utils.dart';
import 'package:core/presentation/utils/theme_utils.dart';
import 'package:core/utils/app_logger.dart';
import 'package:core/utils/platform_info.dart';
import 'package:debounce_throttle/debounce_throttle.dart';
Expand Down Expand Up @@ -31,6 +32,7 @@ class ContactController extends BaseController {
final searchQuery = SearchQuery.initial().obs;
final session = Rxn<Session>();
final listContactSearched = RxList<EmailAddress>();
final contactArguments = Rxn<ContactArguments>();

GetAllAutoCompleteInteractor? _getAllAutoCompleteInteractor;
GetAutoCompleteInteractor? _getAutoCompleteInteractor;
Expand All @@ -39,32 +41,30 @@ class ContactController extends BaseController {
final Debouncer<String> _deBouncerTime = Debouncer<String>(const Duration(milliseconds: 300), initialValue: '');
AccountId? _accountId;

ContactArguments? arguments;
EmailAddress? contactSelected;
SelectedContactCallbackAction? onSelectedContactCallback;
VoidCallback? onDismissContactView;

@override
void onInit() {
super.onInit();
ThemeUtils.setStatusBarTransparentColor();
log('ContactController::onInit():arguments: ${Get.arguments}');
arguments = Get.arguments;
contactArguments.value = Get.arguments;
_deBouncerTime.values.listen((value) {
searchQuery.value = SearchQuery(value);
_searchContactByNameOrEmail(searchQuery.value.value);
});
}

@override
void onReady() async {
void onReady() {
super.onReady();
log('ContactController::onReady():');
textInputSearchFocus.requestFocus();
if (arguments != null) {
_accountId = arguments!.accountId;
session.value = arguments!.session;
final listContactSelected = arguments!.listContactSelected;
log('ContactController::onReady(): arguments: $arguments');
if (contactArguments.value != null) {
_accountId = contactArguments.value!.accountId;
session.value = contactArguments.value!.session;
final listContactSelected = contactArguments.value!.listContactSelected;
log('ContactController::onReady(): listContactSelected: $listContactSelected');
if (listContactSelected.isNotEmpty) {
contactSelected = EmailAddress(listContactSelected.first, listContactSelected.first);
Expand Down Expand Up @@ -167,9 +167,11 @@ class ContactController extends BaseController {
popBack(result: emailAddress);
}

void closeContactView(BuildContext context) {
clearAllTextInputSearchForm();
KeyboardUtils.hideKeyboard(context);
void closeContactView() {
textInputSearchController.clear();
searchQuery.value = SearchQuery.initial();
textInputSearchFocus.unfocus();
FocusManager.instance.primaryFocus?.unfocus();
popBack();
}
}
334 changes: 138 additions & 196 deletions lib/features/contact/presentation/contact_view.dart

Large diffs are not rendered by default.

15 changes: 13 additions & 2 deletions lib/features/contact/presentation/model/contact_arguments.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,20 @@ class ContactArguments with EquatableMixin {
final AccountId accountId;
final Session session;
final Set<String> listContactSelected;
final String? contactViewTitle;

ContactArguments(this.accountId, this.session, this.listContactSelected);
ContactArguments({
required this.accountId,
required this.session,
required this.listContactSelected,
this.contactViewTitle
});

@override
List<Object?> get props => [accountId, session, listContactSelected];
List<Object?> get props => [
accountId,
session,
listContactSelected,
contactViewTitle,
];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

import 'package:core/presentation/utils/responsive_utils.dart';
import 'package:core/utils/platform_info.dart';
import 'package:flutter/material.dart';

class AppBarContactWidgetStyle {
static EdgeInsetsGeometry getAppBarPadding(
BuildContext context,
ResponsiveUtils responsiveUtils
) {
if (PlatformInfo.isWeb) {
return const EdgeInsets.symmetric(horizontal: 16);
} else {
if (responsiveUtils.isScreenWithShortestSide(context)) {
return const EdgeInsets.symmetric(horizontal: 10);
} else {
return const EdgeInsets.symmetric(horizontal: 32);
}
}
}
}
62 changes: 62 additions & 0 deletions lib/features/contact/presentation/styles/contact_view_style.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

import 'package:core/presentation/utils/responsive_utils.dart';
import 'package:core/utils/platform_info.dart';
import 'package:flutter/cupertino.dart';

class ContactViewStyle {
static const double viewMaxHeight = 624.0;
static const double viewMaxWidth = 558.0;

static double getContactViewHeight(
BuildContext context,
ResponsiveUtils responsiveUtils
) {
if ((PlatformInfo.isWeb && responsiveUtils.isMobile(context)) ||
(PlatformInfo.isMobile && responsiveUtils.isScreenWithShortestSide(context))
) {
return double.infinity;
} else if (responsiveUtils.getSizeScreenHeight(context) > ContactViewStyle.viewMaxHeight) {
return ContactViewStyle.viewMaxHeight;
} else {
return double.infinity;
}
}

static double getContactViewWidth(
BuildContext context,
ResponsiveUtils responsiveUtils
) {
if ((PlatformInfo.isWeb && responsiveUtils.isMobile(context)) ||
(PlatformInfo.isMobile && responsiveUtils.isScreenWithShortestSide(context))
) {
return double.infinity;
} else {
return ContactViewStyle.viewMaxWidth;
}
}

static bool isAppBarTopBorderSupported(
BuildContext context,
ResponsiveUtils responsiveUtils
) {
return !(PlatformInfo.isWeb || responsiveUtils.isLandscapeMobile(context));
}

static BorderRadiusGeometry getContactViewBorderRadius(
BuildContext context,
ResponsiveUtils responsiveUtils
) {
if (PlatformInfo.isMobile && responsiveUtils.isLandscapeMobile(context)) {
return BorderRadius.zero;
} else if ((PlatformInfo.isWeb && responsiveUtils.isMobile(context)) ||
(PlatformInfo.isMobile && responsiveUtils.isPortraitMobile(context))
) {
return const BorderRadiusDirectional.only(
topEnd: Radius.circular(16),
topStart: Radius.circular(16),
);
} else {
return const BorderRadius.all(Radius.circular(16));
}
}
}
27 changes: 0 additions & 27 deletions lib/features/contact/presentation/utils/contact_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,6 @@ import 'package:core/utils/platform_info.dart';
import 'package:flutter/material.dart';

class ContactUtils {
static EdgeInsets getPaddingAppBar(BuildContext context, ResponsiveUtils responsiveUtils) {
if (PlatformInfo.isWeb) {
return const EdgeInsets.symmetric(horizontal: 16);
} else {
if (responsiveUtils.isScreenWithShortestSide(context)) {
return const EdgeInsets.symmetric(horizontal: 10);
} else {
return const EdgeInsets.symmetric(horizontal: 32);
}
}
}

static EdgeInsets getPaddingSearchInputForm(BuildContext context, ResponsiveUtils responsiveUtils) {
if (PlatformInfo.isWeb) {
return const EdgeInsets.symmetric(horizontal: 16, vertical: 10);
Expand Down Expand Up @@ -51,19 +39,4 @@ class ContactUtils {
}
}
}

static bool supportAppBarTopBorder(BuildContext context, ResponsiveUtils responsiveUtils) {
if (PlatformInfo.isWeb || responsiveUtils.isLandscapeMobile(context)) {
return false;
}
return true;
}

static double getRadiusBorderAppBarTop(BuildContext context, ResponsiveUtils responsiveUtils) {
if (supportAppBarTopBorder(context, responsiveUtils)) {
return 16;
} else {
return 0;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,48 +1,64 @@

import 'package:core/presentation/extensions/color_extension.dart';
import 'package:core/presentation/resources/image_paths.dart';
import 'package:core/presentation/views/button/icon_button_web.dart';
import 'package:core/presentation/utils/responsive_utils.dart';
import 'package:core/presentation/views/button/tmail_button_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:get/get.dart';
import 'package:tmail_ui_user/features/contact/presentation/styles/app_bar_contact_widget_style.dart';
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';

class AppBarContactWidget extends StatelessWidget {

final _imagePaths = Get.find<ImagePaths>();
final String? title;
final ImagePaths imagePaths;
final ResponsiveUtils responsiveUtils;
final VoidCallback onCloseContactView;

final Function()? onCloseContactView;

AppBarContactWidget({
Key? key,
this.onCloseContactView,
const AppBarContactWidget({
Key? key,
required this.title,
required this.imagePaths,
required this.responsiveUtils,
required this.onCloseContactView,
}) : super(key: key);

@override
Widget build(BuildContext context) {
return Stack(alignment: Alignment.center, children: [
Positioned(
left: 0,
child: buildIconWeb(
icon: SvgPicture.asset(
_imagePaths.icClose,
colorFilter: AppColor.colorCloseButton.asFilter(),
width: 24,
height: 24,
fit: BoxFit.fill),
minSize: 25,
iconSize: 25,
iconPadding: const EdgeInsets.all(5),
splashRadius: 15,
tooltip: AppLocalizations.of(context).close,
onTap: onCloseContactView),
return Container(
height: 56,
color: Colors.white,
padding: AppBarContactWidgetStyle.getAppBarPadding(
context,
responsiveUtils
),
Center(child: Text(
AppLocalizations.of(context).contact,
style: const TextStyle(
width: double.infinity,
child: Stack(
alignment: Alignment.center,
children: [
Text(
title ?? AppLocalizations.of(context).contact,
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Colors.black))),
]);
color: Colors.black
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
PositionedDirectional(
end: 0,
child: TMailButtonWidget.fromIcon(
icon: imagePaths.icClose,
tooltipMessage: AppLocalizations.of(context).close,
iconSize: 24,
padding: const EdgeInsets.all(3),
iconColor: AppColor.colorCloseButton,
backgroundColor: AppColor.colorCloseButton.withOpacity(0.12),
onTapActionCallback: onCloseContactView,
)
),
]
),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1696,13 +1696,15 @@ class MailboxDashBoardController extends ReloadableController with UserSettingPo
dispatchAction(StartSearchEmailAction());
}

Future<void> selectFromSearchFilter() async {
Future<void> selectFromSearchFilter(BuildContext context) async {
if (accountId.value == null || sessionCurrent == null) return;

final contactArgument = ContactArguments(
accountId.value!,
sessionCurrent!,
searchController.searchEmailFilter.value.from);
accountId: accountId.value!,
session: sessionCurrent!,
listContactSelected: searchController.searchEmailFilter.value.from,
contactViewTitle: '${AppLocalizations.of(context).findEmails} ${AppLocalizations.of(context).from_email_address_prefix.toLowerCase()}'
);

final newContact = await DialogRouter.pushGeneralDialog(
routeName: AppRoutes.contact,
Expand All @@ -1714,13 +1716,15 @@ class MailboxDashBoardController extends ReloadableController with UserSettingPo
}
}

Future<void> selectToSearchFilter() async {
Future<void> selectToSearchFilter(BuildContext context) async {
if (accountId.value == null || sessionCurrent == null) return;

final contactArgument = ContactArguments(
accountId.value!,
sessionCurrent!,
searchController.searchEmailFilter.value.to);
accountId: accountId.value!,
session: sessionCurrent!,
listContactSelected: searchController.searchEmailFilter.value.to,
contactViewTitle: '${AppLocalizations.of(context).findEmails} ${AppLocalizations.of(context).to_email_address_prefix.toLowerCase()}'
);

final newContact = await DialogRouter.pushGeneralDialog(
routeName: AppRoutes.contact,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -591,13 +591,13 @@ class MailboxDashBoardView extends BaseMailboxDashBoardView {
}
break;
case QuickSearchFilter.from:
controller.selectFromSearchFilter();
controller.selectFromSearchFilter(context);
break;
case QuickSearchFilter.hasAttachment:
controller.selectHasAttachmentSearchFilter();
break;
case QuickSearchFilter.to:
controller.selectToSearchFilter();
controller.selectToSearchFilter(context);
break;
case QuickSearchFilter.folder:
controller.selectFolderSearchFilter();
Expand Down
Loading

0 comments on commit db8d8d3

Please sign in to comment.