Swiftpack.co - SDGGiesbrecht/SDGInterface as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by SDGGiesbrecht.
SDGGiesbrecht/SDGInterface 0.15.3
Tools for Implementing a Graphical User Interface
⭐️ 6
🕓 47 weeks ago
linux windows android wasi
.package(url: "https://github.com/SDGGiesbrecht/SDGInterface.git", from: "0.15.3")

macOS • Windows • Web • Ubuntu • tvOS • iOS • Android • Amazon Linux • watchOS

Documentation

SDGInterface

SDGInterface provides tools for implementing a graphical user interface.

Καὶ ὁ Λόγος σὰρξ ἐγένετο καὶ ἐσκήνωσεν ἐν ἡμῖν, καὶ ἐθεασάμεθα τὴν δόξαν αὐτοῦ, δόξαν ὡς μονογενοῦς παρὰ πατρός, πλήρης χάριτος καὶ ἀληθείας.

And the Word became flesh and dwelt among us and we have watched His glory, the glory of the Only Begotten of the Father, full of grace and truth.

―‎יוחנן⁩/Yoẖanan

Features

  • API unification accross platforms.
  • Localized menu bar.

Example Usage

import Foundation

import SDGText
import SDGLocalization

import SDGInterface

@available(macOS 11, tvOS 14, iOS 14, watchOS 7, *)
extension SampleApplication: Application {}

@available(watchOS 6, *)
public struct SampleApplication: LegacyApplication {

  public init() {}

  public var applicationName: ProcessInfo.ApplicationNameResolver {
    return { form in
      switch form {
      case .english(let region):
        switch region {
        case .unitedKingdom, .unitedStates, .canada:
          return "Sample"
        }
      case .español(let preposición):
        switch preposición {
        case .ninguna:
          return "Ejemplar"
        case .de:
          return "del Ejemplar"
        }
      case .deutsch(let fall):
        switch fall {
        case .nominativ, .akkusativ, .dativ:
          return "Beispiel"
        }
      case .français(let préposition):
        switch préposition {
        case .aucune:
          return "Exemple"
        case .de:
          return "de l’Exemple"
        }

      case .ελληνικά(let πτώση):
        switch πτώση {
        case .ονομαστική:
          return "Παράδειγμα"
        case .αιτιατική:
          return "το Παράδειγμα"
        case .γενική:
          return "του Παραδείγματος"
        }
      case .עברית:
        return "דוגמה"
      }
    }
  }

  public static func main() {  // @exempt(from: tests)
    if #available(macOS 11, tvOS 14, iOS 14, watchOS 7, *) {
      modernMain()
    } else {
      legacyMain()
    }
  }

  public var mainWindow: Window<Label<InterfaceLocalization>, InterfaceLocalization> {
    return Window(
      type: .primary(nil),
      name: UserFacing<StrictString, InterfaceLocalization>({ localization in
        switch localization {
        case .englishCanada:
          return "Sample"
        }
      }),
      content: Label(
        UserFacing<StrictString, InterfaceLocalization>({ localization in
          switch localization {
          case .englishCanada:
            return "Hello, world!"
          }
        })
      )
    )
  }
}
@main extension SampleApplication {}

Some platforms lack certain features. The compilation conditions which appear throughout the documentation are defined as follows:

.define("PLATFORM_HAS_COCOA_INTERFACE", .when(platforms: [.macOS, .tvOS, .iOS])),
.define(
  "PLATFORM_LACKS_FOUNDATION_NS_USER_ACTIVITY",
  .when(platforms: [.windows, .wasi, .linux, .android])
),
.define("PLATFORM_LACKS_FOUNDATION_PROCESS_INFO", .when(platforms: [.wasi])),
.define("PLATFORM_LACKS_FOUNDATION_RUN_LOOP", .when(platforms: [.wasi])),

Importing

SDGInterface provides libraries for use with the Swift Package Manager.

Simply add SDGInterface as a dependency in Package.swift and specify which of the libraries to use:

let package = Package(
  name: "MyPackage",
  dependencies: [
    .package(
      url: "https://github.com/SDGGiesbrecht/SDGInterface",
      .upToNextMinor(from: Version(0, 15, 3))
    ),
  ],
  targets: [
    .target(
      name: "MyTarget",
      dependencies: [
        .product(name: "SDGInterface", package: "SDGInterface"),
        .product(name: "SDGInterfaceTestUtilities", package: "SDGInterface"),
        .product(name: "SDGErrorMessages", package: "SDGInterface"),
        .product(name: "SDGProgressIndicators", package: "SDGInterface"),
        .product(name: "SDGKeyboard", package: "SDGInterface"),
      ]
    )
  ]
)

The modules can then be imported in source files:

import SDGInterface
import SDGInterfaceTestUtilities
import SDGErrorMessages
import SDGProgressIndicators
import SDGKeyboard

About

The SDGInterface project is maintained by Jeremy David Giesbrecht.

If SDGInterface saves you money, consider giving some of it as a donation.

If SDGInterface saves you time, consider devoting some of it to contributing back to the project.

Ἄξιος γὰρ ὁ ἐργάτης τοῦ μισθοῦ αὐτοῦ ἐστι.

For the worker is worthy of his wages.

―‎ישוע/Yeshuʼa

GitHub

link
Stars: 6
Last commit: 39 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

Version 0.15.3
47 weeks ago

Bug Fixes

  • Swift 5.8 is fully supported.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics