From 382121de2e79303845331d699adcdd777f8f062a Mon Sep 17 00:00:00 2001 From: Dustin Mierau Date: Tue, 9 Jan 2024 10:30:44 -0800 Subject: Split view in News saves position and hiding when an article isn't selected. Some code cleanup. Some plumbing for news posting though it's not hooked up yet. --- Hotline.xcodeproj/project.pbxproj | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'Hotline.xcodeproj/project.pbxproj') diff --git a/Hotline.xcodeproj/project.pbxproj b/Hotline.xcodeproj/project.pbxproj index 8358f3b..b6ef33b 100644 --- a/Hotline.xcodeproj/project.pbxproj +++ b/Hotline.xcodeproj/project.pbxproj @@ -23,6 +23,9 @@ DA5753682B33E88A00FAC277 /* HotlineFileClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA5753672B33E88A00FAC277 /* HotlineFileClient.swift */; }; DA57536C2B36BA1D00FAC277 /* TextDocument.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA57536B2B36BA1D00FAC277 /* TextDocument.swift */; }; DA6300972B24036B0034CBFD /* HotlineClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA6300962B24036B0034CBFD /* HotlineClient.swift */; }; + DA72A0DD2B4CD0BF00A0F48A /* NewsEditorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA72A0DC2B4CD0BF00A0F48A /* NewsEditorView.swift */; }; + DA72A0E02B4DA8CA00A0F48A /* SplitView in Frameworks */ = {isa = PBXBuildFile; productRef = DA72A0DF2B4DA8CA00A0F48A /* SplitView */; }; + DA72A0E22B4DAA4000A0F48A /* NewsArticle.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA72A0E12B4DAA4000A0F48A /* NewsArticle.swift */; }; DA77253F2B21176D006C5ABB /* NewsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA77253E2B21176D006C5ABB /* NewsView.swift */; platformFilter = ios; }; DA7725412B21435B006C5ABB /* ObservableScrollView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA7725402B21435B006C5ABB /* ObservableScrollView.swift */; }; DA9CAFBB2B126D5700CDA197 /* Application.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA9CAFBA2B126D5700CDA197 /* Application.swift */; }; @@ -74,6 +77,8 @@ DA5753672B33E88A00FAC277 /* HotlineFileClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HotlineFileClient.swift; sourceTree = ""; }; DA57536B2B36BA1D00FAC277 /* TextDocument.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextDocument.swift; sourceTree = ""; }; DA6300962B24036B0034CBFD /* HotlineClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HotlineClient.swift; sourceTree = ""; }; + DA72A0DC2B4CD0BF00A0F48A /* NewsEditorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewsEditorView.swift; sourceTree = ""; }; + DA72A0E12B4DAA4000A0F48A /* NewsArticle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewsArticle.swift; sourceTree = ""; }; DA77253E2B21176D006C5ABB /* NewsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewsView.swift; sourceTree = ""; }; DA7725402B21435B006C5ABB /* ObservableScrollView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObservableScrollView.swift; sourceTree = ""; }; DA9CAFB72B126D5700CDA197 /* Hotline.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Hotline.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -111,6 +116,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + DA72A0E02B4DA8CA00A0F48A /* SplitView in Frameworks */, DAB4D8872B4CB3610048A05C /* MarkdownUI in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -222,6 +228,7 @@ DA2863DC2B3E8B7000A7D050 /* FilePreview.swift */, DA32CD4C2B2931B50053B98B /* ChatMessage.swift */, DA32CD4E2B2931CC0053B98B /* NewsInfo.swift */, + DA72A0E12B4DAA4000A0F48A /* NewsArticle.swift */, DAAEE66C2B475F1400A5BA07 /* PreviewFileInfo.swift */, ); path = Models; @@ -239,6 +246,7 @@ DAE735002B2E71F2000C56F6 /* FilesView.swift */, DAAEE66E2B47625600A5BA07 /* FilePreviewImageView.swift */, DAB4D87D2B4C8BCA0048A05C /* FilePreviewTextView.swift */, + DA72A0DC2B4CD0BF00A0F48A /* NewsEditorView.swift */, DA2863D72B37AD1C00A7D050 /* SettingsView.swift */, ); path = macOS; @@ -262,6 +270,7 @@ name = Hotline; packageProductDependencies = ( DAB4D8862B4CB3610048A05C /* MarkdownUI */, + DA72A0DF2B4DA8CA00A0F48A /* SplitView */, ); productName = Hotline; productReference = DA9CAFB72B126D5700CDA197 /* Hotline.app */; @@ -293,6 +302,7 @@ mainGroup = DA9CAFAE2B126D5700CDA197; packageReferences = ( DAB4D8852B4CB3610048A05C /* XCRemoteSwiftPackageReference "swift-markdown-ui" */, + DA72A0DE2B4DA8CA00A0F48A /* XCRemoteSwiftPackageReference "SplitView" */, ); productRefGroup = DA9CAFB82B126D5700CDA197 /* Products */; projectDirPath = ""; @@ -333,6 +343,7 @@ DAC002192B21630900A6C290 /* SwiftUIExtensions.swift in Sources */, DADDB28F2B238D850024040D /* Hotline.swift in Sources */, DADDB28D2B22B5920024040D /* Server.swift in Sources */, + DA72A0E22B4DAA4000A0F48A /* NewsArticle.swift in Sources */, DAE734FB2B2E41F9000C56F6 /* TrackerView.swift in Sources */, DA9CAFBD2B126D5700CDA197 /* TrackerView.swift in Sources */, DAB4D87B2B4B78310048A05C /* AnimatedImageView.swift in Sources */, @@ -346,6 +357,7 @@ DA0D698F2B1E841600C71DF5 /* MessageBoardView.swift in Sources */, DAE735072B3251B3000C56F6 /* Utilities.swift in Sources */, DAE735012B2E71F2000C56F6 /* FilesView.swift in Sources */, + DA72A0DD2B4CD0BF00A0F48A /* NewsEditorView.swift in Sources */, DABFCC292B1530DC009F40D2 /* FoundationExtensions.swift in Sources */, DA57536C2B36BA1D00FAC277 /* TextDocument.swift in Sources */, DA77253F2B21176D006C5ABB /* NewsView.swift in Sources */, @@ -590,6 +602,14 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ + DA72A0DE2B4DA8CA00A0F48A /* XCRemoteSwiftPackageReference "SplitView" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/stevengharris/SplitView"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 3.5.0; + }; + }; DAB4D8852B4CB3610048A05C /* XCRemoteSwiftPackageReference "swift-markdown-ui" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/gonzalezreal/swift-markdown-ui"; @@ -601,6 +621,11 @@ /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ + DA72A0DF2B4DA8CA00A0F48A /* SplitView */ = { + isa = XCSwiftPackageProductDependency; + package = DA72A0DE2B4DA8CA00A0F48A /* XCRemoteSwiftPackageReference "SplitView" */; + productName = SplitView; + }; DAB4D8862B4CB3610048A05C /* MarkdownUI */ = { isa = XCSwiftPackageProductDependency; package = DAB4D8852B4CB3610048A05C /* XCRemoteSwiftPackageReference "swift-markdown-ui" */; -- cgit From 60f90281bf971600733b2d72b747bcb6be9b1c31 Mon Sep 17 00:00:00 2001 From: Dustin Mierau Date: Tue, 9 Jan 2024 14:16:44 -0800 Subject: Focus address field in connect view when window opens. Add a note to connect view. Remove some console logging. --- Hotline.xcodeproj/project.pbxproj | 4 +- Hotline/Hotline/HotlineClient.swift | 2 - Hotline/Models/Hotline.swift | 8 -- Hotline/macOS/ChatView.swift | 1 - Hotline/macOS/FilePreviewImageView.swift | 1 - Hotline/macOS/FilePreviewTextView.swift | 1 - Hotline/macOS/FilesView.swift | 1 - Hotline/macOS/MessageBoardView.swift | 2 - Hotline/macOS/ServerView.swift | 151 +++++++++++++++++-------------- 9 files changed, 87 insertions(+), 84 deletions(-) (limited to 'Hotline.xcodeproj/project.pbxproj') diff --git a/Hotline.xcodeproj/project.pbxproj b/Hotline.xcodeproj/project.pbxproj index b6ef33b..d1448ee 100644 --- a/Hotline.xcodeproj/project.pbxproj +++ b/Hotline.xcodeproj/project.pbxproj @@ -508,7 +508,7 @@ CODE_SIGN_ENTITLEMENTS = Hotline/Hotline.entitlements; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 7; + CURRENT_PROJECT_VERSION = 8; DEVELOPMENT_ASSET_PATHS = "\"Hotline/Preview Content\""; DEVELOPMENT_TEAM = 5AEEV7QB2U; "ENABLE_HARDENED_RUNTIME[sdk=macosx*]" = YES; @@ -547,7 +547,7 @@ CODE_SIGN_ENTITLEMENTS = Hotline/Hotline.entitlements; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 7; + CURRENT_PROJECT_VERSION = 8; DEVELOPMENT_ASSET_PATHS = "\"Hotline/Preview Content\""; DEVELOPMENT_TEAM = 5AEEV7QB2U; "ENABLE_HARDENED_RUNTIME[sdk=macosx*]" = YES; diff --git a/Hotline/Hotline/HotlineClient.swift b/Hotline/Hotline/HotlineClient.swift index c1b13ff..ccb0c4c 100644 --- a/Hotline/Hotline/HotlineClient.swift +++ b/Hotline/Hotline/HotlineClient.swift @@ -178,7 +178,6 @@ class HotlineClient { } func disconnect() { - print("DISCONNECT?") for (_, replyInfo) in self.transactionLog { let replyCallback = replyInfo.1 replyCallback?(HotlineTransaction(type: replyInfo.0), .networkFailure) @@ -193,7 +192,6 @@ class HotlineClient { private func sendTransaction(_ t: HotlineTransaction, sent sentCallback: ((Bool) -> Void)? = nil, reply replyCallback: ((HotlineTransaction, HotlineTransactionError?) -> Void)? = nil) { guard let c = connection else { - print("NO CONNECTION?????") sentCallback?(false) return } diff --git a/Hotline/Models/Hotline.swift b/Hotline/Models/Hotline.swift index c018e55..e62ac15 100644 --- a/Hotline/Models/Hotline.swift +++ b/Hotline/Models/Hotline.swift @@ -246,8 +246,6 @@ final class Hotline: HotlineClientDelegate, HotlineFileClientDelegate { self.username = username self.iconID = iconID - print("CLIENT LOGIN: '\(server.login)' '\(server.password)'") - self.client.login(server.address, port: UInt16(server.port), login: server.login, password: server.password, username: username, iconID: UInt16(iconID)) { [weak self] err, serverName, serverVersion in self?.serverVersion = serverVersion if serverName != nil { @@ -335,8 +333,6 @@ final class Hotline: HotlineClientDelegate, HotlineFileClientDelegate { continuation.resume(returning: nil) return } - - print("GET NEWS CATS FROM \(path)") }, reply: { articleText in // let parentNews = self?.findNews(in: self?.news ?? [], at: path) @@ -376,8 +372,6 @@ final class Hotline: HotlineClientDelegate, HotlineFileClientDelegate { continuation.resume(returning: []) return } - - print("GET NEWS CATS FROM \(path)") }, reply: { [weak self] categories in // let parentNews = self?.findNews(in: self?.news ?? [], at: path) @@ -445,8 +439,6 @@ final class Hotline: HotlineClientDelegate, HotlineFileClientDelegate { } return } - - print("GET NEWS CATS FROM \(path)") }, reply: { [weak self] categories in let parentNews = self?.findNews(in: self?.news ?? [], at: path) diff --git a/Hotline/macOS/ChatView.swift b/Hotline/macOS/ChatView.swift index 2c154d3..7f7d677 100644 --- a/Hotline/macOS/ChatView.swift +++ b/Hotline/macOS/ChatView.swift @@ -118,7 +118,6 @@ struct ChatView: View { // withAnimation { reader.scrollTo(bottomID, anchor: .bottom) // } - print("SCROLLED TO BOTTOM") } .onAppear { reader.scrollTo(bottomID, anchor: .bottom) diff --git a/Hotline/macOS/FilePreviewImageView.swift b/Hotline/macOS/FilePreviewImageView.swift index 1ee4e9b..461f5a4 100644 --- a/Hotline/macOS/FilePreviewImageView.swift +++ b/Hotline/macOS/FilePreviewImageView.swift @@ -13,7 +13,6 @@ struct FilePreviewImageView: View { @Binding var info: PreviewFileInfo? @State var preview: FilePreview? = nil - @Namespace var mainNamespace @FocusState private var focusField: FilePreviewFocus? var body: some View { diff --git a/Hotline/macOS/FilePreviewTextView.swift b/Hotline/macOS/FilePreviewTextView.swift index 8b5b4f3..2cb192c 100644 --- a/Hotline/macOS/FilePreviewTextView.swift +++ b/Hotline/macOS/FilePreviewTextView.swift @@ -12,7 +12,6 @@ struct FilePreviewTextView: View { @Binding var info: PreviewFileInfo? @State var preview: FilePreview? = nil - @Namespace var mainNamespace @FocusState private var focusField: FilePreviewFocus? var body: some View { diff --git a/Hotline/macOS/FilesView.swift b/Hotline/macOS/FilesView.swift index 1eab0cf..b9f15db 100644 --- a/Hotline/macOS/FilesView.swift +++ b/Hotline/macOS/FilesView.swift @@ -218,7 +218,6 @@ struct FilesView: View { ToolbarItem(placement: .primaryAction) { Button { if let s = selection, !s.isFolder { - print("DOWNLOAD FILE", s.name, s.path) model.downloadFile(s.name, path: s.path) } } label: { diff --git a/Hotline/macOS/MessageBoardView.swift b/Hotline/macOS/MessageBoardView.swift index d72b122..65a947f 100644 --- a/Hotline/macOS/MessageBoardView.swift +++ b/Hotline/macOS/MessageBoardView.swift @@ -22,8 +22,6 @@ struct MessageBoardView: View { .task { if !model.messageBoardLoaded { let _ = await model.getMessageBoard() -// self.initialLoadComplete = true - print("INITIAL LOAD?") } } .overlay { diff --git a/Hotline/macOS/ServerView.swift b/Hotline/macOS/ServerView.swift index 366fff2..b21e4fb 100644 --- a/Hotline/macOS/ServerView.swift +++ b/Hotline/macOS/ServerView.swift @@ -171,88 +171,107 @@ struct ServerView: View { MenuItem(name: "Files", image: "folder", type: .files), ] + enum FocusFields { + case address + case login + case password + } + + @FocusState private var focusedField: FocusFields? + var connectForm: some View { - GroupBox { - Form { - Group { - TextField(text: $connectAddress) { - Text("Address:") - } - TextField(text: $connectLogin, prompt: Text("optional")) { - Text("Login:") + VStack(alignment: .center) { + GroupBox { + Form { + Group { + TextField(text: $connectAddress) { + Text("Address:") + } + .focused($focusedField, equals: .address) + + Text("Type the address of the Hotline server you would like to connect to. If you have an account on that server, type your login and password too.") + .font(.caption) + .foregroundStyle(.secondary) + + TextField(text: $connectLogin, prompt: Text("optional")) { + Text("Login:") + } + .focused($focusedField, equals: .login) + SecureField(text: $connectPassword, prompt: Text("optional")) { + Text("Password:") + } + .focused($focusedField, equals: .password) } - SecureField(text: $connectPassword, prompt: Text("optional")) { - Text("Password:") + .textFieldStyle(.roundedBorder) + .controlSize(.regular) + + HStack { + Button { + print("SAVE BOOKMARK... SOMEHOW") + } label: { + Text("Save...") + } + .controlSize(.regular) + .buttonStyle(.automatic) + .help("Save server as bookmark") + + Spacer() + + Button { + dismiss() + } label: { + Text("Cancel") + } + .controlSize(.regular) + .buttonStyle(.automatic) + .keyboardShortcut(.cancelAction) + + Button { + + // if var s = server { + // print("CHANGING EXISTING SERVER") + // s.name = newServer.name + // s.description = newServer.description + // s.users = newServer.users + // s.address = newServer.address + // s.port = newServer.port + // s.login = newServer.login + // s.password = newServer.password + // } + // else { + // server = newServer + // } + + Task { + await connectToServer() + } + } label: { + Text("Connect") + } + .controlSize(.regular) + .buttonStyle(.automatic) + .keyboardShortcut(.defaultAction) } + .padding(.top, 8) + } - .textFieldStyle(.roundedBorder) - .controlSize(.regular) + .padding() .onChange(of: connectAddress) { let (a, p) = Server.parseServerAddressAndPort(connectAddress) server.address = a server.port = p - print("ADDRESS CHANGED: '\(connectAddress)' \(a) \(p)") } .onChange(of: connectLogin) { server.login = connectLogin.trimmingCharacters(in: .whitespacesAndNewlines) - print("LOGIN CHANGED: '\(connectLogin)'" + $server.wrappedValue.login) } .onChange(of: connectPassword) { server.password = connectPassword - print("PASS CHANGED: '\(connectPassword)'" + server.password) - } - - HStack { - Button { - print("SAVE BOOKMARK... SOMEHOW") - } label: { - Text("Save...") - } - .controlSize(.regular) - .buttonStyle(.automatic) - .help("Save server as bookmark") - - Spacer() - - Button { - dismiss() - } label: { - Text("Cancel") - } - .controlSize(.regular) - .buttonStyle(.automatic) - .keyboardShortcut(.cancelAction) - - Button { - -// if var s = server { -// print("CHANGING EXISTING SERVER") -// s.name = newServer.name -// s.description = newServer.description -// s.users = newServer.users -// s.address = newServer.address -// s.port = newServer.port -// s.login = newServer.login -// s.password = newServer.password -// } -// else { -// server = newServer -// } - - Task { - await connectToServer() - } - } label: { - Text("Connect") - } - .controlSize(.regular) - .buttonStyle(.automatic) - .keyboardShortcut(.defaultAction) } - .padding(.top, 8) - } - .padding() +// .padding(.top, 8) + .onAppear { + focusedField = .address + } } .frame(maxWidth: 350) .padding() -- cgit