mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Add animation to demo disconnect
This commit is contained in:
parent
8e68f3bbd5
commit
f65fb5890c
1 changed files with 43 additions and 0 deletions
|
|
@ -26,6 +26,10 @@ struct Connect: View {
|
|||
@State var liveActivityStarted = false
|
||||
@State var presentingSwitchPreferredPeripheral = false
|
||||
@State var selectedPeripherialId = ""
|
||||
@State private var showSwipeDemo = false
|
||||
@State private var swipeDemoOffset: CGFloat = 0
|
||||
@State private var showDeleteButton: Bool = false
|
||||
@AppStorage("hasSeenSwipeDemo") private var hasSeenSwipeDemo = false
|
||||
|
||||
init () {
|
||||
let notificationCenter = UNUserNotificationCenter.current()
|
||||
|
|
@ -89,6 +93,28 @@ struct Connect: View {
|
|||
.font(.caption)
|
||||
.foregroundColor(Color.gray)
|
||||
.padding([.top])
|
||||
.offset(x: swipeDemoOffset)
|
||||
.overlay(
|
||||
GeometryReader { geometry in
|
||||
ZStack {
|
||||
Rectangle()
|
||||
.foregroundColor(.red)
|
||||
.frame(width: 80)
|
||||
.offset(x: geometry.size.width - 80)
|
||||
VStack {
|
||||
Image(systemName: "antenna.radiowaves.left.and.right.slash")
|
||||
.foregroundColor(.white)
|
||||
.font(.title3)
|
||||
Text("Disconnect")
|
||||
.foregroundColor(.white)
|
||||
.font(.caption)
|
||||
}
|
||||
}
|
||||
.offset(x: geometry.size.width - 50)
|
||||
|
||||
.opacity(showDeleteButton ? 1 : 0)
|
||||
}
|
||||
)
|
||||
.swipeActions {
|
||||
Button(role: .destructive) {
|
||||
if let connectedPeripheral = bleManager.connectedPeripheral,
|
||||
|
|
@ -323,6 +349,23 @@ struct Connect: View {
|
|||
} else {
|
||||
isUnsetRegion = false
|
||||
}
|
||||
// Show swipe demo if user hasn't seen it before and we're connected
|
||||
if !hasSeenSwipeDemo && bleManager.isSubscribed && node != nil {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
|
||||
withAnimation(.easeInOut(duration: 0.6)) {
|
||||
swipeDemoOffset = -80
|
||||
showDeleteButton = true
|
||||
}
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
|
||||
withAnimation(.easeInOut(duration: 0.6)) {
|
||||
swipeDemoOffset = 0
|
||||
showDeleteButton = false
|
||||
}
|
||||
// Mark as seen so it doesn't appear again
|
||||
hasSeenSwipeDemo = true
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
Logger.data.error("💥 Error fetching node info: \(error.localizedDescription, privacy: .public)")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue