Migrate from SwiftGui to Libadwaita

This commit is contained in:
david-swift 2023-11-26 14:50:20 +01:00
parent 490e1a5be8
commit 7a97d36585
49 changed files with 88 additions and 88 deletions

View File

@ -14,9 +14,9 @@ body:
- type: textarea - type: textarea
attributes: attributes:
label: Name the equivalents in GTUI. label: Name the equivalents in Libadwaita.
placeholder: >- placeholder: >-
A list of the equivalents in the GTUI library in SwiftGui (see dependencies). A list of the equivalents in the Libadwaita library (see dependencies).
validations: validations:
required: true required: true

View File

@ -96,7 +96,7 @@ disabled_rules:
custom_rules: custom_rules:
github_issue: github_issue:
name: 'GitHub Issue' name: 'GitHub Issue'
regex: '//.(TODO|FIXME):.(?!.*(https://github\.com/david-swift/Adwaita/issues/\d))' regex: '//.(TODO|FIXME):.(?!.*(https://github\.com/AparokshaUI/Adwaita/issues/\d))'
message: 'The related GitHub issue must be included in a TODO or FIXME.' message: 'The related GitHub issue must be included in a TODO or FIXME.'
severity: warning severity: warning

View File

@ -9,7 +9,7 @@ Just open a new issue on GitHub and describe the bug. It helps if your descripti
Just open a new issue on GitHub and describe the idea. Thank you very much for your contribution! Just open a new issue on GitHub and describe the idea. Thank you very much for your contribution!
### Suggest a New Component ### Suggest a New Component
If you want to be able to access a component from Libadwaita or GTK that is currently not available in Adwaita, you can add it to [SwiftGui](https://github.com/JCWasmx86/SwiftGui). If you want to be able to access a component from Libadwaita or GTK that is currently not available in Adwaita, you can add it to [Libadwaita](https://github.com/AparokshaUI/Libadwaita).
If you want to add an Adwaita interface for an already existing GTUI widget, open an issue. If you want to add an Adwaita interface for an already existing GTUI widget, open an issue.
## Pull Requests ## Pull Requests

View File

@ -5,5 +5,5 @@
## Methods ## Methods
### `vertical()` ### `vertical()`
Initialize a vertical `GTUI.Box`. Initialize a vertical `Libadwaita.Box`.
- Returns: The vertical box. - Returns: The vertical box.

View File

@ -5,14 +5,14 @@
## Methods ## Methods
### `update(_:modifiers:)` ### `update(_:modifiers:)`
A `GTUI.NativeWidgetPeer` is static. A `Libadwaita.NativeWidgetPeer` is static.
- Parameters: - Parameters:
- storage: The view storage. - storage: The view storage.
- modifiers: Modify views before being updated. - modifiers: Modify views before being updated.
### `container(modifiers:)` ### `container(modifiers:)`
A `GTUI.NativeWidgetPeer`'s container is itself. A `Libadwaita.NativeWidgetPeer`'s container is itself.
- Parameter modifiers: Modify views before being updated. - Parameter modifiers: Modify views before being updated.
- Returns: The view storage. - Returns: The view storage.

View File

@ -8,7 +8,7 @@ A structure conforming to `App` is the entry point of your app.
@main @main
struct Test: App { struct Test: App {
let id = "io.github.david-swift.TestApp" let id = "io.github.AparokshaUI.TestApp"
var app: GTUIApp! var app: GTUIApp!
var scene: Scene { var scene: Scene {

View File

@ -18,12 +18,12 @@ let package = Package(
) )
], ],
dependencies: [ dependencies: [
.package(url: "https://github.com/david-swift/SwiftGui", from: "0.1.0") .package(url: "https://github.com/AparokshaUI/Libadwaita", from: "0.1.0")
], ],
targets: [ targets: [
.target( .target(
name: "Adwaita", name: "Adwaita",
dependencies: [.product(name: "GTUI", package: "swiftgui")] dependencies: [.product(name: "Libadwaita", package: "Libadwaita")]
), ),
.executableTarget( .executableTarget(
name: "Swift Adwaita Demo", name: "Swift Adwaita Demo",

View File

@ -8,7 +8,7 @@
User Manual User Manual
</a> </a>
· ·
<a href="https://github.com/david-swift/Adwaita"> <a href="https://github.com/AparokshaUI/Adwaita">
GitHub GitHub
</a> </a>
· ·
@ -88,7 +88,7 @@ If you want to use _Adwaita_ in a project, but there are widgets missing, open a
| Syntax | Description | | Syntax | Description |
| ---------------------------- | --------------------------------------------------------------------------------------- | | ---------------------------- | --------------------------------------------------------------------------------------- |
| `inspect(_:)` | Edit the underlying [GTUI][10] widget. | | `inspect(_:)` | Edit the underlying [Libadwaita][10] widget. |
| `padding(_:_:)` | Add empty space around a view. | | `padding(_:_:)` | Add empty space around a view. |
| `hexpand(_:)` | Enable or disable the horizontal expansion of a view. | | `hexpand(_:)` | Enable or disable the horizontal expansion of a view. |
| `vexpand(_:)` | Enable or disable the vertical expansion of a view. | | `vexpand(_:)` | Enable or disable the vertical expansion of a view. |
@ -168,7 +168,7 @@ brew install libadwaita
2. Open the `Package.swift` file. 2. Open the `Package.swift` file.
3. Into the `Package` initializer, under `dependencies`, paste: 3. Into the `Package` initializer, under `dependencies`, paste:
```swift ```swift
.package(url: "https://github.com/david-swift/Adwaita", from: "0.1.0") .package(url: "https://github.com/AparokshaUI/Adwaita", from: "0.1.0")
``` ```
## Usage ## Usage
@ -189,7 +189,7 @@ brew install libadwaita
## Thanks ## Thanks
### Dependencies ### Dependencies
- [SwiftGui][18] licensed under the [GPL-3.0 license][19] - [Libadwaita][18] licensed under the [GPL-3.0 license][19]
### Other Thanks ### Other Thanks
- The [contributors][20] - The [contributors][20]
@ -205,8 +205,8 @@ brew install libadwaita
[6]: #thanks [6]: #thanks
[7]: https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1-latest/index.html [7]: https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1-latest/index.html
[8]: https://docs.gtk.org/gtk4/ [8]: https://docs.gtk.org/gtk4/
[9]: https://github.com/david-swift/Adwaita/issues [9]: https://github.com/AparokshaUI/Adwaita/issues
[10]: https://github.com/JCWasmx86/SwiftGui [10]: https://github.com/AparokshaUI/Libadwaita
[11]: https://brew.sh [11]: https://brew.sh
[12]: user-manual/GettingStarted.md [12]: user-manual/GettingStarted.md
[13]: user-manual/Basics/HelloWorld.md [13]: user-manual/Basics/HelloWorld.md
@ -214,8 +214,8 @@ brew install libadwaita
[15]: user-manual/Basics/Windows.md [15]: user-manual/Basics/Windows.md
[16]: user-manual/Basics/KeyboardShortcuts.md [16]: user-manual/Basics/KeyboardShortcuts.md
[17]: user-manual/Advanced/CreatingWidgets.md [17]: user-manual/Advanced/CreatingWidgets.md
[18]: https://github.com/JCWasmx86/SwiftGui [18]: https://github.com/AparokshaUI/Libadwaita
[19]: https://github.com/JCWasmx86/SwiftGui/blob/main/COPYING [19]: https://github.com/AparokshaUI/Libadwaita/blob/main/LICENSE.md
[20]: Contributors.md [20]: Contributors.md
[21]: https://github.com/realm/SwiftLint [21]: https://github.com/realm/SwiftLint
[22]: https://github.com/apple/swift [22]: https://github.com/apple/swift

View File

@ -5,7 +5,7 @@
// Created by david-swift on 22.10.23. // Created by david-swift on 22.10.23.
// //
import GTUI import Libadwaita
/// A button widget for menus. /// A button widget for menus.
public struct MenuButton: MenuItem { public struct MenuButton: MenuItem {
@ -35,7 +35,7 @@ public struct MenuButton: MenuItem {
/// - menu: The menu. /// - menu: The menu.
/// - app: The application containing the menu. /// - app: The application containing the menu.
/// - window: The application window containing the menu. /// - window: The application window containing the menu.
public func addMenuItem(menu: GTUI.Menu, app: GTUIApp, window: GTUIApplicationWindow?) { public func addMenuItem(menu: Libadwaita.Menu, app: GTUIApp, window: GTUIApplicationWindow?) {
if let window, preferApplicationWindow { if let window, preferApplicationWindow {
_ = menu.append(label, window: window, shortcut: shortcut, handler: handler) _ = menu.append(label, window: window, shortcut: shortcut, handler: handler)
} else { } else {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 22.10.23. // Created by david-swift on 22.10.23.
// //
import GTUI import Libadwaita
/// A section for menus. /// A section for menus.
public struct MenuSection: MenuItem { public struct MenuSection: MenuItem {
@ -24,8 +24,8 @@ public struct MenuSection: MenuItem {
/// - menu: The menu. /// - menu: The menu.
/// - app: The application containing the menu. /// - app: The application containing the menu.
/// - window: The application window containing the menu. /// - window: The application window containing the menu.
public func addMenuItem(menu: GTUI.Menu, app: GTUIApp, window: GTUIApplicationWindow?) { public func addMenuItem(menu: Libadwaita.Menu, app: GTUIApp, window: GTUIApplicationWindow?) {
let section = GTUI.Menu() let section = Libadwaita.Menu()
_ = menu.append("", section: section) _ = menu.append("", section: section)
for element in sectionContent { for element in sectionContent {
element.addMenuItems(menu: section, app: app, window: window) element.addMenuItems(menu: section, app: app, window: window)

View File

@ -5,7 +5,7 @@
// Created by david-swift on 22.10.23. // Created by david-swift on 22.10.23.
// //
import GTUI import Libadwaita
/// A submenu widget. /// A submenu widget.
public struct Submenu: MenuItem { public struct Submenu: MenuItem {
@ -29,8 +29,8 @@ public struct Submenu: MenuItem {
/// - menu: The menu. /// - menu: The menu.
/// - app: The application containing the menu. /// - app: The application containing the menu.
/// - window: The application window containing the menu. /// - window: The application window containing the menu.
public func addMenuItem(menu: GTUI.Menu, app: GTUIApp, window: GTUIApplicationWindow?) { public func addMenuItem(menu: Libadwaita.Menu, app: GTUIApp, window: GTUIApplicationWindow?) {
let submenu = GTUI.Menu() let submenu = Libadwaita.Menu()
_ = menu.append(label, submenu: submenu) _ = menu.append(label, submenu: submenu)
for element in submenuContent { for element in submenuContent {
element.addMenuItems(menu: submenu, app: app, window: window) element.addMenuItems(menu: submenu, app: app, window: window)

View File

@ -5,7 +5,7 @@
// Created by david-swift on 06.08.23. // Created by david-swift on 06.08.23.
// //
import GTUI import Libadwaita
extension Array: View where Element == View { extension Array: View where Element == View {

View File

@ -5,17 +5,17 @@
// Created by david-swift on 05.08.23. // Created by david-swift on 05.08.23.
// //
import GTUI import Libadwaita
extension NativeWidgetPeer: Widget { extension NativeWidgetPeer: Widget {
/// A `GTUI.NativeWidgetPeer` is static. /// A `Libadwaita.NativeWidgetPeer` is static.
/// - Parameters: /// - Parameters:
/// - storage: The view storage. /// - storage: The view storage.
/// - modifiers: Modify views before being updated. /// - modifiers: Modify views before being updated.
public func update(_ storage: ViewStorage, modifiers: [(View) -> View]) { } public func update(_ storage: ViewStorage, modifiers: [(View) -> View]) { }
/// A `GTUI.NativeWidgetPeer`'s container is itself. /// A `Libadwaita.NativeWidgetPeer`'s container is itself.
/// - Parameter modifiers: Modify views before being updated. /// - Parameter modifiers: Modify views before being updated.
/// - Returns: The view storage. /// - Returns: The view storage.
public func container(modifiers: [(View) -> View]) -> ViewStorage { public func container(modifiers: [(View) -> View]) -> ViewStorage {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 05.08.23. // Created by david-swift on 05.08.23.
// //
import GTUI import Libadwaita
/// A structure conforming to `App` is the entry point of your app. /// A structure conforming to `App` is the entry point of your app.
/// ///
@ -13,7 +13,7 @@ import GTUI
/// @main /// @main
/// struct Test: App { /// struct Test: App {
/// ///
/// let id = "io.github.david-swift.TestApp" /// let id = "io.github.AparokshaUI.TestApp"
/// var app: GTUIApp! /// var app: GTUIApp!
/// ///
/// var scene: Scene { /// var scene: Scene {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 05.08.23. // Created by david-swift on 05.08.23.
// //
import GTUI import Libadwaita
/// The GTUI application. /// The GTUI application.
public class GTUIApp: Application { public class GTUIApp: Application {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 22.10.23. // Created by david-swift on 22.10.23.
// //
import GTUI import Libadwaita
/// A structure representing the content for a certain menu item type. /// A structure representing the content for a certain menu item type.
public protocol MenuItem: MenuItemGroup { public protocol MenuItem: MenuItemGroup {
@ -15,7 +15,7 @@ public protocol MenuItem: MenuItemGroup {
/// - menu: The menu. /// - menu: The menu.
/// - app: The application containing the menu. /// - app: The application containing the menu.
/// - window: The application window containing the menu. /// - window: The application window containing the menu.
func addMenuItem(menu: GTUI.Menu, app: GTUIApp, window: GTUIApplicationWindow?) func addMenuItem(menu: Libadwaita.Menu, app: GTUIApp, window: GTUIApplicationWindow?)
} }

View File

@ -5,7 +5,7 @@
// Created by david-swift on 22.10.23. // Created by david-swift on 22.10.23.
// //
import GTUI import Libadwaita
/// A structure conforming to `MenuItemGroup` can be added to the content accepting a menu. /// A structure conforming to `MenuItemGroup` can be added to the content accepting a menu.
public protocol MenuItemGroup { public protocol MenuItemGroup {
@ -19,7 +19,7 @@ extension MenuItemGroup {
/// Add the menu items described by the group to a menu. /// Add the menu items described by the group to a menu.
/// - Parameter menu: The menu. /// - Parameter menu: The menu.
func addMenuItems(menu: GTUI.Menu, app: GTUIApp, window: GTUIApplicationWindow?) { func addMenuItems(menu: Libadwaita.Menu, app: GTUIApp, window: GTUIApplicationWindow?) {
for element in content { for element in content {
if let item = element as? MenuItem { if let item = element as? MenuItem {
item.addMenuItem(menu: menu, app: app, window: window) item.addMenuItem(menu: menu, app: app, window: window)

View File

@ -5,7 +5,7 @@
// Created by david-swift on 05.08.23. // Created by david-swift on 05.08.23.
// //
import GTUI import Libadwaita
/// A structure conforming to `View` is referred to as a view. /// A structure conforming to `View` is referred to as a view.
/// It can be part of a body. /// It can be part of a body.

View File

@ -5,7 +5,7 @@
// Created by david-swift on 31.08.23. // Created by david-swift on 31.08.23.
// //
import GTUI import Libadwaita
/// Store a rendered view in a view storage. /// Store a rendered view in a view storage.
public class ViewStorage { public class ViewStorage {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 16.08.23. // Created by david-swift on 16.08.23.
// //
import GTUI import Libadwaita
/// A widget is a view that know about its GTUI widget. /// A widget is a view that know about its GTUI widget.
public protocol Widget: View { public protocol Widget: View {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 19.10.23. // Created by david-swift on 19.10.23.
// //
import GTUI import Libadwaita
/// A GTUI application window. /// A GTUI application window.
public typealias GTUIApplicationWindow = GTUI.ApplicationWindow public typealias GTUIApplicationWindow = Libadwaita.ApplicationWindow

View File

@ -5,7 +5,7 @@
// Created by david-swift on 12.10.23. // Created by david-swift on 12.10.23.
// //
import GTUI import Libadwaita
/// A GTUI window. /// A GTUI window.
public typealias GTUIWindow = GTUI.Window public typealias GTUIWindow = Libadwaita.Window

View File

@ -5,7 +5,7 @@
// Created by david-swift on 05.08.23. // Created by david-swift on 05.08.23.
// //
import GTUI import Libadwaita
/// A structure representing the content for a certain window type. /// A structure representing the content for a certain window type.
public protocol WindowScene: WindowSceneGroup { public protocol WindowScene: WindowSceneGroup {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 31.08.23. // Created by david-swift on 31.08.23.
// //
import GTUI import Libadwaita
/// A storage for an app's window. /// A storage for an app's window.
public class WindowStorage { public class WindowStorage {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 10.09.23. // Created by david-swift on 10.09.23.
// //
import GTUI import Libadwaita
/// A button widget. /// A button widget.
public struct Button: Widget { public struct Button: Widget {
@ -44,7 +44,7 @@ public struct Button: Widget {
/// - storage: The view storage. /// - storage: The view storage.
/// - modifiers: Modify views before being updated. /// - modifiers: Modify views before being updated.
public func update(_ storage: ViewStorage, modifiers: [(View) -> View]) { public func update(_ storage: ViewStorage, modifiers: [(View) -> View]) {
if let button = storage.view as? GTUI.Button { if let button = storage.view as? Libadwaita.Button {
let content = button.getContent() let content = button.getContent()
if let label { if let label {
if icon == nil { if icon == nil {
@ -64,9 +64,9 @@ public struct Button: Widget {
/// - Returns: The button's view storage. /// - Returns: The button's view storage.
public func container(modifiers: [(View) -> View]) -> ViewStorage { public func container(modifiers: [(View) -> View]) -> ViewStorage {
if let icon { if let icon {
return .init(GTUI.Button(label, icon: icon).handler(handler)) return .init(Libadwaita.Button(label, icon: icon).handler(handler))
} else { } else {
return .init(GTUI.Button(label ?? .init()).handler(handler)) return .init(Libadwaita.Button(label ?? .init()).handler(handler))
} }
} }

View File

@ -5,7 +5,7 @@
// Created by david-swift on 22.08.23. // Created by david-swift on 22.08.23.
// //
import GTUI import Libadwaita
/// An equivalent to GtkStack for two views. /// An equivalent to GtkStack for two views.
public struct EitherView: Widget { public struct EitherView: Widget {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 26.09.23. // Created by david-swift on 26.09.23.
// //
import GTUI import Libadwaita
/// A horizontal GtkBox equivalent. /// A horizontal GtkBox equivalent.
public struct HStack: Widget { public struct HStack: Widget {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 23.08.23. // Created by david-swift on 23.08.23.
// //
import GTUI import Libadwaita
/// A header bar widget. /// A header bar widget.
public struct HeaderBar: Widget { public struct HeaderBar: Widget {
@ -62,7 +62,7 @@ public struct HeaderBar: Widget {
/// - storage: The view storage. /// - storage: The view storage.
/// - modifiers: Modify views before being updated. /// - modifiers: Modify views before being updated.
public func update(_ storage: ViewStorage, modifiers: [(View) -> View]) { public func update(_ storage: ViewStorage, modifiers: [(View) -> View]) {
if let bar = storage.view as? GTUI.HeaderBar { if let bar = storage.view as? Libadwaita.HeaderBar {
_ = bar.showTitleButtons(titleButtons) _ = bar.showTitleButtons(titleButtons)
} }
start.update(storage.content[startID] ?? [], modifiers: modifiers) start.update(storage.content[startID] ?? [], modifiers: modifiers)
@ -76,7 +76,7 @@ public struct HeaderBar: Widget {
/// - Parameter modifiers: Modify views before being updated. /// - Parameter modifiers: Modify views before being updated.
/// - Returns: The view storage. /// - Returns: The view storage.
public func container(modifiers: [(View) -> View]) -> ViewStorage { public func container(modifiers: [(View) -> View]) -> ViewStorage {
let bar: GTUI.HeaderBar = .init() let bar: Libadwaita.HeaderBar = .init()
var startContent: [ViewStorage] = [] var startContent: [ViewStorage] = []
var endContent: [ViewStorage] = [] var endContent: [ViewStorage] = []
for element in start { for element in start {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 25.09.23. // Created by david-swift on 25.09.23.
// //
import GTUI import Libadwaita
/// A list box widget. /// A list box widget.
public struct List<Element>: Widget where Element: Identifiable { public struct List<Element>: Widget where Element: Identifiable {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 21.10.23. // Created by david-swift on 21.10.23.
// //
import GTUI import Libadwaita
/// A menu button widget. /// A menu button widget.
public struct Menu: Widget { public struct Menu: Widget {
@ -67,7 +67,7 @@ public struct Menu: Widget {
/// - storage: The view storage. /// - storage: The view storage.
/// - modifiers: Modify views before being updated. /// - modifiers: Modify views before being updated.
public func update(_ storage: ViewStorage, modifiers: [(View) -> View]) { public func update(_ storage: ViewStorage, modifiers: [(View) -> View]) {
if let button = storage.view as? GTUI.MenuButton { if let button = storage.view as? Libadwaita.MenuButton {
let content = button.getContent() let content = button.getContent()
if let label { if let label {
if icon == nil { if icon == nil {
@ -86,7 +86,7 @@ public struct Menu: Widget {
/// - Parameter modifiers: Modify views before being updated. /// - Parameter modifiers: Modify views before being updated.
/// - Returns: The button's view storage. /// - Returns: The button's view storage.
public func container(modifiers: [(View) -> View]) -> ViewStorage { public func container(modifiers: [(View) -> View]) -> ViewStorage {
let button: GTUI.MenuButton let button: Libadwaita.MenuButton
if let icon { if let icon {
button = .init(label, icon: icon) button = .init(label, icon: icon)
} else { } else {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 12.10.23. // Created by david-swift on 12.10.23.
// //
import GTUI import Libadwaita
/// A horizontal AdwClamp equivalent. /// A horizontal AdwClamp equivalent.
struct Clamp: Widget { struct Clamp: Widget {
@ -20,7 +20,7 @@ struct Clamp: Widget {
/// - storage: The view storage. /// - storage: The view storage.
/// - modifiers: Modify views before being updated. /// - modifiers: Modify views before being updated.
func update(_ storage: ViewStorage, modifiers: [(View) -> View]) { func update(_ storage: ViewStorage, modifiers: [(View) -> View]) {
if let clamp = storage.view as? GTUI.Clamp { if let clamp = storage.view as? Libadwaita.Clamp {
_ = clamp.maximumSize(maxSize) _ = clamp.maximumSize(maxSize)
} }
if let storage = storage.content[.mainContent]?[safe: 0] { if let storage = storage.content[.mainContent]?[safe: 0] {
@ -33,7 +33,7 @@ struct Clamp: Widget {
/// - Returns: The view storage. /// - Returns: The view storage.
func container(modifiers: [(View) -> View]) -> ViewStorage { func container(modifiers: [(View) -> View]) -> ViewStorage {
let container = content.storage(modifiers: modifiers) let container = content.storage(modifiers: modifiers)
let clamp: GTUI.Clamp = .init(container.view) let clamp: Libadwaita.Clamp = .init(container.view)
_ = clamp.maximumSize(maxSize) _ = clamp.maximumSize(maxSize)
return .init(clamp, content: [.mainContent: [container]]) return .init(clamp, content: [.mainContent: [container]])
} }

View File

@ -5,7 +5,7 @@
// Created by david-swift on 11.11.23. // Created by david-swift on 11.11.23.
// //
import GTUI import Libadwaita
/// A widget which replaces views of a specific type in its content. /// A widget which replaces views of a specific type in its content.
struct ContentModifier<Content>: Widget where Content: View { struct ContentModifier<Content>: Widget where Content: View {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 10.09.23. // Created by david-swift on 10.09.23.
// //
import GTUI import Libadwaita
/// A widget which executes a custom code on the GTUI widget when being created and updated. /// A widget which executes a custom code on the GTUI widget when being created and updated.
struct InspectorWrapper: Widget { struct InspectorWrapper: Widget {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 11.11.23. // Created by david-swift on 11.11.23.
// //
import GTUI import Libadwaita
/// Remove all of the content modifiers for the wrapped views. /// Remove all of the content modifiers for the wrapped views.
struct ModifierStopper: Widget { struct ModifierStopper: Widget {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 24.09.23. // Created by david-swift on 24.09.23.
// //
import GTUI import Libadwaita
/// A toolbar view widget. /// A toolbar view widget.
struct ToolbarView: Widget { struct ToolbarView: Widget {
@ -27,7 +27,7 @@ struct ToolbarView: Widget {
/// - Returns: The view storage. /// - Returns: The view storage.
func container(modifiers: [(View) -> View]) -> ViewStorage { func container(modifiers: [(View) -> View]) -> ViewStorage {
let content = content.storage(modifiers: modifiers) let content = content.storage(modifiers: modifiers)
let view = GTUI.ToolbarView(content.view) let view = Libadwaita.ToolbarView(content.view)
var toolbarContent: [ViewStorage] = [] var toolbarContent: [ViewStorage] = []
for item in toolbar() { for item in toolbar() {
let storage = item.storage(modifiers: modifiers) let storage = item.storage(modifiers: modifiers)
@ -59,7 +59,7 @@ struct ToolbarView: Widget {
self.toolbar()[safe: index]?.updateStorage(content, modifiers: modifiers) self.toolbar()[safe: index]?.updateStorage(content, modifiers: modifiers)
} }
} }
if let view = storage.view as? GTUI.ToolbarView { if let view = storage.view as? Libadwaita.ToolbarView {
if bottom { if bottom {
view.setRevealBottomBar(visible) view.setRevealBottomBar(visible)
} else { } else {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 10.09.23. // Created by david-swift on 10.09.23.
// //
import GTUI import Libadwaita
/// A widget which executes a custom code when being updated. /// A widget which executes a custom code when being updated.
struct UpdateObserver: Widget { struct UpdateObserver: Widget {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 24.09.23. // Created by david-swift on 24.09.23.
// //
import GTUI import Libadwaita
/// A navigation split view widget. /// A navigation split view widget.
public struct NavigationSplitView: Widget { public struct NavigationSplitView: Widget {
@ -33,7 +33,7 @@ public struct NavigationSplitView: Widget {
/// - Parameter modifiers: Modify views before being updated. /// - Parameter modifiers: Modify views before being updated.
/// - Returns: The view storage. /// - Returns: The view storage.
public func container(modifiers: [(View) -> View]) -> ViewStorage { public func container(modifiers: [(View) -> View]) -> ViewStorage {
let splitView: GTUI.NavigationSplitView = .init() let splitView: Libadwaita.NavigationSplitView = .init()
var content: [String: [ViewStorage]] = [:] var content: [String: [ViewStorage]] = [:]
let sidebar = sidebar().widget(modifiers: modifiers).container(modifiers: modifiers) let sidebar = sidebar().widget(modifiers: modifiers).container(modifiers: modifiers)

View File

@ -5,7 +5,7 @@
// Created by david-swift on 26.09.23. // Created by david-swift on 26.09.23.
// //
import GTUI import Libadwaita
/// A GtkScrolledWindow equivalent. /// A GtkScrolledWindow equivalent.
public struct ScrollView: Widget { public struct ScrollView: Widget {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 26.09.23. // Created by david-swift on 26.09.23.
// //
import GTUI import Libadwaita
/// A storage for `@State` properties. /// A storage for `@State` properties.
public struct StateWrapper: Widget { public struct StateWrapper: Widget {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 25.09.23. // Created by david-swift on 25.09.23.
// //
import GTUI import Libadwaita
/// A status page widget. /// A status page widget.
public struct StatusPage: Widget { public struct StatusPage: Widget {
@ -42,7 +42,7 @@ public struct StatusPage: Widget {
/// - storage: The view storage. /// - storage: The view storage.
/// - modifiers: Modify views before being updated. /// - modifiers: Modify views before being updated.
public func update(_ storage: ViewStorage, modifiers: [(View) -> View]) { public func update(_ storage: ViewStorage, modifiers: [(View) -> View]) {
if let statusPage = storage.view as? GTUI.StatusPage { if let statusPage = storage.view as? Libadwaita.StatusPage {
_ = statusPage.title(title).description(description).icon(icon) _ = statusPage.title(title).description(description).icon(icon)
} }
if let storage = storage.content[.mainContent]?.first { if let storage = storage.content[.mainContent]?.first {
@ -56,7 +56,7 @@ public struct StatusPage: Widget {
public func container(modifiers: [(View) -> View]) -> ViewStorage { public func container(modifiers: [(View) -> View]) -> ViewStorage {
let child = content.widget(modifiers: []).container(modifiers: modifiers) let child = content.widget(modifiers: []).container(modifiers: modifiers)
return .init( return .init(
GTUI.StatusPage().title(title).description(description).icon(icon).child(child.view), Libadwaita.StatusPage().title(title).description(description).icon(icon).child(child.view),
content: [.mainContent: [child]] content: [.mainContent: [child]]
) )
} }

View File

@ -5,7 +5,7 @@
// Created by david-swift on 23.08.23. // Created by david-swift on 23.08.23.
// //
import GTUI import Libadwaita
/// A text widget. /// A text widget.
public struct Text: Widget { public struct Text: Widget {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 23.08.23. // Created by david-swift on 23.08.23.
// //
import GTUI import Libadwaita
/// A GtkBox equivalent. /// A GtkBox equivalent.
public struct VStack: Widget { public struct VStack: Widget {

View File

@ -5,7 +5,7 @@
// Created by david-swift on 14.09.23. // Created by david-swift on 14.09.23.
// //
import GTUI import Libadwaita
/// A structure representing an application window type. /// A structure representing an application window type.
/// ///

View File

@ -8,7 +8,7 @@
// swiftlint:disable missing_docs // swiftlint:disable missing_docs
import Adwaita import Adwaita
import GTUI import Libadwaita
struct CounterDemo: View { struct CounterDemo: View {

View File

@ -12,7 +12,7 @@ import Adwaita
@main @main
struct Demo: App { struct Demo: App {
let id = "io.github.david-swift.Demo" let id = "io.github.AparokshaUI.Demo"
var app: GTUIApp! var app: GTUIApp!
@State private var toolbar = false @State private var toolbar = false

View File

@ -8,7 +8,7 @@
// swiftlint:disable missing_docs implicitly_unwrapped_optional // swiftlint:disable missing_docs implicitly_unwrapped_optional
import Adwaita import Adwaita
import GTUI import Libadwaita
enum Page: String, Identifiable, CaseIterable { enum Page: String, Identifiable, CaseIterable {
@ -33,7 +33,7 @@ enum Page: String, Identifiable, CaseIterable {
} }
} }
var icon: GTUI.Icon? { var icon: Libadwaita.Icon? {
switch self { switch self {
case .welcome: case .welcome:
return .default(icon: .gnomeAdwaita1Demo) return .default(icon: .gnomeAdwaita1Demo)

View File

@ -2,7 +2,7 @@
Widgets are special views that do not provide a collection of other views as a content, Widgets are special views that do not provide a collection of other views as a content,
but have functions that are called when creating or updating the view. but have functions that are called when creating or updating the view.
Normally, a widget manages a GTK or Libadwaita widget using [SwiftGui][1]. Normally, a widget manages a GTK or Libadwaita widget using [Libadwaita][1].
## Recreate the `Text` widget ## Recreate the `Text` widget
In this tutorial, we will recreate the text widget. In this tutorial, we will recreate the text widget.
@ -40,7 +40,7 @@ func container() -> ViewStorage {
.init(MarkupLabel(self.text)) .init(MarkupLabel(self.text))
} }
``` ```
`MarkupLabel` is defined in [SwiftGui][1]. `MarkupLabel` is defined in [Libadwaita][1].
## The `update(_:)` Function ## The `update(_:)` Function
Whenever a state of the app changes, the `update(_:)` function of the widget gets called. Whenever a state of the app changes, the `update(_:)` function of the widget gets called.
@ -60,5 +60,5 @@ In that case, use the `ViewStorage`'s `content` property for storing their view
In the `update(_:)` function, update the children's storages. In the `update(_:)` function, update the children's storages.
An example showcasing how to implement containers is the [VStack][2]. An example showcasing how to implement containers is the [VStack][2].
[1]: https://github.com/JCWasmx86/SwiftGui [1]: https://github.com/AparokshaUI/Libadwaita
[2]: ../../Sources/Adwaita/View/VStack.swift [2]: ../../Sources/Adwaita/View/VStack.swift

View File

@ -15,7 +15,7 @@ This is a beginner tutorial. We will create a simple "Hello, world!" app using _
1. Open the `Package.swift` file. 1. Open the `Package.swift` file.
2. Add the following line of code after `name: "HelloWorld",`: 2. Add the following line of code after `name: "HelloWorld",`:
``` ```
dependencies: [.package(url: "https://github.com/david-swift/Adwaita", from: "0.1.1")], dependencies: [.package(url: "https://github.com/AparokshaUI/Adwaita", from: "0.1.1")],
``` ```
## Create the App ## Create the App

View File

@ -16,4 +16,4 @@ Install `libadwaita-devel` or `libadwaita` (or something similar, based on the p
Adwaita is an open source project. Visit the [GitHub repository][2] for bug reports, feature requests, pull requests and more information. Adwaita is an open source project. Visit the [GitHub repository][2] for bug reports, feature requests, pull requests and more information.
[1]: https://brew.sh [1]: https://brew.sh
[2]: https://github.com/david-swift/Adwaita [2]: https://github.com/AparokshaUI/Adwaita