added blur support

This commit is contained in:
Phani Pavan Kambhampati
2022-08-12 18:12:22 +05:30
parent e830aba3cd
commit 8bf7b8fe10
8 changed files with 78 additions and 35 deletions

View File

@@ -1,3 +1,8 @@
## 0.3.0
- Added blur option for background blur
- Attempted a fix for missed dart formatting
## 0.2.1 ## 0.2.1
- Minor fixes in README file. - Minor fixes in README file.

View File

@@ -4,13 +4,13 @@ A simple widget wrapper to enable modal progress HUD (a modal progress indicator
[![pub package](https://img.shields.io/pub/v/modal_progress_hud_nsn.svg)](https://pub.dartlang.org/packages/modal_progress_hud_nsn) [![pub package](https://img.shields.io/pub/v/modal_progress_hud_nsn.svg)](https://pub.dartlang.org/packages/modal_progress_hud_nsn)
Inspired by [this](https://codingwithjoe.com/flutter-how-to-build-a-modal-progress-indicator/) article. ~~Inspired by [this](https://codingwithjoe.com/flutter-how-to-build-a-modal-progress-indicator/) article.~~ Link broken, Dont click.
A fork of [this](https://github.com/mmcc007/modal_progress_hud) with support for Null Safety. A fork of [this](https://github.com/mmcc007/modal_progress_hud) with support for Null Safety.
## Demo ## Demo
![Demo](https://raw.githubusercontent.com/mmcc007/modal_progress_hud/master/modal_progress_hud.gif) ![Demo](https://raw.githubusercontent.com/kphanipavan/modal_progress_hud/master/modal_progress_hud.gif)
_See example for details_ _See example for details_
@@ -20,7 +20,7 @@ Add the package to your `pubspec.yml` file.
```yml ```yml
dependencies: dependencies:
modal_progress_hud_nsn: ^0.2.1 modal_progress_hud_nsn: ^0.3.0
``` ```
Next, import the library into your widget. Next, import the library into your widget.
@@ -59,9 +59,17 @@ ModalProgressHUD(
progressIndicator: CircularProgressIndicator, progressIndicator: CircularProgressIndicator,
offset: double offset: double
dismissible: bool, dismissible: bool,
blur: double,
); );
``` ```
## Similar Packages
* [modal_progress_hud](https://pub.dev/packages/modal_progress_hud) : Original
* [modal_progress_hud_alt](https://pub.dev/packages/modal_progress_hud_alt) : Alternative
* [blurry_modal_progress_hud](https://pub.dev/packages/blurry_modal_progress_hud) : With blur
* [flutter_progress_hud](https://pub.dev/packages/flutter_progress_hud) : With fade
## Example ## Example
Here is an example app that demonstrates the usage. Here is an example app that demonstrates the usage.
@@ -138,7 +146,7 @@ for a complete sample app using the modal progress HUD. Included in the
example is a method for using a form's validators while making async example is a method for using a form's validators while making async
calls (see [flutter/issues/9688](https://github.com/flutter/flutter/issues/9688) for details). calls (see [flutter/issues/9688](https://github.com/flutter/flutter/issues/9688) for details).
### Issues and feedback ## Issues and feedback
Please file [issues](https://github.com/kphanipavan/modal_progress_hud_nsn/issues/new) Please file [issues](https://github.com/kphanipavan/modal_progress_hud_nsn/issues/new)
to send feedback or report a bug. Thank you! to send feedback or report a bug. Thank you!

View File

@@ -43,6 +43,7 @@ class _LoginPageState extends State<LoginPage> {
String? _username; String? _username;
String? _password; String? _password;
bool _isLoggedIn = false; bool _isLoggedIn = false;
double bur = 0;
// validate user name // validate user name
String? _validateUserName(String? userName) { String? _validateUserName(String? userName) {
@@ -135,13 +136,16 @@ class _LoginPageState extends State<LoginPage> {
inAsyncCall: _isInAsyncCall, inAsyncCall: _isInAsyncCall,
// demo of some additional parameters // demo of some additional parameters
opacity: 0.5, opacity: 0.5,
blur: bur,
progressIndicator: CircularProgressIndicator(), progressIndicator: CircularProgressIndicator(),
), ),
); );
} }
Widget buildLoginForm(BuildContext context) { Widget buildLoginForm(BuildContext context) {
final TextTheme textTheme = Theme.of(context).textTheme; final TextTheme textTheme = Theme
.of(context)
.textTheme;
// run the validators on reload to process async results // run the validators on reload to process async results
_loginFormKey.currentState?.validate(); _loginFormKey.currentState?.validate();
return Form( return Form(
@@ -182,18 +186,27 @@ class _LoginPageState extends State<LoginPage> {
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: _isLoggedIn child: _isLoggedIn
? Text( ? Text(
'Login successful!', 'Login successful!',
key: Key('loggedIn'), key: Key('loggedIn'),
style: TextStyle(fontSize: 20.0), style: TextStyle(fontSize: 20.0),
) )
: Text( : Text(
'Not logged in', 'Not logged in',
key: Key('notLoggedIn'), key: Key('notLoggedIn'),
style: TextStyle(fontSize: 20.0), style: TextStyle(fontSize: 20.0),
), ),
), ),
Slider(min: 0,
max: 10,
value: bur,
divisions: 100,
onChanged: (val) {
setState(() {
bur = val;
});
},),
], ],
), ),
); );
} }
} }

View File

@@ -6,6 +6,9 @@ list(APPEND FLUTTER_PLUGIN_LIST
modal_progress_hud_nsn modal_progress_hud_nsn
) )
list(APPEND FLUTTER_FFI_PLUGIN_LIST
)
set(PLUGIN_BUNDLED_LIBRARIES) set(PLUGIN_BUNDLED_LIBRARIES)
foreach(plugin ${FLUTTER_PLUGIN_LIST}) foreach(plugin ${FLUTTER_PLUGIN_LIST})
@@ -14,3 +17,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST})
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>) list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
endforeach(plugin) endforeach(plugin)
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
endforeach(ffi_plugin)

