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 package #50

Merged
merged 1 commit into from
Dec 27, 2023
Merged
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
20 changes: 20 additions & 0 deletions Example/Pow Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
54F15E5429D59D250054690B /* PulseExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 54F15E5329D59D250054690B /* PulseExample.swift */; };
54F15E5629D5A0D70054690B /* GlowExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 54F15E5529D5A0D70054690B /* GlowExample.swift */; };
B7A5DA8D2B0E853A0035FC0A /* Pow in Frameworks */ = {isa = PBXBuildFile; productRef = B7A5DA8C2B0E853A0035FC0A /* Pow */; };
FA13B8ED2B3BAF5600F58836 /* SnapshotPreferences in Frameworks */ = {isa = PBXBuildFile; productRef = FA13B8EC2B3BAF5600F58836 /* SnapshotPreferences */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -212,6 +213,7 @@
buildActionMask = 2147483647;
files = (
B7A5DA8D2B0E853A0035FC0A /* Pow in Frameworks */,
FA13B8ED2B3BAF5600F58836 /* SnapshotPreferences in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -420,6 +422,7 @@
name = "Pow Example";
packageProductDependencies = (
B7A5DA8C2B0E853A0035FC0A /* Pow */,
FA13B8EC2B3BAF5600F58836 /* SnapshotPreferences */,
);
productName = "Pow Example";
productReference = 546A2986292A31BB00A80DE2 /* Pow Example.app */;
Expand Down Expand Up @@ -450,6 +453,7 @@
);
mainGroup = 546A297D292A31BB00A80DE2;
packageReferences = (
FA13B8EB2B3BAF5600F58836 /* XCRemoteSwiftPackageReference "SnapshotPreviews-iOS" */,
);
productRefGroup = 546A2987292A31BB00A80DE2 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -777,11 +781,27 @@
};
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
FA13B8EB2B3BAF5600F58836 /* XCRemoteSwiftPackageReference "SnapshotPreviews-iOS" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/EmergeTools/SnapshotPreviews-iOS";
requirement = {
kind = exactVersion;
version = 0.7.6;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
B7A5DA8C2B0E853A0035FC0A /* Pow */ = {
isa = XCSwiftPackageProductDependency;
productName = Pow;
};
FA13B8EC2B3BAF5600F58836 /* SnapshotPreferences */ = {
isa = XCSwiftPackageProductDependency;
package = FA13B8EB2B3BAF5600F58836 /* XCRemoteSwiftPackageReference "SnapshotPreviews-iOS" */;
productName = SnapshotPreferences;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 546A297E292A31BB00A80DE2 /* Project object */;
Expand Down
2 changes: 2 additions & 0 deletions Example/Pow Example/Examples/Screens/CheckoutExample.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Pow
import SwiftUI
import SnapshotPreferences

struct CheckoutExample: View, Example {
enum PaymentError: Error {
Expand Down Expand Up @@ -271,5 +272,6 @@ struct CheckoutExample_Previews: PreviewProvider {
CheckoutExample()
.toolbar(.visible, for: .navigationBar)
}
.emergeSnapshotPrecision(0.99)
}
}
4 changes: 4 additions & 0 deletions Fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ fastlane_require 'git'
default_platform(:ios)

def build_for_config(config)

package_file = "../Package.swift"
`sed -i '' 's/let enablePreviews = .*/let enablePreviews = #{config == "Debug" ? "true" : "false"}/' "#{package_file}"`

g = Git.open('.')
build_app(
project: "./Example/Pow Example.xcodeproj",
Expand Down
6 changes: 5 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

import PackageDescription

let enablePreviews = false

let package = Package(
name: "Pow",
platforms: [
Expand All @@ -19,13 +21,15 @@ let package = Package(
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
.package(url: "https://github.com/EmergeTools/SnapshotPreviews-iOS", exact: "0.7.6")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "Pow",
dependencies: []),
dependencies: enablePreviews ? [.product(name: "SnapshotPreferences", package: "SnapshotPreviews-iOS", condition: .when(platforms: [.iOS]))] : [],
swiftSettings: enablePreviews ? [.define("EMG_PREVIEWS")] : nil),
.testTarget(
name: "PowTests",
dependencies: ["Pow"]),
Expand Down
38 changes: 23 additions & 15 deletions Sources/Pow/Effects/SmokeEffect.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import SwiftUI
import simd
#if os(iOS) && EMG_PREVIEWS
import SnapshotPreferences
#endif

public extension AnyConditionalEffect {
/// An effect that emits smoke from the view.
Expand Down Expand Up @@ -336,30 +339,35 @@ struct ContinuousParticleEffect_Previews: PreviewProvider {
}

static var previews: some View {
Group {
Preview()
.preferredColorScheme(.dark)
.previewDisplayName("Dark")
.preferredColorScheme(.dark)
.previewDisplayName("Dark")
Preview()
.preferredColorScheme(.light)
.previewDisplayName("Light")
.preferredColorScheme(.light)
.previewDisplayName("Light")
PreviewS()
.preferredColorScheme(.dark)
.previewDisplayName("Small")
.preferredColorScheme(.dark)
.previewDisplayName("Small")
Preview2()
.preferredColorScheme(.dark)
.previewDisplayName("Large")
.preferredColorScheme(.dark)
.previewDisplayName("Large")
Preview3()
.preferredColorScheme(.dark)
.previewDisplayName("Particle Layer")
.preferredColorScheme(.dark)
.previewDisplayName("Particle Layer")

#if os(iOS)
#if os(iOS)
PreviewLayer()
.previewDisplayName("Emitter Layer")
#endif
.previewDisplayName("Emitter Layer")
#endif

PreviewAlt()
.preferredColorScheme(.dark)
.previewDisplayName("Emitter Dark")
.preferredColorScheme(.dark)
.previewDisplayName("Emitter Dark")
}
#if os(iOS) && EMG_PREVIEWS
.emergeSnapshotPrecision(0)
#endif
}
}
#endif
6 changes: 6 additions & 0 deletions Sources/Pow/Transitions/Anvil.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import SwiftUI
#if os(iOS) && EMG_PREVIEWS
import SnapshotPreferences
#endif

public extension AnyTransition.MovingParts {
/// A transition that drops the view down from the top.
Expand Down Expand Up @@ -280,6 +283,9 @@ struct Anvil_Previews: PreviewProvider {
.navigationBarHidden(true)
}
.environment(\.colorScheme, .dark)
#if os(iOS) && EMG_PREVIEWS
.emergeSnapshotPrecision(0)
#endif
}
}
#endif
9 changes: 9 additions & 0 deletions Sources/Pow/Transitions/Boing.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import SwiftUI
#if os(iOS) && EMG_PREVIEWS
import SnapshotPreferences
#endif

public extension AnyTransition.MovingParts {
/// A transition that moves the view down with any overshoot resulting in an
Expand Down Expand Up @@ -218,6 +221,9 @@ struct Bounce_Previews: PreviewProvider {
.navigationBarHidden(true)
}
.environment(\.colorScheme, .dark)
#if os(iOS) && EMG_PREVIEWS
.emergeSnapshotPrecision(0)
#endif
}
}

Expand Down Expand Up @@ -290,6 +296,9 @@ struct Boing_2_Previews: PreviewProvider {
NavigationView {
Preview()
}
#if os(iOS) && EMG_PREVIEWS
.emergeSnapshotPrecision(0)
#endif
}
}
#endif
Expand Down
6 changes: 6 additions & 0 deletions Sources/Pow/Transitions/Clock.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import SwiftUI
#if os(iOS) && EMG_PREVIEWS
import SnapshotPreferences
#endif

