Adwaita

0.2.5

A framework for creating user interfaces for GNOME with an API similar to SwiftUI
AparokshaUI/adwaita-swift

What's New

0.2.5

2024-04-13T21:02:18Z

Improvements

  • Move documentation to DocC and start writing a full tutorial which is available in this repo
  • focused checks now whether a widget contains the focus instead of whether it has the focus
  • Add easier way to access an element of an array wrapped in a binding at a specific index or with a specific ID
  • Add support for alert dialogs
  • Add support for spawning windows outside the app structure (e.g. for CLI using windows for certain tasks, #20)
  • Make the navigation split view more capable
  • Easily observe when a binding is set
  • Simpler array bounds checking (by @ZevEisenberg in #7)
  • Simpler focused modifier implementation
  • Make Linux build matrix on SPI succeed (by @finestructure in #15)
  • Update docs for macOS platform (by @jrwren in #10)

New Contributors

Full Changelog: 0.2.4...0.2.5

Adwaita Icon

Adwaita for Swift

Documentation · GitHub

Adwaita is a framework for creating user interfaces for GNOME with an API similar to SwiftUI.

The following code:

struct Counter: View {

    @State private var count = 0

    var view: Body {
        HStack {
            Button(icon: .default(icon: .goPrevious)) {
                count -= 1
            }
            Text("\(count)")
                .style("title-1")
                .frame(minWidth: 100)
            Button(icon: .default(icon: .goNext)) {
                count += 1
            }
        }
    }

}

Describes a simple counter view:

Counter Example

More examples are available in the demo app.

Table of Contents

Goals

Adwaita’s main goal is to provide an easy-to-use interface for creating GNOME apps. The backend should stay as simple as possible, while not limiting the possibilities there are with Libadwaita and GTK.

If you want to use Adwaita in a project, but there are widgets missing, open an issue on GitHub.

Find more information about the project's motivation in this blog post.

Widgets

An overview of the widgets supported by Adwaita is available here.

Installation

Dependencies

Flatpak

It is recommended to develop apps inside of a Flatpak. That way, you don't have to install Swift or any of the dependencies on your system, and you always have access to the latest versions. Take a look at the template repository. This works on Linux only.

Directly on System

You can also run your apps directly on the system.

If you are using a Linux distribution, install libadwaita-devel or libadwaita (or something similar, based on the package manager) as well as gtk4-devel, gtk4 or similar.

On macOS, follow these steps:

  1. Install Homebrew.
  2. Install Libadwaita (and thereby GTK 4):
brew install libadwaita

Swift Package

  1. Open your Swift package in GNOME Builder, Xcode, or any other IDE.
  2. Open the Package.swift file.
  3. Into the Package initializer, under dependencies, paste:
.package(url: "https://github.com/AparokshaUI/Adwaita", from: "0.1.0")   

Usage

I recommend using the template repository as a starting point.

Follow the interactive tutorial or read the docs in order to get to know Adwaita for Swift.

Thanks

Dependencies

Other Thanks

Description

  • Swift Tools 5.8.0
View More Packages from this Author

Dependencies

Last updated: Wed May 01 2024 20:57:57 GMT-0900 (Hawaii-Aleutian Daylight Time)