Skip to content

Commit

Permalink
visionOS
Browse files Browse the repository at this point in the history
  • Loading branch information
xnth97 committed Jan 27, 2024
1 parent e060123 commit c4b8e7d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
12 changes: 5 additions & 7 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"]),
]
)
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"))
]
```

Expand Down
22 changes: 18 additions & 4 deletions Sources/SymbolPicker/SymbolPicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand All @@ -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))
Expand All @@ -246,7 +258,7 @@ public struct SymbolPicker: View {
#endif
searchableSymbolGrid

#if os(iOS)
#if os(iOS) || os(visionOS)
if canDeleteIcon {
VStack {
Spacer()
Expand All @@ -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"))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/SymbolPicker/Symbols.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit c4b8e7d

Please sign in to comment.