Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.
/ Dvandva Public archive

An imperative UI framework for cross-platform apps

License

Notifications You must be signed in to change notification settings

AparokshaUI/Dvandva

Repository files navigation

Note

This project is no longer maintained. I'm working on a declarative framework as an alternative.

Dvandva Icon

Dvandva

GitHub · Contributor Docs

Dvandva is a framework for creating user interfaces for GNOME and macOS with one shared code.

GitHub Banner

Table of Contents

Goals

Dvandva’s goal is not to provide bindings for every widget on both platforms, but to make the creation of cross-platform apps easier. It’s always possible to add any widget to an app using the NativeWrapper widget.

If you find yourself using NativeWrapper for a widget that is available on both platforms in a similar form, consider opening an issue here.

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, I recommend installing Swift Bundler.

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/Dvandva", from: "0.1.0")   

Usage

Create an executable target in the Swift package and add the following code:

import Dvandva

let app = Application("AppName", version: "0.1.0", id: "id.for.Gnome", developer: "Developer")

app.run {
    let window = Window(id: "main", app: app)
    window.setChild(
        PaddingWrapper(
            Label().setText("Hello, world!")
        )
        .setPadding(20)
    )
    window.show()
}

Now, you can modify the windows. Take a look at the sample app and the docs for help.

Run the App

On macOS, I recommend using Swift Bundler for building the app. When building the app simply with swift run, the menu bar and therefore keyboard shortcuts are not supported.

On Linux, you can simply use swift run. In certain scenarios, setting up a Flatpak with the Swift extension may be sensible. This tutorial is very helpful.

Thanks

Dependencies

Other Thanks