Skip to content

Commit

Permalink
fixup! fixup! TW-613: Update icon and title when select multi
Browse files Browse the repository at this point in the history
  • Loading branch information
nqhhdev committed Sep 22, 2023
1 parent 150b36e commit 8eea944
Show file tree
Hide file tree
Showing 8 changed files with 128 additions and 146 deletions.
74 changes: 3 additions & 71 deletions lib/pages/chat_list/chat_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -633,59 +633,6 @@ class ChatListController extends State<ChatList>
}
}

String _getTitleContextMenuSelection(
ChatListSelectionActions chatListBottomNavigatorBar,
Room room,
) {
switch (chatListBottomNavigatorBar) {
case ChatListSelectionActions.read:
if (room.markedUnread) {
return L10n.of(context)!.markThisMessageAsRead;
} else {
return L10n.of(context)!.markThisMessageAsUnRead;
}
case ChatListSelectionActions.mute:
if (room.pushRuleState == PushRuleState.notify) {
return L10n.of(context)!.muteThisMessage;
} else {
return L10n.of(context)!.unmuteThisMessage;
}
case ChatListSelectionActions.pin:
return L10n.of(context)!.pinThisMessage;
case ChatListSelectionActions.more:
return L10n.of(context)!.more;
}
}

IconData _getIconContextMenuSelection(
ChatListSelectionActions chatListBottomNavigatorBar,
Room room,
) {
switch (chatListBottomNavigatorBar) {
case ChatListSelectionActions.read:
if (room.markedUnread) {
return Icons.mark_chat_read;
} else {
return Icons.mark_chat_unread;
}
case ChatListSelectionActions.mute:
if (room.pushRuleState == PushRuleState.notify) {
return Icons.volume_off;
} else {
return Icons.volume_up;
}

case ChatListSelectionActions.pin:
if (room.isFavourite) {
return Icons.push_pin_outlined;
} else {
return Icons.push_pin;
}
case ChatListSelectionActions.more:
return Icons.more_vert;
}
}

