Skip to content

Commit

Permalink
feat: chatgpt advanced options
Browse files Browse the repository at this point in the history
  • Loading branch information
purr100 committed Nov 9, 2024
1 parent 09a0245 commit c15e8c5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 9 additions & 3 deletions Chato/Views/Widget/WheelPicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,21 @@ struct WheelPicker: View {
let end: Int
let defaultValue: Int
let spacing: CGFloat
let haptic: Bool

private let defaultIndex: Int
@State private var actualIndex: Int
@State private var loaded: Bool
@State private var indicatorX: CGFloat = .zero
@State private var defaultIndexX: CGFloat = .zero

init(value: Binding<Double>, start: Int, end: Int, defaultValue: Int, spacing: CGFloat = 13) {
init(value: Binding<Double>, start: Int, end: Int, defaultValue: Int, spacing: CGFloat = 13, haptic: Bool = true) {
self._value = value
self.start = start
self.end = end
self.defaultValue = defaultValue
self.spacing = spacing
self.haptic = haptic

self.defaultIndex = Int(round((Double(defaultValue) - Double(start)) * 10))
self._actualIndex = State(initialValue: Int(round((value.wrappedValue - Double(start)) * Double(steps))))
Expand Down Expand Up @@ -129,7 +131,9 @@ struct WheelPicker: View {
withAnimation{
value = indexToValue(b)
}
AudioServicesPlayAlertSound(SystemSoundID(1460))
if haptic{
AudioServicesPlayAlertSound(SystemSoundID(1460))
}
isUpdating = false
}
}
Expand All @@ -139,7 +143,9 @@ struct WheelPicker: View {
withAnimation{
actualIndex = valueToIndex(b)
}
AudioServicesPlayAlertSound(SystemSoundID(1460))
if haptic{
AudioServicesPlayAlertSound(SystemSoundID(1460))
}
isUpdating = false
}
}
Expand Down
4 changes: 3 additions & 1 deletion Chato/Views/Widget/WheelPickerView.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import SwiftUI

struct WheelPickerView: View {
@EnvironmentObject var pref: Pref

let name: String
@Binding var value: Double
let start: Int
Expand Down Expand Up @@ -63,7 +65,7 @@ struct WheelPickerView: View {
value = Double(defaultValue)
}

WheelPicker(value: $value, start: start, end: end, defaultValue: defaultValue,spacing: spacing)
WheelPicker(value: $value, start: start, end: end, defaultValue: defaultValue,spacing: spacing, haptic: pref.haptics)
.frame(height: 50)
}
.grayscale(doubleEqual(Double(defaultValue), value) ? 1 : 0)
Expand Down

0 comments on commit c15e8c5

Please sign in to comment.