Skip to content
Draft
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
World Wide Weather is an attempt to improve Apple's default weather app by giving more hour-by-hour data, similar to BBC Weather but with cleaner and better looking UI. Some things in World Wide Weather don't exist inside of Apple Weather!

### Downloads?
Soon, if I manage to get the .dmg to work properly.
Yes, in the release tab there is a .dmg file, minimum deployment is macOS 13.0
14 changes: 8 additions & 6 deletions Weather.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@
CODE_SIGN_ENTITLEMENTS = Weather/Weather.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 18;
CURRENT_PROJECT_VERSION = 23;
DEVELOPMENT_ASSET_PATHS = "\"Weather/Preview Content\"";
ENABLE_PREVIEWS = NO;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -702,14 +702,15 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 0.8;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = RaymondVleeshouwer.WorldWideWeather;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = macosx;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 2;
};
name = Debug;
};
Expand All @@ -722,7 +723,7 @@
CODE_SIGN_ENTITLEMENTS = Weather/Weather.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 18;
CURRENT_PROJECT_VERSION = 23;
DEVELOPMENT_ASSET_PATHS = "\"Weather/Preview Content\"";
ENABLE_PREVIEWS = NO;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -735,14 +736,15 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 0.8;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = RaymondVleeshouwer.WorldWideWeather;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = macosx;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 2;
};
name = Release;
};
Expand Down
11 changes: 6 additions & 5 deletions Weather/Features/WeatherData/MultipleDayLoading.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import Foundation
import SwiftUI
import AppKit
import CoreLocation
import SwiftyJSON

Expand All @@ -20,6 +19,7 @@ func constructURL(_ baseURL: String, _ location: String) -> String {
return baseURL + location + apiKey + units
}

/*
/// Throws an NSAlert with specified text and severity.
func throwNSAlert(messageText: String, severity: NSAlert.Style) {
let alert: NSAlert = NSAlert()
Expand All @@ -28,6 +28,7 @@ func throwNSAlert(messageText: String, severity: NSAlert.Style) {
alert.addButton(withTitle: "Ok")
alert.runModal()
}
*/

/// Gets coordinates from the specified address, if it doesn't exist, will return 0, 0.
func getCoordinateFrom(address: String) -> CLLocationCoordinate2D {
Expand All @@ -50,7 +51,7 @@ func getHourlyWeatherData(location: Location) -> WeatherData {
let latAndLon: String = location.urlVersion

guard let url = URL(string: constructURL(url, latAndLon)) else {
throwNSAlert(messageText: "URL: \(constructURL(url, latAndLon)) does not exist.", severity: .critical)
// throwNSAlert(messageText: "URL: \(constructURL(url, latAndLon)) does not exist.", severity: .critical)
fatalError()
}

Expand All @@ -59,7 +60,7 @@ func getHourlyWeatherData(location: Location) -> WeatherData {

return WeatherData(json: JSON(parseJSON: contents))
} catch {
throwNSAlert(messageText: "Failed to gather weather data", severity: .critical)
// throwNSAlert(messageText: "Failed to gather weather data", severity: .critical)
fatalError()
}
}
Expand All @@ -72,7 +73,7 @@ func getThreeHourWeatherData(location: Location) -> [FiveDayWeatherHour] {
let latAndLon: String = location.urlVersion

guard let URL = URL(string: constructURL(url, latAndLon)) else {
throwNSAlert(messageText: "URL: \(constructURL(url, latAndLon)) does not exist.", severity: .critical)
// throwNSAlert(messageText: "URL: \(constructURL(url, latAndLon)) does not exist.", severity: .critical)
fatalError()
}

Expand All @@ -87,7 +88,7 @@ func getThreeHourWeatherData(location: Location) -> [FiveDayWeatherHour] {

return hours
} catch {
throwNSAlert(messageText: "Failed to gather weather data", severity: .critical)
// throwNSAlert(messageText: "Failed to gather weather data", severity: .critical)
fatalError("Failed to gather weather data")
}
}
12 changes: 6 additions & 6 deletions Weather/Features/WeatherData/WeatherForecast.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,25 @@ struct WeatherForecast {

init(coordinateLocation: Location) {
/// Get the weather data
weatherData = getHourlyWeatherData(location: coordinateLocation)
address = coordinateLocation.locationString
weatherData = getHourlyWeatherData(location: coordinateLocation); address = coordinateLocation.locationString
weatherMinutes = weatherData.minutes

var weatherHours: [WeatherHour] = weatherData.hours

let fiveDayWeatherHours: [FiveDayWeatherHour] = getThreeHourWeatherData(location: coordinateLocation)

/// Loops through the FiveDayWeatherHours and appends it to the weatherHours array by converting
for hour in fiveDayWeatherHours {
weatherHours.append(toWeatherHour(fiveDayWeatherHour: hour))
}

print(weatherHours[1].time
.toTimestamp())
var lastDay: Int = Int(weatherHours[1].time
.toTimestamp()
.split(separator: " ")[0])!
.split(separator: " ")[1]) ?? 30
var day: Int = 0

/// Intialize the WeatherHour arrays
/// Initialize the WeatherHour arrays
var otherDayHours: [WeatherHour] = [], todayWeatherHours: [WeatherHour] = []
precipitationInNext24H = 0

Expand All @@ -46,7 +46,7 @@ struct WeatherForecast {
let currentHour = weatherHours[index]
let currentDay: Int = Int(
currentHour.time.toTimestamp()
.split(separator: " ")[0])!
.split(separator: " ")[0]) ?? 26

if currentDay != lastDay {
if !(day == 0) && !otherDayHours.isEmpty {
Expand Down
10 changes: 4 additions & 6 deletions Weather/WeatherApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,16 @@ struct WeatherApp: App {
var body: some Scene {
WindowGroup {
WeatherView()
/*
.presentedWindowToolbarStyle(
.unifiedCompact(
showsTitle: false
)
)
/*
.background(
Image("Clouds")
.scaledToFit()
)
*/
*/
}

/*
Settings {
SettingsView()
.frame(width: 600, height: 600)
Expand All @@ -33,5 +30,6 @@ struct WeatherApp: App {
)
)
}
*/
}
}
5 changes: 5 additions & 0 deletions Weather/WeatherView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,14 @@ H: \(String(location.weatherForecast.today.maxTemp))º L: \(String(location.weat
RoundedRectangle(
cornerRadius: 5
)
/*
.foregroundColor(
Color(
nsColor: NSColor.textColor
)
)
*/
.foregroundColor(Color.white)
.colorInvert()
)
}
Expand Down Expand Up @@ -184,5 +187,7 @@ H: \(String(location.weatherForecast.today.maxTemp))º L: \(String(location.weat
.disabled(dataSave.weatherMainViews.count == 1)
}
.navigationSplitViewColumnWidth(215)
// .toolbarBackground(.white.opacity(0), for: .windowToolbar)
.navigationTitle("")
}
}