A framework for creating user interfaces for GNOME with an API similar to SwiftUI https://adwaita-swift.aparoksha.dev/
Go to file
2023-09-12 08:17:52 +02:00
.github Initial Commit 2023-09-12 08:17:52 +02:00
Documentation/Reference Initial Commit 2023-09-12 08:17:52 +02:00
Icons Initial Commit 2023-09-12 08:17:52 +02:00
Sources/Adwaita Initial Commit 2023-09-12 08:17:52 +02:00
Tests Initial Commit 2023-09-12 08:17:52 +02:00
user-manual Initial Commit 2023-09-12 08:17:52 +02:00
.gitignore Initial Commit 2023-09-12 08:17:52 +02:00
.swiftlint.yml Initial Commit 2023-09-12 08:17:52 +02:00
CONTRIBUTING.md Initial Commit 2023-09-12 08:17:52 +02:00
Contributors.md Initial Commit 2023-09-12 08:17:52 +02:00
LICENSE.md Initial Commit 2023-09-12 08:17:52 +02:00
Makefile Initial Commit 2023-09-12 08:17:52 +02:00
Package.swift Initial Commit 2023-09-12 08:17:52 +02:00
README.md Initial Commit 2023-09-12 08:17:52 +02:00
SUMMARY.md Initial Commit 2023-09-12 08:17:52 +02:00

Adwaita Icon

Adwaita

User Manual · GitHub · Contributor Docs

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

The following code:

struct Example: View {

    @State private var count = 0

    var view: Body {
        HeaderBar.start {
            Button(icon: .default(icon: .goPrevious)) {
                count -= 1
            }
            Button(icon: .default(icon: .goNext)) {
                count += 1
            }
        }
        Text("\(count)")
            .padding(50)
    }

}

Creates a simple counter view:

Counter Example

Table of Contents

Goals

Adwaitas main goal is to provide an easy-to-use interface for creating GNOME apps. The back end 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.

Widgets

Name Description Widget
Button A widget that triggers a function when being clicked. GtkButton
EitherView A widget that displays one of its child views based on a boolean. GtkStack
HeaderBar A widget for creating custom title bars for windows. GtkHeaderBar
Text A widget for displaying a small amount of text. GtkLabel
VStack A widget which arranges child widgets into a single column. GtkBox

View Modifiers

Syntax Description
inspect(_:) Edit the underlying GTUI widget.
padding(_:_:) Add empty space around a view.
hexpand(_:) Enable or disable the horizontal expansion of a view.
vexpand(_:) Enable or disable the vertical expansion of a view.
frame(minWidth:minHeight:) Set the views minimal width or height.
frame(maxSize:) Set the views maximal size.
transition(_:) Assign a transition with the view that is used if it is a direct child of a HeaderBar.
onUpdate(_:) Run a function every time a view gets updated.

Installation

Dependencies

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/david-swift/Adwaita", from: "0.1.0")   

Usage

Basics

Thanks

Dependencies

Other Thanks