Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Swift Package Manager #8

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// swift-tools-version: 5.8
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "YMTreeMap",
platforms: [
.iOS(.v11),
.macOS(.v10_13),
],
products: [
// Products define the executables and libraries a package produces, making them visible to other packages.
.library(
name: "YMTreeMap",
targets: ["YMTreeMap"]
)
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.target(
name: "YMTreeMap",
path: "",
exclude: ["Example", "Research"],
sources: ["YMTreeMap.swift"]
)
]
)
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ The output rectangles can easily be used to render the shapes using whatever ren
- Using CoreGraphics (in drawRect, etc)
- Using OpenGL
- Using a custom UICollectionView layout
- Using a SwiftUI view

## Usage

Expand Down Expand Up @@ -100,13 +101,17 @@ To run the example project, clone the repo, and run `pod install` from the Examp

## Installation

YMTreeMap is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:
YMTreeMap is available through [CocoaPods](http://cocoapods.org) and [Swift Package Manager](https://www.swift.org/package-manager/).
To install it, simply add the following line to your Podfile or Package.swift file:

```ruby
pod 'YMTreeMap'
```

```swift
.package(name: "YMTreeMap", url: "https://github.com/yahoo/YMTreeMap.git",
```

## Further Reading

Various papers on treemapping layout algorithms and usability that helped influence this project. A copy of each paper is in the Research folder.
Expand Down
7 changes: 4 additions & 3 deletions YMTreeMap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Copyright 2017 Yahoo Holdings Inc.

import Foundation
import CoreGraphics

@objc public class YMTreeMap: NSObject {

Expand Down Expand Up @@ -291,7 +292,7 @@ import Foundation

// MARK: Platform Extensions for NSRect/CGRect

public extension YMTreeMap {
extension YMTreeMap {

#if os(iOS) || os(tvOS) || os(watchOS)
public typealias SystemRect = CGRect
Expand All @@ -305,13 +306,13 @@ public extension YMTreeMap {
}
}

internal extension YMTreeMap.Rect {
extension YMTreeMap.Rect {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, what’s the right way to do this now? Ideally public APIs are minimized because they’re contracts. But this is very minor.

Copy link
Author

@wvteijlingen wvteijlingen Jun 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I merely removed the access modifiers on the extensions because they are redundant. The properties and functions inside the extensions already specify their access level. This just fixes a compiler warning, there is no actual change to the access levels.

internal var toSystemRect: YMTreeMap.SystemRect {
return YMTreeMap.SystemRect(x: x, y: y, width: width, height: height)
}
}

internal extension YMTreeMap.SystemRect {
extension YMTreeMap.SystemRect {
internal var toYMTreeMapRect: YMTreeMap.Rect {
return YMTreeMap.Rect(x: Double(minX),
y: Double(minY),
Expand Down