Skip to content

Commit fe854d2

Browse files
committed
2.0.2
1 parent 15718c5 commit fe854d2

File tree

7 files changed

+156
-7
lines changed

7 files changed

+156
-7
lines changed

.spi.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: 1
2+
builder:
3+
configs:
4+
- documentation_targets: [Ignition]
5+
platform: macos
6+
- documentation_targets: [Ignition]
7+
platform: ios
8+
- documentation_targets: [Ignition]
9+
platform: tvos
10+
- documentation_targets: [Ignition]
11+
platform: watchos
12+
- documentation_targets: [Ignition]
13+
platform: visionos

Example/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ let package = Package(
1919
),
2020
],
2121
dependencies: [
22-
.package(url: "https://github.com/nathantannar4/Engine", from: "2.1.1"),
22+
.package(url: "https://github.com/nathantannar4/Engine", from: "2.1.14"),
2323
],
2424
targets: [
2525
.target(

Sources/Ignition/BlurEffect.swift

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
//
2+
// Copyright (c) Nathan Tannar
3+
//
4+
5+
import SwiftUI
6+
7+
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
8+
extension ViewEffect where Self == BlurEffect {
9+
10+
/// A ``ViewEffect`` that applies a blur to the view
11+
public static func blur(
12+
radius: Double,
13+
opaque: Bool = false
14+
) -> BlurEffect {
15+
BlurEffect(radius: radius, opaque: opaque)
16+
}
17+
}
18+
19+
/// A ``ViewEffect`` that applies a blur to the view
20+
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
21+
@frozen
22+
public struct BlurEffect: ViewEffect {
23+
24+
public var radius: Double
25+
public var opaque: Bool = false
26+
27+
@inlinable
28+
public init(radius: Double, opaque: Bool = false) {
29+
self.radius = radius
30+
self.opaque = opaque
31+
}
32+
33+
public func makeBody(configuration: Configuration) -> some View {
34+
configuration.content
35+
.blur(radius: radius * configuration.progress, opaque: opaque)
36+
}
37+
}
38+
39+
// MARK: - Previews
40+
41+
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
42+
struct BlurEffect_Previews: PreviewProvider {
43+
static var previews: some View {
44+
VStack(spacing: 24) {
45+
Text("Hello, World")
46+
.scheduledEffect(
47+
.blur(radius: 5),
48+
interval: 1
49+
)
50+
51+
Text("Hello, World")
52+
.scheduledEffect(
53+
.blur(radius: 20),
54+
interval: 1
55+
)
56+
}
57+
}
58+
}

Sources/Ignition/ChangeEffectButtonStyle.swift

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ extension PrimitiveButtonStyle {
1414
) -> ChangeEffectButtonStyle<Effect> where Self == ChangeEffectButtonStyle<Effect> {
1515
ChangeEffectButtonStyle(effect: effect)
1616
}
17+
18+
/// A ``PrimitiveButtonStyle`` that runs a ``ViewEffect`` when pressed
19+
public static func changeEffect<Effect: ViewEffect>(
20+
effect: Effect,
21+
animation: Animation
22+
) -> ChangeEffectButtonStyle<Effect> where Self == ChangeEffectButtonStyle<Effect> {
23+
ChangeEffectButtonStyle(effect: effect, animation: animation)
24+
}
1725
}
1826

1927
/// A ``PrimitiveButtonStyle`` that runs a ``ViewEffect`` when pressed
@@ -24,12 +32,26 @@ public struct ChangeEffectButtonStyle<
2432
>: PrimitiveButtonStyle {
2533

2634
public var effect: Effect
35+
public var animation: ViewEffectAnimation
2736

2837
@State private var trigger: UInt = 0
2938

3039
@inlinable
31-
public init(effect: Effect) {
40+
public init(
41+
effect: Effect,
42+
animation: Animation
43+
) {
44+
self.effect = effect
45+
self.animation = .continuous(animation)
46+
}
47+
48+
@inlinable
49+
public init(
50+
effect: Effect,
51+
animation: ViewEffectAnimation = .default
52+
) {
3253
self.effect = effect
54+
self.animation = animation
3355
}
3456

3557
public func makeBody(configuration: Configuration) -> some View {
@@ -39,7 +61,7 @@ public struct ChangeEffectButtonStyle<
3961
} label: {
4062
configuration.label
4163
}
42-
.changeEffect(effect, value: trigger)
64+
.changeEffect(effect, value: trigger, animation: animation)
4365
}
4466
}
4567

Sources/Ignition/OffsetEffect.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ extension ViewEffect where Self == OffsetEffect {
2323
}
2424

2525
/// A ``ViewEffect`` that moves the view between an offset
26-
public static func offset(offset: CGPoint) -> OffsetEffect {
26+
public static func offset(_ offset: CGPoint) -> OffsetEffect {
2727
OffsetEffect(offset: offset)
2828
}
2929
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
//
2+
// Copyright (c) Nathan Tannar
3+
//
4+
5+
import SwiftUI
6+
7+
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
8+
extension ViewEffect where Self == OpacityEffect {
9+
10+
/// A ``ViewEffect`` that applies an opacity to the view
11+
public static var opacity: OpacityEffect {
12+
OpacityEffect(opacity: 0)
13+
}
14+
15+
/// A ``ViewEffect`` that applies an opacity to the view
16+
public static func opacity(_ opacity: Double) -> OpacityEffect {
17+
OpacityEffect(opacity: opacity)
18+
}
19+
}
20+
21+
/// A ``ViewEffect`` that applies an opacity to the view
22+
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
23+
@frozen
24+
public struct OpacityEffect: ViewEffect {
25+
26+
public var opacity: Double
27+
28+
@inlinable
29+
public init(opacity: Double) {
30+
self.opacity = opacity
31+
}
32+
33+
public func makeBody(configuration: Configuration) -> some View {
34+
configuration.content
35+
.opacity(1 - (configuration.progress * (1 - opacity)))
36+
}
37+
}
38+
39+
// MARK: - Previews
40+
41+
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
42+
struct OpacityEffect_Previews: PreviewProvider {
43+
static var previews: some View {
44+
VStack(spacing: 0) {
45+
ForEach(0..<10) { index in
46+
Rectangle()
47+
.fill(.blue)
48+
.scheduledEffect(
49+
.opacity(Double(index) / 10),
50+
interval: 1
51+
)
52+
}
53+
}
54+
.ignoresSafeArea()
55+
}
56+
}

0 commit comments

Comments
 (0)