showBottomActionSheet method
Implementation
showBottomActionSheet(CometChatTheme theme, BuildContext context) async {
ActionItem? item = await showCometChatActionSheet(
context: context,
actionItems: _actionItems,
titleStyle: TextStyle(
fontSize: 17,
fontWeight: FontWeight.w500,
color: theme.palette.getAccent()),
backgroundColor: theme.palette.getBackground(),
iconBackground: theme.palette.getAccent100(),
layoutIconColor: theme.palette.getPrimary());
if (item == null) {
return;
}
if (item.onItemClick != null &&
item.onItemClick is Function(BuildContext, User?, Group?)) {
try {
if (context.mounted) {
item.onItemClick(context, user, group);
}
} catch (e) {
if (kDebugMode) {
debugPrint("the option could not be executed");
}
}
} else {
PickedFile? pickedFile;
String? type;
if (item.id == 'photoAndVideo') {
pickedFile = await MediaPicker.pickImageVideo();
type = pickedFile?.fileType;
} else if (item.id == 'takePhoto') {
pickedFile = await MediaPicker.takePhoto();
type = MessageTypeConstants.image;
} else if (item.id == MessageTypeConstants.file) {
pickedFile = await MediaPicker.pickAnyFile();
type = MessageTypeConstants.file;
} else if (item.id == MessageTypeConstants.audio) {
pickedFile = await MediaPicker.pickAudio();
type = MessageTypeConstants.audio;
} else if (item.id == MessageTypeConstants.image) {
pickedFile = await MediaPicker.pickImage();
type = MessageTypeConstants.image;
} else if (item.id == MessageTypeConstants.video) {
pickedFile = await MediaPicker.pickVideo();
type = MessageTypeConstants.video;
}
if (pickedFile != null && type != null) {
if (kDebugMode) {
debugPrint("File Path is: ${pickedFile.path}");
}
sendMediaMessage(path: pickedFile.path, messageType: type);
}
}
}