Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions DatWeatherDoe.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@
CODE_SIGN_IDENTITY = "Mac Developer";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Mac Developer";
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 51;
CURRENT_PROJECT_VERSION = 52;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"DatWeatherDoe/Resources/DevelopmentAssets\" \"DatWeatherDoe/Resources/DevelopmentAssets/TestData.swift\"";
DEVELOPMENT_TEAM = Q8X4D3A8MT;
Expand All @@ -879,7 +879,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 5.3.1;
MARKETING_VERSION = 5.4.0;
PRODUCT_BUNDLE_IDENTIFIER = com.inderdhir.DatWeatherDoe.debug;
PRODUCT_NAME = DatWeatherDoe;
PROVISIONING_PROFILE = "";
Expand All @@ -896,7 +896,7 @@
CODE_SIGN_IDENTITY = "Mac Developer";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Mac Developer";
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 51;
CURRENT_PROJECT_VERSION = 52;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"DatWeatherDoe/Resources/DevelopmentAssets\" \"DatWeatherDoe/Resources/DevelopmentAssets/TestData.swift\"";
DEVELOPMENT_TEAM = Q8X4D3A8MT;
Expand All @@ -908,7 +908,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 5.3.1;
MARKETING_VERSION = 5.4.0;
PRODUCT_BUNDLE_IDENTIFIER = com.inderdhir.DatWeatherDoe;
PRODUCT_NAME = DatWeatherDoe;
PROVISIONING_PROFILE = "";
Expand Down
24 changes: 0 additions & 24 deletions DatWeatherDoe/API/Repository/Zip Code/ZipCodeValidator.swift

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 1 addition & 0 deletions DatWeatherDoe/API/Response/ForecastData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ struct ForecastDayData: Decodable {
}

struct HourlyUVIndex: Decodable {
// swiftlint:disable:next identifier_name
let uv: Double
}
3 changes: 2 additions & 1 deletion DatWeatherDoe/API/Response/WeatherAPIResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ struct WeatherAPIResponse: Decodable {
)
}

let airQualityContainer = try currentContainer.nestedContainer(keyedBy: AirQualityKeys.self, forKey: .airQuality)
let airQualityContainer =
try currentContainer.nestedContainer(keyedBy: AirQualityKeys.self, forKey: .airQuality)
airQualityIndex = try airQualityContainer.decode(AirQualityIndex.self, forKey: .usEpaIndex)
}

