Skip to content

Commit

Permalink
Lots of housekeeping (but now location is broken lol)
Browse files Browse the repository at this point in the history
  • Loading branch information
daneden committed Jul 6, 2024
1 parent ce4f01b commit c919cda
Show file tree
Hide file tree
Showing 18 changed files with 142 additions and 323 deletions.
12 changes: 3 additions & 9 deletions Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -1552,6 +1552,9 @@
}
}
}
},
"Set up" : {

},
"Set Up Location Access" : {
"extractionState" : "stale",
Expand All @@ -1574,9 +1577,6 @@
}
}
}
},
"Set up location services" : {

},
"Set Up Location Services" : {
"extractionState" : "stale",
Expand Down Expand Up @@ -2004,9 +2004,6 @@
}
}
}
},
"Welcome to Solstice" : {

},
"What location do you want to see the daylight for?" : {
"localizations" : {
Expand Down Expand Up @@ -2037,9 +2034,6 @@
}
}
}
},
"You can use Solstice with or without your real location. Tap this button to allow or deny access to your location." : {

},
"You will need to enable location services for Solstice or choose a different location in order to receive notifications." : {
"localizations" : {
Expand Down
54 changes: 19 additions & 35 deletions Solstice.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
Expand Down
6 changes: 5 additions & 1 deletion Solstice.xcodeproj/xcshareddata/xcschemes/Solstice.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
Expand Down Expand Up @@ -57,6 +58,9 @@
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
<StoreKitConfigurationFileReference
identifier = "../../Solstice/StoreKitConfiguration.storekit">
</StoreKitConfigurationFileReference>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
3 changes: 1 addition & 2 deletions Solstice/Charts/AnnualDaylightChart.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import SwiftUI
import Solar
import CoreLocation
import Charts

struct AnnualDaylightChart<Location: AnyLocation>: View {
Expand Down Expand Up @@ -107,7 +106,7 @@ extension AnnualDaylightChart {
}

return dates.map { date in
return Solar(for: date, coordinate: CLLocationCoordinate2D(latitude: location.latitude, longitude: location.longitude))
return Solar(for: date, coordinate: location.coordinate)
}.compactMap { $0 }
}
}
Expand Down
8 changes: 0 additions & 8 deletions Solstice/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import SwiftUI
import CoreData
import Solar
import CoreLocation

struct ContentView: View {
@AppStorage(Preferences.listViewSortDimension) private var itemSortDimension
Expand Down Expand Up @@ -77,13 +76,6 @@ struct ContentView: View {
}
}
.resolveDeepLink(Array(items))
.task(id: scenePhase) {
if currentLocation.isAuthorized,
selectedLocation == currentLocation.id,
scenePhase == .active {
currentLocation.requestLocation()
}
}
.overlay {
TimelineView(.everyMinute) { timelineContext in
Color.clear.task(id: timelineContext.date) {
Expand Down
1 change: 0 additions & 1 deletion Solstice/Detail View/DetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import SwiftUI
import Solar
import CoreLocation

struct DetailView<Location: ObservableLocation>: View {
static var userActivity: String {
Expand Down
15 changes: 0 additions & 15 deletions Solstice/Extensions/CLLocationCoordinate2D++.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,6 @@
import Foundation
import CoreLocation

extension CLLocationCoordinate2D: RawRepresentable {
public init?(rawValue: String) {
let parts = rawValue.split(separator: ",", maxSplits: 2)
guard let lat = Double(parts.first ?? .init()), let long = Double(parts.last ?? .init()) else {
return nil
}

self = CLLocationCoordinate2D(latitude: lat, longitude: long)
}

public var rawValue: String {
"\(latitude),\(longitude)"
}
}

extension CLLocationCoordinate2D {
static var proxiedToTimeZone: CLLocationCoordinate2D {
let offset = Double(TimeZone.current.secondsFromGMT()) / (60 * 60)
Expand Down
43 changes: 43 additions & 0 deletions Solstice/Helper Views/LocationPermissionScreenerView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// LocationPermissionScreenerView.swift
// Solstice
//
// Created by Daniel Eden on 28/02/2023.
//

import SwiftUI

struct LocationPermissionScreenerView: View {
@Environment(\.openURL) var openURL
@EnvironmentObject var currentLocation: CurrentLocation

var body: some View {
AdaptiveLabeledContent {
Button {
currentLocation.requestAccess()
} label: {
Text("Set up")
}
.buttonStyle(.bordered)

} label: {
HStack {
Image(systemName: "location")
.imageScale(.small)
.foregroundStyle(.secondary)
.symbolVariant(.fill)

Text("Current location")
}
}
.padding(.vertical, 6)
}
}

struct LocationPermissionScreenerView_Previews: PreviewProvider {
static var previews: some View {
Form {
LocationPermissionScreenerView()
}
}
}
17 changes: 3 additions & 14 deletions Solstice/Helpers/AnyLocation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import CoreLocation
import CoreData

protocol AnyLocation: Hashable {
var title: String? { get set }
var subtitle: String? { get set }
var timeZoneIdentifier: String? { get set }
var title: String? { get }
var subtitle: String? { get }
var timeZoneIdentifier: String? { get }
var latitude: Double { get }
var longitude: Double { get }
}
Expand All @@ -32,17 +32,6 @@ extension AnyLocation {
var coordinate: CLLocationCoordinate2D {
CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
}

mutating func reverseGeocodeLocation() async {
guard let placemarks = try? await CLGeocoder().reverseGeocodeLocation(CLLocation(latitude: coordinate.latitude, longitude: coordinate.longitude)),
let placemark = placemarks.first else {
return
}

title = placemark.name ?? title
subtitle = placemark.country ?? subtitle
timeZoneIdentifier = placemark.timeZone?.identifier ?? timeZoneIdentifier
}
}

extension SavedLocation: ObservableLocation { }
Expand Down
Loading

0 comments on commit c919cda

Please sign in to comment.