Skip to content

Commit 324307c

Browse files
authored
Add SPM updates and changes to the base (#4)
1 parent af8d44e commit 324307c

File tree

16 files changed

+115
-85
lines changed

16 files changed

+115
-85
lines changed

base/base.xcodeproj/project.pbxproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
2937EB7629636BEB00BBC0E6 /* RegisterNetworking.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2937EB2329636BEA00BBC0E6 /* RegisterNetworking.swift */; };
2020
2937EB7729636BEB00BBC0E6 /* RegisterViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2937EB2429636BEA00BBC0E6 /* RegisterViewModel.swift */; };
2121
2937EB7829636BEB00BBC0E6 /* RegisterFields.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2937EB2529636BEA00BBC0E6 /* RegisterFields.swift */; };
22-
2937EB7929636BEB00BBC0E6 /* LoginScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2937EB2629636BEA00BBC0E6 /* LoginScreen.swift */; };
22+
2937EB7929636BEB00BBC0E6 /* RegisterScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2937EB2629636BEA00BBC0E6 /* RegisterScreen.swift */; };
2323
2937EB8029636BEB00BBC0E6 /* ImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2937EB2F29636BEA00BBC0E6 /* ImageView.swift */; };
2424
2937EB8129636BEB00BBC0E6 /* Taskable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2937EB3129636BEA00BBC0E6 /* Taskable.swift */; };
2525
2937EB8229636BEB00BBC0E6 /* Usable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2937EB3229636BEA00BBC0E6 /* Usable.swift */; };
@@ -92,7 +92,7 @@
9292
2937EB2329636BEA00BBC0E6 /* RegisterNetworking.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RegisterNetworking.swift; sourceTree = "<group>"; };
9393
2937EB2429636BEA00BBC0E6 /* RegisterViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RegisterViewModel.swift; sourceTree = "<group>"; };
9494
2937EB2529636BEA00BBC0E6 /* RegisterFields.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RegisterFields.swift; sourceTree = "<group>"; };
95-
2937EB2629636BEA00BBC0E6 /* LoginScreen.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoginScreen.swift; sourceTree = "<group>"; };
95+
2937EB2629636BEA00BBC0E6 /* RegisterScreen.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RegisterScreen.swift; sourceTree = "<group>"; };
9696
2937EB2F29636BEA00BBC0E6 /* ImageView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageView.swift; sourceTree = "<group>"; };
9797
2937EB3129636BEA00BBC0E6 /* Taskable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Taskable.swift; sourceTree = "<group>"; };
9898
2937EB3229636BEA00BBC0E6 /* Usable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Usable.swift; sourceTree = "<group>"; };
@@ -257,7 +257,7 @@
257257
2937EB2229636BEA00BBC0E6 /* Register */,
258258
2937EB1F29636BEA00BBC0E6 /* ProfileScreen.swift */,
259259
2937EB2529636BEA00BBC0E6 /* RegisterFields.swift */,
260-
2937EB2629636BEA00BBC0E6 /* LoginScreen.swift */,
260+
2937EB2629636BEA00BBC0E6 /* RegisterScreen.swift */,
261261
);
262262
path = Profile;
263263
sourceTree = "<group>";
@@ -657,7 +657,7 @@
657657
2937EB8229636BEB00BBC0E6 /* Usable.swift in Sources */,
658658
2937EB8D29636BEB00BBC0E6 /* ForwardNavigatable.swift in Sources */,
659659
2937EB9529636BEB00BBC0E6 /* CartographyAlert.swift in Sources */,
660-
2937EB7929636BEB00BBC0E6 /* LoginScreen.swift in Sources */,
660+
2937EB7929636BEB00BBC0E6 /* RegisterScreen.swift in Sources */,
661661
2937EB7029636BEB00BBC0E6 /* HomeScreen.swift in Sources */,
662662
2937EBA729636BEB00BBC0E6 /* User.swift in Sources */,
663663
2937EB9229636BEB00BBC0E6 /* AlertPresenting.swift in Sources */,
@@ -774,7 +774,7 @@
774774
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
775775
GCC_WARN_UNUSED_FUNCTION = YES;
776776
GCC_WARN_UNUSED_VARIABLE = YES;
777-
IPHONEOS_DEPLOYMENT_TARGET = 16.1;
777+
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
778778
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
779779
MTL_FAST_MATH = YES;
780780
ONLY_ACTIVE_ARCH = YES;
@@ -828,7 +828,7 @@
828828
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
829829
GCC_WARN_UNUSED_FUNCTION = YES;
830830
GCC_WARN_UNUSED_VARIABLE = YES;
831-
IPHONEOS_DEPLOYMENT_TARGET = 16.1;
831+
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
832832
MTL_ENABLE_DEBUG_INFO = NO;
833833
MTL_FAST_MATH = YES;
834834
SDKROOT = iphoneos;
@@ -983,8 +983,8 @@
983983
isa = XCRemoteSwiftPackageReference;
984984
repositoryURL = "https://github.com/0xOpenBytes/o";
985985
requirement = {
986-
kind = upToNextMinorVersion;
987-
minimumVersion = 0.3.0;
986+
kind = upToNextMajorVersion;
987+
minimumVersion = 1.0.0;
988988
};
989989
};
990990
2937EBC529636D1500BBC0E6 /* XCRemoteSwiftPackageReference "c" */ = {

base/base.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"kind" : "remoteSourceControl",
66
"location" : "https://github.com/0xOpenBytes/c",
77
"state" : {
8-
"revision" : "f24cc61b1ca4b72bcc690748232f254771e4d6a8",
9-
"version" : "3.0.0"
8+
"revision" : "e50c296ae2e0cdb9f5032534dfc8e590c7b0cfce",
9+
"version" : "3.0.1"
1010
}
1111
},
1212
{
@@ -23,17 +23,17 @@
2323
"kind" : "remoteSourceControl",
2424
"location" : "https://github.com/0xOpenBytes/o",
2525
"state" : {
26-
"revision" : "f0ef1e44a79443782f69b5dcab08bdadcb787faa",
27-
"version" : "0.3.0"
26+
"revision" : "7751d08c5db1c7e4f339289dce1e92b033114ffd",
27+
"version" : "1.0.0"
2828
}
2929
},
3030
{
3131
"identity" : "t",
3232
"kind" : "remoteSourceControl",
3333
"location" : "https://github.com/0xOpenBytes/t",
3434
"state" : {
35-
"revision" : "78294df737c524f40267bca42beb8e10ca28aa41",
36-
"version" : "0.2.0"
35+
"revision" : "f4b8f43622a8b772d995210428dd2b3eb66904cd",
36+
"version" : "1.0.1"
3737
}
3838
}
3939
],

