showShareType static method

Future<void> showShareType(
  1. BuildContext context, {
  2. Future<void> onShareUrl()?,
  3. Future<void> onShareArquive()?,
  4. Future<void> onDelete()?,
  5. ModernFormPopupMenuLocation? menuLocation,
})

Implementation

static Future<void> showShareType(
  BuildContext context, {
  Future<void> Function()? onShareUrl,
  Future<void> Function()? onShareArquive,
  Future<void> Function()? onDelete,
  menu.ModernFormPopupMenuLocation? menuLocation,
}) async {
  List<ModernFormBottomSheetModel<int>> list = [
    ModernFormBottomSheetModel<int>(text: "Compartilhar URL", value: 0)
  ];
  if (!kIsWeb) {
    if (onShareArquive != null) {
      list.add(
        ModernFormBottomSheetModel<int>(
          text: "Compartilhar Arquivo",
          value: 1,
        ),
      );
    }

    if (onDelete != null) {
      list.add(
        ModernFormBottomSheetModel<int>(
          text: "Deletar arquivo do dispositivo",
          value: 2,
        ),
      );
    }
  }
  int? response = await showModernFormFilterPopupMenu<int>(
    context,
    forceMenu: true,
    menuLocation: menuLocation,
    list: list,
  );

  if (response != null) {
    switch (response) {
      case 0:
        if (onShareUrl != null) {
          await onShareUrl();
        }
        break;
      case 1:
        if (onShareArquive != null) {
          await onShareArquive();
        }
        break;
      case 2:
        if (onDelete != null) {
          await onDelete();
        }
        break;
      default:
        break;
    }
  }
}