diff --git a/SwiftSageiOS/SwiftSageiOS.xcodeproj/project.pbxproj b/SwiftSageiOS/SwiftSageiOS.xcodeproj/project.pbxproj index 6efec46..d2d217a 100644 --- a/SwiftSageiOS/SwiftSageiOS.xcodeproj/project.pbxproj +++ b/SwiftSageiOS/SwiftSageiOS.xcodeproj/project.pbxproj @@ -81,6 +81,7 @@ B767E9C329F6DAED003EC13F /* GestureEndpointPredictor.swift in Sources */ = {isa = PBXBuildFile; fileRef = B767E9BD29F6DAED003EC13F /* GestureEndpointPredictor.swift */; }; B767E9C429F6DAED003EC13F /* SystemReport.swift in Sources */ = {isa = PBXBuildFile; fileRef = B767E9BE29F6DAED003EC13F /* SystemReport.swift */; }; B767E9C629F6DAED003EC13F /* BorderManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = B767E9C029F6DAED003EC13F /* BorderManager.swift */; }; + B76AFCA52A15788100980EC7 /* Settings+ForkGithub.swift in Sources */ = {isa = PBXBuildFile; fileRef = B76AFCA42A15788100980EC7 /* Settings+ForkGithub.swift */; }; B78DA95F2A02AF01002343AB /* InstructionsPopup.swift in Sources */ = {isa = PBXBuildFile; fileRef = B78DA95E2A02AF01002343AB /* InstructionsPopup.swift */; }; B78DA9652A02AF3A002343AB /* AsciiAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = B78DA9612A02AF3A002343AB /* AsciiAnimator.swift */; }; B78DA9662A02AF3A002343AB /* SpinnerThread.swift in Sources */ = {isa = PBXBuildFile; fileRef = B78DA9622A02AF3A002343AB /* SpinnerThread.swift */; }; @@ -103,7 +104,6 @@ B78EAF812A13B7D4003095A2 /* SwiftSageiOSTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B78EAF802A13B7D4003095A2 /* SwiftSageiOSTests.swift */; }; B78EAF882A13B820003095A2 /* SettingsViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B78EAF872A13B820003095A2 /* SettingsViewModelTests.swift */; }; B78EAF902A13B955003095A2 /* SwiftSageiOSUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B78EAF8F2A13B955003095A2 /* SwiftSageiOSUITests.swift */; }; - B78EAF922A13B955003095A2 /* SwiftSageiOSUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B78EAF912A13B955003095A2 /* SwiftSageiOSUITestsLaunchTests.swift */; }; B7AED3712A0AC0420013E8D9 /* SageMultiViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7AED3702A0AC0420013E8D9 /* SageMultiViewModel.swift */; }; B7C11F2B2A01C62500701721 /* PTTWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7C11F2A2A01C62500701721 /* PTTWrapper.swift */; }; B7EF2A2B2A0C2D620048CFFC /* View+Keyboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7EF2A2A2A0C2D620048CFFC /* View+Keyboard.swift */; }; @@ -207,6 +207,7 @@ B767E9BD29F6DAED003EC13F /* GestureEndpointPredictor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GestureEndpointPredictor.swift; sourceTree = ""; }; B767E9BE29F6DAED003EC13F /* SystemReport.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SystemReport.swift; sourceTree = ""; }; B767E9C029F6DAED003EC13F /* BorderManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BorderManager.swift; sourceTree = ""; }; + B76AFCA42A15788100980EC7 /* Settings+ForkGithub.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Settings+ForkGithub.swift"; sourceTree = ""; }; B78DA95E2A02AF01002343AB /* InstructionsPopup.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InstructionsPopup.swift; sourceTree = ""; }; B78DA9612A02AF3A002343AB /* AsciiAnimator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AsciiAnimator.swift; sourceTree = ""; }; B78DA9622A02AF3A002343AB /* SpinnerThread.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpinnerThread.swift; sourceTree = ""; }; @@ -231,7 +232,6 @@ B78EAF872A13B820003095A2 /* SettingsViewModelTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingsViewModelTests.swift; sourceTree = ""; }; B78EAF8D2A13B955003095A2 /* SwiftSageiOSUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftSageiOSUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; B78EAF8F2A13B955003095A2 /* SwiftSageiOSUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftSageiOSUITests.swift; sourceTree = ""; }; - B78EAF912A13B955003095A2 /* SwiftSageiOSUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftSageiOSUITestsLaunchTests.swift; sourceTree = ""; }; B7AED3702A0AC0420013E8D9 /* SageMultiViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SageMultiViewModel.swift; sourceTree = ""; }; B7C11F2A2A01C62500701721 /* PTTWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PTTWrapper.swift; sourceTree = ""; }; B7EF2A2A2A0C2D620048CFFC /* View+Keyboard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View+Keyboard.swift"; sourceTree = ""; }; @@ -604,6 +604,7 @@ B78DA9852A07FEC1002343AB /* CommitDownloader.swift */, B78DA9872A07FEF3002343AB /* Settings+Github.swift */, B78EAF632A11C242003095A2 /* Settings+WriteGithub.swift */, + B76AFCA42A15788100980EC7 /* Settings+ForkGithub.swift */, ); name = Github; sourceTree = ""; @@ -621,7 +622,6 @@ isa = PBXGroup; children = ( B78EAF8F2A13B955003095A2 /* SwiftSageiOSUITests.swift */, - B78EAF912A13B955003095A2 /* SwiftSageiOSUITestsLaunchTests.swift */, ); path = SwiftSageiOSUITests; sourceTree = ""; @@ -793,6 +793,7 @@ B767E9C329F6DAED003EC13F /* GestureEndpointPredictor.swift in Sources */, B74A2CD129F7F6990051DB52 /* WSCompression.swift in Sources */, B71C62E529FEB794004296E4 /* SpeechRecog.swift in Sources */, + B76AFCA52A15788100980EC7 /* Settings+ForkGithub.swift in Sources */, B7191F2629F9F09A00078D8D /* SyntaxTextView.swift in Sources */, B7191F1A29F9F09A00078D8D /* NSMutableAttributedString+Tokens.swift in Sources */, B7191F1D29F9F09A00078D8D /* SwiftLexer.swift in Sources */, @@ -883,7 +884,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - B78EAF922A13B955003095A2 /* SwiftSageiOSUITestsLaunchTests.swift in Sources */, B78EAF902A13B955003095A2 /* SwiftSageiOSUITests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1052,7 +1052,7 @@ LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 1.1.5; + MARKETING_VERSION = 1.1.6; PRODUCT_BUNDLE_IDENTIFIER = com.chrisdillard.SwiftSageDev; PRODUCT_NAME = LogicSageDev; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1102,7 +1102,7 @@ LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 1.1.5; + MARKETING_VERSION = 1.1.6; PRODUCT_BUNDLE_IDENTIFIER = com.chrisdillard.SwiftSage; PRODUCT_NAME = LogicSage; SDKROOT = auto; @@ -1121,7 +1121,7 @@ CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = 72WEN2C47N; GENERATE_INFOPLIST_FILE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 16.4; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = com.chrisswiftygpt.SwiftSageiOSTests; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1141,7 +1141,7 @@ CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = 72WEN2C47N; GENERATE_INFOPLIST_FILE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 16.4; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = com.chrisswiftygpt.SwiftSageiOSTests; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1161,7 +1161,7 @@ CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = 72WEN2C47N; GENERATE_INFOPLIST_FILE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 16.4; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = com.chrisswiftygpt.SwiftSageiOSUITests; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1180,7 +1180,7 @@ CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = 72WEN2C47N; GENERATE_INFOPLIST_FILE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 16.4; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = com.chrisswiftygpt.SwiftSageiOSUITests; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/SwiftSageiOS/SwiftSageiOS/ViewViewModel/AddView.swift b/SwiftSageiOS/SwiftSageiOS/ViewViewModel/AddView.swift index a42edbd..f71a830 100644 --- a/SwiftSageiOS/SwiftSageiOS/ViewViewModel/AddView.swift +++ b/SwiftSageiOS/SwiftSageiOS/ViewViewModel/AddView.swift @@ -16,6 +16,8 @@ struct AddView: View { @ObservedObject var settingsViewModel: SettingsViewModel @EnvironmentObject var windowManager: WindowManager + + // TODO: Reuse this to handle open / not open and restore repo / filw and window list @AppStorage("repoListOpen") var repoListOpen: Bool = false @AppStorage("fileListOpen") var fileListOpen: Bool = false @AppStorage("windowListOpen") var windowListOpen: Bool = false @@ -96,16 +98,17 @@ struct AddView: View { } }) { VStack { - Text("New File...") - .font(.subheadline) - .foregroundColor(settingsViewModel.appTextColor) - .padding(.bottom) + resizableButtonImage(systemName: "doc.fill.badge.plus", size: geometry.size) .fontWeight(.bold) .cornerRadius(8) + + Text("New File...") + .font(.subheadline) + .foregroundColor(settingsViewModel.appTextColor) } } .padding(.horizontal, 8) @@ -131,18 +134,18 @@ struct AddView: View { } }) { VStack { - HStack { - Text("New webview: " ) - .font(.subheadline) - .foregroundColor(settingsViewModel.appTextColor) - } resizableButtonImage(systemName: "rectangle.center.inset.filled.badge.plus", size: geometry.size) .fontWeight(.bold) .background(settingsViewModel.buttonColor) .cornerRadius(8) + + Text("New webview: " ) + .font(.subheadline) + .foregroundColor(settingsViewModel.appTextColor) + } } .padding(.horizontal, 8) @@ -192,16 +195,18 @@ struct AddView: View { } }) { VStack { - Text("View Working Changes...") - .font(.subheadline) - .foregroundColor(settingsViewModel.appTextColor) - .padding(.bottom) + resizableButtonImage(systemName: "lasso.and.sparkles", size: geometry.size) - .fontWeight(.bold) - .cornerRadius(8) + .fontWeight(.bold) + .cornerRadius(8) + + Text("View Working Changes...") + .font(.subheadline) + .foregroundColor(settingsViewModel.appTextColor) + .padding(.bottom) } } } @@ -228,9 +233,118 @@ struct AddView: View { if settingsViewModel.repoSettingsShown { VStack { // YOUR GITHUB USERNAME - Text("User Settings") +// Text("User Settings") +// .font(.body) +// .lineLimit(nil) +// .fontWeight(.bold) +// .padding() +// .foregroundColor(settingsViewModel.appTextColor) + HStack { + + if !settingsViewModel.isLoading { + + HStack(spacing: 4) { + VStack { + Button(action: { + logD("FORKING repo...") + settingsViewModel.forkGithubRepo { success in + repoListOpen = true + logD("fork repo success = \(success)") + + } + }) { + VStack { + resizableButtonImage(systemName: + "tuningfork", + size: geometry.size) + .fontWeight(.bold) + .background(settingsViewModel.buttonColor) + .cornerRadius(8) + } + } + .frame( maxWidth: .infinity, maxHeight: .infinity) + .padding(.bottom) + + Text("\(settingsViewModel.yourGitUser):\(settingsViewModel.gitRepo):\(settingsViewModel.gitBranch)") + .font(.caption) + .scaledToFill() + .minimumScaleFactor(0.01) + .foregroundColor(settingsViewModel.appTextColor) + } + + VStack { + HStack(spacing: 4) { + Button(action: { + logD("Downloading repo...") + settingsViewModel.syncGithubRepo { success in + repoListOpen = true + logD("download repo success = \(success)") + } + }) { + VStack { + resizableButtonImage(systemName: + "arrow.down.doc", + size: geometry.size) + .fontWeight(.bold) + .background(settingsViewModel.buttonColor) + .cornerRadius(8) + } + } + .frame( maxWidth: .infinity, maxHeight: .infinity) + .padding(.bottom) + } + + Text("dl/replace: \(settingsViewModel.currentGitRepoKey().replacingOccurrences(of: SettingsViewModel.gitKeySeparator, with: "/"))") + .font(.caption) + .scaledToFill() + .minimumScaleFactor(0.01) + + .foregroundColor(settingsViewModel.appTextColor) + + } + + } + .padding(.leading, 8) + .padding(.trailing, 8) + + + } + else { + if settingsViewModel.unzipProgress > 0.0 { + HStack { + Text("unzip...") + ProgressView(value: settingsViewModel.unzipProgress) + } + .padding(.trailing, 32) + .padding(.leading, 32) + + } + if settingsViewModel.downloadProgress > 0.0 { + HStack { + Text("download...") + + ProgressView(value: settingsViewModel.downloadProgress) + } + .padding(.trailing, 32) + .padding(.leading, 32) + } +// + if settingsViewModel.forkProgress > 0.0 { + HStack { + Text("forking...") + + ProgressView(value: settingsViewModel.forkProgress) + } + .padding(.trailing, 32) + .padding(.leading, 32) + } + } + } + .frame(height: geometry.size.height / 17) + HStack { - Text("git username: ") + + Text("your github username:") .font(.body) .lineLimit(nil) .fontWeight(.bold) @@ -239,7 +353,7 @@ struct AddView: View { TextField( "", - text: $settingsViewModel.gitUser + text: $settingsViewModel.yourGitUser ) .border(.secondary) .submitLabel(.done) @@ -255,9 +369,6 @@ struct AddView: View { .autocapitalization(.none) #endif } - .frame(height: geometry.size.height / 17) - - Text("Remote repo settings:") .font(.body) .lineLimit(nil) @@ -270,7 +381,7 @@ struct AddView: View { TextField( "", - text: $settingsViewModel.yourGitUser + text: $settingsViewModel.gitUser ) .border(.secondary) .submitLabel(.done) @@ -289,7 +400,7 @@ struct AddView: View { .frame(height: geometry.size.height / 17) HStack { - Text("repo: ").font(.caption) + Text("repo:").font(.caption) .foregroundColor(settingsViewModel.appTextColor) TextField( @@ -313,10 +424,8 @@ struct AddView: View { } .frame(height: geometry.size.height / 17) HStack { - Text("branch: ").font(.caption) + Text("branch:").font(.caption) .foregroundColor(settingsViewModel.appTextColor) - - TextField( "", text: $settingsViewModel.gitBranch @@ -342,67 +451,12 @@ struct AddView: View { .padding(.trailing,8) } - Text("download: \(settingsViewModel.currentGitRepoKey().replacingOccurrences(of: SettingsViewModel.gitKeySeparator, with: "/"))") - .font(.subheadline) - .foregroundColor(settingsViewModel.appTextColor) - - if !settingsViewModel.isLoading { - HStack(spacing: 4) { - Button(action: { - logD("Downloading repo...") - settingsViewModel.syncGithubRepo { success in - repoListOpen = true - - } - }) { - VStack { - - resizableButtonImage(systemName: - "arrow.down.doc", - size: geometry.size) - .fontWeight(.bold) - .background(settingsViewModel.buttonColor) - .cornerRadius(8) - } - } - .frame( maxWidth: .infinity, maxHeight: .infinity) - .padding(.bottom) - } - .frame(width: geometry.size.width - (geometry.size.width * 0.3)) - } - else { - if settingsViewModel.unzipProgress > 0.0 { - HStack { - Text("unzip...") - ProgressView(value: settingsViewModel.unzipProgress) - } - .padding(.trailing, 32) - .padding(.leading, 32) - - } - if settingsViewModel.downloadProgress > 0.0 { - HStack { - Text("download...") - - ProgressView(value: settingsViewModel.downloadProgress) - } - .padding(.trailing, 32) - .padding(.leading, 32) - } - } Group { VStack { HStack(spacing: 4) { - Text("Repo File Tree") - .font(.subheadline) - .lineLimit(nil) - .fontWeight(.bold) - .padding() - .foregroundColor(settingsViewModel.appTextColor) VStack { - resizableButtonImage(systemName: "macwindow.on.rectangle", size: geometry.size) @@ -426,17 +480,20 @@ struct AddView: View { #endif } } + Text("Repo File Tree") + .font(.subheadline) + .lineLimit(nil) + .fontWeight(.bold) + .padding() + .foregroundColor(settingsViewModel.appTextColor) + } } } } - HStack(spacing: 4) { + VStack { + - Text("Window List") - .font(.subheadline) - .lineLimit(nil) - .padding() - .foregroundColor(settingsViewModel.appTextColor) resizableButtonImage(systemName: "macwindow.on.rectangle", @@ -460,6 +517,11 @@ struct AddView: View { #endif } } + Text("Window List") + .font(.subheadline) + .lineLimit(nil) + .padding() + .foregroundColor(settingsViewModel.appTextColor) } Button(action: { diff --git a/SwiftSageiOS/SwiftSageiOS/ViewViewModel/SageMultiView.swift b/SwiftSageiOS/SwiftSageiOS/ViewViewModel/SageMultiView.swift index 3c5f94f..b63a5aa 100644 --- a/SwiftSageiOS/SwiftSageiOS/ViewViewModel/SageMultiView.swift +++ b/SwiftSageiOS/SwiftSageiOS/ViewViewModel/SageMultiView.swift @@ -237,7 +237,7 @@ struct WebView: UIViewRepresentable { struct HandleView: View { var body: some View { Circle() - .frame(width: SettingsViewModel.shared.middleHandleSize, height: SettingsViewModel.shared.middleHandleSize) + .frame(width: SettingsViewModel.shared.cornerHandleSize, height: SettingsViewModel.shared.cornerHandleSize) .foregroundColor(Color.white.opacity(0.666)) } } diff --git a/SwiftSageiOS/SwiftSageiOS/ViewViewModel/Settings/Settings+ForkGithub.swift b/SwiftSageiOS/SwiftSageiOS/ViewViewModel/Settings/Settings+ForkGithub.swift new file mode 100644 index 0000000..7e22f36 --- /dev/null +++ b/SwiftSageiOS/SwiftSageiOS/ViewViewModel/Settings/Settings+ForkGithub.swift @@ -0,0 +1,51 @@ +// +// Settings+ForkGithub.swift +// SwiftSageiOS +// +// Created by Chris Dillard on 5/17/23. +// + +import Foundation + + +var forkObservation: NSKeyValueObservation? + +extension SettingsViewModel { + func forkGithubRepo(defaulBranch: String = "main", newBranchName: String = UUID().uuidString, titleOfPR: String = UUID().uuidString, forkCompletion: @escaping (Bool) -> Void) { +#if !os(macOS) + // Create the URL for the request + guard let url = URL(string: "https://api.github.com/repos/\(gitUser)/\(gitRepo)/forks") else { + logD("Invalid URL") + return + } + + // Create the request + var request = URLRequest(url: url) + request.httpMethod = "POST" + request.addValue("token \(ghaPat)", forHTTPHeaderField: "Authorization") + + // Create the URLSession task + let task = URLSession.shared.dataTask(with: request) { (data, response, error) in + if let error = error { + logD("Error: \(error)") + forkCompletion(false) + + } else if let data = data { + // Handle the data from the response + let str = String(data: data, encoding: .utf8) + logD("Received data:\n\(str ?? "")") + forkCompletion(true) + } + } + forkObservation = task.progress.observe(\.fractionCompleted) { progress, _ in + DispatchQueue.main.async { + + self.forkProgress = progress.fractionCompleted + } + } + // Start the task + task.resume() +#endif + } + +} diff --git a/SwiftSageiOS/SwiftSageiOS/ViewViewModel/Settings/Settings+Github.swift b/SwiftSageiOS/SwiftSageiOS/ViewViewModel/Settings/Settings+Github.swift index 3adb9b2..7282ef9 100644 --- a/SwiftSageiOS/SwiftSageiOS/ViewViewModel/Settings/Settings+Github.swift +++ b/SwiftSageiOS/SwiftSageiOS/ViewViewModel/Settings/Settings+Github.swift @@ -85,9 +85,12 @@ extension SettingsViewModel { let fileURL = getDocumentsDirectory().appendingPathComponent(self.gitUser) + + let existingExtraction = fileURL.appendingPathComponent(self.gitRepo + "-" + self.gitBranch) + // TODO: Double check this for multiple repos in same user/org.... do { - try FileManager.default.removeItem(at: fileURL) + try FileManager.default.removeItem(at: existingExtraction) } catch { print("did not delete or didn't exist old REPO") diff --git a/SwiftSageiOS/SwiftSageiOS/ViewViewModel/Settings/Settings+WriteGithub.swift b/SwiftSageiOS/SwiftSageiOS/ViewViewModel/Settings/Settings+WriteGithub.swift index ffeb6cd..7bb6ed8 100644 --- a/SwiftSageiOS/SwiftSageiOS/ViewViewModel/Settings/Settings+WriteGithub.swift +++ b/SwiftSageiOS/SwiftSageiOS/ViewViewModel/Settings/Settings+WriteGithub.swift @@ -8,10 +8,10 @@ import Foundation extension SettingsViewModel { - func actualCreateDraftPR(defaulBranch: String = "main", newBranchName: String = UUID().uuidString, titleOfPR: String = UUID().uuidString) { + func actualCreateDraftPR(defaulBranch: String = "main", newBranchName: String = UUID().uuidString, titleOfPR: String = UUID().uuidString, completion: @escaping (Bool) -> Void) { #if !os(macOS) var hasSentPRCreation = false - print("actually creating draft pr") + logD("actually creating draft pr") getDefaultHeadSha(defaultBranch: defaulBranch) { sha in self.createDrafBranch(newBranchName: newBranchName, commitSha: sha) { success in if success { @@ -24,37 +24,37 @@ extension SettingsViewModel { let trailingPath = trailingPathComps[1] self.getShaOfFileFromPath(path: trailingPath) { sha in - print("got sha of changed file") + logD("got sha of changed file") self.updateFileWithNewContent(branch: newBranchName, sha: sha, path: trailingPath, fileContent: file.newFileContents) { success in if success { - print("Update file success") + logD("Update file success") if !hasSentPRCreation { hasSentPRCreation = true self.createPR(titleOfPR: titleOfPR, branchName: newBranchName) { success in if success { - print("Successful PR creation") + logD("Successful PR creation") } else { - print("fail to create draft PR") + logD("fail to create draft PR") } } } } else { - print("Update file FAIL") + logD("Update file FAIL") } } } } else { - print("failed to extract trailing path") + logD("failed to extract trailing path") } } } else { - print("fail to create draf branch") + logD("fail to create draf branch") } } } @@ -69,17 +69,17 @@ extension SettingsViewModel { let task = URLSession.shared.dataTask(with: request) { data, response, error in if let error = error { - print("Error: \(error)") + logD("Error: \(error)") } else if let data = data { do { if let json = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any], let commit = json["commit"] as? [String: Any] { - print(commit["sha"] as? String ?? "") + logD(commit["sha"] as? String ?? "") completion(commit["sha"] as? String ?? "") } } catch { - print("Error: \(error)") + logD("Error: \(error)") completion("") } } @@ -98,13 +98,13 @@ extension SettingsViewModel { request.httpBody = jsonData let task = URLSession.shared.dataTask(with: request) { data, response, error in if let error = error { - print("Error: \(error)") + logD("Error: \(error)") completion(false) } else if let data = data { let str = String(data: data, encoding: .utf8) - print("Received data:\n\(str ?? "")") + logD("Received data:\n\(str ?? "")") - print("Continuing on to create PR") + logD("Continuing on to create PR") completion(true) } } @@ -123,14 +123,14 @@ extension SettingsViewModel { request.httpBody = jsonData let task = URLSession.shared.dataTask(with: request) { data, response, error in if let error = error { - print("Error: \(error)") + logD("Error: \(error)") } else if let data = data { do { let jsonResponse = try JSONSerialization.jsonObject(with: data, options: []) - print(jsonResponse) + logD("\(jsonResponse)") completion(true) } catch { - print("Error: \(error)") + logD("Error: \(error)") completion(false) } } @@ -145,16 +145,16 @@ extension SettingsViewModel { request.addValue("token \(SettingsViewModel.shared.ghaPat)", forHTTPHeaderField: "Authorization") let task = URLSession.shared.dataTask(with: request) { data, response, error in if let error = error { - print("Error: \(error)") + logD("Error: \(error)") completion("") } else if let data = data { do { if let json = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] { - print(json["sha"] as? String ?? "") + logD(json["sha"] as? String ?? "") completion(json["sha"] as? String ?? "") } } catch { - print("Error: \(error)") + logD("Error: \(error)") completion("") } } @@ -176,11 +176,11 @@ extension SettingsViewModel { request.httpBody = jsonData let task = URLSession.shared.dataTask(with: request) { data, response, error in if let error = error { - print("Error: \(error)") + logD("Error: \(error)") completion(false) } else if let data = data { let str = String(data: data, encoding: .utf8) - print("Received data:\n\(str ?? "")") + logD("Received data:\n\(str ?? "")") completion(true) } } diff --git a/SwiftSageiOS/SwiftSageiOS/ViewViewModel/Settings/SettingsVIew.swift b/SwiftSageiOS/SwiftSageiOS/ViewViewModel/Settings/SettingsVIew.swift index 3eb3098..2dde253 100644 --- a/SwiftSageiOS/SwiftSageiOS/ViewViewModel/Settings/SettingsVIew.swift +++ b/SwiftSageiOS/SwiftSageiOS/ViewViewModel/Settings/SettingsVIew.swift @@ -393,28 +393,7 @@ struct SettingsView: View { .lineLimit(nil) } - Group { - Text("middle handle size") - .fontWeight(.semibold) - .foregroundColor(settingsViewModel.appTextColor) - - HStack { - Text("Small") .foregroundColor(settingsViewModel.appTextColor) - - Slider(value: $settingsViewModel.middleHandleSize, in: 18...48, step: 1) - .accentColor(settingsViewModel.buttonColor) - .foregroundColor(settingsViewModel.appTextColor) - - Text("Large") - .foregroundColor(settingsViewModel.appTextColor) - - } - Text("\(settingsViewModel.middleHandleSize)") - .font(.body) - .foregroundColor(settingsViewModel.appTextColor) - - .lineLimit(nil) - } + Group { Text("corner handle size") .fontWeight(.semibold) diff --git a/SwiftSageiOS/SwiftSageiOS/ViewViewModel/Settings/SettingsViewModel.swift b/SwiftSageiOS/SwiftSageiOS/ViewViewModel/Settings/SettingsViewModel.swift index 40b5cc2..03da0cd 100644 --- a/SwiftSageiOS/SwiftSageiOS/ViewViewModel/Settings/SettingsViewModel.swift +++ b/SwiftSageiOS/SwiftSageiOS/ViewViewModel/Settings/SettingsViewModel.swift @@ -67,6 +67,7 @@ public class SettingsViewModel: ObservableObject { @Published var downloadProgress: Double = 0.0 @Published var unzipProgress: Double = 0.0 + @Published var forkProgress: Double = 0.0 @Published var ipAddress: String = "" @Published var port: String = "" @@ -128,7 +129,6 @@ public class SettingsViewModel: ObservableObject { @AppStorage("cornerHandleSize")var cornerHandleSize: Double = defaultHandleSize - @AppStorage("middleHandleSize")var middleHandleSize: Double = defaultHandleSize @AppStorage("textSize") var textSize: Double = defaultTerminalFontSize { didSet { @@ -584,13 +584,9 @@ public class SettingsViewModel: ObservableObject { // END AUDIO SETTING LOAD ZONE FROM DISK -// // BEGIN LOAD SAVED GIT REPO -// let openRepoKey = currentGitRepoKey() -// logD("open repo key = \(openRepoKey)") + // START LOADING SAVED GIT REPOS LOAD ZONE FROM DISK - // Task { let fileURL = getDocumentsDirectory() - //.appendingPathComponent(self.gitUser).appendingPathComponent(self.gitRepo).appendingPathComponent(self.gitBranch) DispatchQueue.global(qos: .default).async { let files = getFiles(in: fileURL) DispatchQueue.main.async { @@ -598,15 +594,22 @@ public class SettingsViewModel: ObservableObject { } } + // END LOADING SAVED GIT REPOS LOAD ZONE FROM DISK } + enum Device: Int { + case mobile, computer + } + func currentGitRepoKey() -> String { "\(gitUser)\(SettingsViewModel.gitKeySeparator)\(gitRepo)\(SettingsViewModel.gitKeySeparator)\(gitBranch)" } static let gitKeySeparator = "-sws-" + // START THEME ZONE + func applyTheme(theme: AppTheme) { #if !os(macOS) switch theme { @@ -653,9 +656,8 @@ enum AppTheme { case hacker } -enum Device: Int { - case mobile, computer -} +// END THEME ZONE + // CEREPROC VOICE ZONE // Mac OS Cereproc voices for Sw-S: cmd line voices - not streamed to device. SwiftSageiOS acts as remote for this if you have your headphones hooked up to your mac and diff --git a/SwiftSageiOS/SwiftSageiOS/ViewViewModel/WorkingChangesList.swift b/SwiftSageiOS/SwiftSageiOS/ViewViewModel/WorkingChangesList.swift index 184fe1b..6183551 100644 --- a/SwiftSageiOS/SwiftSageiOS/ViewViewModel/WorkingChangesList.swift +++ b/SwiftSageiOS/SwiftSageiOS/ViewViewModel/WorkingChangesList.swift @@ -57,7 +57,7 @@ struct WorkingChangesView: View { Spacer() Button(action: { withAnimation { - logD("Confirm ??? CREATE draft PR on github") + logD("Confirm ?? Create PR on \(settingsViewModel.currentGitRepoKey().replacingOccurrences(of: SettingsViewModel.gitKeySeparator, with: "/"))") isPresentingAlert = true } }) { @@ -80,7 +80,10 @@ struct WorkingChangesView: View { } .confirmationDialog("Are you sure you want to create a PR on \(settingsViewModel.gitRepo)?", isPresented: $isPresentingAlert) { Button("Yes") { - settingsViewModel.actualCreateDraftPR() + settingsViewModel.actualCreateDraftPR { success in + logD("success when creating pr = \(success)") + + } } Button("Cancel", role: .cancel) { } diff --git a/SwiftSageiOS/SwiftSageiOSTests/SwiftSageiOSTests.swift b/SwiftSageiOS/SwiftSageiOSTests/SwiftSageiOSTests.swift index fde3dbb..f779f84 100644 --- a/SwiftSageiOS/SwiftSageiOSTests/SwiftSageiOSTests.swift +++ b/SwiftSageiOS/SwiftSageiOSTests/SwiftSageiOSTests.swift @@ -8,7 +8,7 @@ import XCTest final class SwiftSageiOSTests: XCTestCase { - + override func setUpWithError() throws { // Put setup code here. This method is called before the invocation of each test method in the class. } @@ -24,12 +24,4 @@ final class SwiftSageiOSTests: XCTestCase { // Mark your test throws to produce an unexpected failure when your test encounters an uncaught error. // Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards. } - - func testPerformanceExample() throws { - // This is an example of a performance test case. - measure { - // Put the code you want to measure the time of here. - } - } - } diff --git a/SwiftSageiOS/SwiftSageiOSUITests/SwiftSageiOSUITests.swift b/SwiftSageiOS/SwiftSageiOSUITests/SwiftSageiOSUITests.swift index 0d61ad6..426ced2 100644 --- a/SwiftSageiOS/SwiftSageiOSUITests/SwiftSageiOSUITests.swift +++ b/SwiftSageiOS/SwiftSageiOSUITests/SwiftSageiOSUITests.swift @@ -6,7 +6,7 @@ // import XCTest - +// final class SwiftSageiOSUITests: XCTestCase { override func setUpWithError() throws { @@ -30,12 +30,12 @@ final class SwiftSageiOSUITests: XCTestCase { // Use XCTAssert and related functions to verify your tests produce the correct results. } - func testLaunchPerformance() throws { - if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) { - // This measures how long it takes to launch your application. - measure(metrics: [XCTApplicationLaunchMetric()]) { - XCUIApplication().launch() - } - } - } +// func testLaunchPerformance() throws { +// if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) { +// // This measures how long it takes to launch your application. +// measure(metrics: [XCTApplicationLaunchMetric()]) { +// XCUIApplication().launch() +// } +// } +// } } diff --git a/SwiftSageiOS/SwiftSageiOSUITests/SwiftSageiOSUITestsLaunchTests.swift b/SwiftSageiOS/SwiftSageiOSUITests/SwiftSageiOSUITestsLaunchTests.swift deleted file mode 100644 index 068522d..0000000 --- a/SwiftSageiOS/SwiftSageiOSUITests/SwiftSageiOSUITestsLaunchTests.swift +++ /dev/null @@ -1,32 +0,0 @@ -// -// SwiftSageiOSUITestsLaunchTests.swift -// SwiftSageiOSUITests -// -// Created by Chris Dillard on 5/16/23. -// - -import XCTest - -final class SwiftSageiOSUITestsLaunchTests: XCTestCase { - - override class var runsForEachTargetApplicationUIConfiguration: Bool { - true - } - - override func setUpWithError() throws { - continueAfterFailure = false - } - - func testLaunch() throws { - let app = XCUIApplication() - app.launch() - - // Insert steps here to perform after app launch but before taking a screenshot, - // such as logging into a test account or navigating somewhere in the app - - let attachment = XCTAttachment(screenshot: app.screenshot()) - attachment.name = "Launch Screen" - attachment.lifetime = .keepAlways - add(attachment) - } -}