From 462549720962b46b32468d0435082f288fdceb8c Mon Sep 17 00:00:00 2001 From: stottrop Date: Mon, 13 Jan 2020 15:46:49 +0100 Subject: [PATCH 01/12] Initial. --- ios-app/app.xcodeproj/project.pbxproj | 42 +++++-- ios-app/app/Data/FavoriteLocations.swift | 33 +++-- ios-app/app/Data/LocationExtensions.swift | 23 +++- ios-app/app/Data/PredictionExtensions.swift | 27 ++++ ios-app/app/FavoriteView/FavoriteList.swift | 16 ++- ios-app/app/FavoriteView/FavoriteRow.swift | 44 +++++-- ios-app/app/FavoriteView/FavoriteSearch.swift | 74 +++++++++++ .../FavoriteSearchResultRow.swift | 118 ++++++++++++++++++ .../FavoriteView/FavoriteSearchResults.swift | 35 ++++++ ios-app/app/LocationView/CityDetail.swift | 67 +++++++++- ios-app/app/LocationView/CountryDetail.swift | 2 - ios-app/app/LocationView/FavoriteCity.swift | 56 +++++++++ ios-app/app/LocationView/LocationDetail.swift | 15 +-- .../app/LocationView/LocationHeaderView.swift | 40 ++++++ ios-app/app/LocationView/StateDetail.swift | 3 +- ios-app/app/MockData/LocationMock.swift | 7 +- ios-app/app/SceneDelegate.swift | 5 +- ios-app/app/de.lproj/Localizable.strings | 3 + ios-app/app/en.lproj/Localizable.strings | 3 + 19 files changed, 558 insertions(+), 55 deletions(-) create mode 100644 ios-app/app/Data/PredictionExtensions.swift create mode 100644 ios-app/app/FavoriteView/FavoriteSearch.swift create mode 100644 ios-app/app/FavoriteView/FavoriteSearchResultRow.swift create mode 100644 ios-app/app/FavoriteView/FavoriteSearchResults.swift create mode 100644 ios-app/app/LocationView/FavoriteCity.swift create mode 100644 ios-app/app/LocationView/LocationHeaderView.swift diff --git a/ios-app/app.xcodeproj/project.pbxproj b/ios-app/app.xcodeproj/project.pbxproj index 9c62d927..199e770d 100644 --- a/ios-app/app.xcodeproj/project.pbxproj +++ b/ios-app/app.xcodeproj/project.pbxproj @@ -44,6 +44,12 @@ 9EEAF94E23C1F3DC000AAB49 /* SearchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EEAF94C23C1F3DC000AAB49 /* SearchBar.swift */; }; 9EEAF95023C1F474000AAB49 /* AccountTab.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EEAF94F23C1F474000AAB49 /* AccountTab.swift */; }; 9EFDEF9A23C215A9006EB4B4 /* AlertFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EFDEF9923C215A9006EB4B4 /* AlertFactory.swift */; }; + BC04DC0B23CB3BE7006D0767 /* FavoriteSearch.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC04DC0A23CB3BE7006D0767 /* FavoriteSearch.swift */; }; + BC04DC0D23CB4104006D0767 /* FavoriteSearchResultRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC04DC0C23CB4104006D0767 /* FavoriteSearchResultRow.swift */; }; + BC1A86B723CBB755005DE4F5 /* LocationHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC1A86B623CBB755005DE4F5 /* LocationHeaderView.swift */; }; + BC241EC323CB8B0600F4C0CC /* FavoriteCity.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC241EC223CB8B0600F4C0CC /* FavoriteCity.swift */; }; + BC26444123CB835300330645 /* PredictionExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC26444023CB835300330645 /* PredictionExtensions.swift */; }; + BCFAD1F923CB4BEC0032455B /* FavoriteSearchResults.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCFAD1F823CB4BEC0032455B /* FavoriteSearchResults.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -107,6 +113,12 @@ 9EEAF94C23C1F3DC000AAB49 /* SearchBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchBar.swift; sourceTree = ""; }; 9EEAF94F23C1F474000AAB49 /* AccountTab.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccountTab.swift; sourceTree = ""; }; 9EFDEF9923C215A9006EB4B4 /* AlertFactory.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AlertFactory.swift; sourceTree = ""; }; + BC04DC0A23CB3BE7006D0767 /* FavoriteSearch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoriteSearch.swift; sourceTree = ""; }; + BC04DC0C23CB4104006D0767 /* FavoriteSearchResultRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoriteSearchResultRow.swift; sourceTree = ""; }; + BC1A86B623CBB755005DE4F5 /* LocationHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationHeaderView.swift; sourceTree = ""; }; + BC241EC223CB8B0600F4C0CC /* FavoriteCity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoriteCity.swift; sourceTree = ""; }; + BC26444023CB835300330645 /* PredictionExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PredictionExtensions.swift; sourceTree = ""; }; + BCFAD1F823CB4BEC0032455B /* FavoriteSearchResults.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoriteSearchResults.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -222,6 +234,7 @@ children = ( 9E0C988723A78341001EA11E /* CurrentWeatherData.swift */, 9E8C8C4D23C1FB0500FF8E6D /* LocationExtensions.swift */, + BC26444023CB835300330645 /* PredictionExtensions.swift */, 9EE4771923C3C77F003BA29C /* FavoriteLocations.swift */, 9E81DC9123A7DECE00568CF4 /* UserData.swift */, ); @@ -233,6 +246,9 @@ children = ( 9E3CA3F023A5278E003873E8 /* FavoriteRow.swift */, 9E3CA3F323A52ABF003873E8 /* FavoriteList.swift */, + BC04DC0A23CB3BE7006D0767 /* FavoriteSearch.swift */, + BC04DC0C23CB4104006D0767 /* FavoriteSearchResultRow.swift */, + BCFAD1F823CB4BEC0032455B /* FavoriteSearchResults.swift */, ); path = FavoriteView; sourceTree = ""; @@ -247,11 +263,13 @@ 9E78A74423C916B000D8A27D /* LocationView */ = { isa = PBXGroup; children = ( + BC241EC223CB8B0600F4C0CC /* FavoriteCity.swift */, 9E78A74523C916CF00D8A27D /* LocationDetail.swift */, 9E78A74723C918C600D8A27D /* CityDetail.swift */, 9E78A74923C91B3D00D8A27D /* StateDetail.swift */, 9E78A74B23C91B4A00D8A27D /* CountryDetail.swift */, 9E3CA3EE23A51DFC003873E8 /* DegreeNumberCircle.swift */, + BC1A86B623CBB755005DE4F5 /* LocationHeaderView.swift */, ); path = LocationView; sourceTree = ""; @@ -439,15 +457,19 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + BC1A86B723CBB755005DE4F5 /* LocationHeaderView.swift in Sources */, 9EA0D16323C9118C0068F739 /* LocationMock.swift in Sources */, 9EE4770C23C36363003BA29C /* SearchResults.swift in Sources */, 2C7846D52372F44300766694 /* AppDelegate.swift in Sources */, 9E3CA3EF23A51DFC003873E8 /* DegreeNumberCircle.swift in Sources */, 9E81DC9223A7DECE00568CF4 /* UserData.swift in Sources */, + BC04DC0B23CB3BE7006D0767 /* FavoriteSearch.swift in Sources */, 9EEAF94D23C1F3DC000AAB49 /* SearchTab.swift in Sources */, + BC241EC323CB8B0600F4C0CC /* FavoriteCity.swift in Sources */, 2C7846D72372F44300766694 /* SceneDelegate.swift in Sources */, 9EE4771423C37158003BA29C /* SearchResultRow.swift in Sources */, 9E8C8C4E23C1FB0500FF8E6D /* LocationExtensions.swift in Sources */, + BCFAD1F923CB4BEC0032455B /* FavoriteSearchResults.swift in Sources */, 9EE4771223C36E9E003BA29C /* AlamofireUtils.swift in Sources */, 9EEAF95023C1F474000AAB49 /* AccountTab.swift in Sources */, 9E78A74C23C91B4A00D8A27D /* CountryDetail.swift in Sources */, @@ -463,9 +485,11 @@ 9E3CA3F123A5278E003873E8 /* FavoriteRow.swift in Sources */, 9E78A74823C918C600D8A27D /* CityDetail.swift in Sources */, 9EA0D16523C9133F0068F739 /* UserMock.swift in Sources */, + BC04DC0D23CB4104006D0767 /* FavoriteSearchResultRow.swift in Sources */, 9E78A74623C916CF00D8A27D /* LocationDetail.swift in Sources */, 9E0C988823A78341001EA11E /* CurrentWeatherData.swift in Sources */, 9E8334A123ACFCD300B191A3 /* LoadingView.swift in Sources */, + BC26444123CB835300330645 /* PredictionExtensions.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -650,14 +674,14 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_ASSET_PATHS = "\"app/Preview Content\""; - DEVELOPMENT_TEAM = 2KS4Z77UGE; + DEVELOPMENT_TEAM = 55AG82ZF5A; ENABLE_PREVIEWS = YES; INFOPLIST_FILE = app/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.mowesta.app; + PRODUCT_BUNDLE_IDENTIFIER = com.mowesta.appx; PRODUCT_NAME = MoWeSta; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 5.0; @@ -672,14 +696,14 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_ASSET_PATHS = "\"app/Preview Content\""; - DEVELOPMENT_TEAM = 2KS4Z77UGE; + DEVELOPMENT_TEAM = 55AG82ZF5A; ENABLE_PREVIEWS = YES; INFOPLIST_FILE = app/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.mowesta.app; + PRODUCT_BUNDLE_IDENTIFIER = com.mowesta.appx; PRODUCT_NAME = MoWeSta; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 5.0; @@ -693,7 +717,7 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = JGACNXZK9Q; + DEVELOPMENT_TEAM = 55AG82ZF5A; INFOPLIST_FILE = appTests/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.2; LD_RUNPATH_SEARCH_PATHS = ( @@ -715,7 +739,7 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = JGACNXZK9Q; + DEVELOPMENT_TEAM = 55AG82ZF5A; INFOPLIST_FILE = appTests/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.2; LD_RUNPATH_SEARCH_PATHS = ( @@ -735,8 +759,9 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = JGACNXZK9Q; + DEVELOPMENT_TEAM = 55AG82ZF5A; INFOPLIST_FILE = appUITests/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -756,8 +781,9 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = JGACNXZK9Q; + DEVELOPMENT_TEAM = 55AG82ZF5A; INFOPLIST_FILE = appUITests/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", diff --git a/ios-app/app/Data/FavoriteLocations.swift b/ios-app/app/Data/FavoriteLocations.swift index 9b60ad6a..91faca72 100644 --- a/ios-app/app/Data/FavoriteLocations.swift +++ b/ios-app/app/Data/FavoriteLocations.swift @@ -11,32 +11,45 @@ import MowestaApi class FavoriteLocations : ObservableObject { - @Published var locations = [LocationHierarchy] () - @Published var currentWeathers = [LocationHierarchy : CurrentWeatherData]() + @Published var locations = [LocationHierarchy]() + @Published var currentWeathers = [Int64 : CurrentWeatherData]() + @Published var weatherForecasts = [Int64 : WeatherForecast]() init(locations: [LocationHierarchy]) { self.locations = locations - for location in locations { - currentWeathers[location] = CurrentWeatherData(temperature: 10, icon: "sun.max") - } +// for location in locations { +// currentWeathers[location._id!] = CurrentWeatherData(temperature: 10, icon: "sun.max") +// weatherForecasts[location._id!] = forecast +// } } + public func toggleLocation(_ location: LocationHierarchy) { - guard let pos = locations.firstIndex(where: {l in - location == l - }) else { + guard let pos = locations.firstIndex(where: {$0._id == location._id}) else { locations.append(location) + WeatherAPI.getForecast(_id: location._id!, completion: self.addWeatherForecast) return } locations.remove(at: pos) } - func pull() { + + func addWeatherForecast(weatherforecast: WeatherForecast?, error: Error?) { + if (error != nil) { + //maybe handle + } + if (weatherforecast != nil) { + NSLog("Forecast with id: \(String(describing: weatherforecast?._id)) loaded") + weatherForecasts[(weatherforecast?._id)!] = weatherforecast + } + } + + func addCountry(country : Country?, error: Error?) { } - func push() { + func addState(state : State?, error: Error?) { } diff --git a/ios-app/app/Data/LocationExtensions.swift b/ios-app/app/Data/LocationExtensions.swift index fd06cddf..f6dd8ee8 100644 --- a/ios-app/app/Data/LocationExtensions.swift +++ b/ios-app/app/Data/LocationExtensions.swift @@ -32,6 +32,16 @@ extension City : Hashable, LocationName { hasher.combine(coordinate.longitude) hasher.combine(coordinate.latitude) } + + public func getMillisecondsFromGMT() -> Int { + NSLog("The timezone: \(self.timezone)") + switch self.timezone { + case "+1": + return 3600 * 1000 + default: + return 0 + } + } } extension State : Hashable, LocationName { @@ -60,11 +70,22 @@ extension Country : Hashable, LocationName { } } -extension LocationHierarchy : Hashable, LocationName { +extension LocationHierarchy : Hashable, LocationName, Equatable{ public static func == (lhs: LocationHierarchy, rhs: LocationHierarchy) -> Bool { return lhs._id == rhs._id } + public static func == (lhs: LocationHierarchy, rhs: Int64) -> Bool { + return lhs._id == rhs + } + + func isEqual(object: AnyObject?) -> Bool { + if let rhs = object as? LocationHierarchy { + return self == rhs + } + return false + } + public func hash(into hasher: inout Hasher) { hasher.combine(names) hasher.combine(coordinate.longitude) diff --git a/ios-app/app/Data/PredictionExtensions.swift b/ios-app/app/Data/PredictionExtensions.swift new file mode 100644 index 00000000..37345f2a --- /dev/null +++ b/ios-app/app/Data/PredictionExtensions.swift @@ -0,0 +1,27 @@ +// +// PredictionExtensuins.swift +// app +// +// Created by Tobias Stottrop on 12.01.20. +// Copyright © 2020 Marcus Handte. All rights reserved. +// + +import Foundation +import MowestaApi +import SwiftUI + + +extension WeatherCondition { + + public func getWeatherTypeImageName() -> String { + switch self.type { + case .unknown: return "questionmark" + case .clearSky: return "sun.max" + case .mainlyClear: return "cloud.sun" + case .partlyCloudy: return "cloud" + case .cloudy: return "cloud.fill" + case .fog: return "cloud.fog" + default: return "questionmark" + } + } +} diff --git a/ios-app/app/FavoriteView/FavoriteList.swift b/ios-app/app/FavoriteView/FavoriteList.swift index 63855e3e..ef223a5e 100644 --- a/ios-app/app/FavoriteView/FavoriteList.swift +++ b/ios-app/app/FavoriteView/FavoriteList.swift @@ -10,16 +10,26 @@ import SwiftUI import MowestaApi struct FavoriteList: View { - @EnvironmentObject var data: FavoriteLocations + @EnvironmentObject var favorites: FavoriteLocations + @UIState private var searchFavorites = false; + var body: some View { NavigationView { - List(data.locations, id: \._id) { location in + List(favorites.locations, id: \._id) { location in NavigationLink(destination: LocationDetail(location: location)) { FavoriteRow(location: location) } } - .navigationBarTitle(Text("Favorites")) + .navigationBarTitle("Favorites", displayMode: .inline) + .navigationBarItems(trailing: Button(action: { + self.searchFavorites = true + }){ + Text("Add") + }) + }.sheet(isPresented: $searchFavorites) { + FavoriteSearch(isPresented: self.$searchFavorites) + .environmentObject(self.favorites) } } } diff --git a/ios-app/app/FavoriteView/FavoriteRow.swift b/ios-app/app/FavoriteView/FavoriteRow.swift index 726defc5..61912ca7 100644 --- a/ios-app/app/FavoriteView/FavoriteRow.swift +++ b/ios-app/app/FavoriteView/FavoriteRow.swift @@ -11,24 +11,46 @@ import MowestaApi struct FavoriteRow: View { var location: LocationHierarchy - @EnvironmentObject var data: FavoriteLocations + + var body2: some View { + HStack { + builder() + } + .frame(minWidth: 0 , maxWidth: .infinity) + .background(Color.blue) + .cornerRadius(CGFloat(20)) + .padding() + .shadow(color: Color.blue, radius: CGFloat(4), x: CGFloat(2), y: CGFloat(2)) + } var body: some View { HStack{ Text(location.getName()) + .font(.subheadline) Spacer() - Image(systemName: data.currentWeathers[location]?.icon ?? "sun.min") - Text("\(data.currentWeathers[location]?.temperature ?? 0)°") + Image(systemName: "sun.min") + Text("220°") }.padding() } -} - -struct FavoriteRow_Previews: PreviewProvider { - static var previews: some View { - Group { - FavoriteRow(location: locationEssen) - .environmentObject(FavoriteLocations(locations: [locationEssen])) + + + + @ViewBuilder + func builder() -> some View { + if (self.location.type == .city) { + FavoriteCity(location: location) + } else if (self.location.type == .state) { + FavoriteCity(location: location) + } else { + FavoriteCity(location: location) + } + } + + struct FavoriteRow_Previews: PreviewProvider { + static var previews: some View { + Group { + FavoriteRow(location: locationEssen) + } } - .previewLayout(.fixed(width: 300, height:70)) } } diff --git a/ios-app/app/FavoriteView/FavoriteSearch.swift b/ios-app/app/FavoriteView/FavoriteSearch.swift new file mode 100644 index 00000000..8434a4f9 --- /dev/null +++ b/ios-app/app/FavoriteView/FavoriteSearch.swift @@ -0,0 +1,74 @@ +// +// FavoriteSearch.swift +// app +// +// Created by Tobias Stottrop on 12.01.20. +// Copyright © 2020 Marcus Handte. All rights reserved. +// + +import SwiftUI +import MowestaApi + +struct FavoriteSearch: View { + @Binding var isPresented: Bool + + @UIState private var searchText: String = "" + @UIState private var searchProgress = false + @UIState private var locations: [LocationHierarchy] = [] + + + var body: some View { + NavigationView { + VStack { + SearchBar(text: self.$searchText, onChanged: self.searchTextChanged, onCanceled: self.canceled, onSearch: self.search) + FavoriteSearchResults(searchProgress: self.$searchProgress, locations: self.$locations, isPresented: self.$isPresented) + .navigationBarTitle(Text("Add Favorites"), displayMode: .inline) + .navigationBarItems(trailing: Button(action: { + self.isPresented = false + }){ + Text("Done") + }) + .resignKeyboardOnDragGesture() + } + } + } + + func canceled() { + self.searchText = "" + self.searchProgress = false + self.locations = [] + } + + func search() { + self.searchProgress = true + LocationAPI.searchLocations(language: .de, term: searchText, completion: receivedLocations) + + } + + func searchTextChanged() { + self.searchProgress = true + LocationAPI.searchLocations(language: .de, term: searchText, completion: receivedLocations) + } + + func receivedLocations(locationHierarchyPage: LocationHierarchyPage?, error: Error?) { + self.searchProgress = false + if let locationPage = locationHierarchyPage { + self.locations = [] + for location in locationPage.elements { + self.locations.append(location) + } + return + } + if let err = error { + print(err) + // evtl logging ?! + } + + } + + struct FavoriteSearch_Previews: PreviewProvider { + static var previews: some View { + FavoriteSearch(isPresented: .constant(true)) + } + } +} diff --git a/ios-app/app/FavoriteView/FavoriteSearchResultRow.swift b/ios-app/app/FavoriteView/FavoriteSearchResultRow.swift new file mode 100644 index 00000000..69bf314b --- /dev/null +++ b/ios-app/app/FavoriteView/FavoriteSearchResultRow.swift @@ -0,0 +1,118 @@ +// +// SearchResultRow.swift +// app +// +// Created by Tobias Stottrop on 06.01.20. +// Copyright © 2020 Marcus Handte. All rights reserved. +// + +import SwiftUI +import MowestaApi + +struct FavoriteSearchResultRow: View { + var location: LocationHierarchy + + @EnvironmentObject var favorites: FavoriteLocations + @UIState private var reload = false + + var delimeter: String { + get { + location.parent != nil && location.parent!.parent != nil ? " · " : "" + } + } + + var stateName: String { + get { + if (location.parent?.type == .state) { + return location.parent!.getName() + } else { + return "" + } + } + } + + var countryName: String { + get { + if (location.parent?.type == .country) { + return location.parent!.getName() + } else if (location.parent?.parent?.type == .country) { + return location.parent!.parent!.getName() + } else { + return "" + } + } + } + + var body: some View { + HStack { + ZStack { + Image(systemName: "circle.fill") + .font(Font.system(size: 30)) + .foregroundColor(.red) + Image(systemName: "mappin") + .font(Font.system(size: 20)) + .foregroundColor(.white) + } + VStack { + if (location.type == .city) { + HStack { + Text(location.getName()) + .font(.subtitle) + + Spacer() + } + HStack { + Text(stateName + delimeter + countryName) + .font(.caption) + .foregroundColor(.gray) + Spacer() + } + } else if (location.type == .state) { + HStack { + Text(location.getName()) + .font(.subtitle) + Spacer() + } + HStack { + Text(countryName) + .font(.caption) + .foregroundColor(.gray) + Spacer() + } + } else if (location.type == .country) { + HStack { + Text(location.getName()) + .font(.subtitle) + Spacer() + } + } + } + + Button(action: { + self.favorites.toggleLocation(self.location) + self.reload = !self.reload + }) { + Image(systemName: favorites.locations.contains{ element in + return element == location + } ? "heart.fill" : "heart") + .font(Font.system(size: 25)) + } + + } + .padding(.top, 10) + .padding(.bottom, 10) + } +} + +struct FavoriteSearchResultRow_Previews: PreviewProvider { + static var previews: some View { + Group { + FavoriteSearchResultRow(location: locationEssen) + FavoriteSearchResultRow(location: locationNrw) + //FavoriteSearchResultRow(isPresented: .constant(true), location: locationNrw) + //FavoriteSearchResultRow(isPresented: .constant(true), location: locationDeutschland) + } + .environmentObject(FavoriteLocations(locations: [locationEssen])) + .previewLayout(.fixed(width: 300, height:70)) + } +} diff --git a/ios-app/app/FavoriteView/FavoriteSearchResults.swift b/ios-app/app/FavoriteView/FavoriteSearchResults.swift new file mode 100644 index 00000000..78230114 --- /dev/null +++ b/ios-app/app/FavoriteView/FavoriteSearchResults.swift @@ -0,0 +1,35 @@ +// +// FavoriteSearchResults.swift +// app +// +// Created by Tobias Stottrop on 12.01.20. +// Copyright © 2020 Marcus Handte. All rights reserved. +// + +import SwiftUI +import MowestaApi + +struct FavoriteSearchResults: View { + @Binding var searchProgress: Bool + @Binding var locations: [LocationHierarchy] + @Binding var isPresented: Bool + + @ViewBuilder + var body: some View { + if (self.searchProgress) { + Spacer() + ActivityIndicator(isAnimating: .constant(true), style: .large) + Spacer() + } else { + List(self.locations, id: \._id) { location in + FavoriteSearchResultRow(location: location) + } + } + } +} + +struct FavoriteSearchResults_Previews: PreviewProvider { + static var previews: some View { + FavoriteSearchResults(searchProgress: .constant(false), locations: .constant([locationEssen, locationNrw]), isPresented: .constant(true)) + } +} diff --git a/ios-app/app/LocationView/CityDetail.swift b/ios-app/app/LocationView/CityDetail.swift index ca6ba43c..6fe0d529 100644 --- a/ios-app/app/LocationView/CityDetail.swift +++ b/ios-app/app/LocationView/CityDetail.swift @@ -11,21 +11,77 @@ import MowestaApi struct CityDetail: View { - @EnvironmentObject var favoriteLocations : FavoriteLocations + @EnvironmentObject var favorites : FavoriteLocations @UIState private var location: LocationHierarchy = locationEssen - @UIState private var city: City? = essen + @UIState private var city: City = essen + @UIState private var forecast: WeatherForecast = weatherforecast + @UIState private var current: WeatherCondition = condition + @UIState private var currentType: String = "sun.min" + private var currentTime : Int = Int(Date().timeIntervalSince1970) + func setLocation(_ location: LocationHierarchy) -> some View { self.location = location + NSLog("\(self.city.getMillisecondsFromGMT())") + LocationAPI.getCity(_id: location._id!, completion: { c, err in if let city = c { self.city = city + //NSLog("\(city)") + } + }) + WeatherAPI.getForecast(_id: location._id!, completion: {f, err in + if let fore = f { + self.forecast = fore + let epochInMS = self.currentTime * 1000; + let withGMT = epochInMS + self.city.getMillisecondsFromGMT() + + for item in fore.conditions { + //NSLog("Current stamp: \(Int(epochInMS) + self.city.getMillisecondsFromGMT())") + //NSLog("First stamp: \(item.time)") + //NSLog("withGMT : \(withGMT)") + //NSLog("First stamp: \(item.time)") + //NSLog("Last stamp: \((item.time + Int64(item.duration * 3600 * 1000)))") + if (withGMT > item.time && withGMT <= ((item.time + Int64(item.duration * 3600 * 1000)))) { + //NSLog("CALLLLLLLLED") + //NSLog("\(item.type)") + self.currentType = item.getWeatherTypeImageName() + self.current = item as WeatherCondition + NSLog("after setting: \(self.$current)") + NSLog("after setting: \(item)") + } + } } }) return self } + var body: some View { + List { + Section(header: Text("Now")) { + HStack { + Spacer() + HStack(alignment: .center, spacing: 16) { + Image(systemName: self.currentType) + .font(.largeTitle) + Text(String(self.current.temperature ?? 0)) + .font(.largeTitle) + } + Spacer() + } + } + + Section(header: Text("Today")) { + Text("ff") + } + Section(header: Text("Now")) { + Text("ff") + } + } + } + + var body2: some View { NavigationView{ VStack{ VStack(alignment: .center){ @@ -34,24 +90,23 @@ struct CityDetail: View { }.padding() .offset(y: -30) .padding(.bottom, -30) - DegreeNumberCircle(temperature: favoriteLocations.currentWeathers[location]?.temperature ?? 0, size: 100) + DegreeNumberCircle(temperature: favorites.currentWeathers[city._id!]?.temperature ?? 0, size: 100) Button(action: updateWeather) { Text("Update Wetter") } } } - .navigationBarTitle(Text(city?.getName() ?? "NIL")) + .navigationBarTitle(Text(city.getName() )) } func updateWeather() { - favoriteLocations.currentWeathers[locationEssen]?.temperature = 40 + favorites.currentWeathers[city._id!]?.temperature = 40 } } struct CityDetail_Previews: PreviewProvider { static var previews: some View { CityDetail() - .setLocation(locationEssen) .environmentObject(FavoriteLocations(locations: [locationEssen])) } } diff --git a/ios-app/app/LocationView/CountryDetail.swift b/ios-app/app/LocationView/CountryDetail.swift index aef9ec0e..c8006beb 100644 --- a/ios-app/app/LocationView/CountryDetail.swift +++ b/ios-app/app/LocationView/CountryDetail.swift @@ -11,7 +11,6 @@ import MowestaApi struct CountryDetail: View { - @EnvironmentObject var favoriteLocations : FavoriteLocations @UIState private var location: LocationHierarchy = locationDeutschland @UIState private var country: Country? @@ -34,6 +33,5 @@ struct CountryDetail_Previews: PreviewProvider { static var previews: some View { CountryDetail() .setLocation(locationDeutschland) - .environmentObject(FavoriteLocations(locations: [locationEssen])) } } diff --git a/ios-app/app/LocationView/FavoriteCity.swift b/ios-app/app/LocationView/FavoriteCity.swift new file mode 100644 index 00000000..407ced1f --- /dev/null +++ b/ios-app/app/LocationView/FavoriteCity.swift @@ -0,0 +1,56 @@ +// +// FavoriteCity.swift +// app +// +// Created by Tobias Stottrop on 12.01.20. +// Copyright © 2020 Marcus Handte. All rights reserved. +// + +import SwiftUI +import MowestaApi + +struct FavoriteCity: View { + var location: LocationHierarchy + @EnvironmentObject var favorites: FavoriteLocations + + var body: some View { + VStack(spacing: 10){ + Text(location.getName()) + .foregroundColor(Color.white) + .fontWeight(Font.Weight.heavy) + .font(Font.system(size: 30)) + + Image(systemName: favorites.currentWeathers[location._id!]?.icon ?? "sun.min") + .resizable() + .foregroundColor(Color.white) + .frame(width: 100, height: 100) + .aspectRatio(contentMode: .fit) + + VStack{ Text("\(favorites.currentWeathers[location._id!]?.temperature ?? 0)°") + .foregroundColor(Color.white) + .font(.title) + HStack { + Text("22°C") + .foregroundColor(Color.white) + .font( Font.system(size: 14)) + .opacity(0.5) + Text("33°C") + .foregroundColor(Color.white) + .font( Font.system(size: 14)) + .opacity(1) + } + } + } + } +} + +struct FavoriteCity_Previews: PreviewProvider { + static var previews: some View { + FavoriteCity(location: locationEssen) + .frame(minWidth: 0 , maxWidth: .infinity) + .background(Color.blue) + .cornerRadius(CGFloat(20)) + .padding() + .shadow(color: Color.blue, radius: CGFloat(20), x: CGFloat(10), y: CGFloat(10)) + } +} diff --git a/ios-app/app/LocationView/LocationDetail.swift b/ios-app/app/LocationView/LocationDetail.swift index 20204a11..3d45a153 100644 --- a/ios-app/app/LocationView/LocationDetail.swift +++ b/ios-app/app/LocationView/LocationDetail.swift @@ -10,22 +10,23 @@ import SwiftUI import MowestaApi struct LocationDetail: View { - @EnvironmentObject var favoriteLocations : FavoriteLocations + @EnvironmentObject var favorites : FavoriteLocations var location: LocationHierarchy var body: some View { VStack { builder() } + .navigationBarTitle(location.getName()) .navigationBarItems(trailing: VStack { Button(action: { - self.favoriteLocations.toggleLocation(self.location) + self.favorites.toggleLocation(self.location) }) { - Image(systemName: favoriteLocations.locations.contains{ element in - return element == location - } ? "heart.fill" : "heart") - .font(Font.system(size: 25)) + Image(systemName: favorites.locations.contains{ element in + return element == location + } ? "heart.fill" : "heart") + .font(Font.system(size: 25)) } }) } @@ -45,6 +46,6 @@ struct LocationDetail: View { struct LocationDetail_Previews: PreviewProvider { static var previews: some View { LocationDetail(location: locationEssen) - .environmentObject(FavoriteLocations(locations: [])) + .environmentObject(FavoriteLocations(locations: [locationEssen])) } } diff --git a/ios-app/app/LocationView/LocationHeaderView.swift b/ios-app/app/LocationView/LocationHeaderView.swift new file mode 100644 index 00000000..52498df4 --- /dev/null +++ b/ios-app/app/LocationView/LocationHeaderView.swift @@ -0,0 +1,40 @@ +// +// LocationHeaderView.swift +// app +// +// Created by Tobias Stottrop on 12.01.20. +// Copyright © 2020 Marcus Handte. All rights reserved. +// + +import SwiftUI +import MowestaApi + +struct LocationHeaderView: View { + @Binding var city: City; + @Binding var weatherType: WeatherCondition? + + func test() -> some View{ + NSLog("\(String(describing: weatherType))") + return Spacer() + } + + var body: some View { + HStack { + Spacer() + HStack(alignment: .center, spacing: 16) { + Image(systemName: weatherType?.getWeatherTypeImageName() ?? "questionmark") + .font(.largeTitle) + Text(String(weatherType?.temperature ?? 0)) + .font(.largeTitle) + } + Spacer() + } + .frame(height: 110) + } +} + +struct LocationHeaderView_Previews: PreviewProvider { + static var previews: some View { + LocationHeaderView(city: .constant(essen), weatherType: .constant(condition)) + } +} diff --git a/ios-app/app/LocationView/StateDetail.swift b/ios-app/app/LocationView/StateDetail.swift index 576898d8..06051f33 100644 --- a/ios-app/app/LocationView/StateDetail.swift +++ b/ios-app/app/LocationView/StateDetail.swift @@ -10,7 +10,6 @@ import SwiftUI import MowestaApi struct StateDetail: View { - @EnvironmentObject var favoriteLocations : FavoriteLocations @UIState private var location: LocationHierarchy = locationNrw @UIState private var state: MowestaApi.State? @@ -33,6 +32,6 @@ struct StateDetail_Previews: PreviewProvider { static var previews: some View { StateDetail() .setLocation(locationNrw) - .environmentObject(FavoriteLocations(locations: [locationEssen])) + } } diff --git a/ios-app/app/MockData/LocationMock.swift b/ios-app/app/MockData/LocationMock.swift index 8137ff8f..20d70919 100644 --- a/ios-app/app/MockData/LocationMock.swift +++ b/ios-app/app/MockData/LocationMock.swift @@ -10,7 +10,7 @@ import MowestaApi let locationDeutschland = LocationHierarchy(_id: 6, creationTime: 0, modificationTime: 0, deleted: false, coordinate: Coordinate(latitude: 2.3, longitude: 2.4), type: .country, parent: nil, names: ["de" : "Deutschland", "local" : "Deutschland", "en" : "Germany"]) -let locationNrw = LocationHierarchy(_id: 6, creationTime: 0, modificationTime: 0, deleted: false, coordinate: Coordinate(latitude: 2.3, longitude: 2.4), type: .state, parent: locationDeutschland , names: ["de" : "Nordrhein-Westfalen", "local" : "Nordrhein-Westfalen", "en" : "North Rhine-Westphalia"]) +let locationNrw = LocationHierarchy(_id: 7, creationTime: 0, modificationTime: 0, deleted: false, coordinate: Coordinate(latitude: 2.3, longitude: 2.4), type: .state, parent: locationDeutschland , names: ["de" : "Nordrhein-Westfalen", "local" : "Nordrhein-Westfalen", "en" : "North Rhine-Westphalia"]) let locationEssen = LocationHierarchy(_id: 6, creationTime: 0, modificationTime: 0, deleted: false, coordinate: Coordinate(latitude: 2.3, longitude: 2.4), type: .city, parent: locationNrw, names: ["de" : "Essen", "local" : "Essen", "en" : "Essen"]) @@ -28,6 +28,11 @@ let berlin = City(_id: 5, creationTime: 0, modificationTime: 0, deleted: false, let rain4 = CurrentWeatherData(temperature: 4, icon: "sun") +let condition = WeatherCondition(source: WeatherCondition.Source.cosmoEurope, time: 1578787200000, hour: 0, duration: 1, type: WeatherCondition.ModelType.clearSky, temperature: 23, windDirection: WeatherCondition.WindDirection.east, windSpeed: 6, cloudCoverage: 12, cloudDepth: 22, pressure: 22, precipitation: 32, snowDepth: 0, humidity: 32) + +let weatherforecast = WeatherForecast(_id: 8022, creationTime: 1578852215818, modificationTime: 1578852215818, deleted: false, coordinate: Coordinate(latitude: 7.0243988037109375, longitude: 50.9375), source: WeatherForecast.Source.iconEurope, surfaceHeight: -0.02880859375, plantCoverage: 0, soilType: WeatherForecast.SoilType.clay, conditions: [condition]) + + func loadTestData() -> [City] { return [essen, berlin]; } diff --git a/ios-app/app/SceneDelegate.swift b/ios-app/app/SceneDelegate.swift index 1c3c7a4a..fb8be05c 100644 --- a/ios-app/app/SceneDelegate.swift +++ b/ios-app/app/SceneDelegate.swift @@ -14,9 +14,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? - let favorites = FavoriteLocations(locations: [locationEssen]) - - let favorites2 = FavoriteLocations(locations: []) + let favorites = FavoriteLocations(locations: []) let user = UserData() func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { @@ -27,7 +25,6 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { // Create the SwiftUI view that provides the window content let contentView = ContentView() .environmentObject(favorites) - .environmentObject(favorites2) .environmentObject(user) // Use a UIHostingController as window root view controller. diff --git a/ios-app/app/de.lproj/Localizable.strings b/ios-app/app/de.lproj/Localizable.strings index f242531d..d0d8236c 100644 --- a/ios-app/app/de.lproj/Localizable.strings +++ b/ios-app/app/de.lproj/Localizable.strings @@ -31,3 +31,6 @@ /* Search View */ "SVSearchLocations" = "Suche Orte"; + +/* Favorites View */ +"Favorite_NavigationBarTitle" = "Favoriten"; diff --git a/ios-app/app/en.lproj/Localizable.strings b/ios-app/app/en.lproj/Localizable.strings index 6c5bddd2..8828d6eb 100644 --- a/ios-app/app/en.lproj/Localizable.strings +++ b/ios-app/app/en.lproj/Localizable.strings @@ -31,3 +31,6 @@ /* Search View */ "SVSearchLocations" = "Search Locations"; + +/* Favorites View */ +"Favorite_NavigationBarTitle" = "Favorites"; -- 2.56.1 From e2d99bebc6991992121d2cdc0e70e05d17edbf81 Mon Sep 17 00:00:00 2001 From: stottrop Date: Mon, 13 Jan 2020 18:24:22 +0100 Subject: [PATCH 02/12] Renamed and completed getWeatherType() symbol returns --- ios-app/app.xcodeproj/project.pbxproj | 25 ++++++++-- ios-app/app/Data/PredictionExtensions.swift | 27 ---------- .../app/Data/WeatherConditionExtension.swift | 49 +++++++++++++++++++ ios-app/build.gradle | 2 +- 4 files changed, 71 insertions(+), 32 deletions(-) delete mode 100644 ios-app/app/Data/PredictionExtensions.swift create mode 100644 ios-app/app/Data/WeatherConditionExtension.swift diff --git a/ios-app/app.xcodeproj/project.pbxproj b/ios-app/app.xcodeproj/project.pbxproj index 199e770d..1f4977a8 100644 --- a/ios-app/app.xcodeproj/project.pbxproj +++ b/ios-app/app.xcodeproj/project.pbxproj @@ -48,7 +48,8 @@ BC04DC0D23CB4104006D0767 /* FavoriteSearchResultRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC04DC0C23CB4104006D0767 /* FavoriteSearchResultRow.swift */; }; BC1A86B723CBB755005DE4F5 /* LocationHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC1A86B623CBB755005DE4F5 /* LocationHeaderView.swift */; }; BC241EC323CB8B0600F4C0CC /* FavoriteCity.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC241EC223CB8B0600F4C0CC /* FavoriteCity.swift */; }; - BC26444123CB835300330645 /* PredictionExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC26444023CB835300330645 /* PredictionExtensions.swift */; }; + BC26444123CB835300330645 /* WeatherConditionExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC26444023CB835300330645 /* WeatherConditionExtension.swift */; }; + BC9795FE23CCC4AD00546A6E /* Mowesta.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = BC9795FC23CCC4AD00546A6E /* Mowesta.xcdatamodeld */; }; BCFAD1F923CB4BEC0032455B /* FavoriteSearchResults.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCFAD1F823CB4BEC0032455B /* FavoriteSearchResults.swift */; }; /* End PBXBuildFile section */ @@ -117,7 +118,8 @@ BC04DC0C23CB4104006D0767 /* FavoriteSearchResultRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoriteSearchResultRow.swift; sourceTree = ""; }; BC1A86B623CBB755005DE4F5 /* LocationHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationHeaderView.swift; sourceTree = ""; }; BC241EC223CB8B0600F4C0CC /* FavoriteCity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoriteCity.swift; sourceTree = ""; }; - BC26444023CB835300330645 /* PredictionExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PredictionExtensions.swift; sourceTree = ""; }; + BC26444023CB835300330645 /* WeatherConditionExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherConditionExtension.swift; sourceTree = ""; }; + BC9795FD23CCC4AD00546A6E /* Mowesta.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Mowesta.xcdatamodel; sourceTree = ""; }; BCFAD1F823CB4BEC0032455B /* FavoriteSearchResults.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoriteSearchResults.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -234,7 +236,7 @@ children = ( 9E0C988723A78341001EA11E /* CurrentWeatherData.swift */, 9E8C8C4D23C1FB0500FF8E6D /* LocationExtensions.swift */, - BC26444023CB835300330645 /* PredictionExtensions.swift */, + BC26444023CB835300330645 /* WeatherConditionExtension.swift */, 9EE4771923C3C77F003BA29C /* FavoriteLocations.swift */, 9E81DC9123A7DECE00568CF4 /* UserData.swift */, ); @@ -256,6 +258,7 @@ 9E3CA40223A53A2E003873E8 /* Resources */ = { isa = PBXGroup; children = ( + BC9795FC23CCC4AD00546A6E /* Mowesta.xcdatamodeld */, ); path = Resources; sourceTree = ""; @@ -459,6 +462,7 @@ files = ( BC1A86B723CBB755005DE4F5 /* LocationHeaderView.swift in Sources */, 9EA0D16323C9118C0068F739 /* LocationMock.swift in Sources */, + BC9795FE23CCC4AD00546A6E /* Mowesta.xcdatamodeld in Sources */, 9EE4770C23C36363003BA29C /* SearchResults.swift in Sources */, 2C7846D52372F44300766694 /* AppDelegate.swift in Sources */, 9E3CA3EF23A51DFC003873E8 /* DegreeNumberCircle.swift in Sources */, @@ -489,7 +493,7 @@ 9E78A74623C916CF00D8A27D /* LocationDetail.swift in Sources */, 9E0C988823A78341001EA11E /* CurrentWeatherData.swift in Sources */, 9E8334A123ACFCD300B191A3 /* LoadingView.swift in Sources */, - BC26444123CB835300330645 /* PredictionExtensions.swift in Sources */, + BC26444123CB835300330645 /* WeatherConditionExtension.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -866,6 +870,19 @@ productName = KeychainSwift; }; /* End XCSwiftPackageProductDependency section */ + +/* Begin XCVersionGroup section */ + BC9795FC23CCC4AD00546A6E /* Mowesta.xcdatamodeld */ = { + isa = XCVersionGroup; + children = ( + BC9795FD23CCC4AD00546A6E /* Mowesta.xcdatamodel */, + ); + currentVersion = BC9795FD23CCC4AD00546A6E /* Mowesta.xcdatamodel */; + path = Mowesta.xcdatamodeld; + sourceTree = ""; + versionGroupType = wrapper.xcdatamodel; + }; +/* End XCVersionGroup section */ }; rootObject = 2C7846C92372F44300766694 /* Project object */; } diff --git a/ios-app/app/Data/PredictionExtensions.swift b/ios-app/app/Data/PredictionExtensions.swift deleted file mode 100644 index 37345f2a..00000000 --- a/ios-app/app/Data/PredictionExtensions.swift +++ /dev/null @@ -1,27 +0,0 @@ -// -// PredictionExtensuins.swift -// app -// -// Created by Tobias Stottrop on 12.01.20. -// Copyright © 2020 Marcus Handte. All rights reserved. -// - -import Foundation -import MowestaApi -import SwiftUI - - -extension WeatherCondition { - - public func getWeatherTypeImageName() -> String { - switch self.type { - case .unknown: return "questionmark" - case .clearSky: return "sun.max" - case .mainlyClear: return "cloud.sun" - case .partlyCloudy: return "cloud" - case .cloudy: return "cloud.fill" - case .fog: return "cloud.fog" - default: return "questionmark" - } - } -} diff --git a/ios-app/app/Data/WeatherConditionExtension.swift b/ios-app/app/Data/WeatherConditionExtension.swift new file mode 100644 index 00000000..474ad22c --- /dev/null +++ b/ios-app/app/Data/WeatherConditionExtension.swift @@ -0,0 +1,49 @@ +// +// PredictionExtensuins.swift +// app +// +// Created by Tobias Stottrop on 12.01.20. +// Copyright © 2020 Marcus Handte. All rights reserved. +// + +import Foundation +import MowestaApi +import SwiftUI + + +extension WeatherCondition { + + public func getWeatherTypeImageName() -> String { + switch self.type { + case .unknown: return "questionmark" + case .clearSky: return "sun.max" + case .mainlyClear: return "cloud.sun" + case .partlyCloudy: return "cloud" + case .cloudy: return "cloud.fill" + case .fog: return "cloud.fog" + case .fogDepositingRime : return "cloud.fog" + case .slightDrizzle : return "cloud.drizzle" + case .moderateDrizzle : return "cloud.rain" + case .heavyDrizzle : return "cloud.rheavyrain" + case .drizzleFreezingSlight : return "cloud.snow" + case .drizzleFreezingModerateHeavy : return "cloud.snow" + case .slightRainNotFreezing : return "cloud.drizzle" + case .moderateRainNotFreezing : return "cloud.rain" + case .heavyRainNotFreezing : return "cloud.heavyrain" + case .rainFreezingSlight : return "cloud.snow" + case .rainFreezingModerateHeavy : return "cloud.snow" + case .slightFallOfSnowflakes : return "cloud.snow" + case .moderateFallOfSnowflakes : return "cloud.snow" + case .heavyFallOfSnowflakes : return "cloud.snow" + case .snowGrains : return "snow" + case .rainShowerSlight : return "cloud.rain" + case .rainShowerModerateHeavy : return "cloud.heavyrain" + case .rainShowerViolent : return "cloud.heavyrain" + case .snowShowerSlight : return "cloud.snow" + case .snowShowerModerateHeavy : return "cloud.snow" + case .thunderstormSlightModerate : return "cloud.bolt" + case .thunderstormHailHeavy : return "cloud.bolt" + default: return "questionmark" + } + } +} diff --git a/ios-app/build.gradle b/ios-app/build.gradle index 39862a24..7bd52e2f 100644 --- a/ios-app/build.gradle +++ b/ios-app/build.gradle @@ -1,6 +1,6 @@ description = "Mowesta IOS App" -if (System.getProperty("os.name").equals("Mac OS X")) { +if (System.getProperty("os.name").equals("Mac fOS X")) { apply plugin: "org.openbakery.xcode-plugin" -- 2.56.1 From f4e2ebe81c8bdf8ad6b43cbe798dfcc43b94c39a Mon Sep 17 00:00:00 2001 From: stottrop Date: Mon, 13 Jan 2020 18:26:39 +0100 Subject: [PATCH 03/12] corrected build.gradle --- ios-app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios-app/build.gradle b/ios-app/build.gradle index 7bd52e2f..39862a24 100644 --- a/ios-app/build.gradle +++ b/ios-app/build.gradle @@ -1,6 +1,6 @@ description = "Mowesta IOS App" -if (System.getProperty("os.name").equals("Mac fOS X")) { +if (System.getProperty("os.name").equals("Mac OS X")) { apply plugin: "org.openbakery.xcode-plugin" -- 2.56.1 From 15042d7f01b82042685910136bef86aef82ba7cb Mon Sep 17 00:00:00 2001 From: stottrop Date: Mon, 13 Jan 2020 19:01:36 +0100 Subject: [PATCH 04/12] added date to LocationHeaderView --- .../app/LocationView/LocationHeaderView.swift | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/ios-app/app/LocationView/LocationHeaderView.swift b/ios-app/app/LocationView/LocationHeaderView.swift index 52498df4..fce53bb7 100644 --- a/ios-app/app/LocationView/LocationHeaderView.swift +++ b/ios-app/app/LocationView/LocationHeaderView.swift @@ -18,23 +18,37 @@ struct LocationHeaderView: View { return Spacer() } + func getDateAsString() -> String { + let formatter = DateFormatter() + formatter.locale = Locale(identifier: "de_DE") + formatter.dateStyle = .medium + formatter.timeStyle = .short + let dateString = formatter.string(from: Date()) + return dateString + } + var body: some View { - HStack { - Spacer() - HStack(alignment: .center, spacing: 16) { - Image(systemName: weatherType?.getWeatherTypeImageName() ?? "questionmark") - .font(.largeTitle) - Text(String(weatherType?.temperature ?? 0)) - .font(.largeTitle) + VStack(alignment: .leading) { + Text(getDateAsString()) + HStack { + + Spacer() + HStack(alignment: .center, spacing: 16) { + Image(systemName: weatherType?.getWeatherTypeImageName() ?? "questionmark") + .font(.largeTitle) + Text(String(weatherType?.temperature ?? 0)) + .font(.largeTitle) + } + Spacer() } - Spacer() } .frame(height: 110) - } + } } struct LocationHeaderView_Previews: PreviewProvider { static var previews: some View { LocationHeaderView(city: .constant(essen), weatherType: .constant(condition)) + .previewLayout(.fixed(width: 350, height:110)) } } -- 2.56.1 From 895c6e77abe3a4c27b0d755dcce18335de7ae6ff Mon Sep 17 00:00:00 2001 From: stottrop Date: Mon, 13 Jan 2020 23:10:44 +0100 Subject: [PATCH 05/12] Removed unnecessary case --- ios-app/app/Data/WeatherConditionExtension.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/ios-app/app/Data/WeatherConditionExtension.swift b/ios-app/app/Data/WeatherConditionExtension.swift index 474ad22c..0a27db47 100644 --- a/ios-app/app/Data/WeatherConditionExtension.swift +++ b/ios-app/app/Data/WeatherConditionExtension.swift @@ -43,7 +43,6 @@ extension WeatherCondition { case .snowShowerModerateHeavy : return "cloud.snow" case .thunderstormSlightModerate : return "cloud.bolt" case .thunderstormHailHeavy : return "cloud.bolt" - default: return "questionmark" } } } -- 2.56.1 From b646191708d3ce83e78f670fdfd2e2b657c2b8f4 Mon Sep 17 00:00:00 2001 From: stottrop Date: Mon, 13 Jan 2020 23:11:43 +0100 Subject: [PATCH 06/12] Added EditButton and swipe to delete gesture in FavoriteList.swift --- ios-app/app/FavoriteView/FavoriteList.swift | 29 ++++++++++++++------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/ios-app/app/FavoriteView/FavoriteList.swift b/ios-app/app/FavoriteView/FavoriteList.swift index ef223a5e..adf26e05 100644 --- a/ios-app/app/FavoriteView/FavoriteList.swift +++ b/ios-app/app/FavoriteView/FavoriteList.swift @@ -13,20 +13,31 @@ struct FavoriteList: View { @EnvironmentObject var favorites: FavoriteLocations @UIState private var searchFavorites = false; + private func deleteItem(at indexSet: IndexSet) { + self.favorites.locations.remove(atOffsets: indexSet) + } var body: some View { NavigationView { - List(favorites.locations, id: \._id) { location in - NavigationLink(destination: LocationDetail(location: location)) { - FavoriteRow(location: location) + List{ + ForEach(favorites.locations, id: \._id) { location in + NavigationLink(destination: LocationDetail(location: location)) { + FavoriteRow(location: location) + } + } + .onDelete(perform: self.deleteItem) + .onMove { (indexSet, index) in + self.favorites.locations.move(fromOffsets: indexSet, toOffset: index) } } - .navigationBarTitle("Favorites", displayMode: .inline) - .navigationBarItems(trailing: Button(action: { - self.searchFavorites = true - }){ - Text("Add") - }) + .listStyle(GroupedListStyle()) + .navigationBarTitle("Favorites", displayMode: .automatic) + .navigationBarItems(leading: EditButton(), trailing: + Button(action: { + self.searchFavorites = true + }){ + Text("Add") + }) }.sheet(isPresented: $searchFavorites) { FavoriteSearch(isPresented: self.$searchFavorites) .environmentObject(self.favorites) -- 2.56.1 From 3f6a5d8e365069a7631e259b9d348078ddc10b7f Mon Sep 17 00:00:00 2001 From: stottrop Date: Mon, 13 Jan 2020 23:12:54 +0100 Subject: [PATCH 07/12] Added Views for current-weather-status, next pedictions in a horizontal list and for the next day as vertical list --- .../app/LocationView/LocationDetailView.swift | 43 +++++++++++++++++++ .../LocationView/LocationForecastView.swift | 21 +++++++++ .../app/LocationView/LocationHeaderView.swift | 11 ++--- 3 files changed, 68 insertions(+), 7 deletions(-) create mode 100644 ios-app/app/LocationView/LocationDetailView.swift create mode 100644 ios-app/app/LocationView/LocationForecastView.swift diff --git a/ios-app/app/LocationView/LocationDetailView.swift b/ios-app/app/LocationView/LocationDetailView.swift new file mode 100644 index 00000000..077a133e --- /dev/null +++ b/ios-app/app/LocationView/LocationDetailView.swift @@ -0,0 +1,43 @@ +// +// LocationDetailView.swift +// app +// +// Created by Tobias Stottrop on 13.01.20. +// Copyright © 2020 Marcus Handte. All rights reserved. +// + +import SwiftUI +import MowestaApi + +struct LocationDetailView: View { + @UIState var conditions : [WeatherCondition] + + + var body: some View { + ScrollView(.horizontal) { + HStack(spacing: 8) { + ForEach(conditions, id: \.hour) { cond in + VStack(spacing: 8) { + Text(String(cond.hour)) + .font(.footnote) + Image(systemName: cond.getWeatherTypeImageName()) + .font(.body) + Text("22C") + .font(.headline) + } + } + } + .frame(height: 100) + .padding(.trailing) + } + .listRowInsets(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0)) + .frame(height: 100) + } +} + +struct LocationDetailView_Previews: PreviewProvider { + static var previews: some View { + LocationDetailView(conditions: [condition, condition, condition, condition, condition, condition,condition, condition, condition]) + .previewLayout(.fixed(width: 350, height:100)) + } +} diff --git a/ios-app/app/LocationView/LocationForecastView.swift b/ios-app/app/LocationView/LocationForecastView.swift new file mode 100644 index 00000000..1e02d056 --- /dev/null +++ b/ios-app/app/LocationView/LocationForecastView.swift @@ -0,0 +1,21 @@ +// +// LocationForecastView.swift +// app +// +// Created by Tobias Stottrop on 13.01.20. +// Copyright © 2020 Marcus Handte. All rights reserved. +// + +import SwiftUI + +struct LocationForecastView: View { + var body: some View { + Text("Next days....") + } +} + +struct LocationForecastView_Previews: PreviewProvider { + static var previews: some View { + LocationForecastView() + } +} diff --git a/ios-app/app/LocationView/LocationHeaderView.swift b/ios-app/app/LocationView/LocationHeaderView.swift index fce53bb7..700ab5c8 100644 --- a/ios-app/app/LocationView/LocationHeaderView.swift +++ b/ios-app/app/LocationView/LocationHeaderView.swift @@ -5,13 +5,12 @@ // Created by Tobias Stottrop on 12.01.20. // Copyright © 2020 Marcus Handte. All rights reserved. // - import SwiftUI import MowestaApi struct LocationHeaderView: View { @Binding var city: City; - @Binding var weatherType: WeatherCondition? + @Binding var weatherType: WeatherCondition func test() -> some View{ NSLog("\(String(describing: weatherType))") @@ -31,24 +30,22 @@ struct LocationHeaderView: View { VStack(alignment: .leading) { Text(getDateAsString()) HStack { - Spacer() HStack(alignment: .center, spacing: 16) { - Image(systemName: weatherType?.getWeatherTypeImageName() ?? "questionmark") + Image(systemName: weatherType.getWeatherTypeImageName()) .font(.largeTitle) - Text(String(weatherType?.temperature ?? 0)) + Text(String(weatherType.temperature)) .font(.largeTitle) } Spacer() } } - .frame(height: 110) } } struct LocationHeaderView_Previews: PreviewProvider { static var previews: some View { LocationHeaderView(city: .constant(essen), weatherType: .constant(condition)) - .previewLayout(.fixed(width: 350, height:110)) + .previewLayout(.fixed(width: 350, height:150)) } } -- 2.56.1 From 974d3b23158447c4b28cacb45416c4a9a48c86d1 Mon Sep 17 00:00:00 2001 From: stottrop Date: Mon, 13 Jan 2020 23:14:11 +0100 Subject: [PATCH 08/12] use new weather-views in CityDetail --- ios-app/app/LocationView/CityDetail.swift | 37 +++-------------------- 1 file changed, 5 insertions(+), 32 deletions(-) diff --git a/ios-app/app/LocationView/CityDetail.swift b/ios-app/app/LocationView/CityDetail.swift index 6fe0d529..fd1d3de5 100644 --- a/ios-app/app/LocationView/CityDetail.swift +++ b/ios-app/app/LocationView/CityDetail.swift @@ -60,45 +60,17 @@ struct CityDetail: View { var body: some View { List { Section(header: Text("Now")) { - HStack { - Spacer() - HStack(alignment: .center, spacing: 16) { - Image(systemName: self.currentType) - .font(.largeTitle) - Text(String(self.current.temperature ?? 0)) - .font(.largeTitle) - } - Spacer() - } + LocationHeaderView(city: $city, weatherType: $current) } - Section(header: Text("Today")) { - Text("ff") + LocationDetailView(conditions: forecast.conditions) } - Section(header: Text("Now")) { - Text("ff") + Section(header: Text("Next days")) { + LocationForecastView() } } } - var body2: some View { - NavigationView{ - VStack{ - VStack(alignment: .center){ - Text(location.getName()) - .font(.title) - }.padding() - .offset(y: -30) - .padding(.bottom, -30) - DegreeNumberCircle(temperature: favorites.currentWeathers[city._id!]?.temperature ?? 0, size: 100) - Button(action: updateWeather) { - Text("Update Wetter") - } - } - } - .navigationBarTitle(Text(city.getName() )) - } - func updateWeather() { favorites.currentWeathers[city._id!]?.temperature = 40 } @@ -107,6 +79,7 @@ struct CityDetail: View { struct CityDetail_Previews: PreviewProvider { static var previews: some View { CityDetail() + //.environment(\.locale, .init(identifier: "de")) .environmentObject(FavoriteLocations(locations: [locationEssen])) } } -- 2.56.1 From 17fb9c8dcab5500c880e12aa9350363fda7cc877 Mon Sep 17 00:00:00 2001 From: stottrop Date: Mon, 13 Jan 2020 23:15:20 +0100 Subject: [PATCH 09/12] use of Combine Framework for Published fields --- ios-app/app.xcodeproj/project.pbxproj | 8 ++++++++ ios-app/app/Data/FavoriteLocations.swift | 14 +++++--------- .../Mowesta.xcdatamodel/contents | 10 ++++++++++ ios-app/app/de.lproj/Localizable.strings | 1 + ios-app/app/en.lproj/Localizable.strings | 1 + 5 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 ios-app/app/Resources/Mowesta.xcdatamodeld/Mowesta.xcdatamodel/contents diff --git a/ios-app/app.xcodeproj/project.pbxproj b/ios-app/app.xcodeproj/project.pbxproj index 1f4977a8..88fce62d 100644 --- a/ios-app/app.xcodeproj/project.pbxproj +++ b/ios-app/app.xcodeproj/project.pbxproj @@ -50,6 +50,8 @@ BC241EC323CB8B0600F4C0CC /* FavoriteCity.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC241EC223CB8B0600F4C0CC /* FavoriteCity.swift */; }; BC26444123CB835300330645 /* WeatherConditionExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC26444023CB835300330645 /* WeatherConditionExtension.swift */; }; BC9795FE23CCC4AD00546A6E /* Mowesta.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = BC9795FC23CCC4AD00546A6E /* Mowesta.xcdatamodeld */; }; + BCEE929023CCEDD80029CC73 /* LocationDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCEE928F23CCEDD80029CC73 /* LocationDetailView.swift */; }; + BCEE929223CCF7B60029CC73 /* LocationForecastView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCEE929123CCF7B60029CC73 /* LocationForecastView.swift */; }; BCFAD1F923CB4BEC0032455B /* FavoriteSearchResults.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCFAD1F823CB4BEC0032455B /* FavoriteSearchResults.swift */; }; /* End PBXBuildFile section */ @@ -120,6 +122,8 @@ BC241EC223CB8B0600F4C0CC /* FavoriteCity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoriteCity.swift; sourceTree = ""; }; BC26444023CB835300330645 /* WeatherConditionExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherConditionExtension.swift; sourceTree = ""; }; BC9795FD23CCC4AD00546A6E /* Mowesta.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Mowesta.xcdatamodel; sourceTree = ""; }; + BCEE928F23CCEDD80029CC73 /* LocationDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationDetailView.swift; sourceTree = ""; }; + BCEE929123CCF7B60029CC73 /* LocationForecastView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationForecastView.swift; sourceTree = ""; }; BCFAD1F823CB4BEC0032455B /* FavoriteSearchResults.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoriteSearchResults.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -273,6 +277,8 @@ 9E78A74B23C91B4A00D8A27D /* CountryDetail.swift */, 9E3CA3EE23A51DFC003873E8 /* DegreeNumberCircle.swift */, BC1A86B623CBB755005DE4F5 /* LocationHeaderView.swift */, + BCEE928F23CCEDD80029CC73 /* LocationDetailView.swift */, + BCEE929123CCF7B60029CC73 /* LocationForecastView.swift */, ); path = LocationView; sourceTree = ""; @@ -463,6 +469,7 @@ BC1A86B723CBB755005DE4F5 /* LocationHeaderView.swift in Sources */, 9EA0D16323C9118C0068F739 /* LocationMock.swift in Sources */, BC9795FE23CCC4AD00546A6E /* Mowesta.xcdatamodeld in Sources */, + BCEE929023CCEDD80029CC73 /* LocationDetailView.swift in Sources */, 9EE4770C23C36363003BA29C /* SearchResults.swift in Sources */, 2C7846D52372F44300766694 /* AppDelegate.swift in Sources */, 9E3CA3EF23A51DFC003873E8 /* DegreeNumberCircle.swift in Sources */, @@ -483,6 +490,7 @@ 9EE4770E23C363F6003BA29C /* ViewExtensions.swift in Sources */, 9E78A74A23C91B3D00D8A27D /* StateDetail.swift in Sources */, 9E8334A423AD003E00B191A3 /* Login.swift in Sources */, + BCEE929223CCF7B60029CC73 /* LocationForecastView.swift in Sources */, 9EE4771A23C3C77F003BA29C /* FavoriteLocations.swift in Sources */, 2C7846D92372F44300766694 /* ContentView.swift in Sources */, 9E3CA3F423A52ABF003873E8 /* FavoriteList.swift in Sources */, diff --git a/ios-app/app/Data/FavoriteLocations.swift b/ios-app/app/Data/FavoriteLocations.swift index 91faca72..96105c3d 100644 --- a/ios-app/app/Data/FavoriteLocations.swift +++ b/ios-app/app/Data/FavoriteLocations.swift @@ -8,8 +8,12 @@ import Foundation import MowestaApi +import SwiftUI +import Combine class FavoriteLocations : ObservableObject { + //The PassthroughSubject provides a convenient way to adapt existing imperative code to the Combine model. + var objectWillChange = PassthroughSubject() @Published var locations = [LocationHierarchy]() @Published var currentWeathers = [Int64 : CurrentWeatherData]() @@ -44,13 +48,5 @@ class FavoriteLocations : ObservableObject { weatherForecasts[(weatherforecast?._id)!] = weatherforecast } } - - func addCountry(country : Country?, error: Error?) { - - } - - func addState(state : State?, error: Error?) { - - } - + } diff --git a/ios-app/app/Resources/Mowesta.xcdatamodeld/Mowesta.xcdatamodel/contents b/ios-app/app/Resources/Mowesta.xcdatamodeld/Mowesta.xcdatamodel/contents new file mode 100644 index 00000000..1cd38239 --- /dev/null +++ b/ios-app/app/Resources/Mowesta.xcdatamodeld/Mowesta.xcdatamodel/contents @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/ios-app/app/de.lproj/Localizable.strings b/ios-app/app/de.lproj/Localizable.strings index d0d8236c..e904ebde 100644 --- a/ios-app/app/de.lproj/Localizable.strings +++ b/ios-app/app/de.lproj/Localizable.strings @@ -34,3 +34,4 @@ /* Favorites View */ "Favorite_NavigationBarTitle" = "Favoriten"; +"Now" = "Jetzt"; diff --git a/ios-app/app/en.lproj/Localizable.strings b/ios-app/app/en.lproj/Localizable.strings index 8828d6eb..c4e43a9c 100644 --- a/ios-app/app/en.lproj/Localizable.strings +++ b/ios-app/app/en.lproj/Localizable.strings @@ -34,3 +34,4 @@ /* Favorites View */ "Favorite_NavigationBarTitle" = "Favorites"; +"Now" = "Now"; -- 2.56.1 From 5dd76dea8ef6a37f6efbe43a73958e9f07010659 Mon Sep 17 00:00:00 2001 From: stottrop Date: Wed, 15 Jan 2020 15:46:24 +0100 Subject: [PATCH 10/12] Heart symbols in FavoriteSearchResultRow are red now --- ios-app/app/FavoriteView/FavoriteSearchResultRow.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios-app/app/FavoriteView/FavoriteSearchResultRow.swift b/ios-app/app/FavoriteView/FavoriteSearchResultRow.swift index 69bf314b..ab110f92 100644 --- a/ios-app/app/FavoriteView/FavoriteSearchResultRow.swift +++ b/ios-app/app/FavoriteView/FavoriteSearchResultRow.swift @@ -94,7 +94,7 @@ struct FavoriteSearchResultRow: View { }) { Image(systemName: favorites.locations.contains{ element in return element == location - } ? "heart.fill" : "heart") + } ? "heart.fill" : "heart").foregroundColor(Color.red) .font(Font.system(size: 25)) } -- 2.56.1 From b85d48c5799d89a0e07ed2bf454b292b62dac312 Mon Sep 17 00:00:00 2001 From: stottrop Date: Wed, 15 Jan 2020 15:53:19 +0100 Subject: [PATCH 11/12] views should now be updated correctly when changing favoritlocations.locations --- ios-app/app.xcodeproj/project.pbxproj | 16 ++++++++-------- ios-app/app/Data/FavoriteLocations.swift | 10 ++++++---- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/ios-app/app.xcodeproj/project.pbxproj b/ios-app/app.xcodeproj/project.pbxproj index 88fce62d..6f42ae6d 100644 --- a/ios-app/app.xcodeproj/project.pbxproj +++ b/ios-app/app.xcodeproj/project.pbxproj @@ -686,14 +686,14 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_ASSET_PATHS = "\"app/Preview Content\""; - DEVELOPMENT_TEAM = 55AG82ZF5A; + DEVELOPMENT_TEAM = 2KS4Z77UGE; ENABLE_PREVIEWS = YES; INFOPLIST_FILE = app/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.mowesta.appx; + PRODUCT_BUNDLE_IDENTIFIER = com.mowesta.app; PRODUCT_NAME = MoWeSta; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 5.0; @@ -708,14 +708,14 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_ASSET_PATHS = "\"app/Preview Content\""; - DEVELOPMENT_TEAM = 55AG82ZF5A; + DEVELOPMENT_TEAM = 2KS4Z77UGE; ENABLE_PREVIEWS = YES; INFOPLIST_FILE = app/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.mowesta.appx; + PRODUCT_BUNDLE_IDENTIFIER = com.mowesta.app; PRODUCT_NAME = MoWeSta; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 5.0; @@ -729,7 +729,7 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = 55AG82ZF5A; + DEVELOPMENT_TEAM = 2KS4Z77UGE; INFOPLIST_FILE = appTests/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.2; LD_RUNPATH_SEARCH_PATHS = ( @@ -751,7 +751,7 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = 55AG82ZF5A; + DEVELOPMENT_TEAM = 2KS4Z77UGE; INFOPLIST_FILE = appTests/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.2; LD_RUNPATH_SEARCH_PATHS = ( @@ -773,7 +773,7 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = 55AG82ZF5A; + DEVELOPMENT_TEAM = 2KS4Z77UGE; INFOPLIST_FILE = appUITests/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -795,7 +795,7 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = 55AG82ZF5A; + DEVELOPMENT_TEAM = 2KS4Z77UGE; INFOPLIST_FILE = appUITests/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", diff --git a/ios-app/app/Data/FavoriteLocations.swift b/ios-app/app/Data/FavoriteLocations.swift index 96105c3d..9e453e33 100644 --- a/ios-app/app/Data/FavoriteLocations.swift +++ b/ios-app/app/Data/FavoriteLocations.swift @@ -9,13 +9,16 @@ import Foundation import MowestaApi import SwiftUI -import Combine class FavoriteLocations : ObservableObject { //The PassthroughSubject provides a convenient way to adapt existing imperative code to the Combine model. - var objectWillChange = PassthroughSubject() + // var objectWillChange = PassthroughSubject() - @Published var locations = [LocationHierarchy]() + @Published var locations = [LocationHierarchy]() { + willSet { + objectWillChange.send() + } + } @Published var currentWeathers = [Int64 : CurrentWeatherData]() @Published var weatherForecasts = [Int64 : WeatherForecast]() @@ -38,7 +41,6 @@ class FavoriteLocations : ObservableObject { locations.remove(at: pos) } - func addWeatherForecast(weatherforecast: WeatherForecast?, error: Error?) { if (error != nil) { //maybe handle -- 2.56.1 From 06080ab902ed1fa65361a58f619f17f8823476ad Mon Sep 17 00:00:00 2001 From: stottrop Date: Wed, 15 Jan 2020 17:06:30 +0100 Subject: [PATCH 12/12] updated to master --- ios-app/app/FavoriteView/FavoriteSearchResults.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios-app/app/FavoriteView/FavoriteSearchResults.swift b/ios-app/app/FavoriteView/FavoriteSearchResults.swift index 78230114..f7ca7dfb 100644 --- a/ios-app/app/FavoriteView/FavoriteSearchResults.swift +++ b/ios-app/app/FavoriteView/FavoriteSearchResults.swift @@ -18,7 +18,7 @@ struct FavoriteSearchResults: View { var body: some View { if (self.searchProgress) { Spacer() - ActivityIndicator(isAnimating: .constant(true), style: .large) + ActivityIndicator(style: .large) Spacer() } else { List(self.locations, id: \._id) { location in -- 2.56.1