Skip to content

Commit 590a3d0

Browse files
committed
Improved view modifier names
1 parent 8ffa1b7 commit 590a3d0

File tree

8 files changed

+65
-60
lines changed

8 files changed

+65
-60
lines changed

‎README.md‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,22 @@ The following modifiers are available to customize the sticker effect:
3737

3838
| Modifier | Default Value | Description |
3939
|----------|---------------|-------------|
40-
| `.stickerEffectScale(_:)` | 1.4 | Controls the overall scale of the effect pattern |
41-
| `.stickerEffectIntensity(_:)` | 0.8 | Adjusts the strength of the holographic effect |
42-
| `.stickerEffectContrast(_:)` | 0.9 | Modifies the contrast between light and dark areas |
43-
| `.stickerEffectBlendFactor(_:)` | 0.4 | Controls how much the effect blends with the original content |
44-
| `.stickerEffectNoiseScale(_:)` | 140.0 | Adjusts the scale of the noise pattern |
45-
| `.stickerEffectNoiseIntensity(_:)` | 0.1 | Controls the intensity of the noise effect |
46-
| `.stickerEffectLightIntensity(_:)` | 0.3 | Adjusts the intensity of the light reflection |
40+
| `.stickerScale(_:)` | 1.4 | Controls the overall scale of the effect pattern |
41+
| `.stickerIntensity(_:)` | 0.8 | Adjusts the strength of the holographic effect |
42+
| `.stickerContrast(_:)` | 0.9 | Modifies the contrast between light and dark areas |
43+
| `.stickerBlend(_:)` | 0.4 | Controls how much the effect blends with the original content |
44+
| `.stickerNoiseScale(_:)` | 140.0 | Adjusts the scale of the noise pattern |
45+
| `.stickerNoiseIntensity(_:)` | 0.1 | Controls the intensity of the noise effect |
46+
| `.stickerLightIntensity(_:)` | 0.3 | Adjusts the intensity of the light reflection |
4747

4848
Example usage:
4949

5050
```swift
5151
Image(.stickerIcon)
5252
.stickerEffect()
53-
.stickerEffectIntensity(0.5)
54-
.stickerEffectNoiseScale(200)
55-
.stickerEffectLightIntensity(0.5)
53+
.stickerIntensity(0.5)
54+
.stickerNoiseScale(200)
55+
.stickerLightIntensity(0.5)
5656
```
5757

5858
## Motion

