Skip to content

Commit

Permalink
Preferences (#35)
Browse files Browse the repository at this point in the history
* feat: removed Preferences dependency

* feat: replaced all Preferences lib usages with native SwiftUI views

* feat: small finishing touches
  • Loading branch information
ggoraa committed Jan 21, 2022
1 parent 4c2ece6 commit 679e549
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 58 deletions.
17 changes: 0 additions & 17 deletions Moc.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

/* Begin PBXBuildFile section */
430B983F278B680600420D75 /* Lottie in Frameworks */ = {isa = PBXBuildFile; productRef = 430B983E278B680600420D75 /* Lottie */; };
43217980279AF52F002AC3A1 /* Preferences in Frameworks */ = {isa = PBXBuildFile; productRef = 4321797F279AF52F002AC3A1 /* Preferences */; };
4321799B279B06AC002AC3A1 /* PreferencesContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43217985279B06AB002AC3A1 /* PreferencesContent.swift */; };
4321799E279B06AC002AC3A1 /* AccountsPrefView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43217989279B06AB002AC3A1 /* AccountsPrefView.swift */; };
4321799F279B06AC002AC3A1 /* PrivacyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4321798A279B06AB002AC3A1 /* PrivacyView.swift */; };
Expand Down Expand Up @@ -131,7 +130,6 @@
430B983F278B680600420D75 /* Lottie in Frameworks */,
43DD9648277E758C000CE509 /* libz.1.tbd in Frameworks */,
4386E47027837A810084F809 /* SwiftUIUtils in Frameworks */,
43217980279AF52F002AC3A1 /* Preferences in Frameworks */,
43DD9646277E7580000CE509 /* libc++.1.tbd in Frameworks */,
43E8FD6727919DD30016BE31 /* Logging in Frameworks */,
43C7B4C4278F3DEF00236503 /* SystemUtils in Frameworks */,
Expand Down Expand Up @@ -333,7 +331,6 @@
43E8FD6627919DD30016BE31 /* Logging */,
436207A02794F6AD008C7FFE /* Generated */,
436207A52796A3D6008C7FFE /* Backend */,
4321797F279AF52F002AC3A1 /* Preferences */,
);
productName = Moc;
productReference = 43DD9560277E50C0000CE509 /* Moc.app */;
Expand Down Expand Up @@ -391,7 +388,6 @@
430B983D278B680600420D75 /* XCRemoteSwiftPackageReference "lottie-ios" */,
4357F91E278E35F700154012 /* XCRemoteSwiftPackageReference "AlertToast" */,
43E8FD6527919DD30016BE31 /* XCRemoteSwiftPackageReference "swift-log" */,
4321797E279AF52F002AC3A1 /* XCRemoteSwiftPackageReference "Preferences" */,
);
productRefGroup = 43DD9561277E50C0000CE509 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -794,14 +790,6 @@
minimumVersion = 3.0.0;
};
};
4321797E279AF52F002AC3A1 /* XCRemoteSwiftPackageReference "Preferences" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/sindresorhus/Preferences.git";
requirement = {
kind = revision;
revision = ffeaaad1def45d0625720dc1adae3789cd9c167d;
};
};
4357F91E278E35F700154012 /* XCRemoteSwiftPackageReference "AlertToast" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/elai950/AlertToast.git";
Expand Down Expand Up @@ -842,11 +830,6 @@
package = 430B983D278B680600420D75 /* XCRemoteSwiftPackageReference "lottie-ios" */;
productName = Lottie;
};
4321797F279AF52F002AC3A1 /* Preferences */ = {
isa = XCSwiftPackageProductDependency;
package = 4321797E279AF52F002AC3A1 /* XCRemoteSwiftPackageReference "Preferences" */;
productName = Preferences;
};
4357F91F278E35F700154012 /* AlertToast */ = {
isa = XCSwiftPackageProductDependency;
package = 4357F91E278E35F700154012 /* XCRemoteSwiftPackageReference "AlertToast" */;
Expand Down
76 changes: 35 additions & 41 deletions Moc/Views/Preferences/Tabs/AccountsPrefView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import SwiftUI
import SwiftUIUtils
import Preferences
import Resolver
import ImageUtils
import SystemUtils
Expand Down Expand Up @@ -183,52 +182,46 @@ struct AccountsPrefView: View {
}

private var rightColumnContent: some View {
Preferences.Container(contentWidth: 450) {
Preferences.Section(title: "Profile photo:") {
Form {
Section {
HStack {
Image(nsImage: NSImage(contentsOf: URL(string: "file://\(photos[0].local.path)")!)!)
Image(nsImage: NSImage(contentsOf: URL(string: "file://\(photos[0].local.path)")!)!)
.resizable()
.frame(width: 32, height: 32)
.clipShape(Circle())
Button(action: { }) {
Label("Change", systemImage: "square.and.pencil")
Label("Update profile photo", systemImage: "square.and.pencil")
}
}
} footer: {
Text("Chat photo that will be shown next to your messages.")
.preferenceDescription()
.foregroundStyle(.secondary)
}
Preferences.Section(title: "First name:") {
TextField("First name", text: $firstName)
.textFieldStyle(.roundedBorder)
.frame(width: 150)
.onSubmit {
Task {
try await viewModel.dataSource.set(firstName: firstName)
}
TextField("First name", text: $lastName)
.textFieldStyle(.roundedBorder)
.frame(width: 150)
.onSubmit {
Task {
try await viewModel.dataSource.set(lastName: lastName)
}
}
Preferences.Section(title: "Last name:") {
TextField("First name", text: $lastName)
.textFieldStyle(.roundedBorder)
.frame(width: 150)
.onSubmit {
Task {
try await viewModel.dataSource.set(lastName: lastName)
}
}
TextField("Last name", text: $lastName)
.textFieldStyle(.roundedBorder)
.frame(width: 150)
.onSubmit {
Task {
try await viewModel.dataSource.set(lastName: lastName)
}
}
Preferences.Section(title: "Username:") {
TextField("Username", text: $username)
.textFieldStyle(.roundedBorder)
.frame(width: 150)
.onSubmit {
Task {
try await viewModel.dataSource.set(username: username)
}
}
TextField("Username", text: $username)
.textFieldStyle(.roundedBorder)
.frame(width: 150)
.onSubmit {
Task {
try await viewModel.dataSource.set(username: username)
}

}
Preferences.Section(title: "Bio:") {
}
Section {
TextField("Bio", text: $bioText)
.textFieldStyle(.roundedBorder)
.onSubmit {
Expand All @@ -237,13 +230,14 @@ struct AccountsPrefView: View {
}
}
.frame(width: 350)
} footer: {
Text("Any details such as age, occupation or city. Example: 23 y.o designer from San Francisco.")
.foregroundStyle(.secondary)
}
Preferences.Section(title: "Phone number:") {
HStack {
Text(phoneNumber)
Button(action: { }) {
Label("Change", systemImage: "square.and.pencil")
}
HStack {
Text(phoneNumber)
Button(action: { }) {
Label("Change", systemImage: "square.and.pencil")
}
}
}
Expand Down

0 comments on commit 679e549

Please sign in to comment.