Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add horizontal layout #147

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ void configLoading() {
..indicatorType = EasyLoadingIndicatorType.fadingCircle
..loadingStyle = EasyLoadingStyle.dark
..indicatorSize = 45.0
..axis = Axis.horizontal
..radius = 10.0
..progressColor = Colors.yellow
..backgroundColor = Colors.green
Expand All @@ -27,6 +28,7 @@ void configLoading() {
..maskColor = Colors.blue.withOpacity(0.5)
..userInteractions = true
..dismissOnTap = false
..indicatorType = EasyLoadingIndicatorType.chasingDots
..customAnimation = CustomAnimation();
}

Expand Down Expand Up @@ -159,7 +161,8 @@ class _MyHomePageState extends State<MyHomePage> {
_timer = Timer.periodic(const Duration(milliseconds: 100),
(Timer timer) {
EasyLoading.showProgress(_progress,
status: '${(_progress * 100).toStringAsFixed(0)}%');
status:
'${(_progress * 100).toStringAsFixed(0).padLeft(2, ' ')}%');
_progress += 0.03;

if (_progress >= 1) {
Expand Down
22 changes: 11 additions & 11 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
name: async
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.8.1"
version: "2.8.2"
boolean_selector:
dependency: transitive
description:
Expand All @@ -21,7 +21,7 @@ packages:
name: characters
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.0"
version: "1.2.0"
charcode:
dependency: transitive
description:
Expand Down Expand Up @@ -65,17 +65,17 @@ packages:
flutter_easyloading:
dependency: "direct main"
description:
name: flutter_easyloading
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.0.0"
path: ".."
relative: true
source: path
version: "3.0.3"
flutter_spinkit:
dependency: transitive
description:
name: flutter_spinkit
url: "https://pub.flutter-io.cn"
source: hosted
version: "5.0.0"
version: "5.1.0"
flutter_test:
dependency: "direct dev"
description: flutter
Expand All @@ -87,7 +87,7 @@ packages:
name: matcher
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.12.10"
version: "0.12.11"
meta:
dependency: transitive
description:
Expand Down Expand Up @@ -148,7 +148,7 @@ packages:
name: test_api
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.4.2"
version: "0.4.3"
typed_data:
dependency: transitive
description:
Expand All @@ -162,7 +162,7 @@ packages:
name: vector_math
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.0"
version: "2.1.1"
sdks:
dart: ">=2.12.0 <3.0.0"
dart: ">=2.14.0 <3.0.0"
flutter: ">=2.0.0"
5 changes: 4 additions & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@ description: A new Flutter project.
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1

publish_to: none

environment:
sdk: ">=2.12.0 <3.0.0"

dependencies:
flutter:
sdk: flutter

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.
Expand Down
44 changes: 37 additions & 7 deletions lib/src/easy_loading.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,18 @@ class EasyLoading {
/// padding of [status].
late EdgeInsets textPadding;

/// size of indicator, default 40.0.
/// horizontal indicator status space
late double horizontalSpace;

/// vertical Indicator Size, default 40.0.
late double indicatorSize;

/// indicator size in horizontal direction, default 20.0.
late double horizontalIndicatorSize;

/// axis direction, default horizontal
late Axis axis;

/// radius of loading, default 5.0.
late double radius;

Expand Down Expand Up @@ -165,7 +174,7 @@ class EasyLoading {

/// background color of loading, only used for [EasyLoadingStyle.custom].
Color? backgroundColor;

/// boxShadow of loading, only used for [EasyLoadingStyle.custom].
List<BoxShadow>? boxShadow;

Expand Down Expand Up @@ -216,13 +225,16 @@ class EasyLoading {
animationStyle = EasyLoadingAnimationStyle.opacity;
textAlign = TextAlign.center;
indicatorSize = 40.0;
horizontalIndicatorSize = 20.0;
axis = Axis.vertical;
radius = 5.0;
fontSize = 15.0;
progressWidth = 2.0;
lineWidth = 4.0;
displayDuration = const Duration(milliseconds: 2000);
animationDuration = const Duration(milliseconds: 200);
textPadding = const EdgeInsets.only(bottom: 10.0);
horizontalSpace = 8;
contentPadding = const EdgeInsets.symmetric(
vertical: 15.0,
horizontal: 20.0,
Expand Down Expand Up @@ -250,13 +262,17 @@ class EasyLoading {
String? status,
Widget? indicator,
EasyLoadingMaskType? maskType,
Axis? axis,
bool? dismissOnTap,
}) {
Widget w = indicator ?? (_instance.indicatorWidget ?? LoadingIndicator());
Widget w = indicator ??
(_instance.indicatorWidget ?? LoadingIndicator(axis: axis));
return _instance._show(
status: status,
maskType: maskType,
axis: axis,
dismissOnTap: dismissOnTap,
toastPosition: EasyLoadingToastPosition.center,
w: w,
);
}
Expand All @@ -266,6 +282,7 @@ class EasyLoading {
double value, {
String? status,
EasyLoadingMaskType? maskType,
Axis? axis,
}) async {
assert(
value >= 0.0 && value <= 1.0,
Expand All @@ -286,11 +303,14 @@ class EasyLoading {
Widget w = EasyLoadingProgress(
key: _progressKey,
value: value,
axis: axis,
);
_instance._show(
status: status,
maskType: maskType,
axis: axis,
dismissOnTap: false,
toastPosition: EasyLoadingToastPosition.center,
w: w,
);
_instance._progressKey = _progressKey;
Expand All @@ -306,18 +326,20 @@ class EasyLoading {
String status, {
Duration? duration,
EasyLoadingMaskType? maskType,
Axis? axis,
bool? dismissOnTap,
}) {
Widget w = _instance.successWidget ??
Icon(
Icons.done,
color: EasyLoadingTheme.indicatorColor,
size: EasyLoadingTheme.indicatorSize,
size: EasyLoadingTheme.indicatorSizeOf(axis),
);
return _instance._show(
status: status,
duration: duration ?? EasyLoadingTheme.displayDuration,
maskType: maskType,
axis: axis,
dismissOnTap: dismissOnTap,
w: w,
);
Expand All @@ -328,18 +350,20 @@ class EasyLoading {
String status, {
Duration? duration,
EasyLoadingMaskType? maskType,
Axis? axis,
bool? dismissOnTap,
}) {
Widget w = _instance.errorWidget ??
Icon(
Icons.clear,
color: EasyLoadingTheme.indicatorColor,
size: EasyLoadingTheme.indicatorSize,
size: EasyLoadingTheme.indicatorSizeOf(axis),
);
return _instance._show(
status: status,
duration: duration ?? EasyLoadingTheme.displayDuration,
maskType: maskType,
axis: axis,
dismissOnTap: dismissOnTap,
w: w,
);
Expand All @@ -350,18 +374,20 @@ class EasyLoading {
String status, {
Duration? duration,
EasyLoadingMaskType? maskType,
Axis? axis,
bool? dismissOnTap,
}) {
Widget w = _instance.infoWidget ??
Icon(
Icons.info_outline,
color: EasyLoadingTheme.indicatorColor,
size: EasyLoadingTheme.indicatorSize,
size: EasyLoadingTheme.indicatorSizeOf(axis),
);
return _instance._show(
status: status,
duration: duration ?? EasyLoadingTheme.displayDuration,
maskType: maskType,
axis: axis,
dismissOnTap: dismissOnTap,
w: w,
);
Expand All @@ -373,13 +399,15 @@ class EasyLoading {
Duration? duration,
EasyLoadingToastPosition? toastPosition,
EasyLoadingMaskType? maskType,
Axis? axis,
bool? dismissOnTap,
}) {
return _instance._show(
status: status,
duration: duration ?? EasyLoadingTheme.displayDuration,
toastPosition: toastPosition ?? EasyLoadingTheme.toastPosition,
maskType: maskType,
axis: axis,
dismissOnTap: dismissOnTap,
);
}
Expand Down Expand Up @@ -418,6 +446,7 @@ class EasyLoading {
String? status,
Duration? duration,
EasyLoadingMaskType? maskType,
Axis? axis,
bool? dismissOnTap,
EasyLoadingToastPosition? toastPosition,
}) async {
Expand Down Expand Up @@ -456,7 +485,7 @@ class EasyLoading {
);
}

toastPosition ??= EasyLoadingToastPosition.center;
toastPosition ??= EasyLoadingTheme.toastPosition;
bool animation = _w == null;
_progressKey = null;
if (_key != null) await dismiss(animation: false);
Expand All @@ -470,6 +499,7 @@ class EasyLoading {
animation: animation,
toastPosition: toastPosition,
maskType: maskType,
axis: axis,
dismissOnTap: dismissOnTap,
completer: completer,
);
Expand Down
11 changes: 10 additions & 1 deletion lib/src/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,14 @@ class EasyLoadingTheme {
/// font size of status
static double get fontSize => EasyLoading.instance.fontSize;

/// axis
static Axis get axis => EasyLoading.instance.axis;

/// size of indicator
static double get indicatorSize => EasyLoading.instance.indicatorSize;
static double indicatorSizeOf(Axis? axis) =>
(axis ?? EasyLoading.instance.axis) == Axis.horizontal
? EasyLoading.instance.horizontalIndicatorSize
: EasyLoading.instance.indicatorSize;

/// width of progress indicator
static double get progressWidth => EasyLoading.instance.progressWidth;
Expand Down Expand Up @@ -138,6 +144,9 @@ class EasyLoadingTheme {
/// padding of status
static EdgeInsets get textPadding => EasyLoading.instance.textPadding;

/// horizontal indicator status space
static double get horizontalSpace => EasyLoading.instance.horizontalSpace;

/// textAlign of status
static TextAlign get textAlign => EasyLoading.instance.textAlign;

Expand Down
Loading