Skip to content

Commit 6ce24a1

Browse files
committed
disabled timer start, change scramble when generating scramble
1 parent 67b34e0 commit 6ce24a1

File tree

3 files changed

+40
-48
lines changed

3 files changed

+40
-48
lines changed

CubeTime/Timer/StopwatchManager.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,13 @@ class StopWatchManager: ObservableObject {
120120
NSLog("starting")
121121
#endif
122122
mode = .running
123-
123+
124124
timer?.invalidate() // Stop possibly running inspections
125-
125+
126126
secondsElapsed = 0
127127
secondsStr = formatSolveTime(secs: 0)
128128
timerStartTime = Date()
129-
129+
130130
if timeDP != -1 {
131131
timer = Timer.scheduledTimer(withTimeInterval: 1/60, repeats: true) { [self] timer in
132132
self.secondsElapsed = -timerStartTime!.timeIntervalSinceNow

CubeTime/Timer/TimerTouchView.swift

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -139,32 +139,21 @@ final class TimerTouchView: UIViewRepresentable {
139139
func updateUIView(_ uiView: TimerUIView, context: UIViewRepresentableContext<TimerTouchView>) {
140140
if stopWatchManager.scrambleStr == nil {
141141
for gesture in uiView.gestureRecognizers! {
142+
/*
142143
if gesture is UISwipeGestureRecognizer && (gesture as! UISwipeGestureRecognizer).direction == UISwipeGestureRecognizer.Direction.right {
143144
uiView.removeGestureRecognizer(gesture)
144-
} else if gesture is UILongPressGestureRecognizer {
145+
} else */
146+
if gesture is UILongPressGestureRecognizer {
145147
uiView.removeGestureRecognizer(gesture)
146148
}
147149
}
148-
149-
print("RAN")
150150
} else {
151151
let longPressGesture = UILongPressGestureRecognizer(target: context.coordinator, action: #selector(Coordinator.longPress))
152152
longPressGesture.allowableMovement = gestureThreshold
153153
longPressGesture.minimumPressDuration = userHoldTime
154-
155-
156154

157155
uiView.addGestureRecognizer(longPressGesture)
158-
159-
print("ADDED")
160156
}
161-
162-
print("view updated")
163-
164-
165-
166-
167-
168157
}
169158

170159
class Coordinator: NSObject {

CubeTime/Timer/TimerView.swift

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ struct TimerView: View {
123123
Color(uiColor: colourScheme == .light ? .systemGray6 : .black)
124124
.ignoresSafeArea()
125125

126-
// SCRAMBLE
126+
// SCRAMBLE
127127
if stopWatchManager.mode == .inspecting {
128128
if colourScheme == .light {
129129
switch stopWatchManager.inspectionSecs {
@@ -289,6 +289,7 @@ struct TimerView: View {
289289
.font(.system(size: 15, weight: .regular))
290290
}
291291
}
292+
.disabled(stopWatchManager.scrambleStr == nil)
292293
.accentColor(accentColour)
293294
.pickerStyle(.menu)
294295
.onChange(of: playgroundScrambleType) { newValue in
@@ -657,48 +658,50 @@ struct TimerView: View {
657658

658659
if currentSession.session_type != 2 {
659660
if !stopWatchManager.nilSolve {
660-
if !manualInputFocused {
661+
if !manualInputFocused && stopWatchManager.scrambleStr != nil {
661662
Rectangle()
662663
.fill(Color(uiColor: colourScheme == .light ? .systemGray5 : .systemGray4))
663664
.frame(width: 1.5, height: 20)
664665
.padding(.horizontal, 12)
665666
}
666667
}
667668

668-
PenaltyBar(manualInputFocused ? 68 : 34) {
669-
Button(action: {
670-
if manualInputFocused {
671-
if manualInputTime != "" {
672-
stopWatchManager.stop(timeFromStr(manualInputTime))
673-
674-
675-
showInputField = false
669+
if stopWatchManager.scrambleStr != nil {
670+
PenaltyBar(manualInputFocused ? 68 : 34) {
671+
Button(action: {
672+
if manualInputFocused {
673+
if manualInputTime != "" {
674+
stopWatchManager.stop(timeFromStr(manualInputTime))
675+
676+
677+
showInputField = false
678+
679+
680+
manualInputFocused = false
681+
682+
manualInputTime = ""
683+
}
684+
} else {
685+
showInputField = true
676686

687+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.15) {
688+
manualInputFocused = true
689+
}
677690

678-
manualInputFocused = false
679-
680691
manualInputTime = ""
692+
681693
}
682-
} else {
683-
showInputField = true
684-
685-
DispatchQueue.main.asyncAfter(deadline: .now() + 0.15) {
686-
manualInputFocused = true
694+
}, label: {
695+
if manualInputFocused {
696+
Text("Done")
697+
.font(.system(size: 21, weight: .semibold, design: .rounded))
698+
} else {
699+
Image(systemName: "plus.circle")
700+
.font(.system(size: 24, weight: .semibold, design: .rounded))
687701
}
688-
689-
manualInputTime = ""
690-
691-
}
692-
}, label: {
693-
if manualInputFocused {
694-
Text("Done")
695-
.font(.system(size: 21, weight: .semibold, design: .rounded))
696-
} else {
697-
Image(systemName: "plus.circle")
698-
.font(.system(size: 24, weight: .semibold, design: .rounded))
699-
}
700-
})
701-
.disabled(manualInputFocused ? (manualInputTime == "") : false)
702+
})
703+
.disabled(manualInputFocused ? (manualInputTime == "") : false)
704+
}
702705
}
703706
}
704707
}

0 commit comments

Comments
 (0)