-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
197 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:skeletonizer/skeletonizer.dart'; | ||
|
||
import '/nylo.dart'; | ||
|
||
/// The [LoadingStyleType] enum is used to determine the type of loading widget | ||
enum LoadingStyleType { normal, skeletonizer, none } | ||
|
||
enum SkeletonizerEffect { shimmer, leaf, pulse } | ||
|
||
/// The [LoadingStyle] class is used to determine the type of loading widget | ||
class LoadingStyle { | ||
final LoadingStyleType type; | ||
final Widget? child; | ||
final SkeletonizerEffect? skeletonizerEffect; | ||
|
||
/// Construct a [LoadingStyle.skeletonizer] widget | ||
/// Provide a [widget] to display a custom loading widget. | ||
/// By default, the [LoadingStyle.skeletonizer] widget will attempt to | ||
/// render your widget with a skeletonizer loader. | ||
LoadingStyle.skeletonizer({this.child, SkeletonizerEffect? effect}) | ||
: type = LoadingStyleType.skeletonizer, | ||
skeletonizerEffect = effect; | ||
|
||
/// Construct a [LoadingStyle.normal] widget | ||
/// Provide a [widget] to display a custom loading widget. | ||
/// By default, the [LoadingStyle.normal] widget will display your Nylo loader. | ||
LoadingStyle.normal({this.child}) | ||
: type = LoadingStyleType.normal, | ||
skeletonizerEffect = null; | ||
|
||
/// Construct a [LoadingStyle.none] widget | ||
/// This will not display any loading widget. | ||
LoadingStyle.none() | ||
: type = LoadingStyleType.none, | ||
skeletonizerEffect = null, | ||
child = null; | ||
|
||
LoadingStyle({this.child}) | ||
: type = LoadingStyleType.normal, | ||
skeletonizerEffect = null; | ||
|
||
/// Render the loading widget | ||
Widget render() { | ||
switch (type) { | ||
case LoadingStyleType.normal: | ||
return child ?? Nylo.appLoader(); | ||
case LoadingStyleType.skeletonizer: | ||
return Skeletonizer( | ||
enabled: true, | ||
child: child ?? Nylo.appLoader(), | ||
); | ||
case LoadingStyleType.none: | ||
return SizedBox.shrink(); | ||
} | ||
} | ||
} |
Oops, something went wrong.