Skip to content

Commit

Permalink
Fix #55
Browse files Browse the repository at this point in the history
  • Loading branch information
scraptechguy committed Dec 20, 2022
1 parent e4f72eb commit d8c58cd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions Peep/ViewModels/ContentModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 14 additions & 2 deletions Peep/Views/Home/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion Peep/Views/Home/NavigationBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down

0 comments on commit d8c58cd

Please sign in to comment.