From b20bf7d1cb6d43eae50e7c9847561bdf25644c79 Mon Sep 17 00:00:00 2001 From: open-trade Date: Wed, 18 Aug 2021 00:39:48 +0800 Subject: [PATCH] cancel button on loading for iOS --- flutter_hbb/lib/common.dart | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/flutter_hbb/lib/common.dart b/flutter_hbb/lib/common.dart index 15588f13c..2d43d5957 100644 --- a/flutter_hbb/lib/common.dart +++ b/flutter_hbb/lib/common.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'dart:async'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:tuple/tuple.dart'; +import 'dart:io'; typedef F = String Function(String); @@ -33,18 +34,38 @@ void showLoading(String text, BuildContext context) { Navigator.pop(context); } dismissLoading(); - EasyLoading.show(status: text, maskType: EasyLoadingMaskType.black); + if (Platform.isAndroid) { + EasyLoading.show(status: text, maskType: EasyLoadingMaskType.black); + return; + } + EasyLoading.showWidget( + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Center(child: CircularProgressIndicator()), + SizedBox(height: 20), + Center( + child: + Text(Translator.call(text), style: TextStyle(fontSize: 15))), + SizedBox(height: 20), + Center( + child: TextButton( + style: flatButtonStyle, + onPressed: () { + dismissLoading(); + Navigator.pop(context); + }, + child: Text(Translator.call('Cancel'), + style: TextStyle(color: MyTheme.accent)))) + ], + ), + maskType: EasyLoadingMaskType.black); } void dismissLoading() { EasyLoading.dismiss(); } -void showSuccess(String text) { - dismissLoading(); - EasyLoading.showSuccess(text, maskType: EasyLoadingMaskType.black); -} - bool _hasDialog = false; typedef BuildAlertDailog = Tuple3> Function( void Function(void Function()));