Skip to content

Commit

Permalink
1.1.8-1: introducing hapticman
Browse files Browse the repository at this point in the history
  • Loading branch information
cdillard committed May 22, 2023
1 parent fadd969 commit ae820d5
Show file tree
Hide file tree
Showing 10 changed files with 182 additions and 19 deletions.
12 changes: 8 additions & 4 deletions SwiftSageiOS/SwiftSageiOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
B71C62FE2A019144004296E4 /* LocalCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = B71C62FD2A019144004296E4 /* LocalCommand.swift */; };
B71C63002A01924B004296E4 /* CommandTable.swift in Sources */ = {isa = PBXBuildFile; fileRef = B71C62FF2A01924B004296E4 /* CommandTable.swift */; };
B729B14229F9B25600BA6752 /* UIColorExt.swift in Sources */ = {isa = PBXBuildFile; fileRef = B729B14129F9B25600BA6752 /* UIColorExt.swift */; };
B7378BFD2A1B192600A1D44C /* HapticMan.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7378BFC2A1B192500A1D44C /* HapticMan.swift */; };
B737F40B29F837CE00E57577 /* SettingsVIew.swift in Sources */ = {isa = PBXBuildFile; fileRef = B737F40A29F837CE00E57577 /* SettingsVIew.swift */; };
B737F40D29F8395B00E57577 /* SettingsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B737F40C29F8395B00E57577 /* SettingsViewModel.swift */; };
B746DFCE29F5E789002804EB /* SwiftSageiOSApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = B746DFCD29F5E789002804EB /* SwiftSageiOSApp.swift */; };
Expand Down Expand Up @@ -211,6 +212,7 @@
B72BFBAD2A1AAAF900E13C71 /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
B72BFBAE2A1AAB0500E13C71 /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
B72BFBAF2A1AAB1300E13C71 /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
B7378BFC2A1B192500A1D44C /* HapticMan.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HapticMan.swift; sourceTree = "<group>"; };
B737F40A29F837CE00E57577 /* SettingsVIew.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsVIew.swift; sourceTree = "<group>"; };
B737F40C29F8395B00E57577 /* SettingsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsViewModel.swift; sourceTree = "<group>"; };
B746DFCA29F5E789002804EB /* LogicSageDev.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LogicSageDev.app; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -765,6 +767,7 @@
B729B14129F9B25600BA6752 /* UIColorExt.swift */,
B7EF2A2A2A0C2D620048CFFC /* View+Keyboard.swift */,
B78DA97D2A0707DB002343AB /* WindowManager.swift */,
B7378BFC2A1B192500A1D44C /* HapticMan.swift */,
);
path = Utilities;
sourceTree = "<group>";
Expand Down Expand Up @@ -1021,6 +1024,7 @@
B71C63002A01924B004296E4 /* CommandTable.swift in Sources */,
B7191F1629F9F09A00078D8D /* SourceCodeRegexLexer.swift in Sources */,
B7191F2829F9F09A00078D8D /* InnerTextView.swift in Sources */,
B7378BFD2A1B192600A1D44C /* HapticMan.swift in Sources */,
B7191F2929F9F09A00078D8D /* TextViewWrapperView.swift in Sources */,
B78DA96C2A0312F1002343AB /* HelpPopup.swift in Sources */,
B7544E302A191BCE00961F4C /* AudioTranscriptionQuery.swift in Sources */,
Expand Down Expand Up @@ -1241,7 +1245,7 @@
CODE_SIGN_ENTITLEMENTS = SwiftSageiOS/SwiftSageiOS.entitlements;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Mac Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DEVELOPMENT_ASSET_PATHS = "\"SwiftSageiOS/Preview Content\"";
DEVELOPMENT_TEAM = "";
Expand Down Expand Up @@ -1272,7 +1276,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.7;
MARKETING_VERSION = 1.1.8;
PRODUCT_BUNDLE_IDENTIFIER = com.chrisdillard.SwiftSageDev;
PRODUCT_NAME = LogicSageDev;
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -1293,7 +1297,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = SwiftSageiOS/SwiftSageiOS.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DEVELOPMENT_ASSET_PATHS = "\"SwiftSageiOS/Preview Content\"";
DEVELOPMENT_TEAM = 72WEN2C47N;
Expand Down Expand Up @@ -1322,7 +1326,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.7;
MARKETING_VERSION = 1.1.8;
PRODUCT_BUNDLE_IDENTIFIER = com.chrisdillard.SwiftSage;
PRODUCT_NAME = LogicSage;
SDKROOT = auto;
Expand Down
18 changes: 14 additions & 4 deletions SwiftSageiOS/SwiftSageiOS/Command/GPTCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ Question to Answer:
}
config.manualPromptString += "\n\(input)"

