From 54ceda944c70bbc1e640e0cabb9a82f1e592e1dc Mon Sep 17 00:00:00 2001 From: Berkan Aslan Date: Mon, 20 Dec 2021 13:13:21 +0300 Subject: [PATCH 1/7] #111 Blurred mask added. Example brackets issue fixed. --- example/lib/main.dart | 16 +++------ example/pubspec.lock | 46 ++++++++++++------------- lib/src/easy_loading.dart | 2 ++ lib/src/widgets/container.dart | 62 ++++++++++++++++++---------------- pubspec.lock | 40 +++++++++++----------- pubspec.yaml | 2 +- 6 files changed, 83 insertions(+), 85 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 8eb8727..2018982 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -41,7 +41,6 @@ class MyApp extends StatelessWidget { ), home: MyHomePage(title: 'Flutter EasyLoading'), builder: EasyLoading.init(), - ), ); } } @@ -157,10 +156,8 @@ class _MyHomePageState extends State { onPressed: () { _progress = 0; _timer?.cancel(); - _timer = Timer.periodic(const Duration(milliseconds: 100), - (Timer timer) { - EasyLoading.showProgress(_progress, - status: '${(_progress * 100).toStringAsFixed(0)}%'); + _timer = Timer.periodic(const Duration(milliseconds: 100), (Timer timer) { + EasyLoading.showProgress(_progress, status: '${(_progress * 100).toStringAsFixed(0)}%'); _progress += 0.03; if (_progress >= 1) { @@ -245,8 +242,7 @@ class _MyHomePageState extends State { Text('Toast Positon'), Padding( padding: EdgeInsets.only(top: 10.0), - child: - CupertinoSegmentedControl( + child: CupertinoSegmentedControl( selectedColor: Colors.blue, children: { EasyLoadingToastPosition.top: Padding( @@ -277,8 +273,7 @@ class _MyHomePageState extends State { Text('Animation Style'), Padding( padding: EdgeInsets.only(top: 10.0), - child: - CupertinoSegmentedControl( + child: CupertinoSegmentedControl( selectedColor: Colors.blue, children: { EasyLoadingAnimationStyle.opacity: Padding( @@ -316,8 +311,7 @@ class _MyHomePageState extends State { Text('IndicatorType(total: 23)'), Padding( padding: EdgeInsets.only(top: 10.0), - child: - CupertinoSegmentedControl( + child: CupertinoSegmentedControl( selectedColor: Colors.blue, children: { EasyLoadingIndicatorType.circle: Padding( diff --git a/example/pubspec.lock b/example/pubspec.lock index 28c3787..f66286e 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -5,56 +5,56 @@ packages: dependency: transitive description: name: async - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "2.5.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "2.1.0" characters: dependency: transitive description: name: characters - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.1.0" charcode: dependency: transitive description: name: charcode - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.2.0" clock: dependency: transitive description: name: clock - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.1.0" collection: dependency: transitive description: name: collection - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.15.0" cupertino_icons: dependency: "direct main" description: name: cupertino_icons - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "0.1.3" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.2.0" flutter: @@ -66,16 +66,16 @@ packages: dependency: "direct main" description: name: flutter_easyloading - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.0.3" flutter_spinkit: dependency: transitive description: name: flutter_spinkit - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "5.0.0" + version: "5.1.0" flutter_test: dependency: "direct dev" description: flutter @@ -85,21 +85,21 @@ packages: dependency: transitive description: name: matcher - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "0.12.10" meta: dependency: transitive description: name: meta - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.3.0" path: dependency: transitive description: name: path - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.8.0" sky_engine: @@ -111,56 +111,56 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.8.0" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.2.0" test_api: dependency: transitive description: name: test_api - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "0.2.19" typed_data: dependency: transitive description: name: typed_data - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.3.0" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "2.1.0" sdks: diff --git a/lib/src/easy_loading.dart b/lib/src/easy_loading.dart index ac70d3d..b3d831d 100644 --- a/lib/src/easy_loading.dart +++ b/lib/src/easy_loading.dart @@ -59,11 +59,13 @@ enum EasyLoadingAnimationStyle { /// [none] default mask type, allow user interactions while loading is displayed /// [clear] don't allow user interactions while loading is displayed /// [black] don't allow user interactions while loading is displayed +/// [blur] don't allow user interactions while loading is displayed /// [custom] while mask type is custom, maskColor should not be null enum EasyLoadingMaskType { none, clear, black, + blur, custom, } diff --git a/lib/src/widgets/container.dart b/lib/src/widgets/container.dart index 1b47161..44df9a6 100644 --- a/lib/src/widgets/container.dart +++ b/lib/src/widgets/container.dart @@ -21,6 +21,7 @@ // IN THE SOFTWARE. import 'dart:async'; +import 'dart:ui'; import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; @@ -52,17 +53,15 @@ class EasyLoadingContainer extends StatefulWidget { EasyLoadingContainerState createState() => EasyLoadingContainerState(); } -class EasyLoadingContainerState extends State - with SingleTickerProviderStateMixin { +class EasyLoadingContainerState extends State with SingleTickerProviderStateMixin { String? _status; Color? _maskColor; + late EasyLoadingMaskType? _maskType; late AnimationController _animationController; late AlignmentGeometry _alignment; late bool _dismissOnTap, _ignoring; - bool get isPersistentCallbacks => - SchedulerBinding.instance?.schedulerPhase == - SchedulerPhase.persistentCallbacks; + bool get isPersistentCallbacks => SchedulerBinding.instance?.schedulerPhase == SchedulerPhase.persistentCallbacks; @override void initState() { @@ -72,11 +71,10 @@ class EasyLoadingContainerState extends State _alignment = (widget.indicator == null && widget.status?.isNotEmpty == true) ? EasyLoadingTheme.alignment(widget.toastPosition) : AlignmentDirectional.center; - _dismissOnTap = - widget.dismissOnTap ?? (EasyLoadingTheme.dismissOnTap ?? false); - _ignoring = - _dismissOnTap ? false : EasyLoadingTheme.ignoring(widget.maskType); + _dismissOnTap = widget.dismissOnTap ?? (EasyLoadingTheme.dismissOnTap ?? false); + _ignoring = _dismissOnTap ? false : EasyLoadingTheme.ignoring(widget.maskType); _maskColor = EasyLoadingTheme.maskColor(widget.maskType); + _maskType = widget.maskType; _animationController = AnimationController( vsync: this, duration: EasyLoadingTheme.animationDuration, @@ -98,8 +96,8 @@ class EasyLoadingContainerState extends State Future show(bool animation) { if (isPersistentCallbacks) { Completer completer = Completer(); - SchedulerBinding.instance?.addPostFrameCallback((_) => completer - .complete(_animationController.forward(from: animation ? 0 : 1))); + SchedulerBinding.instance + ?.addPostFrameCallback((_) => completer.complete(_animationController.forward(from: animation ? 0 : 1))); return completer.future; } else { return _animationController.forward(from: animation ? 0 : 1); @@ -109,8 +107,8 @@ class EasyLoadingContainerState extends State Future dismiss(bool animation) { if (isPersistentCallbacks) { Completer completer = Completer(); - SchedulerBinding.instance?.addPostFrameCallback((_) => completer - .complete(_animationController.reverse(from: animation ? 1 : 0))); + SchedulerBinding.instance + ?.addPostFrameCallback((_) => completer.complete(_animationController.reverse(from: animation ? 1 : 0))); return completer.future; } else { return _animationController.reverse(from: animation ? 1 : 0); @@ -141,20 +139,8 @@ class EasyLoadingContainerState extends State child: IgnorePointer( ignoring: _ignoring, child: _dismissOnTap - ? GestureDetector( - onTap: _onTap, - behavior: HitTestBehavior.translucent, - child: Container( - width: double.infinity, - height: double.infinity, - color: _maskColor, - ), - ) - : Container( - width: double.infinity, - height: double.infinity, - color: _maskColor, - ), + ? GestureDetector(onTap: _onTap, behavior: HitTestBehavior.translucent, child: _buildMaskContainer()) + : _buildMaskContainerByMaskType(), ), ); }, @@ -175,6 +161,24 @@ class EasyLoadingContainerState extends State ], ); } + + Widget _buildMaskContainerByMaskType() { + if (_maskType == EasyLoadingMaskType.blur) + return BackdropFilter( + filter: ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0), + child: _buildMaskContainer(), + ); + + return _buildMaskContainer(); + } + + Container _buildMaskContainer() { + return Container( + width: double.infinity, + height: double.infinity, + color: _maskColor, + ); + } } class _Indicator extends StatelessWidget { @@ -205,9 +209,7 @@ class _Indicator extends StatelessWidget { children: [ if (indicator != null) Container( - margin: status?.isNotEmpty == true - ? EasyLoadingTheme.textPadding - : EdgeInsets.zero, + margin: status?.isNotEmpty == true ? EasyLoadingTheme.textPadding : EdgeInsets.zero, child: indicator, ), if (status != null) diff --git a/pubspec.lock b/pubspec.lock index 5091533..ad3aef9 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,49 +5,49 @@ packages: dependency: transitive description: name: async - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "2.5.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "2.1.0" characters: dependency: transitive description: name: characters - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.1.0" charcode: dependency: transitive description: name: charcode - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.2.0" clock: dependency: transitive description: name: clock - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.1.0" collection: dependency: transitive description: name: collection - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.15.0" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.2.0" flutter: @@ -59,9 +59,9 @@ packages: dependency: "direct main" description: name: flutter_spinkit - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "5.0.0" + version: "5.1.0" flutter_test: dependency: "direct dev" description: flutter @@ -71,21 +71,21 @@ packages: dependency: transitive description: name: matcher - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "0.12.10" meta: dependency: transitive description: name: meta - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.3.0" path: dependency: transitive description: name: path - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.8.0" sky_engine: @@ -97,56 +97,56 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.8.0" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.2.0" test_api: dependency: transitive description: name: test_api - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "0.2.19" typed_data: dependency: transitive description: name: typed_data - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "1.3.0" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "2.1.0" sdks: diff --git a/pubspec.yaml b/pubspec.yaml index 20fd73f..a4501b8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_easyloading description: ✨A clean and lightweight loading/toast widget for Flutter, Easy to use without context, Support iOS、Android and Web -version: 3.0.3 +version: 3.0.4 homepage: https://github.com/nslog11/flutter_easyloading environment: From 749ad35c20c0b76cf2110b9411913d0fe277eff3 Mon Sep 17 00:00:00 2001 From: Yeikel Uriarte Arteaga Date: Fri, 11 Nov 2022 16:57:10 -0500 Subject: [PATCH 2/7] fix: remove the strange character in the pubspec.yaml description --- example/pubspec.lock | 49 +++++++++++++++++++------------------------- pubspec.lock | 49 +++++++++++++++++++------------------------- pubspec.yaml | 2 +- 3 files changed, 43 insertions(+), 57 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index f66286e..a9fe17b 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0" + version: "2.9.0" boolean_selector: dependency: transitive description: @@ -21,28 +21,21 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" + version: "1.2.1" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" cupertino_icons: dependency: "direct main" description: @@ -56,7 +49,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.1" flutter: dependency: "direct main" description: flutter @@ -87,21 +80,28 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10" + version: "0.12.12" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.5" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.8.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.2" sky_engine: dependency: transitive description: flutter @@ -113,7 +113,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.9.0" stack_trace: dependency: transitive description: @@ -134,35 +134,28 @@ packages: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" + version: "0.4.12" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.2" sdks: - dart: ">=2.12.0 <3.0.0" + dart: ">=2.17.0-0 <3.0.0" flutter: ">=2.0.0" diff --git a/pubspec.lock b/pubspec.lock index ad3aef9..183eb63 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0" + version: "2.9.0" boolean_selector: dependency: transitive description: @@ -21,35 +21,28 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" + version: "1.2.1" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.1" flutter: dependency: "direct main" description: flutter @@ -73,21 +66,28 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10" + version: "0.12.12" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.5" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.8.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.2" sky_engine: dependency: transitive description: flutter @@ -99,7 +99,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.9.0" stack_trace: dependency: transitive description: @@ -120,35 +120,28 @@ packages: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" + version: "0.4.12" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.2" sdks: - dart: ">=2.12.0 <3.0.0" + dart: ">=2.17.0-0 <3.0.0" flutter: ">=2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index a4501b8..0069473 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: flutter_easyloading -description: ✨A clean and lightweight loading/toast widget for Flutter, Easy to use without context, Support iOS、Android and Web +description: ✨A clean and lightweight loading/toast widget for Flutter, Easy to use without context, Support iOS, Android and Web version: 3.0.4 homepage: https://github.com/nslog11/flutter_easyloading From 46a95aa7553712690cdeac65d1c36bc7d7dc0570 Mon Sep 17 00:00:00 2001 From: Yeikel Uriarte Arteaga Date: Fri, 11 Nov 2022 17:18:24 -0500 Subject: [PATCH 3/7] remove comment code --- example/lib/main.dart | 15 ++++++++++----- lib/src/widgets/container.dart | 14 ++++---------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 2018982..85266e2 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -156,8 +156,10 @@ class _MyHomePageState extends State { onPressed: () { _progress = 0; _timer?.cancel(); - _timer = Timer.periodic(const Duration(milliseconds: 100), (Timer timer) { - EasyLoading.showProgress(_progress, status: '${(_progress * 100).toStringAsFixed(0)}%'); + _timer = Timer.periodic(const Duration(milliseconds: 100), + (Timer timer) { + EasyLoading.showProgress(_progress, + status: '${(_progress * 100).toStringAsFixed(0)}%'); _progress += 0.03; if (_progress >= 1) { @@ -242,7 +244,8 @@ class _MyHomePageState extends State { Text('Toast Positon'), Padding( padding: EdgeInsets.only(top: 10.0), - child: CupertinoSegmentedControl( + child: + CupertinoSegmentedControl( selectedColor: Colors.blue, children: { EasyLoadingToastPosition.top: Padding( @@ -273,7 +276,8 @@ class _MyHomePageState extends State { Text('Animation Style'), Padding( padding: EdgeInsets.only(top: 10.0), - child: CupertinoSegmentedControl( + child: + CupertinoSegmentedControl( selectedColor: Colors.blue, children: { EasyLoadingAnimationStyle.opacity: Padding( @@ -311,7 +315,8 @@ class _MyHomePageState extends State { Text('IndicatorType(total: 23)'), Padding( padding: EdgeInsets.only(top: 10.0), - child: CupertinoSegmentedControl( + child: + CupertinoSegmentedControl( selectedColor: Colors.blue, children: { EasyLoadingIndicatorType.circle: Padding( diff --git a/lib/src/widgets/container.dart b/lib/src/widgets/container.dart index e205a19..f5f2ffb 100644 --- a/lib/src/widgets/container.dart +++ b/lib/src/widgets/container.dart @@ -109,14 +109,11 @@ class EasyLoadingContainerState extends State Future show(bool animation) { if (isPersistentCallbacks) { Completer completer = Completer(); -// <<<<<<< HEAD -// SchedulerBinding.instance -// ?.addPostFrameCallback((_) => completer.complete(_animationController.forward(from: animation ? 0 : 1))); -// ======= + _ambiguate(SchedulerBinding.instance)!.addPostFrameCallback((_) => completer .complete(_animationController.forward(from: animation ? 0 : 1))); -// >>>>>>> develop + return completer.future; } else { return _animationController.forward(from: animation ? 0 : 1); @@ -126,14 +123,11 @@ class EasyLoadingContainerState extends State Future dismiss(bool animation) { if (isPersistentCallbacks) { Completer completer = Completer(); -// <<<<<<< HEAD -// SchedulerBinding.instance -// ?.addPostFrameCallback((_) => completer.complete(_animationController.reverse(from: animation ? 1 : 0))); -// ======= + _ambiguate(SchedulerBinding.instance)!.addPostFrameCallback((_) => completer .complete(_animationController.reverse(from: animation ? 1 : 0))); -// >>>>>>> develop + return completer.future; } else { return _animationController.reverse(from: animation ? 1 : 0); From 7bca06f7965a76cc528bb06b78adbee8b9f9be76 Mon Sep 17 00:00:00 2001 From: Yeikel Uriarte Arteaga Date: Fri, 11 Nov 2022 17:54:31 -0500 Subject: [PATCH 4/7] fix old merge --- example/lib/main.dart | 3 ++- example/pubspec.lock | 8 ++++---- example/pubspec.yaml | 5 ++++- lib/src/easy_loading.dart | 3 +-- lib/src/widgets/container.dart | 14 +++++--------- 5 files changed, 16 insertions(+), 17 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 85266e2..48942e3 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -20,6 +20,7 @@ void configLoading() { ..loadingStyle = EasyLoadingStyle.dark ..indicatorSize = 45.0 ..radius = 10.0 + ..maskType = EasyLoadingMaskType.blur ..progressColor = Colors.yellow ..backgroundColor = Colors.green ..indicatorColor = Colors.yellow @@ -115,7 +116,7 @@ class _MyHomePageState extends State { _timer?.cancel(); await EasyLoading.show( status: 'loading...', - maskType: EasyLoadingMaskType.black, + maskType: EasyLoadingMaskType.blur, ); print('EasyLoading show'); }, diff --git a/example/pubspec.lock b/example/pubspec.lock index a9fe17b..052974e 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -58,10 +58,10 @@ packages: flutter_easyloading: dependency: "direct main" description: - name: flutter_easyloading - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.3" + path: ".." + relative: true + source: path + version: "3.0.5" flutter_spinkit: dependency: transitive description: diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 2125937..a86c510 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,5 +1,6 @@ name: example description: A new Flutter project. +publish_to: none # The following defines the version and build number for your application. # A version number is three numbers separated by dots, like 1.2.43 @@ -20,7 +21,9 @@ dependencies: flutter: sdk: flutter - flutter_easyloading: ^3.0.0 + # flutter_easyloading: ^3.0.0 + flutter_easyloading: + path: ../ # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. diff --git a/lib/src/easy_loading.dart b/lib/src/easy_loading.dart index 5713292..05d4b2c 100644 --- a/lib/src/easy_loading.dart +++ b/lib/src/easy_loading.dart @@ -59,14 +59,13 @@ enum EasyLoadingAnimationStyle { /// [none] default mask type, allow user interactions while loading is displayed /// [clear] don't allow user interactions while loading is displayed /// [black] don't allow user interactions while loading is displayed -/// [blur] don't allow user interactions while loading is displayed /// [custom] while mask type is custom, maskColor should not be null enum EasyLoadingMaskType { none, clear, black, - blur, custom, + blur, } /// loading indicator type. see [https://github.com/jogboms/flutter_spinkit#-showcase] diff --git a/lib/src/widgets/container.dart b/lib/src/widgets/container.dart index f5f2ffb..9ad3a1d 100644 --- a/lib/src/widgets/container.dart +++ b/lib/src/widgets/container.dart @@ -60,19 +60,15 @@ class EasyLoadingContainerState extends State with SingleTickerProviderStateMixin { String? _status; Color? _maskColor; - late EasyLoadingMaskType? _maskType; late AnimationController _animationController; late AlignmentGeometry _alignment; late bool _dismissOnTap, _ignoring; + late EasyLoadingMaskType? _maskType; -// // <<<<<<< HEAD -// bool get isPersistentCallbacks => SchedulerBinding.instance.schedulerPhase == SchedulerPhase.persistentCallbacks; -// // ======= //https://docs.flutter.dev/development/tools/sdk/release-notes/release-notes-3.0.0 bool get isPersistentCallbacks => _ambiguate(SchedulerBinding.instance)!.schedulerPhase == SchedulerPhase.persistentCallbacks; -// >>>>>>> develop @override void initState() { @@ -84,10 +80,9 @@ class EasyLoadingContainerState extends State : AlignmentDirectional.center; _dismissOnTap = widget.dismissOnTap ?? (EasyLoadingTheme.dismissOnTap ?? false); - _ignoring = - _dismissOnTap ? false : EasyLoadingTheme.ignoring(widget.maskType); - _maskColor = EasyLoadingTheme.maskColor(widget.maskType); _maskType = widget.maskType; + _ignoring = _dismissOnTap ? false : EasyLoadingTheme.ignoring(_maskType); + _maskColor = EasyLoadingTheme.maskColor(_maskType); _animationController = AnimationController( vsync: this, duration: EasyLoadingTheme.animationDuration, @@ -161,7 +156,8 @@ class EasyLoadingContainerState extends State ? GestureDetector( onTap: _onTap, behavior: HitTestBehavior.translucent, - child: _buildMaskContainer()) + child: _buildMaskContainer(), + ) : _buildMaskContainerByMaskType(), ), ); From 66249ad1e78e86c7329a342c1527bd9048302552 Mon Sep 17 00:00:00 2001 From: Yeikel Uriarte Arteaga Date: Fri, 11 Nov 2022 18:11:20 -0500 Subject: [PATCH 5/7] feat: add `sigmaX` and `sigmaY` property into `EasyLoadingContainer` --- example/lib/main.dart | 1 - lib/src/easy_loading.dart | 10 ++++++++++ lib/src/widgets/container.dart | 6 +++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 48942e3..3f3e0c6 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -20,7 +20,6 @@ void configLoading() { ..loadingStyle = EasyLoadingStyle.dark ..indicatorSize = 45.0 ..radius = 10.0 - ..maskType = EasyLoadingMaskType.blur ..progressColor = Colors.yellow ..backgroundColor = Colors.green ..indicatorColor = Colors.yellow diff --git a/lib/src/easy_loading.dart b/lib/src/easy_loading.dart index 05d4b2c..c4446ef 100644 --- a/lib/src/easy_loading.dart +++ b/lib/src/easy_loading.dart @@ -113,6 +113,12 @@ class EasyLoading { /// loading mask type, default [EasyLoadingMaskType.none]. late EasyLoadingMaskType maskType; + /// Value of blur mask, default 5.0. + late double sigmaX; + + /// Value of blur mask, default 5.0. + late double sigmaY; + /// toast position, default [EasyLoadingToastPosition.center]. late EasyLoadingToastPosition toastPosition; @@ -218,6 +224,8 @@ class EasyLoading { textAlign = TextAlign.center; indicatorSize = 40.0; radius = 5.0; + sigmaX = 5.0; + sigmaY = 5.0; fontSize = 15.0; progressWidth = 2.0; lineWidth = 4.0; @@ -472,6 +480,8 @@ class EasyLoading { toastPosition: toastPosition, maskType: maskType, dismissOnTap: dismissOnTap, + sigmaX: sigmaX, + sigmaY: sigmaY, completer: completer, ); completer.future.whenComplete(() { diff --git a/lib/src/widgets/container.dart b/lib/src/widgets/container.dart index 9ad3a1d..9b89f10 100644 --- a/lib/src/widgets/container.dart +++ b/lib/src/widgets/container.dart @@ -40,6 +40,8 @@ class EasyLoadingContainer extends StatefulWidget { final EasyLoadingMaskType? maskType; final Completer? completer; final bool animation; + final double sigmaX; + final double sigmaY; const EasyLoadingContainer({ Key? key, @@ -49,6 +51,8 @@ class EasyLoadingContainer extends StatefulWidget { this.toastPosition, this.maskType, this.completer, + required this.sigmaX, + required this.sigmaY, this.animation = true, }) : super(key: key); @@ -183,7 +187,7 @@ class EasyLoadingContainerState extends State Widget _buildMaskContainerByMaskType() { if (_maskType == EasyLoadingMaskType.blur) return BackdropFilter( - filter: ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0), + filter: ImageFilter.blur(sigmaX: widget.sigmaX, sigmaY: widget.sigmaY), child: _buildMaskContainer(), ); From 8695646e891dac6a29856a11f759fa902c328956 Mon Sep 17 00:00:00 2001 From: Yeikel Uriarte Arteaga Date: Sat, 24 Dec 2022 11:59:18 -0500 Subject: [PATCH 6/7] feat: add mask padding parameter to `EasyLoading` class --- example/ios/Flutter/AppFrameworkInfo.plist | 2 +- example/ios/Runner.xcodeproj/project.pbxproj | 6 +- example/lib/main.dart | 4 ++ lib/src/easy_loading.dart | 32 +++++++++ lib/src/widgets/container.dart | 68 ++++++++++++++------ 5 files changed, 87 insertions(+), 25 deletions(-) diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index 8d4492f..9625e10 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 9.0 + 11.0 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index a986b59..7374b69 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -272,7 +272,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -350,7 +350,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -399,7 +399,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; diff --git a/example/lib/main.dart b/example/lib/main.dart index 3f3e0c6..45f5709 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -228,6 +228,10 @@ class _MyHomePageState extends State { padding: EdgeInsets.all(5.0), child: Text('custom'), ), + EasyLoadingMaskType.blur: Padding( + padding: EdgeInsets.all(5.0), + child: Text('blur'), + ), }, onValueChanged: (value) { EasyLoading.instance.maskType = value; diff --git a/lib/src/easy_loading.dart b/lib/src/easy_loading.dart index c4446ef..d0e5126 100644 --- a/lib/src/easy_loading.dart +++ b/lib/src/easy_loading.dart @@ -197,6 +197,12 @@ class EasyLoading { /// info widget of loading Widget? infoWidget; + /// padding of mask, default 0. + EdgeInsets? maskPadding; + + /// activate safe area of mask, default false. + bool? maskUseSafeArea; + Widget? _w; EasyLoadingOverlayEntry? overlayEntry; @@ -236,6 +242,8 @@ class EasyLoading { vertical: 15.0, horizontal: 20.0, ); + maskPadding = EdgeInsets.zero; + maskUseSafeArea = false; } static EasyLoading get instance => _instance; @@ -260,6 +268,8 @@ class EasyLoading { Widget? indicator, EasyLoadingMaskType? maskType, bool? dismissOnTap, + EdgeInsets? maskPadding, + bool? maskUseSafeArea, }) { Widget w = indicator ?? (_instance.indicatorWidget ?? LoadingIndicator()); return _instance._show( @@ -267,6 +277,8 @@ class EasyLoading { maskType: maskType, dismissOnTap: dismissOnTap, w: w, + maskPadding: maskPadding, + maskUseSafeArea: maskUseSafeArea, ); } @@ -275,6 +287,8 @@ class EasyLoading { double value, { String? status, EasyLoadingMaskType? maskType, + EdgeInsets? maskPadding, + bool? maskUseSafeArea, }) async { assert( value >= 0.0 && value <= 1.0, @@ -301,6 +315,8 @@ class EasyLoading { maskType: maskType, dismissOnTap: false, w: w, + maskPadding: maskPadding, + maskUseSafeArea: maskUseSafeArea, ); _instance._progressKey = _progressKey; } @@ -316,6 +332,8 @@ class EasyLoading { Duration? duration, EasyLoadingMaskType? maskType, bool? dismissOnTap, + EdgeInsets? maskPadding, + bool? maskUseSafeArea, }) { Widget w = _instance.successWidget ?? Icon( @@ -329,6 +347,8 @@ class EasyLoading { maskType: maskType, dismissOnTap: dismissOnTap, w: w, + maskPadding: maskPadding, + maskUseSafeArea: maskUseSafeArea, ); } @@ -338,6 +358,8 @@ class EasyLoading { Duration? duration, EasyLoadingMaskType? maskType, bool? dismissOnTap, + EdgeInsets? maskPadding, + bool? maskUseSafeArea, }) { Widget w = _instance.errorWidget ?? Icon( @@ -351,6 +373,8 @@ class EasyLoading { maskType: maskType, dismissOnTap: dismissOnTap, w: w, + maskPadding: maskPadding, + maskUseSafeArea: maskUseSafeArea, ); } @@ -360,6 +384,8 @@ class EasyLoading { Duration? duration, EasyLoadingMaskType? maskType, bool? dismissOnTap, + EdgeInsets? maskPadding, + bool? maskUseSafeArea, }) { Widget w = _instance.infoWidget ?? Icon( @@ -373,6 +399,8 @@ class EasyLoading { maskType: maskType, dismissOnTap: dismissOnTap, w: w, + maskPadding: maskPadding, + maskUseSafeArea: maskUseSafeArea, ); } @@ -429,6 +457,8 @@ class EasyLoading { EasyLoadingMaskType? maskType, bool? dismissOnTap, EasyLoadingToastPosition? toastPosition, + EdgeInsets? maskPadding, + bool? maskUseSafeArea, }) async { assert( overlayEntry != null, @@ -483,6 +513,8 @@ class EasyLoading { sigmaX: sigmaX, sigmaY: sigmaY, completer: completer, + padding: maskPadding ?? this.maskPadding, + useSafeArea: maskUseSafeArea ?? this.maskUseSafeArea ?? false, ); completer.future.whenComplete(() { _callback(EasyLoadingStatus.show); diff --git a/lib/src/widgets/container.dart b/lib/src/widgets/container.dart index 9b89f10..f20ea6b 100644 --- a/lib/src/widgets/container.dart +++ b/lib/src/widgets/container.dart @@ -42,6 +42,8 @@ class EasyLoadingContainer extends StatefulWidget { final bool animation; final double sigmaX; final double sigmaY; + final EdgeInsetsGeometry? padding; + final bool useSafeArea; const EasyLoadingContainer({ Key? key, @@ -54,6 +56,8 @@ class EasyLoadingContainer extends StatefulWidget { required this.sigmaX, required this.sigmaY, this.animation = true, + this.useSafeArea = false, + this.padding, }) : super(key: key); @override @@ -146,27 +150,46 @@ class EasyLoadingContainerState extends State @override Widget build(BuildContext context) { + final background = AnimatedBuilder( + animation: _animationController, + builder: (BuildContext context, Widget? child) { + return Opacity( + opacity: _animationController.value, + child: IgnorePointer( + ignoring: _ignoring, + child: Container( + color: Colors.transparent, + child: Padding( + padding: widget.padding ?? EdgeInsets.zero, + child: Container( + color: Colors.transparent, + child: _dismissOnTap + ? GestureDetector( + onTap: _onTap, + behavior: HitTestBehavior.translucent, + child: _buildMaskContainerByMaskType(), + ) + : _buildMaskContainerByMaskType(), + ), + ), + ), + ), + ); + }, + ); + + Widget withSafeArea = background; + + if (widget.useSafeArea) { + withSafeArea = SafeArea( + child: background, + ); + } + return Stack( alignment: _alignment, children: [ - AnimatedBuilder( - animation: _animationController, - builder: (BuildContext context, Widget? child) { - return Opacity( - opacity: _animationController.value, - child: IgnorePointer( - ignoring: _ignoring, - child: _dismissOnTap - ? GestureDetector( - onTap: _onTap, - behavior: HitTestBehavior.translucent, - child: _buildMaskContainer(), - ) - : _buildMaskContainerByMaskType(), - ), - ); - }, - ), + withSafeArea, AnimatedBuilder( animation: _animationController, builder: (BuildContext context, Widget? child) { @@ -186,9 +209,12 @@ class EasyLoadingContainerState extends State Widget _buildMaskContainerByMaskType() { if (_maskType == EasyLoadingMaskType.blur) - return BackdropFilter( - filter: ImageFilter.blur(sigmaX: widget.sigmaX, sigmaY: widget.sigmaY), - child: _buildMaskContainer(), + return ClipRect( + child: BackdropFilter( + filter: + ImageFilter.blur(sigmaX: widget.sigmaX, sigmaY: widget.sigmaY), + child: _buildMaskContainer(), + ), ); return _buildMaskContainer(); From 897c173e7d6c4849abdaed08ba77d54b5b8f2f7f Mon Sep 17 00:00:00 2001 From: Yeikel Uriarte Arteaga Date: Mon, 23 Jan 2023 12:23:56 -0500 Subject: [PATCH 7/7] fix: background container is black when is set to transparent --- example/lib/main.dart | 1 - lib/src/widgets/container.dart | 16 +++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 45f5709..4e0c334 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -115,7 +115,6 @@ class _MyHomePageState extends State { _timer?.cancel(); await EasyLoading.show( status: 'loading...', - maskType: EasyLoadingMaskType.blur, ); print('EasyLoading show'); }, diff --git a/lib/src/widgets/container.dart b/lib/src/widgets/container.dart index f20ea6b..82e9d3b 100644 --- a/lib/src/widgets/container.dart +++ b/lib/src/widgets/container.dart @@ -242,13 +242,15 @@ class _Indicator extends StatelessWidget { Widget build(BuildContext context) { return Container( margin: const EdgeInsets.all(50.0), - decoration: BoxDecoration( - color: EasyLoadingTheme.backgroundColor, - borderRadius: BorderRadius.circular( - EasyLoadingTheme.radius, - ), - boxShadow: EasyLoadingTheme.boxShadow, - ), + decoration: EasyLoadingTheme.backgroundColor == Colors.transparent + ? null + : BoxDecoration( + color: EasyLoadingTheme.backgroundColor, + borderRadius: BorderRadius.circular( + EasyLoadingTheme.radius, + ), + boxShadow: EasyLoadingTheme.boxShadow, + ), padding: EasyLoadingTheme.contentPadding, child: Column( mainAxisAlignment: MainAxisAlignment.center,