Extract core target
This commit is contained in:
parent
47fe78f4ba
commit
3d2ef52cc8
@ -16,6 +16,10 @@ let package = Package(
|
|||||||
.library(
|
.library(
|
||||||
name: "MacBackend",
|
name: "MacBackend",
|
||||||
targets: ["MacBackend"]
|
targets: ["MacBackend"]
|
||||||
|
),
|
||||||
|
.library(
|
||||||
|
name: "Core",
|
||||||
|
targets: ["Core"]
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
dependencies: [
|
dependencies: [
|
||||||
@ -25,13 +29,17 @@ let package = Package(
|
|||||||
],
|
],
|
||||||
targets: [
|
targets: [
|
||||||
.target(
|
.target(
|
||||||
name: "MacBackend",
|
name: "Core",
|
||||||
dependencies: [
|
dependencies: [
|
||||||
.product(name: "Meta", package: "Meta"),
|
.product(name: "Meta", package: "Meta"),
|
||||||
.product(name: "MetaSQLite", package: "meta-sqlite"),
|
.product(name: "MetaSQLite", package: "meta-sqlite"),
|
||||||
.product(name: "LevenshteinTransformations", package: "levenshtein-transformations")
|
.product(name: "LevenshteinTransformations", package: "levenshtein-transformations")
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
|
.target(
|
||||||
|
name: "MacBackend",
|
||||||
|
dependencies: ["Core"]
|
||||||
|
),
|
||||||
.executableTarget(
|
.executableTarget(
|
||||||
name: "Demo",
|
name: "Demo",
|
||||||
dependencies: ["MacBackend"]
|
dependencies: ["MacBackend"]
|
||||||
|
|||||||
@ -26,6 +26,19 @@ public struct Alert: SwiftUIWidget {
|
|||||||
[.mainContent: child]
|
[.mainContent: child]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Initialize the alert.
|
||||||
|
/// - Parameters:
|
||||||
|
/// - title: The alert's title.
|
||||||
|
/// - description: The alert's description.
|
||||||
|
/// - isPresented: Whether the alert is presented.
|
||||||
|
/// - child: The wrapped view.
|
||||||
|
public init(title: String, description: String, isPresented: Meta.Binding<Bool>, child: Meta.AnyView) {
|
||||||
|
self.title = title
|
||||||
|
self.description = description
|
||||||
|
self.isPresented = isPresented
|
||||||
|
self.child = child
|
||||||
|
}
|
||||||
|
|
||||||
/// An alert action.
|
/// An alert action.
|
||||||
enum Action {
|
enum Action {
|
||||||
|
|
||||||
@ -146,19 +159,3 @@ public struct Alert: SwiftUIWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Meta.AnyView {
|
|
||||||
|
|
||||||
// swiftlint:disable function_default_parameter_at_end
|
|
||||||
/// Add an alert to a view.
|
|
||||||
/// - Parameters:
|
|
||||||
/// - title: The title.
|
|
||||||
/// - description: The description.
|
|
||||||
/// - isPresented: Whether the alert is visible.
|
|
||||||
/// - Returns: The alert.
|
|
||||||
public func alert(_ title: String, description: String = "", isPresented: Meta.Binding<Bool>) -> Alert {
|
|
||||||
.init(title: title, description: description, isPresented: isPresented, child: self)
|
|
||||||
}
|
|
||||||
// swiftlint:enable function_default_parameter_at_end
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -8,7 +8,7 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
/// The padding view.
|
/// The padding view.
|
||||||
struct PaddingView: SwiftUIWidget {
|
public struct PaddingView: SwiftUIWidget {
|
||||||
|
|
||||||
/// The padding.
|
/// The padding.
|
||||||
var padding: Double
|
var padding: Double
|
||||||
@ -18,29 +18,27 @@ struct PaddingView: SwiftUIWidget {
|
|||||||
var child: Meta.AnyView
|
var child: Meta.AnyView
|
||||||
|
|
||||||
/// The wrapped views.
|
/// The wrapped views.
|
||||||
var wrappedViews: [String: Meta.AnyView] {
|
public var wrappedViews: [String: Meta.AnyView] {
|
||||||
[.mainContent: child]
|
[.mainContent: child]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Initialize the padding view.
|
||||||
|
/// - Parameters:
|
||||||
|
/// - padding: The padding.
|
||||||
|
/// - edges: The edges.
|
||||||
|
/// - child: The wrapped view.
|
||||||
|
public init(padding: Double, edges: Set<Edge>, child: Meta.AnyView) {
|
||||||
|
self.padding = padding
|
||||||
|
self.edges = edges
|
||||||
|
self.child = child
|
||||||
|
}
|
||||||
|
|
||||||
/// Get the SwiftUI view.
|
/// Get the SwiftUI view.
|
||||||
/// - Parameter properties: The widget data.
|
/// - Parameter properties: The widget data.
|
||||||
/// - Returns: The SwiftUI view.
|
/// - Returns: The SwiftUI view.
|
||||||
static func view(properties: Self) -> some SwiftUI.View {
|
public static func view(properties: Self) -> some SwiftUI.View {
|
||||||
MacBackendView(.mainContent)
|
MacBackendView(.mainContent)
|
||||||
.padding(properties.edges.swiftUI, properties.padding)
|
.padding(properties.edges.swiftUI, properties.padding)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Meta.AnyView {
|
|
||||||
|
|
||||||
/// Set the padding.
|
|
||||||
/// - Parameters:
|
|
||||||
/// - padding: The padding.
|
|
||||||
/// - edges: The edges.
|
|
||||||
/// - Returns: The view.
|
|
||||||
public func padding(_ padding: Double, edges: Set<Edge> = .all) -> Meta.AnyView {
|
|
||||||
PaddingView(padding: padding, edges: edges, child: self)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
33
Sources/MacBackend/AnyView.swift
Normal file
33
Sources/MacBackend/AnyView.swift
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
//
|
||||||
|
// AnyView.swift
|
||||||
|
// MacBackend
|
||||||
|
//
|
||||||
|
// Created by david-swift on 04.12.2024.
|
||||||
|
//
|
||||||
|
|
||||||
|
@_exported import Core
|
||||||
|
|
||||||
|
extension AnyView {
|
||||||
|
|
||||||
|
// swiftlint:disable function_default_parameter_at_end
|
||||||
|
/// Add an alert to a view.
|
||||||
|
/// - Parameters:
|
||||||
|
/// - title: The title.
|
||||||
|
/// - description: The description.
|
||||||
|
/// - isPresented: Whether the alert is visible.
|
||||||
|
/// - Returns: The alert.
|
||||||
|
public func alert(_ title: String, description: String = "", isPresented: Meta.Binding<Bool>) -> Alert {
|
||||||
|
.init(title: title, description: description, isPresented: isPresented, child: self)
|
||||||
|
}
|
||||||
|
// swiftlint:enable function_default_parameter_at_end
|
||||||
|
|
||||||
|
/// Set the padding.
|
||||||
|
/// - Parameters:
|
||||||
|
/// - padding: The padding.
|
||||||
|
/// - edges: The edges.
|
||||||
|
/// - Returns: The view.
|
||||||
|
public func padding(_ padding: Double, edges: Set<Edge> = .all) -> Meta.AnyView {
|
||||||
|
PaddingView(padding: padding, edges: edges, child: self)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user