Skip to content

Commit 30cdb36

Browse files
committed
2.0.1
1 parent ee6a841 commit 30cdb36

File tree

11 files changed

+192
-81
lines changed

11 files changed

+192
-81
lines changed

.github/workflows/swift.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# This workflow will build a Swift project
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift
3+
4+
name: Build
5+
6+
on:
7+
push:
8+
branches: [ "main" ]
9+
pull_request:
10+
branches: [ "main" ]
11+
12+
jobs:
13+
build:
14+
runs-on: macos-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Set up Xcode version
18+
run: sudo xcode-select -s /Applications/Xcode_16.2.app/Contents/Developer
19+
- name: Show available destinations
20+
run: xcodebuild -scheme Ignition -showdestinations
21+
- name: Build for macOS
22+
run: xcodebuild -scheme Ignition -destination 'platform=macOS' build
23+
- name: Build for Catalyst
24+
run: xcodebuild -scheme Ignition -destination 'platform=macOS,variant=Mac Catalyst' build
25+
- name: Build for iOS
26+
run: xcodebuild -scheme Ignition -destination 'platform=iOS Simulator,name=iPhone 16' build
27+
- name: Build for watchOS
28+
run: xcodebuild -scheme Ignition -destination 'platform=watchOS Simulator,name=Apple Watch Ultra 2 (49mm)' build
29+
- name: Build for tvOS
30+
run: xcodebuild -scheme Ignition -destination 'platform=tvOS Simulator,name=Apple TV 4K (3rd generation)' build
31+
- name: Build for visionOS
32+
run: xcodebuild -scheme Ignition -destination 'platform=visionOS Simulator,name=Apple Vision Pro' build

.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

.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist

Lines changed: 0 additions & 8 deletions
This file was deleted.

.swiftpm/xcode/xcshareddata/xcschemes/Ignition.xcscheme

Lines changed: 0 additions & 66 deletions
This file was deleted.

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.0.4"),
22+
.package(url: "https://github.com/nathantannar4/Engine", from: "2.1.14"),
2323
],
2424
targets: [
2525
.target(

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ let package = Package(
5050
)
5151
```
5252

53+
## Documentation
54+
55+
Detailed documentation is available [here](https://swiftpackageindex.com/nathantannar4/Ignition/main/documentation/ignition).
56+
5357
## Effects
5458

5559
`Ignition` provides 5 built in effects, but you can also make your own by conforming to the `ViewEffect` protocol.

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
}

0 commit comments

Comments
 (0)