‎Sources/Sticker/StickerEffect/StickerEffect.swift‎

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// File.swift
2+
// StickerEffect.swift
33
// Sticker
44
//
55
// Created by Benjamin Pisano on 03/11/2024.
@@ -11,32 +11,37 @@ private struct StickerEffectViewModifier: ViewModifier {
1111
@State private var motion: StickerMotion = .init()
1212

1313
@Environment(\.stickerMotionEffect) private var effect
14-
@Environment(\.stickerEffectScale) private var stickerEffectScale
15-
@Environment(\.stickerEffectIntensity) private var stickerEffectIntensity
16-
@Environment(\.stickerEffectContrast) private var stickerEffectContrast
17-
@Environment(\.stickerEffectBlendFactor) private var stickerEffectBlendFactor
18-
@Environment(\.stickerEffectNoiseScale) private var stickerEffectNoiseScale
19-
@Environment(\.stickerEffectNoiseIntensity) private var stickerEffectNoiseIntensity
20-
@Environment(\.stickerEffectLightIntensity) private var stickerEffectLightIntensity
14+
@Environment(\.stickerScale) private var stickerScale
15+
@Environment(\.stickerIntensity) private var stickerIntensity
16+
@Environment(\.stickerContrast) private var stickerContrast
17+
@Environment(\.stickerBlend) private var stickerBlend
18+
@Environment(\.stickerNoiseScale) private var stickerNoiseScale
19+
@Environment(\.stickerNoiseIntensity) private var stickerNoiseIntensity
20+
@Environment(\.stickerLightIntensity) private var stickerLightIntensity
2121

2222
func body(content: Content) -> some View {
2323
content
24-
.visualEffect { [motion, stickerEffectScale, stickerEffectIntensity, stickerEffectContrast, stickerEffectBlendFactor, stickerEffectNoiseScale, stickerEffectNoiseIntensity] view, proxy in
24+
.visualEffect {
25+
[
26+
motion, stickerScale, stickerIntensity, stickerContrast, stickerBlend,
27+
stickerNoiseScale, stickerNoiseIntensity
28+
] view, proxy in
2529
view
2630
.colorEffect(
2731
ShaderLibrary.foilShader(
28-
offset: motion.isActive ? (motion.transform * -150).point : StickerTransform.neutral.point,
32+
offset: motion.isActive
33+
? (motion.transform * -150).point : StickerTransform.neutral.point,
2934
size: proxy.size,
30-
scale: stickerEffectScale,
31-
intensity: stickerEffectIntensity,
32-
contrast: stickerEffectContrast,
33-
blendFactor: stickerEffectBlendFactor,
34-
noiseScale: stickerEffectNoiseScale,
35-
noiseIntensity: stickerEffectNoiseIntensity
35+
scale: stickerScale,
36+
intensity: stickerIntensity,
37+
contrast: stickerContrast,
38+
blendFactor: stickerBlend,
39+
noiseScale: stickerNoiseScale,
40+
noiseIntensity: stickerNoiseIntensity
3641
)
3742
)
3843
}
39-
.visualEffect { [motion, stickerEffectLightIntensity] view, proxy in
44+
.visualEffect { [motion, stickerLightIntensity] view, proxy in
4045
view
4146
.colorEffect(
4247
ShaderLibrary.reflectionShader(
@@ -46,7 +51,7 @@ private struct StickerEffectViewModifier: ViewModifier {
4651
y: motion.transform.y
4752
),
4853
reflectionSize: Float(min(proxy.size.width, proxy.size.height) / 2),
49-
reflectionIntensity: motion.isActive ? stickerEffectLightIntensity : 0
54+
reflectionIntensity: motion.isActive ? stickerLightIntensity : 0
5055
)
5156
)
5257
}
@@ -66,9 +71,9 @@ private struct StickerEffectViewModifier: ViewModifier {
6671
}
6772
}
6873

69-
public extension View {
74+
extension View {
7075
@ViewBuilder
71-
func stickerEffect(_ isEnabled: Bool = true) -> some View {
76+
public func stickerEffect(_ isEnabled: Bool = true) -> some View {
7277
if isEnabled {
7378
modifier(StickerEffectViewModifier())
7479
} else {
Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// File.swift
2+
// StickerEffectParameter.swift
33
// Sticker
44
//
55
// Created by Benjamin Pisano on 05/11/2024.
@@ -8,41 +8,41 @@
88
import SwiftUI
99

1010
extension EnvironmentValues {
11-
@Entry var stickerEffectScale: Float = 1.4
12-
@Entry var stickerEffectIntensity: Float = 0.8
13-
@Entry var stickerEffectContrast: Float = 0.9
14-
@Entry var stickerEffectBlendFactor: Float = 0.4
15-
@Entry var stickerEffectNoiseScale: Float = 140
16-
@Entry var stickerEffectNoiseIntensity: Float = 0.1
17-
@Entry var stickerEffectLightIntensity: Float = 0.3
11+
@Entry var stickerScale: Float = 1.4
12+
@Entry var stickerIntensity: Float = 0.8
13+
@Entry var stickerContrast: Float = 0.9
14+
@Entry var stickerBlend: Float = 0.4
15+
@Entry var stickerNoiseScale: Float = 140
16+
@Entry var stickerNoiseIntensity: Float = 0.1
17+
@Entry var stickerLightIntensity: Float = 0.3
1818
}
1919

20-
public extension View {
21-
func stickerEffectScale(_ scale: Float) -> some View {
22-
environment(\.stickerEffectScale, scale)
20+
extension View {
21+
public func stickerScale(_ scale: Float) -> some View {
22+
environment(\.stickerScale, scale)
2323
}
2424

25-
func stickerEffectIntensity(_ intensity: Float) -> some View {
26-
environment(\.stickerEffectIntensity, intensity)
25+
public func stickerIntensity(_ intensity: Float) -> some View {
26+
environment(\.stickerIntensity, intensity)
2727
}
2828

29-
func stickerEffectContrast(_ contrast: Float) -> some View {
30-
environment(\.stickerEffectContrast, contrast)
29+
public func stickerContrast(_ contrast: Float) -> some View {
30+
environment(\.stickerContrast, contrast)
3131
}
3232

33-
func stickerEffectBlendFactor(_ blendFactor: Float) -> some View {
34-
environment(\.stickerEffectBlendFactor, blendFactor)
33+
public func stickerBlend(_ blendFactor: Float) -> some View {
34+
environment(\.stickerBlend, blendFactor)
3535
}
3636

37-
func stickerEffectNoiseScale(_ scale: Float) -> some View {
38-
environment(\.stickerEffectNoiseScale, scale)
37+
public func stickerNoiseScale(_ scale: Float) -> some View {
38+
environment(\.stickerNoiseScale, scale)
3939
}
4040

41-
func stickerEffectNoiseIntensity(_ intensity: Float) -> some View {
42-
environment(\.stickerEffectNoiseIntensity, intensity)
41+
public func stickerNoiseIntensity(_ intensity: Float) -> some View {
42+
environment(\.stickerNoiseIntensity, intensity)
4343
}
4444

45-
func stickerEffectLightIntensity(_ intensity: Float) -> some View {
46-
environment(\.stickerEffectLightIntensity, intensity)
45+
public func stickerLightIntensity(_ intensity: Float) -> some View {
46+
environment(\.stickerLightIntensity, intensity)
4747
}
4848
}

‎Sources/Sticker/StickerMotion/StickerMotion.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// File.swift
2+
// StickerMotion.swift
33
// Sticker
44
//
55
// Created by Benjamin Pisano on 04/11/2024.

‎Sources/Sticker/StickerMotionEffect/Effects/IdentityStickerTransformer.swift‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// File.swift
2+
// IdentityStickerTransformer.swift
33
// Sticker
44
//
55
// Created by Benjamin Pisano on 03/11/2024.
@@ -13,8 +13,8 @@ public struct IdentityStickerTransformer: StickerMotionEffect {
1313
}
1414
}
1515

16-
public extension StickerMotionEffect where Self == IdentityStickerTransformer {
17-
static var identity: Self {
16+
extension StickerMotionEffect where Self == IdentityStickerTransformer {
17+
public static var identity: Self {
1818
.init()
1919
}
2020
}

‎Sources/Sticker/Utils/Extensions/ShaderLibraryExtension.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// File.swift
2+
// ShaderLibraryExtension.swift
33
// Sticker
44
//
55
// Created by Benjamin Pisano on 03/11/2024.

‎Sources/Sticker/Utils/ViewSize/ViewSizePreferenceKey.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// File.swift
2+
// ViewSizePreferenceKey.swift
33
// Sticker
44
//
55
// Created by Benjamin Pisano on 03/11/2024.

‎Sources/Sticker/Utils/ViewSize/WithViewSizeViewModifier.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// File.swift
2+
// WithViewSizeViewModifier.swift
33
// Sticker
44
//
55
// Created by Benjamin Pisano on 03/11/2024.

0 commit comments

Comments
 (0)