generated from Awesomeplayer165/Template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from martindufort/macos-appkit-with-nsui
- Loading branch information
Showing
11 changed files
with
538 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths-ignore: | ||
- 'README.md' | ||
- 'CODE_OF_CONDUCT.md' | ||
- 'CONTRIBUTING.md' | ||
- 'LICENSE' | ||
- 'SECURITY.md' | ||
- 'ios.yml' | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
runs-on: macOS-latest | ||
strategy: | ||
matrix: | ||
destination: | ||
- "platform=macOS" | ||
# - "platform=macOS,variant=Mac Catalyst" | ||
- "platform=iOS Simulator,name=iPhone 11" | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install XCBeautify | ||
run: brew install xcbeautify | ||
- name: Show buildable schemes | ||
run: xcodebuild -list | ||
- name: Test Each Platform | ||
run: set -o pipefail && xcodebuild -scheme PillboxView -destination "${{ matrix.destination }}" test | xcbeautify --renderer github-actions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
|
||
*.xcuserstate | ||
## User settings | ||
xcuserdata/ | ||
**/.swiftpm | ||
**/.DS_Store | ||
*.xcuserstate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// | ||
// NSUI+Extensions.swift | ||
// | ||
// | ||
|
||
import CoreGraphics | ||
import Foundation | ||
|
||
// --- | ||
import NSUI | ||
|
||
internal extension NSUIView { | ||
|
||
/// Return the origin `UXPoint` for a view which needs to be centered horizontally within its superview | ||
/// This is performed with frame math only and it is set at init type. | ||
/// Changing the window size will not recalculate the origin. | ||
func originForCenter(inRelationTo parentView: NSUIView) -> CGPoint { | ||
guard | ||
parentView.frame != CGRect.zero | ||
else { | ||
fatalError("Your parentView must have a non-zero size") | ||
} | ||
|
||
let midPoint = CGRectGetMidX(parentView.frame) | ||
|
||
// Now get the half the width of our view and substract than from the midPoint | ||
let selfMidPoint = self.frame.width / 2 | ||
|
||
let newOriginX = (midPoint - selfMidPoint).rounded() | ||
let newOriginY = self.frame.origin.y | ||
return CGPoint(x: newOriginX, y: newOriginY) | ||
} | ||
} | ||
|
||
#if canImport(AppKit) | ||
import AppKit | ||
#endif | ||
|
||
internal extension NSUIColor { | ||
#if os(macOS) | ||
@available(OSX 10.14, *) | ||
static var isLight: Bool { NSApp.effectiveAppearance.name == NSAppearance.Name.aqua } | ||
|
||
@available(OSX 10.14, *) | ||
static var isDark: Bool { NSApp.effectiveAppearance.name == NSAppearance.Name.darkAqua } | ||
#endif | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// PillPosition.swift | ||
// | ||
// | ||
// Created by Martin Dufort on 2023-12-14. | ||
// | ||
|
||
|
||
/// Defines the direction from which the ``PillboxView/PillView`` will appear and also the offset from the edge of | ||
/// the containing view to where it will rest. This allows stop coordinates to be different if showing from bottom versus | ||
/// showing from top. | ||
/// | ||
/// It also removes the need to inform the ``PillboxView/PillView`` about the presence of a navigation controller. | ||
import CoreGraphics | ||
|
||
public struct PillAnimation { | ||
enum AnimationDirection { | ||
case fromTop | ||
case fromBottom | ||
} | ||
var direction: AnimationDirection | ||
var offsetFromEdge: CGFloat | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.