base/base/App/Home/HomeScreen.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ struct HomeScreen: View {
2727
.padding()
2828
}
2929
)
30-
Text("Hello, \(settings.user?.username ?? "World")!")
3130
}
31+
.navigationTitle("Hello, \(settings.user?.username ?? "World")!")
3232
}
3333
}
3434

base/base/App/Profile/ProfileScreen.swift

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,26 @@ struct ProfileScreen: View {
1111
@ObservedObject var settings: AppSettings = AppSettings.shared
1212

1313
var body: some View {
14-
if let user = settings.user {
15-
VStack {
16-
Text("Logged in: \(user.username)")
14+
Group {
15+
if let user = settings.user {
16+
VStack {
17+
Text("Logged in: \(user.username)")
1718

18-
Button(
19-
"Logout",
20-
role: .destructive,
21-
action: { settings.user = nil }
19+
Button(
20+
"Logout",
21+
role: .destructive,
22+
action: { settings.user = nil }
23+
)
24+
}
25+
} else {
26+
RegisterScreen(
27+
registerViewModel: RegisterViewModel(
28+
registerNetworking: SuccessMockRegisterService() // TODO: (base-Template) Update to Production
29+
)
2230
)
2331
}
24-
} else {
25-
LoginScreen(
26-
registerViewModel: RegisterViewModel(
27-
registerNetworking: SuccessMockRegisterService() // TODO: (base-Template) Update to Production
28-
)
29-
)
3032
}
33+
.navigationTitle("Profile")
3134
}
3235
}
3336

base/base/App/Profile/Register/RegisterViewModel.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@ class RegisterViewModel: ObservableObject {
4242
)
4343

4444
await MainActor.run {
45+
AppSettings.shared.user = user
46+
}
47+
48+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) {
4549
Navigation.path.toast(
4650
title: "Success",
4751
message: "You have successfully registered an account.",
4852
style: .success
4953
)
5054
}
51-
52-
await MainActor.run {
53-
AppSettings.shared.user = user
54-
}
5555
} catch {
5656
handle(error: error)
5757
}

base/base/App/Profile/RegisterFields.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct RegisterFields: View {
2727
}
2828
}
2929