public extension AnyTransition.MovingParts {
/// A transition using a clockwise sweep around the centerpoint of the view.
Expand Down Expand Up @@ -225,6 +228,9 @@ struct Clock_Previews: PreviewProvider {
.navigationBarHidden(true)
}
.environment(\.colorScheme, .dark)
#if os(iOS) && EMG_PREVIEWS
.emergeSnapshotPrecision(0)
#endif
}
}
#endif
Expand Down
6 changes: 6 additions & 0 deletions Sources/Pow/Transitions/Glare.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import SwiftUI
#if os(iOS) && EMG_PREVIEWS
import SnapshotPreferences
#endif

public extension AnyTransition.MovingParts {
/// A transitions that shows the view by combining a diagonal wipe with a
Expand Down Expand Up @@ -254,6 +257,9 @@ struct Glare_Previews: PreviewProvider {
.navigationBarHidden(true)
}
.environment(\.colorScheme, .dark)
#if os(iOS) && EMG_PREVIEWS
.emergeSnapshotPrecision(0)
#endif
}
}
#endif
6 changes: 6 additions & 0 deletions Sources/Pow/Transitions/Skid.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import SwiftUI
#if os(iOS) && EMG_PREVIEWS
import SnapshotPreferences
#endif

public extension AnyTransition.MovingParts {
/// The direction from which to animate in during a `skid` transition's insertion.
Expand Down Expand Up @@ -182,6 +185,9 @@ struct Skid_Previews: PreviewProvider {
.navigationBarHidden(true)
}
.environment(\.colorScheme, .dark)
#if os(iOS) && EMG_PREVIEWS
.emergeSnapshotPrecision(0)
#endif
}
}

Expand Down
6 changes: 6 additions & 0 deletions Sources/Pow/Transitions/Vanish.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import SwiftUI
#if os(iOS) && EMG_PREVIEWS
import SnapshotPreferences
#endif

public extension AnyTransition.MovingParts {
/// A transition that dissolves the view into many small particles.
Expand Down Expand Up @@ -236,6 +239,9 @@ struct Vanish_Previews: PreviewProvider {
.navigationBarHidden(true)
}
.environment(\.colorScheme, .dark)
#if os(iOS) && EMG_PREVIEWS
.emergeSnapshotPrecision(0)
#endif
}
}
#endif