From a3ed33f53be985edcbae2c8b4c03445aac6f99ac Mon Sep 17 00:00:00 2001 From: Pontus Jacobsson Date: Fri, 26 Jul 2019 17:04:52 +0200 Subject: [PATCH] Added fade in/out duration to config and text color to recoveryState --- SkeletonView.xcodeproj/project.pbxproj | 4 +++ .../Recoverable/RecoverableViewState.swift | 1 + Sources/SkeletonConfig.swift | 27 ++++++++++++++----- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/SkeletonView.xcodeproj/project.pbxproj b/SkeletonView.xcodeproj/project.pbxproj index ee5f690..e458405 100644 --- a/SkeletonView.xcodeproj/project.pbxproj +++ b/SkeletonView.xcodeproj/project.pbxproj @@ -57,6 +57,7 @@ 8785E3A3211C9CE800CC9DFD /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88DEA97D1FCDBD1F006C80EF /* Constants.swift */; }; 88DEA97F1FCDBD78006C80EF /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88DEA97D1FCDBD1F006C80EF /* Constants.swift */; }; 8933C7851EB5B820000D00A4 /* SkeletonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8933C7841EB5B820000D00A4 /* SkeletonView.swift */; }; + E488222C22EB4DAA0061273C /* FadeAnimation.swift in Sources */ = {isa = PBXBuildFile; fileRef = E488222B22EB4DAA0061273C /* FadeAnimation.swift */; }; F51DE1091FBF70A70037919A /* SkeletonAnimationBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = F51DE1081FBF70A70037919A /* SkeletonAnimationBuilder.swift */; }; F51DF871206E91B300D23301 /* SkeletonReusableCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F51DF870206E91B300D23301 /* SkeletonReusableCell.swift */; }; F51DF873206E91FB00D23301 /* GenericCollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F51DF872206E91FB00D23301 /* GenericCollectionView.swift */; }; @@ -167,6 +168,7 @@ 8785E3A0211C9C9800CC9DFD /* SkeletonDebug.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SkeletonDebug.swift; sourceTree = ""; }; 88DEA97D1FCDBD1F006C80EF /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = ""; }; 8933C7841EB5B820000D00A4 /* SkeletonView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SkeletonView.swift; sourceTree = ""; }; + E488222B22EB4DAA0061273C /* FadeAnimation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FadeAnimation.swift; path = "../../../../../Downloads/SkeletonView-feature-Allow_updating_skeleton_layers/Sources/Helpers/FadeAnimation.swift"; sourceTree = ""; }; F51DE1081FBF70A70037919A /* SkeletonAnimationBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SkeletonAnimationBuilder.swift; sourceTree = ""; }; F51DF870206E91B300D23301 /* SkeletonReusableCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SkeletonReusableCell.swift; sourceTree = ""; }; F51DF872206E91FB00D23301 /* GenericCollectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GenericCollectionView.swift; sourceTree = ""; }; @@ -425,6 +427,7 @@ F5F899D11FAB9630002E8FDA /* AssociationPolicy.swift */, F56B94451FAE20AF0095662F /* PrepareForSkeletonProtocol.swift */, F5307E311FB0F42F00EE67C5 /* RecursiveProtocol.swift */, + E488222B22EB4DAA0061273C /* FadeAnimation.swift */, ); path = Helpers; sourceTree = ""; @@ -708,6 +711,7 @@ files = ( 872D5A5621C177E20037D763 /* UIView+Extension.swift in Sources */, F5F899D01FAA6A4D002E8FDA /* UIView+IBInspectable.swift in Sources */, + E488222C22EB4DAA0061273C /* FadeAnimation.swift in Sources */, 872D5A5C21C24EDD0037D763 /* UILabel+Multiline.swift in Sources */, F54CF5E42024CEB000330B0D /* UIView+CollectionSkeleton.swift in Sources */, F5307E371FB1076E00EE67C5 /* SkeletonTableViewProtocols.swift in Sources */, diff --git a/Sources/Recoverable/RecoverableViewState.swift b/Sources/Recoverable/RecoverableViewState.swift index ab06c02..faaede2 100644 --- a/Sources/Recoverable/RecoverableViewState.swift +++ b/Sources/Recoverable/RecoverableViewState.swift @@ -15,6 +15,7 @@ struct RecoverableViewState { // UI text var text: String? + var textColor:UIColor? // UI image var image: UIImage? diff --git a/Sources/SkeletonConfig.swift b/Sources/SkeletonConfig.swift index f945998..317dc00 100644 --- a/Sources/SkeletonConfig.swift +++ b/Sources/SkeletonConfig.swift @@ -14,18 +14,31 @@ struct SkeletonConfig { let animated: Bool /// Used to execute a custom animation let animation: SkeletonLayerAnimation? - + // If the skeletons should fade in + var fadeIn:Bool { get { return fadeInDuration != 0 }} + // If the skeletons should fade out + var fadeOut:Bool { get { return fadeOutDuration != 0 }} + // Duration of fade in + let fadeInDuration:Double + // Duration of fade out + let fadeOutDuration:Double + + init( - type: SkeletonType, - colors: [UIColor], - gradientDirection: GradientDirection? = nil, - animated: Bool = false, - animation: SkeletonLayerAnimation? = nil - ) { + type: SkeletonType, + colors: [UIColor], + gradientDirection: GradientDirection? = nil, + animated: Bool = false, + animation: SkeletonLayerAnimation? = nil, + fadeInDuration: Double = 0, + fadeOutDuration: Double = 0 + ) { self.type = type self.colors = colors self.gradientDirection = gradientDirection self.animated = animated self.animation = animation + self.fadeInDuration = fadeInDuration + self.fadeOutDuration = fadeOutDuration } }