playMediunImpact()

GPT.shared.sendPromptToGPT(conversationId: Conversation.ID(1), prompt: config.manualPromptString, currentRetry: 0) { content, success, isDone in


Expand All @@ -66,13 +68,21 @@ Question to Answer:


if !isDone {
#if !os(macOS)


#if !os(macOS)
consoleManager.printNoNewLine(content)
#endif
#endif
print(content, terminator: "")

if content == "." {
playSoftImpact()
}
else {
playLightImpact()
}
}
else {
playSoftImpact()

// multiPrinter("\n🤖: \(content)")
logD("say: \(content)")
Expand Down Expand Up @@ -142,7 +152,7 @@ func promptText(noGoogle: Bool = true, noLink: Bool = true) -> String {
"""
- The Link url command can be used to get more information by accessing a link. Pass the link: {\"command\": \"Link\",\"name\": \"www.nytimes.com\"}. I will reply with a message containing the text from the link.
"""
let appName = config.appName ?? "DefaultName"
let appName = config.appName
let googSteps = !noGoogle ? "Google, Link," : ""
return """
Develop an iOS app in \(config.language) for a SwiftUI-based \(config.appDesc). Name it \(aiNamedProject ? "a unique name" : appName). Return necessary, valid, and formatted Swift code files as a JSON array. It is essential you return your response as a JSON array matching the structure:. [\(googleStringInclude)\(linkStringInclude){"command": "Create project","name": "UniqueName"}, {"command": "Create file","name": "Filename.swift","fileContents": "SWIFT_FILE_CONTENTS"}, {"command": "Open project", "name": "\(aiNamedProject ? "UniqueName" : appName)"},{"command": "Close project", "name": "UniqueName"}]
Expand Down
2 changes: 1 addition & 1 deletion SwiftSageiOS/SwiftSageiOS/Command/LocalCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func callLocalCommand(_ command: String) -> Bool {
}
}

logD("Invalid sws command. Please try again. (c) for help")
logD("Invalid LOCAL command. Please try again. (c) for help")

return false
}
2 changes: 1 addition & 1 deletion SwiftSageiOS/SwiftSageiOS/Loading/AsciiAnimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let ASCII_CHARS: [Character] = ["@", "#", "S", "%", "?", "*", "+", ";", ":", ","

let heightProp: CGFloat = 0.92
// ASCII MOVIES ZONE ///////////////////////////////
// IF the movie is TOO big/blurry for you and your tastes try manually setting your sws/Xcode console font to 2 or 3 and then turn movie width up :).
// IF the movie is TOO big/blurry for you and your tastes try manually setting your LogicSage/Xcode console font to 2 or 3 and then turn movie width up :).
// We'll need to sync each clients terminal window/s widths to make sure the animations and movies play properly.
let movieWidth = 100
let matrixScreenWidth = 100
Expand Down
89 changes: 89 additions & 0 deletions SwiftSageiOS/SwiftSageiOS/Utilities/HapticMan.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
//
// HapticMan.swift
// SwiftSageiOS
//
// Created by Chris Dillard on 5/21/23.
//


import Foundation
#if !os(macOS)
import UIKit
#endif
//light impatct

#if !os(macOS)

func playType(impType: UIImpactFeedbackGenerator.FeedbackStyle, int: CGFloat = 1.0) {
let hasBat = checkBattery()
guard hasBat else { return }
guard SettingsViewModel.shared.hapticsEnabled else { return }

let generator = UIImpactFeedbackGenerator(style: impType)
generator.impactOccurred(intensity: int)
}
#endif

func playLightImpact() {
#if !os(macOS)

playType(impType: .light)
#endif
}
func playSoftImpact() {
#if !os(macOS)

playType(impType: .soft)
#endif
}
func playMediunImpact() {
#if !os(macOS)

playType(impType: .medium)
#endif
}
func checkBattery(minBatLevl: Float = 0.3) -> Bool {

#if !os(macOS)

UIDevice.current.isBatteryMonitoringEnabled = true

guard UIDevice.current.batteryLevel > minBatLevl || UIDevice.current.batteryLevel < 0 else {
logD("no haptics when no battery :think: ;)")
return false
}

if UIDevice.current.batteryLevel < 0 {
logD("battery undeter")
}
#endif
return true
}


#if !os(macOS)

func playNot(type: UINotificationFeedbackGenerator.FeedbackType) {

let hasBat = checkBattery()
guard hasBat else { return }
guard SettingsViewModel.shared.hapticsEnabled else { return }

let notiGen = UINotificationFeedbackGenerator()
notiGen.notificationOccurred(type)
}
#endif


func playSelect() {
#if !os(macOS)

let hasBat = checkBattery()
guard hasBat else { return }
guard SettingsViewModel.shared.hapticsEnabled else { return }


let selectGen = UISelectionFeedbackGenerator()
selectGen.selectionChanged()
#endif
}
2 changes: 2 additions & 0 deletions SwiftSageiOS/SwiftSageiOS/ViewViewModel/AddView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ struct AddView: View {
.padding(.vertical, 8)
.foregroundColor(settingsViewModel.appTextColor)
.onTapGesture {
playSelect()

withAnimation {
settingsViewModel.repoSettingsShown.toggle()
}
Expand Down
8 changes: 2 additions & 6 deletions SwiftSageiOS/SwiftSageiOS/ViewViewModel/HelpPopup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ struct HelpPopup: View {

Text("Tap me! \(verGoodMoji) , I will expand/collapse a section...")
.onTapGesture {
playSelect()

withAnimation {
veryGoodOpen.toggle()
}
Expand All @@ -63,12 +65,6 @@ struct HelpPopup: View {
Text("-COMMANDS\nCheck the following link for the Swifty-GPT server command list:\n https://github.com/cdillard/LogicSage/blob/main/Swifty-GPT/Command/CommandTable.swift\nmobile command list:\n https://github.com/cdillard/LogicSage/blob/main/SwiftSageiOS/SwiftSageiOS/Command/CommandTable.swift")
.foregroundColor(settingsViewModel.appTextColor)
.accentColor(settingsViewModel.buttonColor)

Text("-CREDITS: https://github.com/cdillard/LogicSage#credits")
.foregroundColor(settingsViewModel.appTextColor)
.accentColor(settingsViewModel.buttonColor)

Text("Thank you!!! to the open source maintainers who created the MIT and Apache 2.0 Licensed source included in this project.")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ struct InstructionsPopup: View {
Text("2. Running the vapor server.")
}
Text("Without these 3 steps, the LogicSage server will not work.")

Text("-CREDITS: https://github.com/cdillard/LogicSage#credits")
.foregroundColor(settingsViewModel.appTextColor)
.accentColor(settingsViewModel.buttonColor)

Text("Thank you!!! to the open source maintainers who created the MIT and Apache 2.0 Licensed source included in this project.")
}
.padding(.leading, 15)
.padding(.trailing, 15)
Expand Down
Loading

0 comments on commit ae820d5

Please sign in to comment.