diff --git a/Package.swift b/Package.swift index 1c7c1ed..920bc5e 100644 --- a/Package.swift +++ b/Package.swift @@ -15,23 +15,21 @@ let package = Package( products: [ .library( name: "SymbolPicker", - targets: ["SymbolPicker"] - ), + targets: ["SymbolPicker"]), ], dependencies: [ ], targets: [ .target( name: "SymbolPicker", - dependencies: [], + dependencies: [ + ], path: "Sources/SymbolPicker", resources: [ .process("Resources"), - ] - ), + ]), .testTarget( name: "SymbolPickerTests", - dependencies: ["SymbolPicker"] - ), + dependencies: ["SymbolPicker"]), ] ) diff --git a/README.md b/README.md index 2014307..1e1f9dc 100644 --- a/README.md +++ b/README.md @@ -11,10 +11,6 @@ SymbolPicker provides a simple and cross-platform interface for picking a SFSymb ![](/Screenshots/demo.png) -### visionOS - -Please use [xrOS branch](https://github.com/xnth97/SymbolPicker/tree/xrOS) for visionOS. Main branch should also work fine out-of-box thanks to SwiftUI, but I'll be experimenting visionOS-only features on xrOS branch. - ![](/Screenshots/xros.png) ## Usage @@ -31,7 +27,7 @@ SymbolPicker is available as a Swift Package. Add this repo to your project thro ```swift dependencies: [ - .package(url: "https://github.com/xnth97/SymbolPicker.git", .upToNextMajor(from: "1.4.0")) + .package(url: "https://github.com/xnth97/SymbolPicker.git", .upToNextMajor(from: "1.5.0")) ] ``` diff --git a/Sources/SymbolPicker/SymbolPicker.swift b/Sources/SymbolPicker/SymbolPicker.swift index 47c01d3..f4f7ba7 100644 --- a/Sources/SymbolPicker/SymbolPicker.swift +++ b/Sources/SymbolPicker/SymbolPicker.swift @@ -76,6 +76,14 @@ public struct SymbolPicker: View { #endif } + private static var deleteButtonTextVerticalPadding: CGFloat { + #if os(iOS) + return 12.0 + #else + return 8.0 + #endif + } + // MARK: - Properties @Binding public var symbol: String? @@ -191,7 +199,11 @@ public struct SymbolPicker: View { .frame(maxWidth: .infinity, minHeight: Self.gridDimension) #endif .background(Self.selectedItemBackgroundColor) + #if os(visionOS) + .clipShape(Circle()) + #else .cornerRadius(Self.symbolCornerRadius) + #endif .foregroundColor(.white) } else { Image(systemName: thisSymbol) @@ -210,7 +222,7 @@ public struct SymbolPicker: View { } .padding(.horizontal) - #if os(iOS) + #if os(iOS) || os(visionOS) /// Avoid last row being hidden. if canDeleteIcon { Spacer() @@ -230,7 +242,7 @@ public struct SymbolPicker: View { .frame(maxWidth: .infinity) #endif #if !os(watchOS) - .padding(.vertical, 12.0) + .padding(.vertical, Self.deleteButtonTextVerticalPadding) #endif .background(Self.unselectedItemBackgroundColor) .clipShape(RoundedRectangle(cornerRadius: 12.0, style: .continuous)) @@ -246,7 +258,7 @@ public struct SymbolPicker: View { #endif searchableSymbolGrid - #if os(iOS) + #if os(iOS) || os(visionOS) if canDeleteIcon { VStack { Spacer() @@ -265,8 +277,10 @@ public struct SymbolPicker: View { /// tvOS can use back button on remote .toolbar { ToolbarItem(placement: .cancellationAction) { - Button(LocalizedString("cancel")) { + Button { dismiss() + } label: { + Text(LocalizedString("cancel")) } } } diff --git a/Sources/SymbolPicker/Symbols.swift b/Sources/SymbolPicker/Symbols.swift index d9aefb6..941a0e0 100644 --- a/Sources/SymbolPicker/Symbols.swift +++ b/Sources/SymbolPicker/Symbols.swift @@ -17,7 +17,7 @@ class Symbols { let allSymbols: [String] private init() { - if #available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *) { + if #available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, visionOS 1.0, *) { self.allSymbols = Self.fetchSymbols(fileName: "sfsymbol5") } else if #available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *) { self.allSymbols = Self.fetchSymbols(fileName: "sfsymbol4")