@overrideFuture<List<CustomMenu>> getCustomMenus() async {CustomMenu menu1 = CustomMenu(100, 'res/images/tcmpp_demo_share_whatsapp.jpeg', 'WhatsApp', true,shareKey: "whatsapp");CustomMenu menu2 = CustomMenu(101,'res/images/tcmpp_demo_share_more.png','Custom',false);return [menu1,menu2,];}
@overrideFuture<List<CustomMenu>> getImageShareCustomMenus() async {CustomMenu menu1 = CustomMenu(200, '', 'Share To Friend', true);CustomMenu menu2 = CustomMenu(201, '', 'Share To WhatsApp', true);return [menu1, menu2];}
@overrideFuture<void> customMenuClick(int menuId, ShareData? shareMenu) async {print("click menuId:$menuId shareMenu:$shareMenu");Fluttertoast.showToast(msg: "click menuId:$menuId");if (menuId == 101) {// System shareString text = "This is the content to share:${shareMenu?.appTitle}";await Share.share(text);return;}if (menuId == 100) {// Share to WhatsAppString text = "This is the content to share${shareMenu?.appTitle}";String whatsappUrl = "whatsapp://send?text=$text";if (await canLaunchUrl(Uri.parse(whatsappUrl))) {await launchUrl(Uri.parse(whatsappUrl));} else {await Share.share(text);}return;}if (menuId == 200) {final imageUrl = shareMenu?.imageUrl;if (imageUrl != null && imageUrl.isNotEmpty) {await Share.shareXFiles([XFile(imageUrl)], text: "Share image");final appId = shareMenu?.appId;if(appId != null && appId.isNotEmpty) {TcmppFlutter().moveMiniAppToFront(appId);}} else {Fluttertoast.showToast(msg: "Image url not found");}return;} else if(menuId == 201) {Fluttertoast.showToast(msg: "Share to WhatsApp");}}
Feedback