diff --git a/Peep/ViewModels/ContentModel.swift b/Peep/ViewModels/ContentModel.swift index e9c6e53..3fc69b2 100644 --- a/Peep/ViewModels/ContentModel.swift +++ b/Peep/ViewModels/ContentModel.swift @@ -41,6 +41,7 @@ class ContentModel: NSObject, CLLocationManagerDelegate, ObservableObject { @Published var goToLocation = false @Published var isOnLocation = true @Published var shouldCheckIsOnLocation = false + @Published var didClickOnLocationButtonWhenLocationOff = false // MARK: - Location diff --git a/Peep/Views/Home/HomeView.swift b/Peep/Views/Home/HomeView.swift index 7f85a20..392a6af 100644 --- a/Peep/Views/Home/HomeView.swift +++ b/Peep/Views/Home/HomeView.swift @@ -33,9 +33,9 @@ struct HomeView: View { Spacer() Button(action: { - withAnimation { - if model.authorizationState == .authorizedAlways || model.authorizationState == .authorizedWhenInUse { + if model.authorizationState == .authorizedAlways || model.authorizationState == .authorizedWhenInUse { + withAnimation { if !model.isOnLocation { model.goToLocation = true @@ -44,8 +44,20 @@ struct HomeView: View { model.devLog = String(localized: "userLocation") } + } + } else { + + withAnimation(.spring(blendDuration: 0.5)) { + model.didClickOnLocationButtonWhenLocationOff = true } + + DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) { + withAnimation(.spring(blendDuration: 0.5)) { + model.didClickOnLocationButtonWhenLocationOff = false + } + } + } }, label: { if model.authorizationState == .authorizedAlways || model.authorizationState == .authorizedWhenInUse { diff --git a/Peep/Views/Home/NavigationBar.swift b/Peep/Views/Home/NavigationBar.swift index 6e3b700..a936c1b 100644 --- a/Peep/Views/Home/NavigationBar.swift +++ b/Peep/Views/Home/NavigationBar.swift @@ -40,10 +40,12 @@ struct NavigationBar: View { } if model.authorizationState == .denied || model.authorizationState == .restricted { - + Text(String(localized: "noLocation")) + .tracking(model.didClickOnLocationButtonWhenLocationOff ? 2 : 0) .foregroundColor(Color("Font")) .lineLimit(1) + .animation(.interactiveSpring(response: 0.9, dampingFraction: 0.8, blendDuration: 0.5), value: model.didClickOnLocationButtonWhenLocationOff) } else {