Implementation
actionBarItems(BuildContext context, {bool isSelected = false}) {
if (isSelected) {
return [
if ((controller.arguments?.isAppBarReplyEnabled).checkNull()) ...[
CustomAction(
visibleWidget: IconButton(
onPressed: () {
controller
.handleReplyChatMessage(controller.selectedChatList[0]);
controller.clearChatSelection(controller.selectedChatList[0]);
},
icon: AppUtils.svgIcon(
icon: replyIcon,
colorFilter: ColorFilter.mode(
AppStyleConfig.chatPageStyle.appBarTheme.actionsIconTheme
?.color ??
Colors.black,
BlendMode.srcIn),
),
tooltip: 'Reply',
),
overflowWidget: Text(getTranslated("reply"),
style:
AppStyleConfig.chatPageStyle.popupMenuThemeData.textStyle),
showAsAction: (controller.canBeReplied.value &&
controller.availableFeatures.value.isClearChatAvailable
.checkNull())
? ShowAsAction.always
: ShowAsAction.gone,
keyValue: 'Reply',
onItemClick: () {
controller.closeKeyBoard();
controller.handleReplyChatMessage(controller.selectedChatList[0]);
controller.clearChatSelection(controller.selectedChatList[0]);
},
),
],
if ((controller.arguments?.isAppBarForwardEnabled).checkNull()) ...[
CustomAction(
visibleWidget: IconButton(
onPressed: () {
controller.checkBusyStatusForForward();
},
icon: AppUtils.svgIcon(
icon: forwardIcon,
colorFilter: ColorFilter.mode(
AppStyleConfig.chatPageStyle.appBarTheme.actionsIconTheme
?.color ??
Colors.black,
BlendMode.srcIn)),
tooltip: 'Forward',
),
overflowWidget: Text(getTranslated("forward"),
style:
AppStyleConfig.chatPageStyle.popupMenuThemeData.textStyle),
showAsAction: controller.canBeForwarded.value
? ShowAsAction.always
: ShowAsAction.gone,
keyValue: 'Forward',
onItemClick: () {
controller.closeKeyBoard();
controller.checkBusyStatusForForward();
},
)
],
if ((controller.arguments?.isAppBarStarEnabled).checkNull()) ...[
CustomAction(
visibleWidget: IconButton(
onPressed: () {
controller.favouriteMessage();
},
// icon: controller.getOptionStatus('Favourite') ? const Icon(Icons.star_border_outlined)
// icon: controller.selectedChatList[0].isMessageStarred
icon: AppUtils.svgIcon(
icon: favouriteIcon,
colorFilter: ColorFilter.mode(
AppStyleConfig.chatPageStyle.appBarTheme.actionsIconTheme
?.color ??
Colors.black,
BlendMode.srcIn)),
tooltip: 'Favourite',
),
overflowWidget: Text(getTranslated("favourite"),
style:
AppStyleConfig.chatPageStyle.popupMenuThemeData.textStyle),
showAsAction: controller.canBeStarred.value
? ShowAsAction.always
: ShowAsAction.gone,
keyValue: 'favourite',
onItemClick: () {
controller.closeKeyBoard();
controller.favouriteMessage();
},
),
],
if ((controller.arguments?.isAppBarStarEnabled).checkNull()) ...[
CustomAction(
visibleWidget: IconButton(
onPressed: () {
controller.favouriteMessage();
},
// icon: controller.getOptionStatus('Favourite') ? const Icon(Icons.star_border_outlined)
// icon: controller.selectedChatList[0].isMessageStarred
icon: AppUtils.svgIcon(
icon: unFavouriteIcon,
colorFilter: ColorFilter.mode(
AppStyleConfig.chatPageStyle.appBarTheme.actionsIconTheme
?.color ??
Colors.black,
BlendMode.srcIn)),
tooltip: 'unFavourite',
),
overflowWidget: Text(getTranslated("unFavourite"),
style:
AppStyleConfig.chatPageStyle.popupMenuThemeData.textStyle),
showAsAction: controller.canBeUnStarred.value
? ShowAsAction.always
: ShowAsAction.gone,
keyValue: 'favourite',
onItemClick: () {
controller.closeKeyBoard();
controller.favouriteMessage();
},
),
],
if ((controller.arguments?.isAppBarDeleteMessageEnabled)
.checkNull()) ...[
CustomAction(
visibleWidget: IconButton(
onPressed: () {
controller.deleteMessages();
},
icon: AppUtils.svgIcon(
icon: deleteIcon,
colorFilter: ColorFilter.mode(
AppStyleConfig.chatPageStyle.appBarTheme.actionsIconTheme
?.color ??
Colors.black,
BlendMode.srcIn)),
tooltip: 'Delete',
),
overflowWidget: Text(getTranslated("delete"),
style:
AppStyleConfig.chatPageStyle.popupMenuThemeData.textStyle),
showAsAction: controller
.availableFeatures.value.isDeleteMessageAvailable
.checkNull()
? ShowAsAction.always
: ShowAsAction.gone,
keyValue: 'Delete',
onItemClick: () {
controller.closeKeyBoard();
controller.deleteMessages();
},
),
],
if ((controller.arguments?.isAppBarReportEnabled).checkNull()) ...[
CustomAction(
visibleWidget: IconButton(
onPressed: () {
controller.reportChatOrMessage();
},
icon: const Icon(Icons.report_problem_rounded)),
overflowWidget: Text(getTranslated("report"),
style:
AppStyleConfig.chatPageStyle.popupMenuThemeData.textStyle),
showAsAction: controller.canShowReport.value
? ShowAsAction.never
: ShowAsAction.gone,
keyValue: 'Report',
onItemClick: () {
controller.closeKeyBoard();
controller.reportChatOrMessage();
},
),
],
if ((controller.arguments?.isAppBarCopyMessageEnabled).checkNull()) ...[
CustomAction(
visibleWidget: IconButton(
onPressed: () {
controller.closeKeyBoard();
controller.copyTextMessages();
},
icon: AppUtils.svgIcon(
icon: copyIcon,
fit: BoxFit.contain,
colorFilter: ColorFilter.mode(
AppStyleConfig.chatPageStyle.appBarTheme.actionsIconTheme
?.color ??
Colors.black,
BlendMode.srcIn)),
tooltip: 'Copy',
),
overflowWidget: Text(getTranslated("copy"),
style:
AppStyleConfig.chatPageStyle.popupMenuThemeData.textStyle),
showAsAction: controller.canBeCopied.value
? ShowAsAction.never
: ShowAsAction.gone,
keyValue: 'Copy',
onItemClick: () {
controller.closeKeyBoard();
controller.copyTextMessages();
},
),
],
if ((controller.arguments?.isAppBarMessageInfoEnabled).checkNull()) ...[
CustomAction(
visibleWidget: IconButton(
onPressed: () {
controller.messageInfo();
},
icon: AppUtils.svgIcon(
icon: infoIcon,
fit: BoxFit.contain,
colorFilter: ColorFilter.mode(
AppStyleConfig.chatPageStyle.appBarTheme.actionsIconTheme
?.color ??
Colors.black,
BlendMode.srcIn)),
tooltip: 'Message Info',
),
overflowWidget: Text(getTranslated("messageInfo"),
style:
AppStyleConfig.chatPageStyle.popupMenuThemeData.textStyle),
showAsAction: controller.canShowInfo.value
? ShowAsAction.never
: ShowAsAction.gone,
keyValue: 'MessageInfo',
onItemClick: () {
controller.closeKeyBoard();
controller.messageInfo();
},
),
],
if ((controller.arguments?.isAppBarShareEnabled).checkNull()) ...[
CustomAction(
visibleWidget: IconButton(
onPressed: () {},
icon: AppUtils.svgIcon(
icon: shareIcon,
colorFilter: ColorFilter.mode(
AppStyleConfig.chatPageStyle.appBarTheme.actionsIconTheme
?.color ??
Colors.black,
BlendMode.srcIn)),
tooltip: 'Share',
),
overflowWidget: Text(getTranslated("share"),
style:
AppStyleConfig.chatPageStyle.popupMenuThemeData.textStyle),
showAsAction: controller.canBeShared.value
? ShowAsAction.never
: ShowAsAction.gone,
keyValue: 'Share',
onItemClick: () {
controller.closeKeyBoard();
controller.share();
},
),
],
if ((controller.arguments?.isAppBarEditMessageEnabled).checkNull()) ...[
CustomAction(
visibleWidget: IconButton(
onPressed: () {},
icon: AppUtils.svgIcon(
icon: shareIcon,
colorFilter: ColorFilter.mode(
AppStyleConfig.chatPageStyle.appBarTheme.actionsIconTheme
?.color ??
Colors.black,
BlendMode.srcIn)),
tooltip: 'Edit Message',
),
overflowWidget: Text(getTranslated("editMessage"),
style:
AppStyleConfig.chatPageStyle.popupMenuThemeData.textStyle),
showAsAction: controller.canEditMessage.value
? ShowAsAction.never
: ShowAsAction.gone,
keyValue: 'Edit Message',
onItemClick: () {
controller.closeKeyBoard();
controller.editMessage();
},
),
],
];
} else {
return [
CustomActionBarIcons(
popupMenuThemeData: AppStyleConfig.chatPageStyle.popupMenuThemeData,
availableWidth: NavUtils.width / 2, // half the screen width
actionWidth: 48, // default for IconButtons
actions: [
if ((controller.arguments?.isAppBarClearChatEnabled)
.checkNull()) ...[
CustomAction(
overflowWidget: Text(getTranslated("clearChat"),
style: AppStyleConfig
.chatPageStyle.popupMenuThemeData.textStyle),
showAsAction: controller
.availableFeatures.value.isClearChatAvailable
.checkNull()
? ShowAsAction.never
: ShowAsAction.gone,
keyValue: 'Clear Chat',
onItemClick: () {
controller.closeKeyBoard();
debugPrint("Clear chat tap");
controller.clearUserChatHistory();
},
),
],
if ((controller.arguments?.isAppBarReportEnabled).checkNull()) ...[
CustomAction(
visibleWidget: IconButton(
onPressed: () {
controller.reportChatOrMessage();
},
icon: const Icon(Icons.report_problem_rounded),
),
overflowWidget: Text(getTranslated("report"),
style: AppStyleConfig
.chatPageStyle.popupMenuThemeData.textStyle),
showAsAction: ShowAsAction.never,
keyValue: 'Report',
onItemClick: () {
controller.closeKeyBoard();
controller.reportChatOrMessage();
},
),
],
if ((controller.arguments?.isAppBarBlockEnabled).checkNull()) ...[
controller.isBlocked.value
? CustomAction(
visibleWidget: IconButton(
onPressed: () {
controller.unBlockUser();
},
icon: const Icon(Icons.block),
),
overflowWidget: Text(getTranslated("unblock"),
style: AppStyleConfig
.chatPageStyle.popupMenuThemeData.textStyle),
showAsAction: ShowAsAction.never,
keyValue: 'Unblock',
onItemClick: () {
debugPrint('onItemClick unblock');
controller.unBlockUser();
},
)
: CustomAction(
visibleWidget: IconButton(
onPressed: () {
controller.blockUser();
},
icon: const Icon(Icons.block),
),
overflowWidget: Text(getTranslated("block"),
style: AppStyleConfig
.chatPageStyle.popupMenuThemeData.textStyle),
showAsAction: controller.profile.isGroupProfile ?? false
? ShowAsAction.gone
: ShowAsAction.never,
keyValue: 'Block',
onItemClick: () {
controller.closeKeyBoard();
controller.blockUser();
},
),
],
if ((controller.arguments?.isAppBarSearchEnabled).checkNull()) ...[
CustomAction(
visibleWidget: IconButton(
onPressed: () {},
icon: const Icon(Icons.search),
),
overflowWidget: Text(getTranslated("search"),
style: AppStyleConfig
.chatPageStyle.popupMenuThemeData.textStyle),
showAsAction: ShowAsAction.never,
keyValue: 'Search',
onItemClick: () {
controller.closeKeyBoard();
controller.gotoSearch();
},
),
],
if ((controller.arguments?.isAppBarEmailEnabled).checkNull()) ...[
CustomAction(
visibleWidget: IconButton(
onPressed: () {},
icon: const Icon(Icons.email_outlined),
),
overflowWidget: GestureDetector(
onTap: () {
controller.closeKeyBoard();
controller.exportChat();
},
child: Text(getTranslated("emailChat"),
style: AppStyleConfig
.chatPageStyle.popupMenuThemeData.textStyle),
),
showAsAction: ShowAsAction.never,
keyValue: 'EmailChat',
onItemClick: () {
controller.closeKeyBoard();
controller.exportChat();
},
),
],
CustomAction(
visibleWidget: IconButton(
onPressed: () {},
icon: const Icon(Icons.shortcut),
),
overflowWidget: Text(getTranslated("addChatShortcut"),
style: AppStyleConfig
.chatPageStyle.popupMenuThemeData.textStyle),
showAsAction: ShowAsAction.gone,
keyValue: 'Shortcut',
onItemClick: () {
controller.closeKeyBoard();
},
),
if ((controller.arguments?.isVideoCallEnabled).checkNull()) ...[
CustomAction(
visibleWidget: IconButton(
onPressed: controller.ableToCall
? () {
controller.makeVideoCall();
}
: null,
icon: AppUtils.svgIcon(
icon: videoCallIcon,
colorFilter: ColorFilter.mode(
AppStyleConfig.chatPageStyle.appBarTheme
.actionsIconTheme?.color ??
Colors.black,
BlendMode.srcIn)),
),
overflowWidget: Text(getTranslated("videoCall"),
style: AppStyleConfig
.chatPageStyle.popupMenuThemeData.textStyle),
showAsAction: controller.isVideoCallAvailable &&
(controller.arguments?.enableCalls).checkNull()
? ShowAsAction.always
: ShowAsAction.gone,
keyValue: 'Video Call',
onItemClick: controller.ableToCall
? () {
controller.makeVideoCall();
}
: null,
),
],
if ((controller.arguments?.isVoiceCallEnabled).checkNull()) ...[
CustomAction(
visibleWidget: IconButton(
onPressed: controller.ableToCall
? () {
controller.makeVoiceCall();
}
: null,
icon: AppUtils.svgIcon(
icon: audioCallIcon,
colorFilter: ColorFilter.mode(
AppStyleConfig.chatPageStyle.appBarTheme
.actionsIconTheme?.color ??
Colors.black,
BlendMode.srcIn)),
),
overflowWidget: Text(getTranslated("audioCall"),
style: AppStyleConfig
.chatPageStyle.popupMenuThemeData.textStyle),
showAsAction: controller.isAudioCallAvailable &&
(controller.arguments?.enableCalls).checkNull()
? ShowAsAction.always
: ShowAsAction.gone,
keyValue: 'Audio Call',
onItemClick: controller.ableToCall
? () {
controller.makeVoiceCall();
}
: null,
),
],
],
),
];
}
}