[SYNC] Altered the laoding helper.

This commit is contained in:
2025-05-31 13:56:28 +03:00
parent 6a263ba47a
commit 78e1057444
2 changed files with 41 additions and 12 deletions

View File

@@ -1,6 +1,7 @@
//s1 Imports //s1 Imports
//s2 Core Package Imports //s2 Core Package Imports
import 'dart:async'; import 'dart:async';
import 'package:astromic_elements/astromic_elements.dart' show AstromicWidgets;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
//s2 1st-party Package Imports //s2 1st-party Package Imports
//s2 3rd-party Package Imports //s2 3rd-party Package Imports
@@ -23,7 +24,6 @@ class AstromicLoadingHelper {
}) { }) {
_style = style; _style = style;
return GlobalLoaderOverlay( return GlobalLoaderOverlay(
child: child,
disableBackButton: !style.canDismess, disableBackButton: !style.canDismess,
closeOnBackButton: style.canDismess, closeOnBackButton: style.canDismess,
// //
@@ -33,8 +33,25 @@ class AstromicLoadingHelper {
switchOutCurve: style.outCurve, switchOutCurve: style.outCurve,
transitionBuilder: (Widget w, Animation<double> a) => style.animationBuilder?.call(w, a), transitionBuilder: (Widget w, Animation<double> a) => style.animationBuilder?.call(w, a),
// //
overlayColor: style.backgroundColor, overlayColor: style.maskColor,
overlayWidgetBuilder: (dynamic progress) => style.loadingWidget(progress), overlayWidgetBuilder: (dynamic progress) => AstromicWidgets.blur(
child: Container(),
childOnTop: ConstrainedBox(
constraints: const BoxConstraints.tightFor(),
child: Center(
child: Container(
padding: style.loadingBoxPadding,
decoration: BoxDecoration(
color: style.loadingBoxColor,
borderRadius: style.loadingBoxRadius,
),
child: style.loadingWidget(progress),
),
),
),
sigma: style.maskBlur != null ? (style.maskBlur!.$1.toDouble(), style.maskBlur!.$2.toDouble()) : null,
),
child: child,
); );
} }

View File

@@ -3,8 +3,11 @@ import 'package:flutter/material.dart';
class AstromicLoadingOverlayStyle { class AstromicLoadingOverlayStyle {
final Widget Function(dynamic progress) loadingWidget; final Widget Function(dynamic progress) loadingWidget;
// //
final Color? backgroundColor; final Color? maskColor;
final (int sigmaX, int sigmaY)? backgroundBlur; final (int sigmaX, int sigmaY)? maskBlur;
final Color? loadingBoxColor;
final EdgeInsetsGeometry? loadingBoxPadding;
final BorderRadiusGeometry? loadingBoxRadius;
// //
final bool canDismess; final bool canDismess;
// //
@@ -15,8 +18,11 @@ class AstromicLoadingOverlayStyle {
final Function(Widget child, Animation<double> animation)? animationBuilder; final Function(Widget child, Animation<double> animation)? animationBuilder;
AstromicLoadingOverlayStyle({ AstromicLoadingOverlayStyle({
required this.loadingWidget, required this.loadingWidget,
this.backgroundColor, this.maskColor,
this.backgroundBlur, this.maskBlur,
this.loadingBoxColor,
this.loadingBoxPadding,
this.loadingBoxRadius,
this.canDismess = false, this.canDismess = false,
this.inCurve = Curves.easeOut, this.inCurve = Curves.easeOut,
this.inDuration = const Duration(milliseconds: 250), this.inDuration = const Duration(milliseconds: 250),
@@ -27,8 +33,11 @@ class AstromicLoadingOverlayStyle {
AstromicLoadingOverlayStyle copyWith({ AstromicLoadingOverlayStyle copyWith({
Widget Function(dynamic progress)? loadingWidget, Widget Function(dynamic progress)? loadingWidget,
Color? backgroundColor, Color? maskColor,
(int sigmaX, int sigmaY)? backgroundBlur, (int sigmaX, int sigmaY)? maskBlur,
Color? loadingBoxColor,
EdgeInsetsGeometry? loadingBoxPadding,
BorderRadiusGeometry? loadingBoxRadius,
bool? canDismess, bool? canDismess,
Duration? inDuration, Duration? inDuration,
Duration? outDuration, Duration? outDuration,
@@ -38,8 +47,11 @@ class AstromicLoadingOverlayStyle {
}) { }) {
return AstromicLoadingOverlayStyle( return AstromicLoadingOverlayStyle(
loadingWidget: loadingWidget ?? this.loadingWidget, loadingWidget: loadingWidget ?? this.loadingWidget,
backgroundColor: backgroundColor ?? this.backgroundColor, maskColor: maskColor ?? this.maskColor,
backgroundBlur: backgroundBlur ?? this.backgroundBlur, maskBlur: maskBlur ?? this.maskBlur,
loadingBoxColor: loadingBoxColor ?? this.loadingBoxColor,
loadingBoxPadding: loadingBoxPadding ?? this.loadingBoxPadding,
loadingBoxRadius: loadingBoxRadius ?? this.loadingBoxRadius,
canDismess: canDismess ?? this.canDismess, canDismess: canDismess ?? this.canDismess,
inDuration: inDuration ?? this.inDuration, inDuration: inDuration ?? this.inDuration,
outDuration: outDuration ?? this.outDuration, outDuration: outDuration ?? this.outDuration,
@@ -51,6 +63,6 @@ class AstromicLoadingOverlayStyle {
@override @override
String toString() { String toString() {
return 'AstromicLoadingOverlayStyle(loadingWidget: $loadingWidget, backgroundColor: $backgroundColor, backgroundBlur: $backgroundBlur, canDismess: $canDismess, inDuration: $inDuration, outDuration: $outDuration, inCurve: $inCurve, outCurve: $outCurve, animationBuilder: $animationBuilder)'; return 'AstromicLoadingOverlayStyle(loadingWidget: $loadingWidget, maskColor: $maskColor, maskBlur: $maskBlur, loadingBoxColor: $loadingBoxColor, loadingBoxPadding: $loadingBoxPadding, loadingBoxRadius: $loadingBoxRadius, canDismess: $canDismess, inDuration: $inDuration, outDuration: $outDuration, inCurve: $inCurve, outCurve: $outCurve, animationBuilder: $animationBuilder)';
} }
} }