30-
struct RegisterScreen_Previews: PreviewProvider {
30+
struct RegisterFields_Previews: PreviewProvider {
3131
static var previews: some View {
3232
RegisterFields(
3333
username: .constant(""),

base/base/App/Profile/LoginScreen.swift renamed to base/base/App/Profile/RegisterScreen.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
//
2-
// LoginScreen.swift
2+
// RegisterScreen.swift
33
// base
44
//
55
// Created by Rob Maltese on 12/18/22.
66
//
77

88
import SwiftUI
99

10-
struct LoginScreen: View {
10+
struct RegisterScreen: View {
1111
@ObservedObject var registerViewModel: RegisterViewModel
1212

1313
@FocusState var isFocused: Bool
@@ -57,9 +57,9 @@ struct LoginScreen: View {
5757
}
5858
}
5959

60-
struct LoginScreen_Previews: PreviewProvider {
60+
struct RegisterScreen_Previews: PreviewProvider {
6161
static var previews: some View {
62-
LoginScreen(
62+
RegisterScreen(
6363
registerViewModel: RegisterViewModel(
6464
registerNetworking: SuccessMockRegisterService()
6565
)

base/base/App/RootView.swift

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,45 +14,48 @@ struct RootView: View {
1414
case profile
1515
}
1616

17-
@ObservedObject var cartography: CartographyPath
18-
19-
@State private var selection: Tab = .home
17+
@ObservedObject var navigation: Navigation
2018

2119
var body: some View {
22-
CartographyView(path: cartography) {
23-
TabView(selection: $selection) {
20+
TabView(selection: $navigation.tab) {
21+
CartographyView(path: navigation.home) {
2422
HomeScreen()
25-
.tag(Tab.home)
26-
.tabItem {
27-
Image(systemName: "house")
28-
Text("Home")
29-
}
23+
}
24+
.tag(Tab.home)
25+
.tabItem {
26+
Image(systemName: "house")
27+
Text("Home")
28+
}
3029

30+
CartographyView(path: navigation.search) {
3131
SearchScreen()
32-
.tag(Tab.search)
33-
.tabItem {
34-
Image(systemName: "magnifyingglass")
35-
Text("Search")
36-
}
32+
}
33+
.tag(Tab.search)
34+
.tabItem {
35+
Image(systemName: "magnifyingglass")
36+
Text("Search")
37+
}
3738

39+
CartographyView(path: navigation.profile) {
3840
ProfileScreen()
39-
.tag(Tab.profile)
40-
.tabItem {
41-
Image(systemName: "person")
42-
Text("Profile")
43-
}
41+
}
42+
.tag(Tab.profile)
43+
.tabItem {
44+
Image(systemName: "person")
45+
Text("Profile")
4446
}
4547
}
4648
}
4749
}
4850

4951
struct RootView_Previews: PreviewProvider {
5052
static var previews: some View {
51-
Navigation.use { nav -> RootView in
52-
nav.isPreview = true
53-
nav.path = CartographyPath()
53+
Navigation.shared.use { navigation -> RootView in
54+
navigation.home = CartographyPath(id: "home.preview")
55+
navigation.search = CartographyPath(id: "search.preview")
56+
navigation.profile = CartographyPath(id: "profile.preview")
5457

55-
return RootView(cartography: Navigation.path)
58+
return RootView(navigation: navigation)
5659
}
5760
}
5861
}

base/base/App/Search/SearchScreen.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ struct SearchScreen: View {
6464
Text(date, format: .dateTime)
6565
}
6666
)
67+
.navigationTitle("Search")
6768
}
6869
}
6970

base/base/App/Views/Components/ImageView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class ImageViewModel: ObservableObject {
3030

3131
do {
3232
guard
33-
let data = try await Network.get(url: url).0,
33+
let data = try await Network.get(url: url).data,
3434
let imageData = UIImage(data: data)
3535
else { return nil }
3636

base/base/App/baseApp.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import SwiftUI
99

1010
@main
1111
struct OBbaseApp: App {
12-
let navigate: CartographyPath = Navigation.path
12+
@ObservedObject var navigation: Navigation = Navigation.shared
1313

1414
var body: some Scene {
1515
WindowGroup {
16-
RootView(cartography: navigate)
16+
RootView(navigation: navigation)
1717
}
1818
}
1919
}

base/base/Navigation/Implementation/CartographyPath.swift

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,18 @@
88
import SwiftUI
99

1010
class CartographyPath: ObservableObject {
11-
private static let filename = "CartographyPath"
11+
private static let filePrefix = "CartographyPath"
12+
13+
let id: String
1214

1315
@Published var navigation: NavigationPath
1416
@Published var modal: CartographyModal?
1517
@Published var alert: CartographyAlert?
1618
@Published var actionSheet: CartographyActionSheet?
1719
@Published var toast: CartographyToast?
1820

19-
init(_ codable: NavigationPath.CodableRepresentation? = nil) {
21+
init(id: String, _ codable: NavigationPath.CodableRepresentation? = nil) {
22+
self.id = id
2023
if let codable {
2124
navigation = NavigationPath(codable)
2225
} else {
@@ -30,23 +33,27 @@ class CartographyPath: ObservableObject {
3033

3134
func save() {
3235
guard
33-
Navigation.isPreview == false,
36+
Navigation.shared.isPreview == false,
3437
let representation = navigation.codable
3538
else { return }
3639

3740
do {
38-
try Disk.out(representation, filename: Self.filename)
41+
try Disk.out(representation, filename: Self.name(id: id))
3942
} catch {
4043
print(error.localizedDescription)
4144
}
4245
}
4346

44-
static func load() -> CartographyPath {
47+
static func load(id: String) -> CartographyPath {
4548
defer {
46-
try? Disk.delete(filename: filename)
49+
try? Disk.delete(filename: name(id: id))
4750
}
4851

49-
return CartographyPath(try? Disk.in(filename: filename))
52+
return CartographyPath(id: id, try? Disk.in(filename: name(id: id)))
53+
}
54+
55+
static func name(id: String) -> String {
56+
"\(filePrefix).\(id)"
5057
}
5158
}
5259

base/base/Navigation/Implementation/CartographyView.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ struct CartographyView<RootView: View>: View {
5656

5757
extension CartographyView {
5858
static func preview(_ content: @escaping () -> RootView) -> CartographyView {
59-
Navigation.isPreview = true
60-
Navigation.path = CartographyPath()
59+
Navigation.shared.isPreview = true
6160

6261
return CartographyView(path: Navigation.path, rootView: content)
6362
}

base/base/Navigation/Implementation/Toast/ToastModifier.swift

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
import SwiftUI
99

10-
/// This `ViewModifier` allows us to define the actual view modifier, its animation and interaction within the view.
11-
/// This is built to be applied over any of the content shown, using `ZStack`.
1210
struct ToastModifer: ViewModifier {
1311
@Binding var toast: CartographyToast?
1412
@State private var workItem: DispatchWorkItem?
@@ -17,9 +15,8 @@ struct ToastModifer: ViewModifier {
1715
content
1816
.frame(maxWidth: .infinity, maxHeight: .infinity)
1917
.overlay(
20-
ZStack {
21-
toastView()
22-
}.animation(.spring(), value: toast)
18+
toastView()
19+
.animation(.spring(), value: toast)
2320
)
2421
.onChange(of: toast) { _ in
2522
showToast()

0 commit comments

Comments
 (0)