void handleContextMenuAction(
BuildContext context,
Room room,
Expand All @@ -711,8 +658,8 @@ class ChatListController extends State<ChatList>
padding: EdgeInsets.zero,
child: popupItem(
context,
_getTitleContextMenuSelection(action, room),
iconAction: _getIconContextMenuSelection(action, room),
action.getTitleContextMenuSelection(context, room),
iconAction: action.getIconContextMenuSelection(room),
onCallbackAction: () => _handleClickOnContextMenuItem(
action,
room,
Expand Down Expand Up @@ -784,7 +731,7 @@ class ChatListController extends State<ChatList>
Padding(
padding: paddingIcon,
child: Icon(
_getIconBottomNavigation(item),
item.getIconBottomNavigation(),
size: iconSize,
color: Theme.of(context).colorScheme.primary,
),
Expand Down Expand Up @@ -829,21 +776,6 @@ class ChatListController extends State<ChatList>
}
}

IconData _getIconBottomNavigation(
ChatListSelectionActions actionBottomNavigation,
) {
switch (actionBottomNavigation) {
case ChatListSelectionActions.read:
return Icons.mark_email_read;
case ChatListSelectionActions.mute:
return Icons.notifications_off;
case ChatListSelectionActions.pin:
return Icons.push_pin;
case ChatListSelectionActions.more:
return Icons.more_vert;
}
}

@override
Widget build(BuildContext context) {
return ChatListView(
Expand Down
1 change: 0 additions & 1 deletion lib/pages/chat_list/chat_list_body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ class ChatListViewBody extends StatelessWidget {
onTap: controller.isSelectMode
? () => controller.toggleSelection(rooms[index].id)
: null,
// onLongPress: () => controller.toggleSelection(rooms[i].id),
onSecondaryTap: () => controller.handleContextMenuAction(
context,
rooms[index],
Expand Down
10 changes: 4 additions & 6 deletions lib/pages/chat_list/chat_list_item.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:adaptive_dialog/adaptive_dialog.dart';
import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/pages/chat_list/chat_list_item_mixin.dart';
import 'package:fluffychat/pages/chat_list/chat_list_item_style.dart';
import 'package:fluffychat/pages/chat_list/chat_list_item_subtitle.dart';
import 'package:fluffychat/pages/chat_list/chat_list_item_title.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
Expand Down Expand Up @@ -87,10 +88,7 @@ class ChatListItem extends StatelessWidget with ChatListItemMixin {
MatrixLocals(L10n.of(context)!),
);
return Padding(
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 1,
),
padding: ChatListItemStyle.paddingConversation,
child: Material(
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
clipBehavior: Clip.hardEdge,
Expand All @@ -104,12 +102,12 @@ class ChatListItem extends StatelessWidget with ChatListItemMixin {
// onLongPress: onLongPress,
onSecondaryTap: onSecondaryTap,
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 8),
padding: ChatListItemStyle.paddingBody,
child: Row(
children: [
if (isEnableSelectMode) checkBoxWidget ?? const SizedBox(),
Padding(
padding: const EdgeInsetsDirectional.only(end: 8),
padding: ChatListItemStyle.paddingAvatar,
child: Avatar(
mxContent: room.avatar,
name: displayname,
Expand Down
12 changes: 12 additions & 0 deletions lib/pages/chat_list/chat_list_item_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ class ChatListItemStyle {
: 0.0;
}

static const EdgeInsetsDirectional paddingConversation =
EdgeInsetsDirectional.symmetric(
horizontal: 8,
vertical: 1,
);

static const EdgeInsetsDirectional paddingAvatar =
EdgeInsetsDirectional.only(end: 8);

static const EdgeInsetsDirectional paddingBody =
EdgeInsetsDirectional.symmetric(horizontal: 8);

static const double unreadBadgePaddingWhenMoreThanOne = 9.0;
static double notificationBadgeSize(
bool unread,
Expand Down
74 changes: 73 additions & 1 deletion lib/presentation/enum/chat_list/chat_list_enum.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:matrix/matrix.dart';

enum SelectMode {
normal,
select,
Expand All @@ -18,4 +22,72 @@ enum ActiveFilter {
spaces,
}

enum ChatListSelectionActions { read, mute, pin, more }
enum ChatListSelectionActions {
read,
mute,
pin,
more;

IconData getIconBottomNavigation() {
switch (this) {
case ChatListSelectionActions.read:
return Icons.mark_email_read;
case ChatListSelectionActions.mute:
return Icons.notifications_off;
case ChatListSelectionActions.pin:
return Icons.push_pin;
case ChatListSelectionActions.more:
return Icons.more_vert;
}
}

IconData getIconContextMenuSelection(Room room) {
switch (this) {
case ChatListSelectionActions.read:
if (room.markedUnread) {
return Icons.mark_chat_read;
} else {
return Icons.mark_chat_unread;
}
case ChatListSelectionActions.mute:
if (room.pushRuleState == PushRuleState.notify) {
return Icons.volume_off;
} else {
return Icons.volume_up;
}

case ChatListSelectionActions.pin:
if (room.isFavourite) {
return Icons.push_pin_outlined;
} else {
return Icons.push_pin;
}
case ChatListSelectionActions.more:
return Icons.more_vert;
}
}

String getTitleContextMenuSelection(
BuildContext context,
Room room,
) {
switch (this) {
case ChatListSelectionActions.read:
if (room.markedUnread) {
return L10n.of(context)!.markThisMessageAsRead;
} else {
return L10n.of(context)!.markThisMessageAsUnRead;
}
case ChatListSelectionActions.mute:
if (room.pushRuleState == PushRuleState.notify) {
return L10n.of(context)!.muteThisMessage;
} else {
return L10n.of(context)!.unmuteThisMessage;
}
case ChatListSelectionActions.pin:
return L10n.of(context)!.pinThisMessage;
case ChatListSelectionActions.more:
return L10n.of(context)!.more;
}
}
}
19 changes: 2 additions & 17 deletions lib/widgets/layouts/adaptive_layout/adaptive_scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,8 @@ class AdaptiveScaffoldAppController extends State<AdaptiveScaffoldApp> {

void onDestinationSelected(int index) {
final destinationType = destinations[index];
switch (destinationType) {
//FIXME: NOW WE SUPPORT FOR ONLY 2 TABS
case AdaptiveDestinationEnum.contacts:
activeNavigationBar.value = AdaptiveDestinationEnum.contacts;
pageController.jumpToPage(index);
break;
case AdaptiveDestinationEnum.rooms:
activeNavigationBar.value = AdaptiveDestinationEnum.rooms;
pageController.jumpToPage(index);
break;
case AdaptiveDestinationEnum.settings:
activeNavigationBar.value = AdaptiveDestinationEnum.settings;
pageController.jumpToPage(index);
break;
default:
break;
}
activeNavigationBar.value = destinationType;
pageController.jumpToPage(index);
}

void clientSelected(
Expand Down
21 changes: 6 additions & 15 deletions lib/widgets/layouts/adaptive_layout/adaptive_scaffold_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@ import 'package:fluffychat/pages/chat_list/chat_list.dart';
import 'package:fluffychat/pages/contacts_tab/contacts_tab.dart';
import 'package:fluffychat/pages/search/search.dart';
import 'package:fluffychat/pages/settings/settings.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions/client_stories_extension.dart';
import 'package:fluffychat/utils/responsive/responsive_utils.dart';
import 'package:fluffychat/widgets/layouts/adaptive_layout/adaptive_scaffold_primary_navigation.dart';
import 'package:fluffychat/widgets/layouts/adaptive_layout/adaptive_scaffold.dart';
import 'package:fluffychat/widgets/layouts/enum/adaptive_destinations_enum.dart';
import 'package:fluffychat/widgets/twake_components/twake_navigation_icon/twake_navigation_icon.dart';
import 'package:fluffychat/widgets/unread_rooms_badge.dart';
import 'package:flutter/material.dart';
import 'package:flutter_adaptive_scaffold/flutter_adaptive_scaffold.dart';
import 'package:linagora_design_flutter/linagora_design_flutter.dart';
Expand Down Expand Up @@ -129,6 +126,10 @@ class AppScaffoldView extends StatelessWidget {
);
}

int _getActiveBottomNavigationBarIndex() {
return destinations.indexOf(activeNavigationBar.value);
}

Widget _triggerPageViewBuilder({
required AdaptiveDestinationEnum navigatorBarType,
required Widget navigatorBarWidget,
Expand Down Expand Up @@ -160,8 +161,7 @@ class AppScaffoldView extends StatelessWidget {
children: [
NavigationBar(
height: ResponsiveUtils.heightBottomNavigation,
selectedIndex: activeNavigationBar.value
.getActiveBottomNavigationBarIndex(),
selectedIndex: _getActiveBottomNavigationBarIndex(),
destinations: getNavigationDestinations(context),
onDestinationSelected: onDestinationSelected,
),
Expand Down Expand Up @@ -190,16 +190,7 @@ class AppScaffoldView extends StatelessWidget {

List<NavigationDestination> getNavigationDestinations(BuildContext context) {
return destinations.map((destination) {
return NavigationDestination(
icon: destination.getIcon() != null
? TwakeNavigationIcon(
icon: destination.getIcon()!,
)
: UnreadRoomsBadge(
filter: (room) => !room.isSpace && !room.isStoryRoom,
),
label: destination.getTitle(context),
);
return destination.getNavigationDestination(context);
}).toList();
}
}
Loading

0 comments on commit 8eea944

Please sign in to comment.