Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
helje5 committed Mar 19, 2024
2 parents ff1bcba + c6ca176 commit 493b31e
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 49 deletions.
6 changes: 3 additions & 3 deletions AppLogic/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ let package = Package(
// The dependencies.
dependencies: [
.package(url: "https://github.com/Lighter-swift/Lighter.git",
from: "1.0.24"),
.package(url: "https://github.com/Lighter-swift/NorthwindSQLite.swift.git",
from: "1.0.10"),
from: "1.0.32"),
.package(url: "https://github.com/Northwind-swift/NorthwindSQLite.swift.git",
from: "1.0.16"),

.package(url: "https://github.com/Macro-swift/MacroExpress.git",
from: "1.0.2"),
Expand Down
20 changes: 11 additions & 9 deletions LighterExamples.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
E8224FE128A05CB900246A1F /* ProductsList.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8224FE028A05CB900246A1F /* ProductsList.swift */; };
E86B87D728AD4DE400C5B588 /* Lighter in Frameworks */ = {isa = PBXBuildFile; productRef = E86B87D628AD4DE400C5B588 /* Lighter */; };
E87B410D28A3C40500576D8A /* NavView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E87B410C28A3C40500576D8A /* NavView.swift */; };
E87B411228A3C4B900576D8A /* NavVIewProductsList.swift in Sources */ = {isa = PBXBuildFile; fileRef = E87B411128A3C4B900576D8A /* NavVIewProductsList.swift */; };
E87B411228A3C4B900576D8A /* NavViewProductsList.swift in Sources */ = {isa = PBXBuildFile; fileRef = E87B411128A3C4B900576D8A /* NavViewProductsList.swift */; };
E87B411428A3C58500576D8A /* MainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E87B411328A3C58500576D8A /* MainView.swift */; };
E87B411628A3C7EB00576D8A /* Sidebar.swift in Sources */ = {isa = PBXBuildFile; fileRef = E87B411528A3C7EB00576D8A /* Sidebar.swift */; };
E87B412328A3DC6500576D8A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E87B412228A3DC6500576D8A /* Assets.xcassets */; };
Expand Down Expand Up @@ -58,6 +58,7 @@
E81B195A28A0782D003A0F1C /* SupplierForm.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SupplierForm.swift; sourceTree = "<group>"; };
E81B195C28A07836003A0F1C /* CategoryInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CategoryInfo.swift; sourceTree = "<group>"; };
E81B195E28A078B8003A0F1C /* Picture.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Picture.swift; sourceTree = "<group>"; };
E81D692B28CCCA5D004F5E26 /* Lighter */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = Lighter; path = ../Lighter; sourceTree = "<group>"; };
E8224F9D28A0060F00246A1F /* AppLogic */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = AppLogic; sourceTree = "<group>"; };
E8224FA328A0063A00246A1F /* NorthwindWebAPI */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = NorthwindWebAPI; sourceTree = BUILT_PRODUCTS_DIR; };
E8224FAB28A0065C00246A1F /* Products.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Products.swift; sourceTree = "<group>"; };
Expand All @@ -75,24 +76,24 @@
E8224FC928A0071100246A1F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
E8224FCB28A0071100246A1F /* NorthwindSwiftUI.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = NorthwindSwiftUI.entitlements; sourceTree = "<group>"; };
E8224FCD28A0071100246A1F /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
E8224FD328A0073000246A1F /* NorthwindApp.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NorthwindApp.swift; sourceTree = "<group>"; };
E8224FD328A0073000246A1F /* NorthwindApp.swift */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.swift; path = NorthwindApp.swift; sourceTree = "<group>"; };
E8224FD428A0073000246A1F /* ContentView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
E8224FDB28A0557000246A1F /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
E8224FDC28A0557000246A1F /* CONTRIBUTING.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = CONTRIBUTING.md; sourceTree = "<group>"; };
E8224FDD28A0557000246A1F /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
E8224FE028A05CB900246A1F /* ProductsList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductsList.swift; sourceTree = "<group>"; };
E86867D428A3F43300117E0E /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
E87B410C28A3C40500576D8A /* NavView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavView.swift; sourceTree = "<group>"; };
E87B411128A3C4B900576D8A /* NavVIewProductsList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavVIewProductsList.swift; sourceTree = "<group>"; };
E87B411128A3C4B900576D8A /* NavViewProductsList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavViewProductsList.swift; sourceTree = "<group>"; };
E87B411328A3C58500576D8A /* MainView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainView.swift; sourceTree = "<group>"; };
E87B411528A3C7EB00576D8A /* Sidebar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Sidebar.swift; sourceTree = "<group>"; };
E87B411728A3CF9D00576D8A /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
E87B411C28A3DC6500576D8A /* Bodies.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Bodies.app; sourceTree = BUILT_PRODUCTS_DIR; };
E87B412228A3DC6500576D8A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
E87B412428A3DC6500576D8A /* Bodies.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Bodies.entitlements; sourceTree = "<group>"; };
E87B412628A3DC6500576D8A /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
E87B412C28A3DCAD00576D8A /* BodiesApp.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BodiesApp.swift; sourceTree = "<group>"; };
E87B412D28A3DCAD00576D8A /* ContentView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
E87B412C28A3DCAD00576D8A /* BodiesApp.swift */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.swift; path = BodiesApp.swift; sourceTree = "<group>"; };
E87B412D28A3DCAD00576D8A /* ContentView.swift */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
E87D45FE28A3C341008E04EA /* NavViewMain.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavViewMain.swift; sourceTree = "<group>"; };
E8AF70C928A3DDE9008444B2 /* BodiesDB-001.sql */ = {isa = PBXFileReference; lastKnownFileType = text; path = "BodiesDB-001.sql"; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -128,6 +129,7 @@
E8224F8228A005CF00246A1F = {
isa = PBXGroup;
children = (
E81D692B28CCCA5D004F5E26 /* Lighter */,
E8224FDB28A0557000246A1F /* README.md */,
E8224FDD28A0557000246A1F /* LICENSE */,
E8224FDC28A0557000246A1F /* CONTRIBUTING.md */,
Expand All @@ -138,7 +140,7 @@
E8224F8C28A005CF00246A1F /* Products */,
E8224FBC28A0066800246A1F /* Frameworks */,
);
indentWidth = 4;
indentWidth = 2;
sourceTree = "<group>";
};
E8224F8C28A005CF00246A1F /* Products */ = {
Expand Down Expand Up @@ -271,7 +273,7 @@
E87B410C28A3C40500576D8A /* NavView.swift */,
E87D45FE28A3C341008E04EA /* NavViewMain.swift */,
E81B195228A065A6003A0F1C /* NavViewSidebar.swift */,
E87B411128A3C4B900576D8A /* NavVIewProductsList.swift */,
E87B411128A3C4B900576D8A /* NavViewProductsList.swift */,
);
path = NavigationViewBasedUI;
sourceTree = "<group>";
Expand Down Expand Up @@ -432,7 +434,7 @@
E87B411428A3C58500576D8A /* MainView.swift in Sources */,
E81B195728A07563003A0F1C /* ProductForm.swift in Sources */,
E87D45FF28A3C341008E04EA /* NavViewMain.swift in Sources */,
E87B411228A3C4B900576D8A /* NavVIewProductsList.swift in Sources */,
E87B411228A3C4B900576D8A /* NavViewProductsList.swift in Sources */,
E8224FE128A05CB900246A1F /* ProductsList.swift in Sources */,
E81B195128A06525003A0F1C /* ProductCell.swift in Sources */,
E81B195928A0769D003A0F1C /* Ambiguities.swift in Sources */,
Expand Down Expand Up @@ -809,7 +811,7 @@
repositoryURL = "https://github.com/Lighter-swift/Lighter.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 1.0.24;
minimumVersion = 1.0.32;
};
};
E8AF70C028A3DD80008444B2 /* XCRemoteSwiftPackageReference "Lighter" */ = {
Expand Down
6 changes: 3 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ var package = Package(
],

dependencies: [
.package(url: "https://github.com/Lighter-swift/Lighter.git", from: "1.0.24"),
.package(url: "https://github.com/Lighter-swift/NorthwindSQLite.swift.git",
from: "1.0.10"),
.package(url: "https://github.com/Lighter-swift/Lighter.git", from: "1.0.30"),
.package(url: "https://github.com/Northwind-swift/NorthwindSQLite.swift.git",
from: "1.0.14"),

.package(url: "https://github.com/Macro-swift/MacroExpress.git",
from: "1.0.2"),
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Examples for the Lighter SQLite environment, SwiftUI and server side.
Note: The examples require Swift 5.7 / Xcode 14b for proper plugin support.

When embedding a package using Enlighter (like
[NorthwindSQLite.swift](https://github.com/Lighter-swift/NorthwindSQLite.swift.git)),
[NorthwindSQLite.swift](https://github.com/Northwind-swift/NorthwindSQLite.swift.git)),
[a local package](https://developer.apple.com/documentation/xcode/organizing-your-code-with-local-packages)
seems to be required w/ the Xcode 14 beta (3...5).
Otherwise the Swift package plugins do not seem to run.
Expand All @@ -22,7 +22,7 @@ help.
The Northwind database is a common database example that has been ported
to SQLite.
Lighter provides a Swift version of that in the
[NorthwindSQLite.swift](https://github.com/Lighter-swift/NorthwindSQLite.swift)
[NorthwindSQLite.swift](https://github.com/Northwind-swift/NorthwindSQLite.swift)
repository.

> Note: The particular SQLite version of the Northwind database is quite
Expand All @@ -31,7 +31,7 @@ repository.
> That actually makes it a good example on how to deal with such databases in
> Lighter.
The Swift Northwind API: [Documentation](https://Lighter-swift.github.io/NorthwindSQLite.swift/documentation/northwind/).
The Swift Northwind API: [Documentation](https://Northwind-swift.github.io/NorthwindSQLite.swift/documentation/northwind/).


### Examples
Expand Down
3 changes: 3 additions & 0 deletions Sources/NorthwindSwiftUI/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ struct MainView: View {
case .products:
ProductsList(products: $products,
selectedProduct: $selectedProductID)
#if os(macOS)
.frame(minWidth: 274) // otherwise overlaps on macOS 13
#endif

case .none:
Text("No section is selected")
Expand Down
2 changes: 2 additions & 0 deletions Sources/NorthwindSwiftUI/NorthwindApp.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import SwiftUI
import Northwind
import Lighter
import SQLite3

/// Global application state. A good place to setup the database object.
@main
Expand All @@ -9,6 +10,7 @@ struct NorthwindApp: App {
let database = (try? Northwind.bootstrap(
copying: Northwind.module.connectionHandler.url
)) ?? .module!


var body: some Scene {
WindowGroup {
Expand Down
46 changes: 23 additions & 23 deletions Sources/NorthwindSwiftUI/ProductCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,32 @@ struct ProductCell: View {
VStack(alignment: .leading) {
Text(verbatim: product.productName)
.font(.headline)

HStack(spacing: 0) {
Text(product.unitPrice ?? 0, format: .currency(code: "USD"))
if unitsInStock > 0 {
Text(", \(unitsInStock) in stock")
}
else if product.discontinued != "0" {
Text(", ") +
Text("discontinued").foregroundColor(.red)
}
else {
Text(", ") +
Text("out of stock.").foregroundColor(.red)
if let ordered = product.unitsOnOrder, ordered > 0 {
Text(", ordered \(ordered)")
}
}
}

if unitsInStock > 0 && product.discontinued != "0" {
Text("Discontinued")
.foregroundColor(.red)
}

detailText
}
},
icon: { Image(systemName: "p.circle") }
)
}

var detailText : Text {
var text = Text(product.unitPrice ?? 0, format: .currency(code: "USD"))

if unitsInStock > 0 {
text = text + Text(", \(unitsInStock) in stock")
}
else {
text = text + Text(", ")
text = text + Text("out of stock").foregroundColor(.red)
if let ordered = product.unitsOnOrder, ordered > 0 {
text = text + Text(", ordered \(ordered)")
}
}

if product.discontinued != "0" {
text = text + Text(", ")
text = text + Text("discontinued").foregroundColor(.red)
}
return text
}
}
12 changes: 8 additions & 4 deletions Sources/NorthwindSwiftUI/ProductsList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,17 @@ struct ProductsList: View {
)
}

#if !os(macOS)
if horizontalSizeClass != .compact {
// Pre-select the first match if none is selected
// Pre-select the first match if none is selected.
#if os(macOS)
if selectedProduct == nil, let product = products.first {
selectedProduct = product.id
}
}
#else
if horizontalSizeClass != .compact { // this waits for the tap
if selectedProduct == nil, let product = products.first {
selectedProduct = product.id
}
}
#endif
}
catch { // really, do proper error handling :-)
Expand Down
2 changes: 1 addition & 1 deletion Sources/NorthwindSwiftUI/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ but keeps everything in local states.

Note: The example requires Swift 5.7 / Xcode 14b for proper plugin support.

Northwind API: [Documentation](https://55db091a-8471-447b-8f50-5dff4c1b14ac.github.io/NorthwindSQLite.swift/documentation/northwind/)
Northwind API: [Documentation](https://Northwind-sqlite.github.io/NorthwindSQLite.swift/documentation/northwind/)



Expand Down
2 changes: 1 addition & 1 deletion Sources/NorthwindSwiftUI/Sidebar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import SwiftUI
import Northwind

@available(iOS 16.0, macOS 13, *)
extension MainView: View {
extension MainView {

struct Sidebar: View {

Expand Down
2 changes: 1 addition & 1 deletion Sources/NorthwindWebAPI/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ The example in a nutshell:
```swift
#!/usr/bin/swift sh
import MacroExpress // @Macro-swift
import Northwind // @Lighter-swift/NorthwindSQLite.swift
import Northwind // @Northwind-swift/NorthwindSQLite.swift

// Get a handle to the database
let db = Northwind.module!
Expand Down
2 changes: 1 addition & 1 deletion Sources/NorthwindWebAPI/views/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ <h2 class="ui header">Server Setup</h2>
<pre><code class="language-swift"
>#!/usr/bin/swift sh
import MacroExpress // @Macro-swift
import Northwind // @Lighter-swift/NorthwindSQLite.swift
import Northwind // @Northwind-swift/NorthwindSQLite.swift

let db = Northwind.module!
let app = express()
Expand Down

0 comments on commit 493b31e

Please sign in to comment.