View File

@@ -42,7 +42,7 @@ packages:
name: collection name: collection
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.15.0" version: "1.16.0"
cupertino_icons: cupertino_icons:
dependency: "direct main" dependency: "direct main"
description: description:
@@ -56,7 +56,7 @@ packages:
name: fake_async name: fake_async
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.3.0"
flutter: flutter:
dependency: "direct main" dependency: "direct main"
description: flutter description: flutter
@@ -94,7 +94,7 @@ packages:
name: material_color_utilities name: material_color_utilities
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.1.3" version: "0.1.4"
meta: meta:
dependency: transitive dependency: transitive
description: description:
@@ -108,14 +108,14 @@ packages:
path: ".." path: ".."
relative: true relative: true
source: path source: path
version: "0.2.1" version: "0.3.0"
path: path:
dependency: transitive dependency: transitive
description: description:
name: path name: path
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.0" version: "1.8.1"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
@@ -127,7 +127,7 @@ packages:
name: source_span name: source_span
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.1" version: "1.8.2"
stack_trace: stack_trace:
dependency: transitive dependency: transitive
description: description:
@@ -162,21 +162,14 @@ packages:
name: test_api name: test_api
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.4.8" version: "0.4.9"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
vector_math: vector_math:
dependency: transitive dependency: transitive
description: description:
name: vector_math name: vector_math
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.1" version: "2.1.2"
sdks: sdks:
dart: ">=2.14.0 <3.0.0" dart: ">=2.17.0-0 <3.0.0"
flutter: ">=1.20.0" flutter: ">=1.20.0"

View File

@@ -6,6 +6,9 @@ list(APPEND FLUTTER_PLUGIN_LIST
modal_progress_hud_nsn modal_progress_hud_nsn
) )
list(APPEND FLUTTER_FFI_PLUGIN_LIST
)
set(PLUGIN_BUNDLED_LIBRARIES) set(PLUGIN_BUNDLED_LIBRARIES)
foreach(plugin ${FLUTTER_PLUGIN_LIST}) foreach(plugin ${FLUTTER_PLUGIN_LIST})
@@ -14,3 +17,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST})
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>) list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
endforeach(plugin) endforeach(plugin)
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
endforeach(ffi_plugin)

View File

@@ -1,6 +1,7 @@
library modal_progress_hud; library modal_progress_hud;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'dart:ui';
/// ///
/// Wrap around any widget that makes an async call to show a modal progress /// Wrap around any widget that makes an async call to show a modal progress
@@ -31,6 +32,9 @@ class ModalProgressHUD extends StatelessWidget {
/// A [Widget] which should be the the widget to be shown behind the loading barrier. /// A [Widget] which should be the the widget to be shown behind the loading barrier.
final Widget child; final Widget child;
/// A [double] value specifying the amount of background blur of the progress.
final double blur;
const ModalProgressHUD({ const ModalProgressHUD({
Key? key, Key? key,
required this.inAsyncCall, required this.inAsyncCall,
@@ -40,6 +44,7 @@ class ModalProgressHUD extends StatelessWidget {
this.offset, this.offset,
this.dismissible = false, this.dismissible = false,
required this.child, required this.child,
this.blur = 0.0,
}) : super(key: key); }) : super(key: key);
@override @override
@@ -60,12 +65,15 @@ class ModalProgressHUD extends StatelessWidget {
return Stack( return Stack(
children: [ children: [
child, child,
Opacity( BackdropFilter(
child: ModalBarrier(dismissible: dismissible, color: color), filter: ImageFilter.blur(sigmaX: blur, sigmaY: blur),
opacity: opacity, child: Opacity(
child: ModalBarrier(dismissible: dismissible, color: color),
opacity: opacity,
),
), ),
layOutProgressIndicator, layOutProgressIndicator,
], ],
); );
} }
} }

View File

@@ -1,6 +1,6 @@
name: modal_progress_hud_nsn name: modal_progress_hud_nsn
description: A modal progress indicator widget with Sound Null Safety. A fork of https://github.com/mmcc007/modal_progress_hud description: A modal progress indicator widget with Sound Null Safety. A fork of https://github.com/mmcc007/modal_progress_hud
version: 0.2.1 version: 0.3.0
#author: Phani Pavan K #author: Phani Pavan K
homepage: https://github.com/kphanipavan/modal_progress_hud_nsn homepage: https://github.com/kphanipavan/modal_progress_hud_nsn