Skip to content

Commit

Permalink
Merge pull request #72 from paololeonardi/visionOS
Browse files Browse the repository at this point in the history
Add Support for visionOS
  • Loading branch information
paololeonardi authored Jul 25, 2024
2 parents d902037 + e3dd026 commit c7c0865
Show file tree
Hide file tree
Showing 23 changed files with 381 additions and 79 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/run-tests-WaterfallGridSample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,8 @@ jobs:
- name: Build (tvOS)
run: xcodebuild build -scheme WaterfallGrid -destination "platform=tvOS Simulator,OS=17.5,name=Apple TV" | xcpretty

- name: Build (visionOS)
run: xcodebuild build -scheme WaterfallGrid -destination "platform=visionOS Simulator,OS=1.2,name=Apple Vision Pro" | xcpretty

- name: Build (watchOS)
run: xcodebuild build -scheme WaterfallGrid -destination "platform=watchOS Simulator,OS=10.5,name=Apple Watch Ultra 2 (49mm)" | xcpretty
3 changes: 2 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.1
// swift-tools-version:5.9

//
// Copyright © 2019 Paolo Leonardi.
Expand All @@ -14,6 +14,7 @@ let package = Package(
.iOS(.v13),
.macOS(.v10_15),
.tvOS(.v13),
.visionOS(.v1),
.watchOS(.v6)
],
products: [
Expand Down
23 changes: 4 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,8 @@ A waterfall grid layout view for SwiftUI.
<img src="https://paololeonardi.github.io/waterfallgrid/resources/demo1.png" alt="Image Demo 1"/>
</p>

<p align="center">
<img src="https://img.shields.io/badge/Swift-5.1-red?style=flat" />
<img src="https://img.shields.io/cocoapods/p/WaterfallGrid" />
<a href="https://swift.org/package-manager">
<img src="https://img.shields.io/badge/spm-compatible-brightgreen.svg?style=flat" alt="Swift Package Manager" />
</a>
<img src="https://img.shields.io/cocoapods/v/WaterfallGrid?color=blue" />
<a href="https://twitter.com/paololeonardi">
<img src="https://img.shields.io/badge/[email protected]?style=flat" alt="Twitter: @paololeonardi" />
</a>
</p>
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fpaololeonardi%2FWaterfallGrid%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/paololeonardi/WaterfallGrid)
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fpaololeonardi%2FWaterfallGrid%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/paololeonardi/WaterfallGrid)

## Features

Expand All @@ -26,12 +17,6 @@ A waterfall grid layout view for SwiftUI.
- [x] Horizontal or vertical scroll direction.
- [x] Items update can be animated.

## Requirements

- iOS 13.0+ / macOS 10.15+ / tvOS 13.0+ / watchOS 6.0+
- Xcode 11.0+
- Swift 5.1+

## Usage

### Initialization
Expand Down Expand Up @@ -174,7 +159,7 @@ Add it as a dependency within your `Package.swift` manifest:

```swift
dependencies: [
.package(url: "https://github.com/paololeonardi/WaterfallGrid.git", from: "1.0.0")
.package(url: "https://github.com/paololeonardi/WaterfallGrid.git", from: "1.1.0")
]
```

Expand All @@ -183,7 +168,7 @@ dependencies: [
You can install `WaterfallGrid` via CocoaPods by adding the following line to your `Podfile`:

```ruby
pod 'WaterfallGrid', '~> 1.0.0'
pod 'WaterfallGrid', '~> 1.1.0'
```

Run the `pod install` command to download the library
Expand Down
2 changes: 1 addition & 1 deletion Sources/WaterfallGrid/Environment/GridSyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct GridSyle {
let animation: Animation?

var columns: Int {
#if os(OSX) || os(tvOS) || targetEnvironment(macCatalyst)
#if os(OSX) || os(tvOS) || targetEnvironment(macCatalyst) || os(visionOS)
return columnsInLandscape
#elseif os(watchOS)
return columnsInPortrait
Expand Down
1 change: 1 addition & 0 deletions Sources/WaterfallGrid/View+GridStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ extension View {
/// - Parameter animation: The animation to apply when data change. If `animation` is `nil`, the grid doesn't animate.
@available(OSX, unavailable)
@available(tvOS, unavailable)
@available(visionOS, unavailable)
@available(watchOS, unavailable)
public func gridStyle(
columnsInPortrait: Int = 2,
Expand Down
4 changes: 2 additions & 2 deletions Sources/WaterfallGrid/WaterfallGrid.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import SwiftUI

/// A container that presents items of variable heights arranged in a grid.
@available(iOS 13, OSX 10.15, tvOS 13, watchOS 6, *)
@available(iOS 13, OSX 10.15, tvOS 13, visionOS 1, watchOS 6, *)
public struct WaterfallGrid<Data, ID, Content>: View where Data : RandomAccessCollection, Content : View, ID : Hashable {

@Environment(\.gridStyle) private var style
Expand Down Expand Up @@ -61,7 +61,7 @@ public struct WaterfallGrid<Data, ID, Content>: View where Data : RandomAccessCo
.opacity(self.alignmentGuides[element[keyPath: self.dataId]] != nil ? 1 : 0)
}
}
.animation(self.loaded ? self.style.animation : nil)
.animation(self.loaded ? self.style.animation : nil, value: UUID())
}

// MARK: - Helpers
Expand Down
4 changes: 2 additions & 2 deletions WaterfallGrid.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = "WaterfallGrid"
spec.version = "1.0.1"
spec.version = "1.1.0"
spec.summary = "A waterfall grid layout view for SwiftUI."
spec.homepage = "https://github.com/paololeonardi/WaterfallGrid"

Expand All @@ -14,7 +14,7 @@ Pod::Spec.new do |spec|
spec.watchos.deployment_target = "6.0"
spec.tvos.deployment_target = "13.0"

spec.swift_version = '5.1'
spec.swift_version = '5.9'

spec.source = { :git => "https://github.com/paololeonardi/WaterfallGrid.git", :tag => "#{spec.version}" }

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"images" : [
{
"filename" : "[email protected]",
"idiom" : "vision",
"scale" : "2x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"info" : {
"author" : "xcode",
"version" : 1
},
"layers" : [
{
"filename" : "Front.solidimagestacklayer"
},
{
"filename" : "Middle.solidimagestacklayer"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"idiom" : "vision",
"scale" : "2x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"images" : [
{
"filename" : "[email protected]",
"idiom" : "vision",
"scale" : "2x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
15 changes: 15 additions & 0 deletions WaterfallGridSample/WaterfallGridSample visionOS/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationPreferredDefaultSceneSessionRole</key>
<string>UIWindowSceneSessionRoleApplication</string>
<key>UIApplicationSupportsMultipleScenes</key>
<true/>
<key>UISceneConfigurations</key>
<dict/>
</dict>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// Copyright © 2024 Paolo Leonardi.
//
// Licensed under the MIT license. See the LICENSE file for more info.
//

import SwiftUI

@main
struct WaterfallGridSample_visionOSApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
Loading

0 comments on commit c7c0865

Please sign in to comment.