-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathView+.swift
More file actions
56 lines (48 loc) · 1.64 KB
/
Copy pathView+.swift
File metadata and controls
56 lines (48 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//
// View+.swift
// DevLog
//
// Created by 최윤진 on 11/22/25.
//
import SwiftUI
extension View {
var sceneWidth: CGFloat {
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene
else { return UIScreen.main.bounds.width }
return windowScene.screen.bounds.width
}
var sceneHeight: CGFloat {
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene
else { return UIScreen.main.bounds.height }
return windowScene.screen.bounds.height
}
var safeAreaInsets: UIEdgeInsets {
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
let window = windowScene.windows.first
else { return UIEdgeInsets.zero }
return window.safeAreaInsets
}
@ViewBuilder
func adaptiveButtonStyle(_ color: Color? = nil) -> some View {
if #available(iOS 26.0, *), color == nil {
self.buttonStyle(.glass)
} else {
self.foregroundStyle(Color(.label))
.font(.footnote)
.padding(.vertical, 8)
.padding(.horizontal, 16)
.background {
Capsule()
.fill(.ultraThinMaterial)
.background {
Capsule()
.fill(color ?? Color.clear)
}
.overlay {
Capsule()
.stroke(Color.white.opacity(0.2), lineWidth: 1)
}
}
}
}
}