Expand Down
15 changes: 12 additions & 3 deletions DatWeatherDoe/DatWeatherDoeApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import SwiftUI
@main
struct DatWeatherDoeApp: App {
@State private var configManager: ConfigManager
@ObservedObject private var configureViewModel = ConfigureViewModel(configManager: ConfigManager())
@ObservedObject private var viewModel: WeatherViewModel
@State private var isMenuPresented: Bool = false
@State private var isMenuPresented = false
@State private var statusItem: NSStatusItem?

init() {
Expand All @@ -39,6 +40,7 @@ struct DatWeatherDoeApp: App {
content: {
MenuView(
viewModel: viewModel,
configureViewModel: configureViewModel,
onSeeWeather: {
viewModel.seeForecastForCurrentCity()
closePopover()
Expand All @@ -48,7 +50,6 @@ struct DatWeatherDoeApp: App {
closePopover()
},
onSave: {
viewModel.getUpdatedWeatherAfterRefresh()
closePopover()
}
)
Expand All @@ -61,7 +62,15 @@ struct DatWeatherDoeApp: App {
}
)
.menuBarExtraAccess(isPresented: $isMenuPresented) { statusItem in
self.statusItem = statusItem
Task { @MainActor in
self.statusItem = statusItem
}
}
.onChange(of: isMenuPresented) { newValue in
if !newValue {
configureViewModel.saveConfig()
viewModel.getUpdatedWeatherAfterRefresh()
}
}
.windowStyle(.hiddenTitleBar)
.menuBarExtraStyle(.window)
Expand Down
1 change: 1 addition & 0 deletions DatWeatherDoe/Resources/DevelopmentAssets/TestData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation

let uvIndicesFor24Hours: [HourlyUVIndex] = {
var arr: [HourlyUVIndex] = []
// swiftlint:disable:next identifier_name
for i in 1 ... 24 {
arr.append(HourlyUVIndex(uv: 0))
}
Expand Down
3 changes: 2 additions & 1 deletion DatWeatherDoe/UI/Configure/ConfigureViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class ConfigureViewModel: ObservableObject {
didSet { configManager.weatherSource = weatherSource.rawValue }
}

@Published var weatherSourceText = "" {
@Published var weatherSourceText: String {
didSet { configManager.weatherSourceText = weatherSourceText }
}

Expand Down Expand Up @@ -69,6 +69,7 @@ final class ConfigureViewModel: ObservableObject {

measurementUnit = configManager.parsedMeasurementUnit
weatherSource = WeatherSource(rawValue: configManager.weatherSource) ?? .location
weatherSourceText = configManager.weatherSourceText

switch configManager.refreshInterval {
case 300: refreshInterval = .fiveMinutes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,15 @@ final class TemperatureForecastTextBuilder: TemperatureForecastTextBuilderType {
}

private func buildTemperatureForUnit(_ unit: TemperatureUnit) -> String {
let maxTemp = unit == .fahrenheit ? forecastTemperatureData.maxTempF : forecastTemperatureData.maxTempC
let maxTemp = unit == .fahrenheit ?
forecastTemperatureData.maxTempF : forecastTemperatureData.maxTempC
let formattedMaxTemp = buildFormattedTemperature(maxTemp, unit: unit)
let maxTempStr = [upArrowStr, formattedMaxTemp]
.compactMap { $0 }
.joined()

let minTemp = unit == .fahrenheit ? forecastTemperatureData.minTempF : forecastTemperatureData.minTempC
let minTemp = unit == .fahrenheit ?
forecastTemperatureData.minTempF : forecastTemperatureData.minTempC
let formatedMinTemp = buildFormattedTemperature(minTemp, unit: unit)
let minTempStr = [downArrowStr, formatedMinTemp]
.compactMap { $0 }
Expand Down
7 changes: 6 additions & 1 deletion DatWeatherDoe/UI/Menu Bar/CustomButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ struct CustomButton: View {
let shortcutKey: KeyEquivalent
let onClick: () -> Void

init(text: LocalizedStringKey, textColor: Color = Color.primary, shortcutKey: KeyEquivalent, onClick: @escaping () -> Void) {
init(
text: LocalizedStringKey,
textColor: Color = Color.primary,
shortcutKey: KeyEquivalent,
onClick: @escaping () -> Void
) {
self.text = text
self.textColor = textColor
self.shortcutKey = shortcutKey
Expand Down
5 changes: 4 additions & 1 deletion DatWeatherDoe/UI/Menu Bar/MenuOptionsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ struct MenuOptionsView: View {
NonInteractiveMenuOptionView(icon: .thermometer, text: data?.weatherText)
NonInteractiveMenuOptionView(icon: .sun, text: data?.sunriseSunsetText)
NonInteractiveMenuOptionView(icon: .wind, text: data?.tempHumidityWindText)
NonInteractiveMenuOptionView(icon: .uvIndexAndAirQualityText, text: data?.uvIndexAndAirQualityText)
NonInteractiveMenuOptionView(
icon: .uvIndexAndAirQualityText,
text: data?.uvIndexAndAirQualityText
)
}

HStack {
Expand Down
10 changes: 4 additions & 6 deletions DatWeatherDoe/UI/Menu Bar/MenuView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,26 @@ import SwiftUI

struct MenuView: View {
@ObservedObject var viewModel: WeatherViewModel
@ObservedObject var configureViewModel: ConfigureViewModel
private var menuOptionData: MenuOptionData?
@State private var configureViewModel: ConfigureViewModel
private var version: String
private var onSeeWeather: () -> Void
private var onRefresh: () -> Void
private var onSave: () -> Void

init(
viewModel: WeatherViewModel,
configureViewModel: ConfigureViewModel,
onSeeWeather: @escaping () -> Void,
onRefresh: @escaping () -> Void,
onSave: @escaping () -> Void
) {
self.viewModel = viewModel
self.configureViewModel = configureViewModel
self.onSeeWeather = onSeeWeather
self.onRefresh = onRefresh
self.onSave = onSave

configureViewModel = ConfigureViewModel(configManager: ConfigManager())
version = (Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String) ?? "1.0.0"
}

Expand All @@ -45,10 +46,7 @@ struct MenuView: View {
ConfigureView(
viewModel: configureViewModel,
version: version,
onSave: {
configureViewModel.saveConfig()
onSave()
},
onSave: onSave,
onQuit: {
NSApp.terminate(self)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ extension SystemLocationFetcher: CLLocationManagerDelegate {
nonisolated func locationManager(_ manager: CLLocationManager, didUpdateLocations _: [CLLocation]) {
let coordinate = manager.location?.coordinate ?? .init(latitude: .zero, longitude: .zero)
Task(priority: .high) {
await locationUpdateContinuation?.resume(returning: coordinate)
await updateCachedLocation(coordinate)
await locationUpdateContinuation?.resume(returning: coordinate)
}
}
}
5 changes: 4 additions & 1 deletion DatWeatherDoe/ViewModel/WeatherViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ final class WeatherViewModel: WeatherViewModelType, ObservableObject {
)
}

private func getWeather(repository: WeatherRepositoryType, unit: MeasurementUnit) async throws -> WeatherData {
private func getWeather(
repository: WeatherRepositoryType,
unit: MeasurementUnit
) async throws -> WeatherData {
let repository = repository

let responseTask = Task {
Expand Down