Add meta-sqlite to adwaita-swift
This commit is contained in:
parent
34f5b46d60
commit
0a6f1043b9
@ -24,6 +24,7 @@ let package = Package(
|
||||
],
|
||||
dependencies: [
|
||||
.package(url: "https://github.com/AparokshaUI/Meta", branch: "main"),
|
||||
.package(url: "https://github.com/AparokshaUI/meta-sqlite", branch: "main"),
|
||||
.package(
|
||||
url: "https://github.com/david-swift/LevenshteinTransformations",
|
||||
from: "0.1.1"
|
||||
@ -40,7 +41,8 @@ let package = Package(
|
||||
dependencies: [
|
||||
"CAdw",
|
||||
.product(name: "LevenshteinTransformations", package: "LevenshteinTransformations"),
|
||||
.product(name: "Meta", package: "Meta")
|
||||
.product(name: "Meta", package: "Meta"),
|
||||
.product(name: "MetaSQLite", package: "meta-sqlite")
|
||||
]
|
||||
),
|
||||
.executableTarget(
|
||||
|
@ -6,7 +6,9 @@
|
||||
//
|
||||
|
||||
import CAdw
|
||||
import Foundation
|
||||
@_exported import Meta
|
||||
@_exported import MetaSQLite
|
||||
|
||||
/// The Meta app storage for the Adwaita backend.
|
||||
public class AdwaitaApp: AppStorage {
|
||||
@ -31,6 +33,7 @@ public class AdwaitaApp: AppStorage {
|
||||
/// - Parameter id: The identifier.
|
||||
public required init(id: String) {
|
||||
pointer = adw_application_new(id, G_APPLICATION_DEFAULT_FLAGS)?.cast()
|
||||
DatabaseInformation.setPath(Self.userDataDir().appendingPathComponent("data.sqlite").path)
|
||||
}
|
||||
|
||||
/// Copy a string to the clipboard.
|
||||
@ -39,6 +42,12 @@ public class AdwaitaApp: AppStorage {
|
||||
gdk_clipboard_set_text(clipboard, text)
|
||||
}
|
||||
|
||||
/// The directory used for storing user data.
|
||||
/// - Returns: The URL.
|
||||
public static func userDataDir() -> URL {
|
||||
.init(fileURLWithPath: .init(cString: g_get_user_data_dir()))
|
||||
}
|
||||
|
||||
/// Execute the app.
|
||||
/// - Parameter setup: Set the scene elements up.
|
||||
public func run(setup: @escaping () -> Void) {
|
||||
|
@ -11,7 +11,8 @@ import Adwaita
|
||||
|
||||
struct CounterDemo: View {
|
||||
|
||||
@State private var count = 0
|
||||
@State("count")
|
||||
private var count = 0
|
||||
|
||||
var view: Body {
|
||||
VStack {
|
||||
|
@ -68,7 +68,8 @@ struct Demo: App {
|
||||
|
||||
struct DemoContent: WindowView {
|
||||
|
||||
@State private var selection: Page = .welcome
|
||||
@State("selection")
|
||||
private var selection: Page = .welcome
|
||||
@State private var toast: Signal = .init()
|
||||
@State private var sidebarVisible = true
|
||||
@State private var width = 650
|
||||
|
Loading…
Reference in New Issue
Block a user