Adwaita for Swift is a framework for creating user interfaces for GNOME with an API similar to SwiftUI.
Write user interfaces in a declarative way.
As an example, the following code defines a view (more information: View
).
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
}
}
}
}
A view can be implemented in different ways, the following screenshot showing an example.
Adwaita for Swift's main goal is to provide an easy-to-use interface for creating apps for the GNOME ecosystem. An article about the project's motivation is available on the website of the Swift programming language.
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.
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:
- Install Homebrew.
- Install Libadwaita (and thereby GTK 4):
brew install libadwaita
- Open your Swift package in GNOME Builder, Xcode, or any other IDE.
- Open the
Package.swift
file. - Into the
Package
initializer, underdependencies
, paste:
.package(url: "https://github.com/AparokshaUI/Adwaita", from: "0.1.0")
It is recommended to develop apps on Linux inside a Flatpak. Find more information in the template repository.
- doc:Table-of-Contents
- doc:CreatingViews
- doc:Windows
- doc:KeyboardShortcuts
- doc:CreatingWidgets
- doc:PublishingApps
ActionRow
AlertDialog
AspectFrame
Avatar
Banner
Bin
Box
Button
ButtonContent
Carousel
CenterBox
CheckButton
Clamp
ComboRow
EntryRow
ExpanderRow
Fixed
FlowBox
ForEach
Form
FormSection
HStack
HeaderBar
Label
LevelBar
LinkButton
List
ListBox
Menu
NavigationSplitView
NavigationView
Overlay
OverlaySplitView
PasswordEntryRow
Picture
Popover
PreferencesGroup
PreferencesPage
PreferencesRow
ProgressBar
ScrolledWindow
ScrollView
SearchBar
SearchEntry
Separator
SpinRow
Spinner
SplitButton
StateWrapper
StatusPage
SwitchRow
Text
ToastOverlay
Toggle
ToggleButton
ToolbarView
ViewStack
ViewSwitcher
VStack
WindowTitle
AboutWindow
FileDialog
Window
MenuButton
MenuSection
Submenu