Skip to content

Commit d8c58cd

Browse files
committed
Fix #55
1 parent e4f72eb commit d8c58cd

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

Peep/ViewModels/ContentModel.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class ContentModel: NSObject, CLLocationManagerDelegate, ObservableObject {
4141
@Published var goToLocation = false
4242
@Published var isOnLocation = true
4343
@Published var shouldCheckIsOnLocation = false
44+
@Published var didClickOnLocationButtonWhenLocationOff = false
4445

4546
// MARK: - Location
4647

Peep/Views/Home/HomeView.swift

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ struct HomeView: View {
3333
Spacer()
3434

3535
Button(action: {
36-
withAnimation {
37-
if model.authorizationState == .authorizedAlways || model.authorizationState == .authorizedWhenInUse {
36+
if model.authorizationState == .authorizedAlways || model.authorizationState == .authorizedWhenInUse {
3837

38+
withAnimation {
3939
if !model.isOnLocation {
4040

4141
model.goToLocation = true
@@ -44,8 +44,20 @@ struct HomeView: View {
4444
model.devLog = String(localized: "userLocation")
4545

4646
}
47+
}
4748

49+
} else {
50+
51+
withAnimation(.spring(blendDuration: 0.5)) {
52+
model.didClickOnLocationButtonWhenLocationOff = true
4853
}
54+
55+
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
56+
withAnimation(.spring(blendDuration: 0.5)) {
57+
model.didClickOnLocationButtonWhenLocationOff = false
58+
}
59+
}
60+
4961
}
5062
}, label: {
5163
if model.authorizationState == .authorizedAlways || model.authorizationState == .authorizedWhenInUse {

Peep/Views/Home/NavigationBar.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@ struct NavigationBar: View {
4040
}
4141

4242
if model.authorizationState == .denied || model.authorizationState == .restricted {
43-
43+
4444
Text(String(localized: "noLocation"))
45+
.tracking(model.didClickOnLocationButtonWhenLocationOff ? 2 : 0)
4546
.foregroundColor(Color("Font"))
4647
.lineLimit(1)
48+
.animation(.interactiveSpring(response: 0.9, dampingFraction: 0.8, blendDuration: 0.5), value: model.didClickOnLocationButtonWhenLocationOff)
4749

4850
} else {
4951

0 commit comments

Comments
 (0)