Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TF-3002 Search more filters #3145

Open
wants to merge 9 commits into
base: refactor
Choose a base branch
from
3 changes: 3 additions & 0 deletions assets/images/ic_delete_selection.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions core/lib/presentation/extensions/color_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,14 @@ extension AppColor on Color {
static const loginViewShadowColor = Color(0x3DBCBCBC);
static const colorEmailTileCheckboxUnhover = Color(0xFFAEB7C2);
static const colorEmailTileHoverWeb = Color(0xFFDFEEFF);
static const colorSearchFilterButton = Color(0xFFECEEF1);
static const colorSearchFilterTitle = Color(0xFF686E76);
static const colorSearchFilterIcon = Color(0xFF686E76);
static const colorSuggestionSearchFilterButton = Color(0xFFEBEDF0);
static const colorFilterMessageButton = Color(0xFFEBEDF0);
static const colorFilterMessageIcon = Color(0xFF686E76);
static const colorFilterMessageTitle = Color(0xFF686E76);
static const colorStarredSearchFilterIcon = Color(0xFFFFCC00);

static const mapGradientColor = [
[Color(0xFF21D4FD), Color(0xFFB721FF)],
Expand Down
1 change: 1 addition & 0 deletions core/lib/presentation/resources/image_paths.dart
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ class ImagePaths {
String get icCheckboxSelected => _getImagePath('ic_checkbox_selected.svg');
String get icGoodSignature => _getImagePath('ic_good_signature.svg');
String get icBadSignature => _getImagePath('ic_bad_signature.svg');
String get icDeleteSelection => _getImagePath('ic_delete_selection.svg');

String _getImagePath(String imageName) {
return AssetsPaths.images + imageName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ typedef ItemBuilder<T> = Widget Function(BuildContext context, T itemData);
typedef SuggestionSelectionCallback<T> = void Function(T suggestion);
typedef RecentSelectionCallback<R> = void Function(R recent);
typedef ErrorBuilder = Widget Function(BuildContext context, Object? error);
typedef ButtonActionBuilder = Widget Function(BuildContext context, dynamic action);
typedef ButtonActionBuilder = Widget Function(
BuildContext context,
dynamic action,
SuggestionsListState suggestionsListState);
typedef ButtonActionCallback = void Function(dynamic action);

typedef AnimationTransitionBuilder = Widget Function(
Expand Down Expand Up @@ -315,8 +318,8 @@ class TypeAheadFieldQuickSearch<T, P, R> extends StatefulWidget {

final QuickSearchSuggestionsBoxDecoration suggestionsBoxDecoration;

/// Used to control the `_SuggestionsBox`. Allows manual control to
/// open, close, toggle, or resize the `_SuggestionsBox`.
/// Used to control the `SuggestionsBox`. Allows manual control to
/// open, close, toggle, or resize the `SuggestionsBox`.
final QuickSearchSuggestionsBoxController? suggestionsBoxController;

/// The duration to wait after the user stops typing before calling
Expand Down Expand Up @@ -590,7 +593,7 @@ class _TypeAheadFieldQuickSearchState<T, P, R> extends State<TypeAheadFieldQuick
with WidgetsBindingObserver {
FocusNode? _focusNode;
TextEditingController? _textEditingController;
_SuggestionsBox? _suggestionsBox;
SuggestionsBox? _suggestionsBox;
late TextDirection _textDirection;

TextEditingController? get _effectiveController =>
Expand Down Expand Up @@ -648,7 +651,7 @@ class _TypeAheadFieldQuickSearchState<T, P, R> extends State<TypeAheadFieldQuick
_focusNode = FocusNode();
}

_suggestionsBox = _SuggestionsBox(
_suggestionsBox = SuggestionsBox(
context,
widget.direction,
widget.autoFlipDirection,
Expand Down Expand Up @@ -721,7 +724,7 @@ class _TypeAheadFieldQuickSearchState<T, P, R> extends State<TypeAheadFieldQuick

void _initOverlayEntry() {
_suggestionsBox!._overlayEntry = OverlayEntry(builder: (context) {
final suggestionsList = _SuggestionsList<T, P, R>(
final suggestionsList = SuggestionsList<T, P, R>(
suggestionsBox: _suggestionsBox,
decoration: widget.suggestionsBoxDecoration,
debounceDuration: widget.debounceDuration,
Expand Down Expand Up @@ -905,8 +908,8 @@ class _TypeAheadFieldQuickSearchState<T, P, R> extends State<TypeAheadFieldQuick
}
}

class _SuggestionsList<T, P, R> extends StatefulWidget {
final _SuggestionsBox? suggestionsBox;
class SuggestionsList<T, P, R> extends StatefulWidget {
final SuggestionsBox? suggestionsBox;
final TextEditingController? controller;
final bool getImmediateSuggestions;
final SuggestionSelectionCallback<T>? onSuggestionSelected;
Expand Down Expand Up @@ -942,7 +945,8 @@ class _SuggestionsList<T, P, R> extends StatefulWidget {
final SuggestionsCallback<P>? contactSuggestionCallback;
final SuggestionSelectionCallback<P>? onContactSuggestionSelected;

const _SuggestionsList({
const SuggestionsList({
super.key,
required this.suggestionsBox,
this.controller,
this.getImmediateSuggestions = false,
Expand Down Expand Up @@ -981,10 +985,10 @@ class _SuggestionsList<T, P, R> extends StatefulWidget {
});

@override
_SuggestionsListState<T, P, R> createState() => _SuggestionsListState<T, P, R>();
SuggestionsListState<T, P, R> createState() => SuggestionsListState<T, P, R>();
}

class _SuggestionsListState<T, P, R> extends State<_SuggestionsList<T, P, R>>
class SuggestionsListState<T, P, R> extends State<SuggestionsList<T, P, R>>
with SingleTickerProviderStateMixin {
Iterable<T>? _suggestions;
Iterable<R>? _recentItems;
Expand All @@ -998,7 +1002,7 @@ class _SuggestionsListState<T, P, R> extends State<_SuggestionsList<T, P, R>>
late final ScrollController _scrollController =
widget.scrollController ?? ScrollController();

_SuggestionsListState() {
SuggestionsListState() {
_controllerListener = () async {
// If we came here because of a change in selected text, not because of
// actual change in text
Expand All @@ -1015,7 +1019,7 @@ class _SuggestionsListState<T, P, R> extends State<_SuggestionsList<T, P, R>>
recentItems = await widget.fetchRecentActionCallback!(widget.controller!.text);
}
} catch (e) {
logError('_SuggestionsListState::_SuggestionsListState(): $e');
logError('SuggestionsListState::SuggestionsListState(): $e');
}

setState(() {
Expand Down Expand Up @@ -1046,7 +1050,7 @@ class _SuggestionsListState<T, P, R> extends State<_SuggestionsList<T, P, R>>
}

@override
void didUpdateWidget(_SuggestionsList<T, P, R> oldWidget) {
void didUpdateWidget(SuggestionsList<T, P, R> oldWidget) {
super.didUpdateWidget(oldWidget);
widget.controller!.addListener(_controllerListener);
_getSuggestions();
Expand Down Expand Up @@ -1215,7 +1219,7 @@ class _SuggestionsListState<T, P, R> extends State<_SuggestionsList<T, P, R>>
if (listActionWidget != null) listActionWidget,
if (loadingWidget != null) loadingWidget,
if (widget.buttonShowAllResult != null && widget.controller?.text.isNotEmpty == true)
widget.buttonShowAllResult!(context, widget.controller?.text),
widget.buttonShowAllResult!(context, widget.controller?.text, this),
if (listItemContactWidget.isNotEmpty)
... listItemContactWidget,
if (listItemContactWidget.isNotEmpty && listItemSuggestionWidget.isNotEmpty)
Expand Down Expand Up @@ -1253,7 +1257,7 @@ class _SuggestionsListState<T, P, R> extends State<_SuggestionsList<T, P, R>>
if (listActionWidget != null) listActionWidget,
if (loadingWidget != null) loadingWidget,
if (widget.buttonShowAllResult != null && widget.controller?.text.isNotEmpty == true)
widget.buttonShowAllResult!(context, widget.controller?.text),
widget.buttonShowAllResult!(context, widget.controller?.text, this),
if (_recentItems?.isNotEmpty == true && widget.itemRecentBuilder != null && widget.titleHeaderRecent != null)
widget.titleHeaderRecent!,
if (listItemRecent.isNotEmpty)
Expand Down Expand Up @@ -1286,19 +1290,22 @@ class _SuggestionsListState<T, P, R> extends State<_SuggestionsList<T, P, R>>
if (widget.buttonActionCallback != null) {
return Padding(
padding: const EdgeInsetsDirectional.only(end: 8, bottom: 8),
child: InkWell(
borderRadius: const BorderRadius.all(Radius.circular(10)),
onTap: () {
widget.buttonActionCallback?.call(action);
invalidateSuggestions();
},
child: widget.actionButtonBuilder!(context, action),
child: Material(
type: MaterialType.transparency,
child: InkWell(
borderRadius: const BorderRadius.all(Radius.circular(10)),
onTap: () {
widget.buttonActionCallback?.call(action);
invalidateSuggestions();
},
child: widget.actionButtonBuilder!(context, action, this),
),
),
);
} else {
return Padding(
padding: const EdgeInsetsDirectional.only(end: 8, bottom: 8),
child: widget.actionButtonBuilder!(context, action)
child: widget.actionButtonBuilder!(context, action, this)
);
}
})
Expand Down Expand Up @@ -1729,7 +1736,7 @@ class QuickSearchTextFieldConfiguration {
}
}

class _SuggestionsBox {
class SuggestionsBox {
static const int waitMetricsTimeoutMillis = 1000;
static const double minOverlaySpace = 64.0;

Expand All @@ -1748,7 +1755,7 @@ class _SuggestionsBox {
double textBoxHeight = 100.0;
late double directionUpOffset;

_SuggestionsBox(
SuggestionsBox(
this.context,
this.direction,
this.autoFlipDirection,
Expand Down Expand Up @@ -1947,7 +1954,7 @@ class _SuggestionsBox {
/// Supply an instance of this class to the [TypeAhead.suggestionsBoxController]
/// property to manually control the suggestions box
class QuickSearchSuggestionsBoxController {
_SuggestionsBox? _suggestionsBox;
SuggestionsBox? _suggestionsBox;
FocusNode? _effectiveFocusNode;

/// Opens the suggestions box
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ class DestinationPickerView extends GetWidget<DestinationPickerController>
MailboxId? mailboxIdSelected
) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
padding: const EdgeInsets.symmetric(horizontal: 24),
child: Material(
color: Colors.transparent,
child: InkWell(
Expand All @@ -494,8 +494,8 @@ class DestinationPickerView extends GetWidget<DestinationPickerController>
child: Row(children: [
SvgPicture.asset(
controller.imagePaths.icFolderMailbox,
width: PlatformInfo.isWeb ? 20 : 24,
height: PlatformInfo.isWeb ? 20 : 24,
width: PlatformInfo.isWeb ? 24 : 20,
height: PlatformInfo.isWeb ? 24 : 20,
fit: BoxFit.fill
),
const SizedBox(width: 8),
Expand Down
5 changes: 2 additions & 3 deletions lib/features/email/presentation/email_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -251,19 +251,18 @@ class EmailView extends GetWidget<SingleEmailController> {
);
}

EdgeInsetsGeometry _getMarginEmailView(BuildContext context) {
EdgeInsetsGeometry? _getMarginEmailView(BuildContext context) {
if (PlatformInfo.isWeb) {
if (controller.responsiveUtils.isDesktop(context)) {
return const EdgeInsetsDirectional.only(
end: 16,
top: 8,
bottom: 16
);
} else {
return const EdgeInsets.symmetric(vertical: 16);
}
} else {
return EdgeInsets.zero;
return null;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

import 'package:flutter/cupertino.dart';
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
import 'package:model/email/email_action_type.dart';
Expand Down Expand Up @@ -28,36 +27,33 @@ class CancelSelectionAllEmailAction extends DashBoardAction {}

class FilterMessageAction extends DashBoardAction {

final BuildContext context;
final FilterMessageOption option;

FilterMessageAction(this.context, this.option);
FilterMessageAction(this.option);

@override
List<Object?> get props => [context, option];
List<Object?> get props => [option];
}

class HandleEmailActionTypeAction extends DashBoardAction {

final BuildContext context;
final EmailActionType emailAction;
final List<PresentationEmail> listEmailSelected;

HandleEmailActionTypeAction(this.context, this.listEmailSelected, this.emailAction);
HandleEmailActionTypeAction(this.listEmailSelected, this.emailAction);

@override
List<Object> get props => [context, listEmailSelected, emailAction];
List<Object> get props => [listEmailSelected, emailAction];
}

class OpenEmailDetailedFromSuggestionQuickSearchAction extends DashBoardAction {

final BuildContext context;
final PresentationEmail presentationEmail;

OpenEmailDetailedFromSuggestionQuickSearchAction(this.context, this.presentationEmail);
OpenEmailDetailedFromSuggestionQuickSearchAction(this.presentationEmail);

@override
List<Object?> get props => [context, presentationEmail];
List<Object?> get props => [presentationEmail];
}

class StartSearchEmailAction extends DashBoardAction {
Expand All @@ -69,15 +65,7 @@ class StartSearchEmailAction extends DashBoardAction {
List<Object?> get props => [filter];
}

class EmptyTrashAction extends DashBoardAction {

final BuildContext context;

EmptyTrashAction(this.context);

@override
List<Object?> get props => [context];
}
class EmptyTrashAction extends DashBoardAction {}

class ClearSearchEmailAction extends DashBoardAction {}

Expand Down Expand Up @@ -163,4 +151,8 @@ class SearchEmailByFromFieldsAction extends DashBoardAction {

class CloseSearchEmailViewAction extends DashBoardAction {}

class CancelSelectionSearchEmailAction extends DashBoardAction {}
class CancelSelectionSearchEmailAction extends DashBoardAction {}

class OpenAdvancedSearchViewAction extends DashBoardAction {}

class ClearSearchFilterAppliedAction extends DashBoardAction {}
Loading
Loading