Skip to content

Commit 98e3b53

Browse files
Added simple navigation example
1 parent 03a9622 commit 98e3b53

18 files changed

Lines changed: 691 additions & 0 deletions

File tree

6 KB
Binary file not shown.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.DS_Store
2+
/.build
3+
/Packages
4+
xcuserdata/
5+
DerivedData/
6+
.swiftpm/configuration/registries.json
7+
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
8+
.netrc
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// swift-tools-version: 6.2
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "ManageCartLib",
8+
platforms: [.iOS(.v16)], // Optional: Add platform requirements
9+
products: [
10+
.library(
11+
name: "ManageCartLib",
12+
targets: ["ManageCartLib"]
13+
),
14+
],
15+
dependencies: [
16+
.package(name: "NavigationLib", path: "../NavigationLib") // Local path
17+
],
18+
targets: [
19+
.target(
20+
name: "ManageCartLib",
21+
dependencies: ["NavigationLib"] // Explicit dependency
22+
),
23+
]
24+
)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// The Swift Programming Language
2+
// https://docs.swift.org/swift-book
3+
import Foundation
4+
import SwiftUI
5+
import NavigationLib
6+
7+
@available(iOS 14.0, *)
8+
9+
public struct AddToCartView: View {
10+
@Binding var path: [AppRoute]
11+
12+
// Public initializer (required for cross-module use)
13+
public init(path: Binding<[AppRoute]>) {
14+
self._path = path
15+
}
16+
17+
public var body: some View {
18+
Button("Place Order") {
19+
path.append(AppRoute.orders(.orderPlaced))
20+
21+
}
22+
}
23+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.DS_Store
2+
/.build
3+
/Packages
4+
xcuserdata/
5+
DerivedData/
6+
.swiftpm/configuration/registries.json
7+
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
8+
.netrc
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// swift-tools-version: 6.2
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "NavigationLib",
8+
products: [
9+
// Products define the executables and libraries a package produces, making them visible to other packages.
10+
.library(
11+
name: "NavigationLib",
12+
targets: ["NavigationLib"]
13+
),
14+
],
15+
targets: [
16+
// Targets are the basic building blocks of a package, defining a module or a test suite.
17+
// Targets can depend on other targets in this package and products from dependencies.
18+
.target(
19+
name: "NavigationLib"
20+
),
21+
22+
]
23+
)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// The Swift Programming Language
2+
// https://docs.swift.org/swift-book
3+
public enum AppRoute: Hashable {
4+
case dashboard
5+
case cart(CartRoute) // All cart-related routes
6+
case orders(OrderRoute) // All order-related routes
7+
// case profile(ProfileRoute)
8+
}
9+
10+
public enum CartRoute: Hashable {
11+
case addToCart
12+
case checkout
13+
case paymentMethods
14+
}
15+
16+
public enum OrderRoute: Hashable {
17+
case orderPlaced
18+
case orderHistory
19+
case orderDetails(id: String)
20+
}

0 commit comments

Comments
 (0)