Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: BeauNouvelle/SwiftyGuitarChords
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.7.2
Choose a base ref
...
head repository: BeauNouvelle/SwiftyGuitarChords
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
  • 9 commits
  • 10 files changed
  • 3 contributors

Commits on Jun 12, 2023

  1. added 7#5 for all chords

    BeauNouvelle committed Jun 12, 2023
    Copy the full SHA
    6233350 View commit details
  2. Merge branch 'develop'

    BeauNouvelle committed Jun 12, 2023
    Copy the full SHA
    8040d5f View commit details

Commits on Sep 7, 2023

  1. Reduce amount of compiler directives

    This with aliases and static declarations.
    Now the package is also compatible with visionOS.
    Desbeers committed Sep 7, 2023
    Copy the full SHA
    f9ed7e2 View commit details

Commits on Sep 11, 2023

  1. Fix finger color for barres

    Desbeers committed Sep 11, 2023
    Copy the full SHA
    6a0758a View commit details

Commits on Sep 23, 2023

  1. Merge pull request #29 from Desbeers/main

    Reduce amount of compiler directives
    BeauNouvelle authored Sep 23, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    38562c1 View commit details

Commits on Jul 28, 2024

  1. [ADD] Added matching keyword to improve chords searching

    [MOD] Updated Swift tools version to 5.9
    x-0o0 committed Jul 28, 2024
    Copy the full SHA
    e59e463 View commit details

Commits on Aug 4, 2024

  1. Merge pull request #30 from x-0o0/jaesung/feature/keyword-based-search

    String keyword-based search
    BeauNouvelle authored Aug 4, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    7b249ba View commit details
  2. [MOD] Modified README.md

    x-0o0 authored Aug 4, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    1a53f61 View commit details

Commits on Aug 7, 2024

  1. Merge pull request #31 from x-0o0/patch-1

    Minor fixes: Fixed header level
    BeauNouvelle authored Aug 7, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    77ea3f8 View commit details
15 changes: 9 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
// swift-tools-version:5.4
// The swift-tools-version declares the minimum version of Swift required to build this package.
// swift-tools-version:5.9

import PackageDescription

let package = Package(
name: "SwiftyChords",
platforms: [.iOS(.v13), .macOS(.v11)],
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "SwiftyChords",
targets: ["SwiftyChords"]),
targets: ["SwiftyChords"]
),
],
dependencies: [],
targets: [
.target(
name: "SwiftyChords",
dependencies: [],
resources: [.process("Resources")]
),
.testTarget(
name: "SwiftyChordsTests",
dependencies: [
"SwiftyChords"
]
)
]
)
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -60,6 +60,14 @@ Returns all suspended chords in the database along with their variants such as s
Chords.guitar.matching(group: .suspended)
```

#### Filter by String Keyword
Returns all Dsus4 chords. This works the same as filtering by key and suffix.

```swift
Chords.guitar.matching(keyword: "Dsus4") // same as Chords.guitar.matching(key: .d).matching(suffix: .sus4)
```


## Display
Swifty Chords suports a number of alternative texts you can use in your UI including an accessibility text-to-speech friendly variant.
Display texts from both Key and Suffix properties can be combined to complete the chord name.
43 changes: 43 additions & 0 deletions Sources/SwiftyChords/Aliasses.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// File.swift
//
//
// Created by Nick Berendsen on 07/09/2023.
//

#if os(macOS)
import AppKit
#else
import UIKit
#endif


#if os(macOS)

/// Alias for NSImage
public typealias SWIFTImage = NSImage

/// Alias for NSColor
public typealias SWIFTColor = NSColor

let primaryColor = NSColor.labelColor
let backgroundColor = NSColor.windowBackgroundColor

/// Alias for NSFont
public typealias SWIFTFont = NSFont

#else

/// Alias for UIImage
public typealias SWIFTImage = UIImage

/// Alias for UIColor
public typealias SWIFTColor = UIColor

/// Alias for UIFont
public typealias SWIFTFont = UIFont

let primaryColor = UIColor.label
let backgroundColor = UIColor.systemBackground

#endif
37 changes: 37 additions & 0 deletions Sources/SwiftyChords/Array+Chords.swift
Original file line number Diff line number Diff line change
@@ -29,4 +29,41 @@ public extension Array where Element == ChordPosition {
return self.filter { $0.suffix.group == group }
}

func matching(keyword: String) -> [ChordPosition] {
// check keyword invalidation...
let trimmedKeyword = keyword.trimmingCharacters(in: .whitespaces)
if trimmedKeyword.isEmpty { return [] }

// If the keyword has 1 or 0 character, returns the matching `ChordPosition`s immediately
if trimmedKeyword.count < 2 {
guard let key = Chords.Key(rawValue: trimmedKeyword) else { return [] }
return self.matching(key: key)
}

// Get second character
let sharpOrFlat = trimmedKeyword[trimmedKeyword.index(trimmedKeyword.startIndex, offsetBy: 1)]
let hasSharpOrFlat = (sharpOrFlat == "b") || (sharpOrFlat == "#") // C#, Bb, Eb, D#, ...

// Get string for key
let keyString = String(trimmedKeyword.prefix(hasSharpOrFlat ? 2 : 1))

// If the string for key is invalid, returns immediately
guard let key = Chords.Key(rawValue: keyString) else { return [] }

// Get string for suffix
var suffixString = String(trimmedKeyword.dropFirst(hasSharpOrFlat ? 2 : 1))

// If the string for suffix is empty, assigns "major" instead.
// If the string for suffix is "m", assigns "minor" instead.
if suffixString.isEmpty {
suffixString = "major"
} else if suffixString == "m" {
suffixString = "minor"
}

guard let suffix = Chords.Suffix(rawValue: suffixString) else { return [] }

// Returns the matching chord positions
return self.matching(key: key).matching(suffix: suffix)
}
}
Loading