Skip to content

Commit 67ea757

Browse files
committed
Added more stuff.
1 parent e21966d commit 67ea757

File tree

12 files changed

+239
-30
lines changed

12 files changed

+239
-30
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import SwiftUI
2+
3+
extension View {
4+
5+
public func symbolEffectCompability(_ model: SymbolEffectCompability) -> some View {
6+
return self
7+
/*if #available(iOS 17, *) {
8+
switch model {
9+
case .pulse:
10+
return self.symbolEffect(.pulse)
11+
default:
12+
return self
13+
}
14+
} else {
15+
return self
16+
}*/
17+
}
18+
19+
public func scrollTargetBehaviorCompability22() -> some View {
20+
if #available(iOS 17.0, watchOS 10.0, macOS 14.0, *) {
21+
return self.scrollTargetBehavior(.viewAligned)
22+
} else {
23+
return self
24+
}
25+
}
26+
}
27+
28+
public enum SymbolEffectCompability {
29+
30+
case pulse
31+
}
32+

Sources/SwiftUIExtension/Compability/ViewCompability.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ extension View {
1818
}
1919
}
2020

21-
public func fontWeightCompability(_ weight: Font.Weight) -> some View {
21+
/*public func fontWeightCompability(_ weight: Font.Weight) -> some View {
2222
if #available(iOS 16.0, watchOS 9.0, macOS 13.0, *) {
2323
return self.fontWeight(weight)
2424
} else {
2525
return self
2626
}
27-
}
27+
}*/
2828

2929
public func invalidatableContentCompability() -> some View {
3030
if #available(iOS 17.0, watchOS 10.0, macOS 14.0, *) {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import SwiftUI
2+
3+
extension View {
4+
5+
public func matchedTransitionSourceCompability(id: some Hashable, in namespace: Namespace.ID) -> some View {
6+
if #available(iOS 18.0, macOS 14.0, visionOS 2.0, *) {
7+
return self.matchedTransitionSource(id: id, in: namespace)
8+
} else {
9+
return self
10+
}
11+
}
12+
13+
public func navigationTransitionZoom(id: some Hashable, in namespace: Namespace.ID) -> some View {
14+
if #available(iOS 18.0, macOS 14.0, visionOS 2.0, *) {
15+
return self.navigationTransition(.zoom(sourceID: id, in: namespace))
16+
} else {
17+
return self
18+
}
19+
}
20+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import SwiftUI
2+
import SwiftBoost
3+
4+
extension View {
5+
6+
public func higlight<S>(clipShape: S) -> some View where S : Shape {
7+
self.modifier(HiglightModifier(clipShape: clipShape))
8+
}
9+
}
10+
11+
struct HiglightModifier<S>: ViewModifier where S : Shape {
12+
13+
@State private var isAnimatingHiglight = false
14+
@State private var isAnimatingScale = false
15+
16+
private let clipShape: S
17+
18+
private var higlightDuration: TimeInterval = 1
19+
private var calmDuration: TimeInterval = 3
20+
private var changeAppearanceDuration: TimeInterval = 0.26
21+
22+
private var blinkWidth: CGFloat { 18 }
23+
private var scale: CGFloat = 0.94
24+
25+
init(clipShape: S) {
26+
self.clipShape = clipShape
27+
}
28+
29+
func body(content: Content) -> some View {
30+
content
31+
.overlay {
32+
GeometryReader { proxy in
33+
Rectangle()
34+
.blur(radius: 6)
35+
.vibrant(0.7)
36+
.frame(width: blinkWidth)
37+
.frame(height: proxy.size.height * 2)
38+
.rotationEffect(.degrees(45))
39+
.position(
40+
x: isAnimatingHiglight ? (proxy.size.width + proxy.size.height) : (0 - proxy.size.height),
41+
y: proxy.size.height / 2
42+
)
43+
.clipShape(clipShape)
44+
.animation(isAnimatingHiglight ? .interpolatingSpring(duration: higlightDuration) : .none, value: isAnimatingHiglight)
45+
}
46+
}
47+
.scaleEffect(isAnimatingScale ? scale : 1)
48+
.animation(.interpolatingSpring(duration: changeAppearanceDuration), value: isAnimatingScale)
49+
.onAppear {
50+
run()
51+
}
52+
}
53+
54+
private func run() {
55+
56+
isAnimatingHiglight = true
57+
isAnimatingScale = true
58+
59+
delay(higlightDuration / 2) {
60+
isAnimatingScale = false
61+
}
62+
63+
delay(higlightDuration) {
64+
isAnimatingHiglight = false
65+
delay(calmDuration) {
66+
self.run()
67+
}
68+
}
69+
}
70+
}

Sources/SwiftUIExtension/Extensions/View+Layout.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import SwiftUI
22

3-
extension View {
3+
#warning("todo to del")
4+
/*extension View {
45

56
public func horizontalSystemPadding(to view: HorizontalSystemPadding.PaddingView) -> some View {
7+
68
modifier(HorizontalSystemPadding(paddingView: view))
79
}
810

@@ -35,7 +37,7 @@ public struct HorizontalSystemPadding: ViewModifier {
3537
@Environment(\.horizontalSizeClass) var horizontalSizeClass
3638

3739
public func body(content: Content) -> some View {
38-
switch paddingView {
40+
/*switch paddingView {
3941
case .scroll:
4042
if #available(iOS 17.0, macOS 14.0, watchOS 10.0, *) {
4143
content
@@ -45,7 +47,8 @@ public struct HorizontalSystemPadding: ViewModifier {
4547
}
4648
case .view:
4749
content.padding(.horizontal, value)
48-
}
50+
}*/
51+
content
4952
}
5053

5154
public enum PaddingView {
@@ -54,3 +57,4 @@ public struct HorizontalSystemPadding: ViewModifier {
5457
case view
5558
}
5659
}
60+
*/

Sources/SwiftUIExtension/Extensions/ViewExtension.swift

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,12 @@ import SwiftUI
22

33
extension View {
44

5-
6-
7-
}
8-
9-
10-
11-
// MARK: - Only iOS
12-
13-
14-
15-
extension View {
16-
17-
public func addBorder<S>(_ content: S, width: CGFloat = 1, cornerRadius: CGFloat, style: RoundedCornerStyle = .continuous) -> some View where S : ShapeStyle {
5+
public func clipShapeWithBorder<S>(_ content: S, width: CGFloat = 1, cornerRadius: CGFloat, style: RoundedCornerStyle = .continuous) -> some View where S : ShapeStyle {
186

197
let roundedRect = RoundedRectangle(cornerRadius: cornerRadius, style: style)
208

21-
return clipShape(roundedRect)
9+
return self
10+
.clipShape(roundedRect)
2211
.overlay(roundedRect.strokeBorder(content, lineWidth: width))
2312
}
2413
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import SwiftUI
2+
3+
extension View {
4+
5+
func vibrant(_ intensity: CGFloat) -> some View {
6+
self.modifier(VibrantModifier(intensity: intensity))
7+
}
8+
}
9+
10+
struct VibrantModifier: ViewModifier {
11+
12+
let intensity: CGFloat
13+
14+
init(intensity: CGFloat) {
15+
self.intensity = intensity
16+
}
17+
18+
func body(content: Content) -> some View {
19+
content
20+
.foregroundColor(.white.opacity(1 - intensity))
21+
.blendMode(.plusLighter)
22+
}
23+
}

Sources/SwiftUIExtension/Views/Mimicrate/ModalHeaderView.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public struct ModalHeaderView: View {
2121
.resizable()
2222
.scaledToFit()
2323
.foregroundColor(.accentColor)
24-
.fontWeightCompability(.regular)
24+
.font(.body.weight(.regular))
2525
.frame(width: 52)
2626
}, title: title, body: body)
2727
}
@@ -35,8 +35,7 @@ public struct ModalHeaderView: View {
3535

3636
VStack(spacing: 8) {
3737
Text(titleText)
38-
.font(.title)
39-
.fontWeight(.semibold)
38+
.font(.title.weight(.semibold))
4039
.foregroundStyle(.primary)
4140
Text(bodyText)
4241
.font(.subheadline)

Sources/SwiftUIExtension/Views/Mimicrate/NativeSection.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,10 @@ public struct NativeSection<Content: View, Detail: View>: View {
3535
HStack(alignment: .firstTextBaseline, spacing: Spaces.step) {
3636
Text(title)
3737
.foregroundColor(.primary)
38-
.font(.title2)
39-
.fontWeightCompability(.bold)
38+
.font(.title2.weight(.bold))
4039
Image(systemName: "chevron.right")
4140
.foregroundColor(.secondary)
42-
.font(.footnote)
43-
.fontWeightCompability(.heavy)
41+
.font(.footnote.weight(.heavy))
4442
}
4543
.baselineOffsetCompability(-1.5)
4644
//.padding(.leading, Spaces.default)
@@ -77,8 +75,7 @@ public struct NativeSection<Content: View, Detail: View>: View {
7775
VStack {
7876
Text(title)
7977
.foregroundColor(.primary)
80-
.font(.title2)
81-
.fontWeightCompability(.bold)
78+
.font(.title2.weight(.bold))
8279
//.padding(.leading, Spaces.default)
8380
//.frame(maxWidth: .infinity, alignment: .leading)
8481
}

Sources/SwiftUIExtension/Views/Mimicrate/ScrollWithBottomContent.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ public struct ScrollWithBottomContent<Content: View, Bottom: View>: View {
2828
.padding(.top, topFade ?? .zero)
2929
.padding(.bottom, bottomFade ?? .zero)
3030
}
31-
.horizontalSystemPadding(to: .scroll)
31+
.fitGuide(.layoutMargings, padding: .scroll)
3232
.fade(top: topFade, bottom: bottomFade)
3333
.safeAreaInset(edge: .bottom) {
3434
bottom()
3535
.padding(.bottom, Spaces.default_more)
36-
.horizontalSystemPadding(to: .view)
36+
.fitGuide(.layoutMargings)
3737
}
3838
}
3939
}

0 commit comments

Comments
 (0)