summaryrefslogtreecommitdiff
path: root/macos/Sources/Helpers/Extensions/View+Extension.swift
blob: fb6e0c20f0add4a37901ddb3628bfa6ceacd891f (plain)
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
import SwiftUI

extension View {
    func innerShadow<S: Shape, ST: ShapeStyle>(
        using shape: S = Rectangle(),
        stroke: ST = Color.black,
        width: CGFloat = 6,
        blur: CGFloat = 6
    ) -> some View {
        return self
            .overlay(
                shape
                    .stroke(stroke, lineWidth: width)
                    .blur(radius: blur)
                    .mask(shape)
            )
    }
}

extension View {
    func pointerStyleFromCursor(_ cursor: NSCursor) -> some View {
        if #available(macOS 15.0, *) {
            return self.pointerStyle(.image(
                Image(nsImage: cursor.image),
                hotSpot: .init(x: cursor.hotSpot.x, y: cursor.hotSpot.y)
            ))
        } else {
            return self
        }
    }
}