mirror of
https://github.com/neon443/NearFuture.git
synced 2026-03-11 06:49:12 +00:00
crazy haptics on completeing events
new alert for importing events (my custom one was pretty shit)
This commit is contained in:
@@ -15,7 +15,7 @@ struct ImportView: View {
|
|||||||
@State private var text: String = "Ready..."
|
@State private var text: String = "Ready..."
|
||||||
@State private var fgColor: Color = .yellow
|
@State private var fgColor: Color = .yellow
|
||||||
|
|
||||||
@State private var showAlert: Bool = false
|
@State private var showAlert: Bool = true
|
||||||
|
|
||||||
@State private var replaceCurrentEvents: Bool = false
|
@State private var replaceCurrentEvents: Bool = false
|
||||||
|
|
||||||
@@ -67,64 +67,18 @@ struct ImportView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.blur(radius: showAlert ? 2 : 0)
|
.blur(radius: showAlert ? 2 : 0)
|
||||||
Group {
|
.alert("Are you sure?", isPresented: $showAlert) {
|
||||||
Rectangle()
|
Button(role: .destructive) {
|
||||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
importEvents()
|
||||||
.foregroundStyle(replaceCurrentEvents ? .red.opacity(0.25) : .black.opacity(0.2))
|
} label: {
|
||||||
.animation(.default, value: replaceCurrentEvents)
|
Text("Replace Events")
|
||||||
.ignoresSafeArea()
|
}
|
||||||
ZStack {
|
Button(role: .cancel) {
|
||||||
Rectangle()
|
importEvents()
|
||||||
.clipShape(RoundedRectangle(cornerRadius: 25))
|
} label: {
|
||||||
VStack(alignment: .center) {
|
Text("Add to Events")
|
||||||
Text("Are you sure?")
|
|
||||||
.font(.largeTitle)
|
|
||||||
.bold()
|
|
||||||
.foregroundStyle(replaceCurrentEvents ? .red : .two)
|
|
||||||
.animation(.default, value: replaceCurrentEvents)
|
|
||||||
Text("This will replace your current events!")
|
|
||||||
.lineLimit(nil)
|
|
||||||
.multilineTextAlignment(.center)
|
|
||||||
.opacity(replaceCurrentEvents ? 1 : 0)
|
|
||||||
.animation(.default, value: replaceCurrentEvents)
|
|
||||||
.foregroundStyle(.two)
|
|
||||||
Toggle("Replace Events", isOn: $replaceCurrentEvents)
|
|
||||||
.foregroundStyle(.two)
|
|
||||||
Spacer()
|
|
||||||
HStack {
|
|
||||||
Button() {
|
|
||||||
withAnimation {
|
|
||||||
showAlert.toggle()
|
|
||||||
}
|
|
||||||
importEvents()
|
|
||||||
} label: {
|
|
||||||
Text("cancel")
|
|
||||||
.font(.title2)
|
|
||||||
.bold()
|
|
||||||
}
|
|
||||||
.buttonStyle(BorderedProminentButtonStyle())
|
|
||||||
|
|
||||||
Spacer()
|
|
||||||
|
|
||||||
Button() {
|
|
||||||
withAnimation {
|
|
||||||
showAlert.toggle()
|
|
||||||
}
|
|
||||||
importEvents()
|
|
||||||
} label: {
|
|
||||||
Text("yes")
|
|
||||||
.font(.title2)
|
|
||||||
.bold()
|
|
||||||
}
|
|
||||||
.buttonStyle(BorderedProminentButtonStyle())
|
|
||||||
}
|
|
||||||
.padding()
|
|
||||||
}
|
|
||||||
.padding()
|
|
||||||
}
|
}
|
||||||
.frame(maxWidth: 250, maxHeight: 250)
|
|
||||||
}
|
}
|
||||||
.opacity(showAlert ? 1 : 0)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,17 +34,22 @@ struct CompleteEventButton: View {
|
|||||||
completeStartTime = .now
|
completeStartTime = .now
|
||||||
progress = 0
|
progress = 0
|
||||||
|
|
||||||
timer = Timer(timeInterval: 0.01, repeats: true) { timer in
|
timer = Timer(timeInterval: 0.02, repeats: true) { timer in
|
||||||
guard completeInProgress else { return }
|
guard completeInProgress else { return }
|
||||||
guard timer.isValid else { return }
|
guard timer.isValid else { return }
|
||||||
let elapsed = Date().timeIntervalSince(completeStartTime)
|
let elapsed = Date().timeIntervalSince(completeStartTime)
|
||||||
progress = min(1, elapsed)
|
progress = min(1, elapsed)
|
||||||
|
#if canImport(UIKit)
|
||||||
|
UIImpactFeedbackGenerator(style: .light).impactOccurred()
|
||||||
|
#endif
|
||||||
|
|
||||||
if progress >= 1 {
|
if progress >= 1 {
|
||||||
withAnimation { completeInProgress = false }
|
withAnimation { completeInProgress = false }
|
||||||
viewModel.completeEvent(&event)
|
viewModel.completeEvent(&event)
|
||||||
#if canImport(UIKit)
|
#if canImport(UIKit)
|
||||||
UINotificationFeedbackGenerator().notificationOccurred(.success)
|
DispatchQueue.main.asyncAfter(deadline: .now()+0.02) {
|
||||||
|
UINotificationFeedbackGenerator().notificationOccurred(.success)
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
timer.invalidate()
|
timer.invalidate()
|
||||||
progress = 0
|
progress = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user