diff --git a/ios-app/app.xcodeproj/project.pbxproj b/ios-app/app.xcodeproj/project.pbxproj index 511c00ae..74dec921 100644 --- a/ios-app/app.xcodeproj/project.pbxproj +++ b/ios-app/app.xcodeproj/project.pbxproj @@ -10,7 +10,7 @@ 2C2CA271237304E200529274 /* MowestaApi in Frameworks */ = {isa = PBXBuildFile; productRef = 2C2CA270237304E200529274 /* MowestaApi */; }; 2C7846D52372F44300766694 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C7846D42372F44300766694 /* AppDelegate.swift */; }; 2C7846D72372F44300766694 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C7846D62372F44300766694 /* SceneDelegate.swift */; }; - 2C7846D92372F44300766694 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C7846D82372F44300766694 /* ContentView.swift */; }; + 2C7846D92372F44300766694 /* MainTabView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C7846D82372F44300766694 /* MainTabView.swift */; }; 2C7846DB2372F44400766694 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2C7846DA2372F44400766694 /* Assets.xcassets */; }; 2C7846DE2372F44400766694 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2C7846DD2372F44400766694 /* Preview Assets.xcassets */; }; 2C7846E12372F44400766694 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2C7846DF2372F44400766694 /* LaunchScreen.storyboard */; }; @@ -58,8 +58,8 @@ 9E86187E23D2254F00957CBE /* ActivityIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E86187D23D2254F00957CBE /* ActivityIndicator.swift */; }; 9E8C8C4E23C1FB0500FF8E6D /* LocationsExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E8C8C4D23C1FB0500FF8E6D /* LocationsExtensions.swift */; }; 9E9F89F123D85DB10014CE69 /* WeatherStationDetailsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E9F89F023D85DB10014CE69 /* WeatherStationDetailsView.swift */; }; - 9E9F89F623D86B3A0014CE69 /* DateExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E9F89F523D86B3A0014CE69 /* DateExtensions.swift */; }; - 9E9F89FA23D899060014CE69 /* StringExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E9F89F923D899060014CE69 /* StringExtensions.swift */; }; + 9E9F89F623D86B3A0014CE69 /* Date+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E9F89F523D86B3A0014CE69 /* Date+Extensions.swift */; }; + 9E9F89FA23D899060014CE69 /* String+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E9F89F923D899060014CE69 /* String+Extensions.swift */; }; 9E9F89FC23D899390014CE69 /* KeychainKeys.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E9F89FB23D899390014CE69 /* KeychainKeys.swift */; }; 9E9F8A0D23D8AEA30014CE69 /* Day.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E9F8A0C23D8AEA30014CE69 /* Day.swift */; }; 9EA0816D240D595C007C53F5 /* OSLogExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EA0816C240D595C007C53F5 /* OSLogExtension.swift */; }; @@ -69,7 +69,7 @@ 9EA8C18C23D1FFB200E54919 /* LoginService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EA8C18B23D1FFB200E54919 /* LoginService.swift */; }; 9EAEFDF023E59C7D002B6DE1 /* DataManager+DeviceExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EAEFDEF23E59C7D002B6DE1 /* DataManager+DeviceExtension.swift */; }; 9EB08D7C23DA4128004AFE51 /* OwnDeviceDetailsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EB08D7B23DA4128004AFE51 /* OwnDeviceDetailsView.swift */; }; - 9EB08D8423DC56A6004AFE51 /* DeviceOsExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EB08D8323DC56A6004AFE51 /* DeviceOsExtension.swift */; }; + 9EB08D8423DC56A6004AFE51 /* DeviceOs+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EB08D8323DC56A6004AFE51 /* DeviceOs+Extension.swift */; }; 9EB08D8A23DC7A20004AFE51 /* AccountView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EB08D8923DC7A20004AFE51 /* AccountView.swift */; }; 9EB7823923EEC50900757709 /* CoordinateExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EB7823823EEC50900757709 /* CoordinateExtension.swift */; }; 9EB7823B23EEC67B00757709 /* CityExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EB7823A23EEC67B00757709 /* CityExtension.swift */; }; @@ -86,11 +86,11 @@ 9EBA34EB23CD1A260013E2AB /* Card.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EBA34EA23CD1A260013E2AB /* Card.swift */; }; 9EBBE38F23E5A7D40025AB37 /* CDevice+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EBBE38D23E5A7D40025AB37 /* CDevice+CoreDataClass.swift */; }; 9EBBE39023E5A7D40025AB37 /* CDevice+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EBBE38E23E5A7D40025AB37 /* CDevice+CoreDataProperties.swift */; }; - 9ED3243223DF045D00ABBEB7 /* UIDeviceExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9ED3243123DF045D00ABBEB7 /* UIDeviceExtensions.swift */; }; + 9ED3243023DF03D500ABBEB7 /* Coordinate+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9ED3242F23DF03D500ABBEB7 /* Coordinate+Extensions.swift */; }; + 9ED3243223DF045D00ABBEB7 /* UIDevice+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9ED3243123DF045D00ABBEB7 /* UIDevice+Extensions.swift */; }; 9EE4770C23C36363003BA29C /* SearchResults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EE4770B23C36363003BA29C /* SearchResults.swift */; }; - 9EE4770E23C363F6003BA29C /* ViewExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EE4770D23C363F6003BA29C /* ViewExtensions.swift */; }; + 9EE4770E23C363F6003BA29C /* View+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EE4770D23C363F6003BA29C /* View+Extensions.swift */; }; 9EE4771423C37158003BA29C /* SearchResultRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EE4771323C37158003BA29C /* SearchResultRow.swift */; }; - 9EE4771A23C3C77F003BA29C /* FavoriteLocations.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EE4771923C3C77F003BA29C /* FavoriteLocations.swift */; }; 9EE67EDF23E23C6600D99940 /* CDCoordinate+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EE67EDD23E23C6600D99940 /* CDCoordinate+CoreDataClass.swift */; }; 9EEAF94D23C1F3DC000AAB49 /* SearchTab.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EEAF94B23C1F3DC000AAB49 /* SearchTab.swift */; }; 9EEAF94E23C1F3DC000AAB49 /* SearchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EEAF94C23C1F3DC000AAB49 /* SearchBar.swift */; }; @@ -110,9 +110,33 @@ BC1A86B723CBB755005DE4F5 /* LocationHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC1A86B623CBB755005DE4F5 /* LocationHeaderView.swift */; }; BC241EC323CB8B0600F4C0CC /* FavoriteCity.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC241EC223CB8B0600F4C0CC /* FavoriteCity.swift */; }; BC26444123CB835300330645 /* WeatherConditionExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC26444023CB835300330645 /* WeatherConditionExtension.swift */; }; + BC2A355E240DD018004710DD /* LocationServiceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC2A355D240DD018004710DD /* LocationServiceView.swift */; }; + BC33403F23E8C3F40076663E /* SwiftUICharts in Frameworks */ = {isa = PBXBuildFile; productRef = BC33403E23E8C3F40076663E /* SwiftUICharts */; }; + BC3BFA8023FAF0B400686E49 /* CDWeatherCondition+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC3BFA7E23FAF0B400686E49 /* CDWeatherCondition+CoreDataClass.swift */; }; + BC3BFA8123FAF0B400686E49 /* CDWeatherCondition+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC3BFA7F23FAF0B400686E49 /* CDWeatherCondition+CoreDataProperties.swift */; }; + BC3C82BF2411032900C038E3 /* FavoriteListEmptyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC3C82BE2411032900C038E3 /* FavoriteListEmptyView.swift */; }; + BC4281C423FBE94200B8B318 /* WeatherForecast+BackgroundService.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC4281C323FBE94200B8B318 /* WeatherForecast+BackgroundService.swift */; }; + BC4281C623FBF3DD00B8B318 /* DataManager+CDLocationExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC4281C523FBF3DD00B8B318 /* DataManager+CDLocationExtension.swift */; }; + BC4281C823FBF55F00B8B318 /* DataManager+CDWeatherforecastExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC4281C723FBF55F00B8B318 /* DataManager+CDWeatherforecastExtension.swift */; }; + BC4281CA23FD40AE00B8B318 /* WeatherMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC4281C923FD40AE00B8B318 /* WeatherMock.swift */; }; + BC48919023E36D0F00D7D962 /* Double+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC48918F23E36D0F00D7D962 /* Double+Extension.swift */; }; + BC48919223E3720D00D7D962 /* City+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC48919123E3720D00D7D962 /* City+Extension.swift */; }; + BC4BF34A240D2AFD00792A3E /* TermsOfServiceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC4BF349240D2AFD00792A3E /* TermsOfServiceView.swift */; }; + BC4BF34C240D824700792A3E /* AppRootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC4BF34B240D824700792A3E /* AppRootView.swift */; }; + BC4D856A23E2FB9400FA61A9 /* LocationMapView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC4D856923E2FB9400FA61A9 /* LocationMapView.swift */; }; + BC4D856C23E31AD800FA61A9 /* CityCurrentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC4D856B23E31AD800FA61A9 /* CityCurrentView.swift */; }; BC71C16F23D9B7B800BBA56E /* NewFavoriteLocations.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC71C16E23D9B7B800BBA56E /* NewFavoriteLocations.swift */; }; BC90508023DB315500414C73 /* Mowesta.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = BC90507E23DB315500414C73 /* Mowesta.xcdatamodeld */; }; BC90508223DB451D00414C73 /* FavoriteListItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC90508123DB451D00414C73 /* FavoriteListItemView.swift */; }; + BC95FD33240FCEB400162423 /* BackgroundServiceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC95FD32240FCEB400162423 /* BackgroundServiceView.swift */; }; + BC95FD35240FD8DB00162423 /* NavigationStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC95FD34240FD8DB00162423 /* NavigationStack.swift */; }; + BC95FD37240FD92F00162423 /* AuthState.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC95FD36240FD92F00162423 /* AuthState.swift */; }; + BC95FD39240FDF6A00162423 /* DailyPrediction.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC95FD38240FDF6A00162423 /* DailyPrediction.swift */; }; + BC9AAB0D240DA67000026E87 /* RegistrationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC9AAB0C240DA67000026E87 /* RegistrationView.swift */; }; + BC9AAB0F240DAA1D00026E87 /* TermsRootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC9AAB0E240DAA1D00026E87 /* TermsRootView.swift */; }; + BC9AAB11240DBC7C00026E87 /* LoginView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC9AAB10240DBC7C00026E87 /* LoginView.swift */; }; + BCD031C423FADAEF00A53C98 /* CDWeatherForecast+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCD031C223FADAEF00A53C98 /* CDWeatherForecast+CoreDataClass.swift */; }; + BCD031C523FADAEF00A53C98 /* CDWeatherForecast+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = BCD031C323FADAEF00A53C98 /* CDWeatherForecast+CoreDataProperties.swift */; }; 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 */; }; @@ -139,7 +163,7 @@ 2C7846D12372F44300766694 /* MoWeSta.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MoWeSta.app; sourceTree = BUILT_PRODUCTS_DIR; }; 2C7846D42372F44300766694 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 2C7846D62372F44300766694 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; - 2C7846D82372F44300766694 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; + 2C7846D82372F44300766694 /* MainTabView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainTabView.swift; sourceTree = ""; }; 2C7846DA2372F44400766694 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 2C7846DD2372F44400766694 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 2C7846E22372F44400766694 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -193,8 +217,8 @@ 9E86187D23D2254F00957CBE /* ActivityIndicator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivityIndicator.swift; sourceTree = ""; }; 9E8C8C4D23C1FB0500FF8E6D /* LocationsExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationsExtensions.swift; sourceTree = ""; }; 9E9F89F023D85DB10014CE69 /* WeatherStationDetailsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherStationDetailsView.swift; sourceTree = ""; }; - 9E9F89F523D86B3A0014CE69 /* DateExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateExtensions.swift; sourceTree = ""; }; - 9E9F89F923D899060014CE69 /* StringExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringExtensions.swift; sourceTree = ""; }; + 9E9F89F523D86B3A0014CE69 /* Date+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Date+Extensions.swift"; sourceTree = ""; }; + 9E9F89F923D899060014CE69 /* String+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Extensions.swift"; sourceTree = ""; }; 9E9F89FB23D899390014CE69 /* KeychainKeys.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeychainKeys.swift; sourceTree = ""; }; 9E9F8A0C23D8AEA30014CE69 /* Day.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Day.swift; sourceTree = ""; }; 9EA0816C240D595C007C53F5 /* OSLogExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSLogExtension.swift; sourceTree = ""; }; @@ -204,7 +228,7 @@ 9EA8C18B23D1FFB200E54919 /* LoginService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginService.swift; sourceTree = ""; }; 9EAEFDEF23E59C7D002B6DE1 /* DataManager+DeviceExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DataManager+DeviceExtension.swift"; sourceTree = ""; }; 9EB08D7B23DA4128004AFE51 /* OwnDeviceDetailsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OwnDeviceDetailsView.swift; sourceTree = ""; }; - 9EB08D8323DC56A6004AFE51 /* DeviceOsExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceOsExtension.swift; sourceTree = ""; }; + 9EB08D8323DC56A6004AFE51 /* DeviceOs+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DeviceOs+Extension.swift"; sourceTree = ""; }; 9EB08D8923DC7A20004AFE51 /* AccountView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccountView.swift; sourceTree = ""; }; 9EB7823823EEC50900757709 /* CoordinateExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoordinateExtension.swift; sourceTree = ""; }; 9EB7823A23EEC67B00757709 /* CityExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CityExtension.swift; sourceTree = ""; }; @@ -221,11 +245,11 @@ 9EBA34EA23CD1A260013E2AB /* Card.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Card.swift; sourceTree = ""; }; 9EBBE38D23E5A7D40025AB37 /* CDevice+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CDevice+CoreDataClass.swift"; sourceTree = SOURCE_ROOT; }; 9EBBE38E23E5A7D40025AB37 /* CDevice+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CDevice+CoreDataProperties.swift"; sourceTree = SOURCE_ROOT; }; - 9ED3243123DF045D00ABBEB7 /* UIDeviceExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIDeviceExtensions.swift; sourceTree = ""; }; + 9ED3242F23DF03D500ABBEB7 /* Coordinate+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Coordinate+Extensions.swift"; sourceTree = ""; }; + 9ED3243123DF045D00ABBEB7 /* UIDevice+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIDevice+Extensions.swift"; sourceTree = ""; }; 9EE4770B23C36363003BA29C /* SearchResults.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchResults.swift; sourceTree = ""; }; - 9EE4770D23C363F6003BA29C /* ViewExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewExtensions.swift; sourceTree = ""; }; + 9EE4770D23C363F6003BA29C /* View+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View+Extensions.swift"; sourceTree = ""; }; 9EE4771323C37158003BA29C /* SearchResultRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchResultRow.swift; sourceTree = ""; }; - 9EE4771923C3C77F003BA29C /* FavoriteLocations.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoriteLocations.swift; sourceTree = ""; }; 9EE67EDD23E23C6600D99940 /* CDCoordinate+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CDCoordinate+CoreDataClass.swift"; sourceTree = ""; }; 9EEAF94B23C1F3DC000AAB49 /* SearchTab.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchTab.swift; sourceTree = ""; }; 9EEAF94C23C1F3DC000AAB49 /* SearchBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchBar.swift; sourceTree = ""; }; @@ -245,9 +269,32 @@ 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 /* WeatherConditionExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherConditionExtension.swift; sourceTree = ""; }; + BC2A355D240DD018004710DD /* LocationServiceView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationServiceView.swift; sourceTree = ""; }; + BC3BFA7E23FAF0B400686E49 /* CDWeatherCondition+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CDWeatherCondition+CoreDataClass.swift"; sourceTree = ""; }; + BC3BFA7F23FAF0B400686E49 /* CDWeatherCondition+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CDWeatherCondition+CoreDataProperties.swift"; sourceTree = ""; }; + BC3C82BE2411032900C038E3 /* FavoriteListEmptyView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoriteListEmptyView.swift; sourceTree = ""; }; + BC4281C323FBE94200B8B318 /* WeatherForecast+BackgroundService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WeatherForecast+BackgroundService.swift"; sourceTree = ""; }; + BC4281C523FBF3DD00B8B318 /* DataManager+CDLocationExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DataManager+CDLocationExtension.swift"; sourceTree = ""; }; + BC4281C723FBF55F00B8B318 /* DataManager+CDWeatherforecastExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DataManager+CDWeatherforecastExtension.swift"; sourceTree = ""; }; + BC4281C923FD40AE00B8B318 /* WeatherMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherMock.swift; sourceTree = ""; }; + BC48918F23E36D0F00D7D962 /* Double+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Double+Extension.swift"; sourceTree = ""; }; + BC48919123E3720D00D7D962 /* City+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "City+Extension.swift"; sourceTree = ""; }; + BC4BF349240D2AFD00792A3E /* TermsOfServiceView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TermsOfServiceView.swift; sourceTree = ""; }; + BC4BF34B240D824700792A3E /* AppRootView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppRootView.swift; sourceTree = ""; }; + BC4D856923E2FB9400FA61A9 /* LocationMapView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationMapView.swift; sourceTree = ""; }; + BC4D856B23E31AD800FA61A9 /* CityCurrentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CityCurrentView.swift; sourceTree = ""; }; BC71C16E23D9B7B800BBA56E /* NewFavoriteLocations.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewFavoriteLocations.swift; sourceTree = ""; }; BC90507F23DB315500414C73 /* Mowesta.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Mowesta.xcdatamodel; sourceTree = ""; }; BC90508123DB451D00414C73 /* FavoriteListItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoriteListItemView.swift; sourceTree = ""; }; + BC95FD32240FCEB400162423 /* BackgroundServiceView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BackgroundServiceView.swift; sourceTree = ""; }; + BC95FD34240FD8DB00162423 /* NavigationStack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationStack.swift; sourceTree = ""; }; + BC95FD36240FD92F00162423 /* AuthState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthState.swift; sourceTree = ""; }; + BC95FD38240FDF6A00162423 /* DailyPrediction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DailyPrediction.swift; sourceTree = ""; }; + BC9AAB0C240DA67000026E87 /* RegistrationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegistrationView.swift; sourceTree = ""; }; + BC9AAB0E240DAA1D00026E87 /* TermsRootView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TermsRootView.swift; sourceTree = ""; }; + BC9AAB10240DBC7C00026E87 /* LoginView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginView.swift; sourceTree = ""; }; + BCD031C223FADAEF00A53C98 /* CDWeatherForecast+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CDWeatherForecast+CoreDataClass.swift"; sourceTree = ""; }; + BCD031C323FADAEF00A53C98 /* CDWeatherForecast+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CDWeatherForecast+CoreDataProperties.swift"; 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 = ""; }; @@ -261,6 +308,7 @@ 9E6D641223CCC2600002CBCF /* Socket in Frameworks */, 9E0D267223AD2E7D00BE14F5 /* AuthenticationServices.framework in Frameworks */, 9E6D640623CC73320002CBCF /* NetworkExtension.framework in Frameworks */, + BC33403F23E8C3F40076663E /* SwiftUICharts in Frameworks */, 9E3BCD3623ACED50002F2D8F /* KeychainSwift in Frameworks */, 2C2CA271237304E200529274 /* MowestaApi in Frameworks */, ); @@ -325,7 +373,8 @@ 9E73B48B23CF733C000FADF3 /* View */, 2C7846D42372F44300766694 /* AppDelegate.swift */, 2C7846D62372F44300766694 /* SceneDelegate.swift */, - 2C7846D82372F44300766694 /* ContentView.swift */, + BC4BF34B240D824700792A3E /* AppRootView.swift */, + 2C7846D82372F44300766694 /* MainTabView.swift */, 2C7846DA2372F44400766694 /* Assets.xcassets */, 2C7846DF2372F44400766694 /* LaunchScreen.storyboard */, 2C7846E22372F44400766694 /* Info.plist */, @@ -371,6 +420,7 @@ 9E0C988723A78341001EA11E /* CurrentWeatherData.swift */, 9E8C8C4D23C1FB0500FF8E6D /* LocationsExtensions.swift */, BC26444023CB835300330645 /* WeatherConditionExtension.swift */, + BC95FD38240FDF6A00162423 /* DailyPrediction.swift */, ); path = Data; sourceTree = ""; @@ -389,6 +439,7 @@ BC11C1C423DF411B008F9E7A /* FavoriteTodayView.swift */, BC11C1C623DF4868008F9E7A /* FavoritesNextDaysView.swift */, BC11C1C823DF776F008F9E7A /* FavoriteNextDaysDayView.swift */, + BC3C82BE2411032900C038E3 /* FavoriteListEmptyView.swift */, ); path = Favorite; sourceTree = ""; @@ -419,7 +470,6 @@ isa = PBXGroup; children = ( 9EA0D16123C911790068F739 /* Mock */, - 9EE4771923C3C77F003BA29C /* FavoriteLocations.swift */, BC71C16E23D9B7B800BBA56E /* NewFavoriteLocations.swift */, ); path = Environment; @@ -428,6 +478,7 @@ 9E73B48B23CF733C000FADF3 /* View */ = { isa = PBXGroup; children = ( + BC4BF348240D2AE400792A3E /* ToS */, 9E73B48D23CF7452000FADF3 /* Custom */, 9E9BD25823A7A6EF008FF0DF /* Account */, 9E3CA3F223A52813003873E8 /* Favorite */, @@ -447,6 +498,8 @@ 9EAEFDF123E59D64002B6DE1 /* DataManager */, 9E73B48E23CF75CA000FADF3 /* Services */, 9E6D641523CCDF900002CBCF /* Error.swift */, + BC95FD34240FD8DB00162423 /* NavigationStack.swift */, + BC95FD36240FD92F00162423 /* AuthState.swift */, 9E9F8A0C23D8AEA30014CE69 /* Day.swift */, ); path = Business; @@ -471,6 +524,7 @@ 9EA6238F23D5B48700BFA8B9 /* LocationService.swift */, 9EA6239123D5C8E900BFA8B9 /* AltimeterService.swift */, 9E6D640223CC730D0002CBCF /* WeatherStationPairingService.swift */, + BC4281C323FBE94200B8B318 /* WeatherForecast+BackgroundService.swift */, ); path = Services; sourceTree = ""; @@ -487,6 +541,8 @@ BC1A86B623CBB755005DE4F5 /* LocationHeaderView.swift */, BCEE928F23CCEDD80029CC73 /* LocationDetailView.swift */, BCEE929123CCF7B60029CC73 /* LocationForecastView.swift */, + BC4D856923E2FB9400FA61A9 /* LocationMapView.swift */, + BC4D856B23E31AD800FA61A9 /* CityCurrentView.swift */, ); path = Location; sourceTree = ""; @@ -534,12 +590,15 @@ 9E9F89F823D898F50014CE69 /* Extensions */ = { isa = PBXGroup; children = ( - 9E9F89F923D899060014CE69 /* StringExtensions.swift */, + 9E9F89F923D899060014CE69 /* String+Extensions.swift */, 9E36A81E23E23ECB00D06184 /* DoubleExtension.swift */, - 9E9F89F523D86B3A0014CE69 /* DateExtensions.swift */, - 9EE4770D23C363F6003BA29C /* ViewExtensions.swift */, - 9EB08D8323DC56A6004AFE51 /* DeviceOsExtension.swift */, - 9ED3243123DF045D00ABBEB7 /* UIDeviceExtensions.swift */, + 9E9F89F523D86B3A0014CE69 /* Date+Extensions.swift */, + 9EE4770D23C363F6003BA29C /* View+Extensions.swift */, + 9EB08D8323DC56A6004AFE51 /* DeviceOs+Extension.swift */, + 9ED3242F23DF03D500ABBEB7 /* Coordinate+Extensions.swift */, + 9ED3243123DF045D00ABBEB7 /* UIDevice+Extensions.swift */, + BC48918F23E36D0F00D7D962 /* Double+Extension.swift */, + BC48919123E3720D00D7D962 /* City+Extension.swift */, 9EB7824C23F0666D00757709 /* MeasurementExtension.swift */, 9EA0816C240D595C007C53F5 /* OSLogExtension.swift */, ); @@ -565,6 +624,7 @@ isa = PBXGroup; children = ( 9EA0D16223C9118C0068F739 /* LocationMock.swift */, + BC4281C923FD40AE00B8B318 /* WeatherMock.swift */, ); path = Mock; sourceTree = ""; @@ -575,6 +635,8 @@ 9E799CC323E2337E00062A6D /* DataManager.swift */, 9EAEFDEF23E59C7D002B6DE1 /* DataManager+DeviceExtension.swift */, 9E2438F023E6E04E00FD5E5C /* DataManager+MeasurementExtension.swift */, + BC4281C523FBF3DD00B8B318 /* DataManager+CDLocationExtension.swift */, + BC4281C723FBF55F00B8B318 /* DataManager+CDWeatherforecastExtension.swift */, 9EB7824A23F0623A00757709 /* DataManager+PlacemarkLocationExtension.swift */, ); path = DataManager; @@ -594,6 +656,10 @@ BC11C1BB23DF0862008F9E7A /* CoreData */ = { isa = PBXGroup; children = ( + BC3BFA7E23FAF0B400686E49 /* CDWeatherCondition+CoreDataClass.swift */, + BC3BFA7F23FAF0B400686E49 /* CDWeatherCondition+CoreDataProperties.swift */, + BCD031C223FADAEF00A53C98 /* CDWeatherForecast+CoreDataClass.swift */, + BCD031C323FADAEF00A53C98 /* CDWeatherForecast+CoreDataProperties.swift */, 9EBBE38D23E5A7D40025AB37 /* CDevice+CoreDataClass.swift */, 9EBBE38E23E5A7D40025AB37 /* CDevice+CoreDataProperties.swift */, 9EE67EDD23E23C6600D99940 /* CDCoordinate+CoreDataClass.swift */, @@ -611,6 +677,19 @@ path = CoreData; sourceTree = ""; }; + BC4BF348240D2AE400792A3E /* ToS */ = { + isa = PBXGroup; + children = ( + BC4BF349240D2AFD00792A3E /* TermsOfServiceView.swift */, + BC9AAB0C240DA67000026E87 /* RegistrationView.swift */, + BC9AAB0E240DAA1D00026E87 /* TermsRootView.swift */, + BC9AAB10240DBC7C00026E87 /* LoginView.swift */, + BC2A355D240DD018004710DD /* LocationServiceView.swift */, + BC95FD32240FCEB400162423 /* BackgroundServiceView.swift */, + ); + path = ToS; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -632,6 +711,7 @@ 2C2CA270237304E200529274 /* MowestaApi */, 9E3BCD3523ACED50002F2D8F /* KeychainSwift */, 9E6D641123CCC2600002CBCF /* Socket */, + BC33403E23E8C3F40076663E /* SwiftUICharts */, ); productName = app; productReference = 2C7846D12372F44300766694 /* MoWeSta.app */; @@ -709,6 +789,7 @@ packageReferences = ( 9E3BCD3423ACED50002F2D8F /* XCRemoteSwiftPackageReference "keychain-swift" */, 9E6D641023CCC2600002CBCF /* XCRemoteSwiftPackageReference "BlueSocket" */, + BC33403D23E8C3F40076663E /* XCRemoteSwiftPackageReference "ChartView" */, ); productRefGroup = 2C7846D22372F44300766694 /* Products */; projectDirPath = ""; @@ -755,6 +836,9 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + BC2A355E240DD018004710DD /* LocationServiceView.swift in Sources */, + BC48919223E3720D00D7D962 /* City+Extension.swift in Sources */, + BC4281CA23FD40AE00B8B318 /* WeatherMock.swift in Sources */, BC1A86B723CBB755005DE4F5 /* LocationHeaderView.swift in Sources */, BC11C1B923DF07FC008F9E7A /* CDLocation+CoreDataClass.swift in Sources */, 9E2438E723E5B95700FD5E5C /* MeasurementAll.swift in Sources */, @@ -765,6 +849,8 @@ BCEE929023CCEDD80029CC73 /* LocationDetailView.swift in Sources */, 9E6D640D23CC798F0002CBCF /* WeatherStationPairRow.swift in Sources */, 9EE4770C23C36363003BA29C /* SearchResults.swift in Sources */, + BC3BFA8123FAF0B400686E49 /* CDWeatherCondition+CoreDataProperties.swift in Sources */, + BC4D856A23E2FB9400FA61A9 /* LocationMapView.swift in Sources */, 2C7846D52372F44300766694 /* AppDelegate.swift in Sources */, 9EB7823F23EEC7FB00757709 /* CountryExtension.swift in Sources */, 9E6D640F23CC7BBD0002CBCF /* Register.swift in Sources */, @@ -775,17 +861,23 @@ 9E6D640B23CC77800002CBCF /* AboutMe.swift in Sources */, 9EA8C18C23D1FFB200E54919 /* LoginService.swift in Sources */, BC11C1C923DF776F008F9E7A /* FavoriteNextDaysDayView.swift in Sources */, + BC48919023E36D0F00D7D962 /* Double+Extension.swift in Sources */, 9EB7823923EEC50900757709 /* CoordinateExtension.swift in Sources */, 9E81DC9223A7DECE00568CF4 /* UserData.swift in Sources */, 9EE67EDF23E23C6600D99940 /* CDCoordinate+CoreDataClass.swift in Sources */, 9EB7824B23F0623A00757709 /* DataManager+PlacemarkLocationExtension.swift in Sources */, BC04DC0B23CB3BE7006D0767 /* FavoriteSearch.swift in Sources */, 9EEAF94D23C1F3DC000AAB49 /* SearchTab.swift in Sources */, + BC4D856C23E31AD800FA61A9 /* CityCurrentView.swift in Sources */, + 9E9F89F123D85DB10014CE69 /* WeatherStationDetailsView.swift in Sources */, + BC4BF34C240D824700792A3E /* AppRootView.swift in Sources */, 9E9F89F123D85DB10014CE69 /* WeatherStationDetailsView.swift in Sources */, 9E2438E823E5B95700FD5E5C /* MeasurementDay.swift in Sources */, - 9E9F89FA23D899060014CE69 /* StringExtensions.swift in Sources */, + 9E9F89FA23D899060014CE69 /* String+Extensions.swift in Sources */, 9E2438EB23E5B95700FD5E5C /* MeasurementDetailDevice.swift in Sources */, + BC95FD35240FD8DB00162423 /* NavigationStack.swift in Sources */, BC241EC323CB8B0600F4C0CC /* FavoriteCity.swift in Sources */, + BC95FD37240FD92F00162423 /* AuthState.swift in Sources */, 9E86187E23D2254F00957CBE /* ActivityIndicator.swift in Sources */, BC11C1C123DF2F79008F9E7A /* FavoriteDetail.swift in Sources */, 9EB7824523EEEADC00757709 /* MeasurementDetailCalculated.swift in Sources */, @@ -802,6 +894,8 @@ 9EB7824F23F0676B00757709 /* MeasurementService.swift in Sources */, BC11C1C323DF3851008F9E7A /* FavoriteHeaderView.swift in Sources */, 9EFDEF9A23C215A9006EB4B4 /* AlertFactory.swift in Sources */, + BCD031C523FADAEF00A53C98 /* CDWeatherForecast+CoreDataProperties.swift in Sources */, + BC9AAB11240DBC7C00026E87 /* LoginView.swift in Sources */, 9E2438EF23E5B9CE00FD5E5C /* CDMeasurement+CoreDataProperties.swift in Sources */, BC11C1BF23DF0ABD008F9E7A /* CDNamesDictionary+CoreDataProperties.swift in Sources */, 9EB7824323EED68100757709 /* CDDataDictionary+CoreDataProperties.swift in Sources */, @@ -809,7 +903,8 @@ 9EEAF94E23C1F3DC000AAB49 /* SearchBar.swift in Sources */, 9EB7824923F05DE000757709 /* CDPlacemarkLocation+CoreDataProperties.swift in Sources */, 9E6D641423CCD2080002CBCF /* WeatherStationPairView.swift in Sources */, - 9EE4770E23C363F6003BA29C /* ViewExtensions.swift in Sources */, + BC9AAB0D240DA67000026E87 /* RegistrationView.swift in Sources */, + 9EE4770E23C363F6003BA29C /* View+Extensions.swift in Sources */, 9E2438EA23E5B95700FD5E5C /* MeasurementDetails.swift in Sources */, 9E78A74A23C91B3D00D8A27D /* StateDetail.swift in Sources */, 9E2438E923E5B95700FD5E5C /* MeasurementDetailRow.swift in Sources */, @@ -817,33 +912,43 @@ 9EAEFDF023E59C7D002B6DE1 /* DataManager+DeviceExtension.swift in Sources */, 9E8334A423AD003E00B191A3 /* Login.swift in Sources */, BCEE929223CCF7B60029CC73 /* LocationForecastView.swift in Sources */, - 9EE4771A23C3C77F003BA29C /* FavoriteLocations.swift in Sources */, + BC95FD33240FCEB400162423 /* BackgroundServiceView.swift in Sources */, BC11C1BA23DF07FC008F9E7A /* CDLocation+CoreDataProperties.swift in Sources */, 9E2438F123E6E04E00FD5E5C /* DataManager+MeasurementExtension.swift in Sources */, - 2C7846D92372F44300766694 /* ContentView.swift in Sources */, + 2C7846D92372F44300766694 /* MainTabView.swift in Sources */, 9E2438EE23E5B9CE00FD5E5C /* CDMeasurement+CoreDataClass.swift in Sources */, 9E3CA3F423A52ABF003873E8 /* FavoriteList.swift in Sources */, + BC4281C823FBF55F00B8B318 /* DataManager+CDWeatherforecastExtension.swift in Sources */, 9EB08D8A23DC7A20004AFE51 /* AccountView.swift in Sources */, 9E6D641623CCDF900002CBCF /* Error.swift in Sources */, + BC95FD39240FDF6A00162423 /* DailyPrediction.swift in Sources */, 9E6D640323CC730D0002CBCF /* WeatherStationPairingService.swift in Sources */, + BC4BF34A240D2AFD00792A3E /* TermsOfServiceView.swift in Sources */, + 9ED3243023DF03D500ABBEB7 /* Coordinate+Extensions.swift in Sources */, 9EA0816D240D595C007C53F5 /* OSLogExtension.swift in Sources */, 9E3CA3F123A5278E003873E8 /* FavoriteRow.swift in Sources */, BC11C1C523DF411B008F9E7A /* FavoriteTodayView.swift in Sources */, + BC3BFA8023FAF0B400686E49 /* CDWeatherCondition+CoreDataClass.swift in Sources */, BC11C1C723DF4868008F9E7A /* FavoritesNextDaysView.swift in Sources */, + BC4281C423FBE94200B8B318 /* WeatherForecast+BackgroundService.swift in Sources */, + BCD031C423FADAEF00A53C98 /* CDWeatherForecast+CoreDataClass.swift in Sources */, + BC9AAB0F240DAA1D00026E87 /* TermsRootView.swift in Sources */, BC90508023DB315500414C73 /* Mowesta.xcdatamodeld in Sources */, 9E78A74823C918C600D8A27D /* CityDetail.swift in Sources */, 9E9F89FC23D899390014CE69 /* KeychainKeys.swift in Sources */, - 9EB08D8423DC56A6004AFE51 /* DeviceOsExtension.swift in Sources */, + 9EB08D8423DC56A6004AFE51 /* DeviceOs+Extension.swift in Sources */, 9E2438E523E5B95700FD5E5C /* MeasurementDetailValues.swift in Sources */, BC04DC0D23CB4104006D0767 /* FavoriteSearchResultRow.swift in Sources */, + BC4281C623FBF3DD00B8B318 /* DataManager+CDLocationExtension.swift in Sources */, 9E78A74623C916CF00D8A27D /* LocationDetail.swift in Sources */, 9EBBE39023E5A7D40025AB37 /* CDevice+CoreDataProperties.swift in Sources */, 9E9F8A0D23D8AEA30014CE69 /* Day.swift in Sources */, 9E0C988823A78341001EA11E /* CurrentWeatherData.swift in Sources */, - 9ED3243223DF045D00ABBEB7 /* UIDeviceExtensions.swift in Sources */, + 9ED3243223DF045D00ABBEB7 /* UIDevice+Extensions.swift in Sources */, + BC3C82BF2411032900C038E3 /* FavoriteListEmptyView.swift in Sources */, 9E799CC423E2337E00062A6D /* DataManager.swift in Sources */, 9E86187423D21CD900957CBE /* WeatherStationDetailsRow.swift in Sources */, - 9E9F89F623D86B3A0014CE69 /* DateExtensions.swift in Sources */, + 9E9F89F623D86B3A0014CE69 /* Date+Extensions.swift in Sources */, 9EB7823D23EEC7BB00757709 /* StateExtension.swift in Sources */, 9E2438E623E5B95700FD5E5C /* MeasurementDetailContext.swift in Sources */, 9EBA34EB23CD1A260013E2AB /* Card.swift in Sources */, @@ -1225,6 +1330,14 @@ minimumVersion = 1.0.52; }; }; + BC33403D23E8C3F40076663E /* XCRemoteSwiftPackageReference "ChartView" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/AppPear/ChartView"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 1.4.7; + }; + }; /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ @@ -1246,6 +1359,11 @@ package = 9E6D641023CCC2600002CBCF /* XCRemoteSwiftPackageReference "BlueSocket" */; productName = Socket; }; + BC33403E23E8C3F40076663E /* SwiftUICharts */ = { + isa = XCSwiftPackageProductDependency; + package = BC33403D23E8C3F40076663E /* XCRemoteSwiftPackageReference "ChartView" */; + productName = SwiftUICharts; + }; /* End XCSwiftPackageProductDependency section */ /* Begin XCVersionGroup section */ diff --git a/ios-app/app/AppDelegate.swift b/ios-app/app/AppDelegate.swift index aa3849ed..a61b2977 100644 --- a/ios-app/app/AppDelegate.swift +++ b/ios-app/app/AppDelegate.swift @@ -15,8 +15,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. NSLog("didLaunchApplication") - LocationService.shared.askUser() BackgroundService.shared.registerMeasurementService() + WeatherForecastService.shared.registerWeatherforecastBackgroundService() + let userDefaults = UserDefaults.standard if !userDefaults.bool(forKey: KeychainKeys.hasRunBefore) { UserData.shared.reset() @@ -28,14 +29,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate { //print(urls[urls.count-1] as URL) return true } - + func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { // Called when a new scene session is being created. // Use this method to select a configuration to create the new scene with. NSLog("new scene session created"); return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) } - + func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { // Called when the user discards a scene session. // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. @@ -44,7 +45,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { } func applicationDidEnterBackground(_ application: UIApplication) { - + WeatherForecastService.shared.scheduleWeatherforecastBackgroundService() } // MARK: - Core Data stack @@ -62,7 +63,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { if let error = error as NSError? { // Replace this implementation with code to handle the error appropriately. // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. - + /* Typical reasons for an error here include: * The parent directory does not exist, cannot be created, or disallows writing. @@ -76,9 +77,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate { }) return container }() - + // MARK: - Core Data Saving support - + func saveContext () { let context = persistentContainer.viewContext if context.hasChanges { diff --git a/ios-app/app/AppRootView.swift b/ios-app/app/AppRootView.swift new file mode 100644 index 00000000..6ce45458 --- /dev/null +++ b/ios-app/app/AppRootView.swift @@ -0,0 +1,29 @@ +// +// AppRootView.swift +// app +// +// Created by Tobias Stottrop on 02.03.20. +// Copyright © 2020 Marcus Handte. All rights reserved. +// + +import SwiftUI + +struct AppRootView: View { + @EnvironmentObject var user: UserData + + var body: some View { + return Group { + if (user.agreedToS) { + MainTabView() + } else { + TermsRootView() + } + } + } +} + +struct AppRootView_Previews: PreviewProvider { + static var previews: some View { + AppRootView() + } +} diff --git a/ios-app/app/Business/AuthState.swift b/ios-app/app/Business/AuthState.swift new file mode 100644 index 00000000..07f97f52 --- /dev/null +++ b/ios-app/app/Business/AuthState.swift @@ -0,0 +1,18 @@ +// +// AuthState.swift +// app +// +// Created by Tobias Stottrop on 04.03.20. +// Copyright © 2020 Marcus Handte. All rights reserved. +// + +import Foundation + +enum AuthState { + case ToSScreen + case LoginScreen + case RegistrationScreen + case LocationScreen + case BackgroundScreen + case Finished +} diff --git a/ios-app/app/Business/Credentials/KeychainKeys.swift b/ios-app/app/Business/Credentials/KeychainKeys.swift index 48ed2a5d..9e350420 100644 --- a/ios-app/app/Business/Credentials/KeychainKeys.swift +++ b/ios-app/app/Business/Credentials/KeychainKeys.swift @@ -22,5 +22,6 @@ struct KeychainKeys { static let humanName: String = "MoWeSta.user.humanName" static let password: String = "MoWeSta.user.password" static let loggedIn: String = "MoWeSta.user.loggedIn" + static let agreedToS: String = "Nowesta.user.agreedToS" } } diff --git a/ios-app/app/Business/Credentials/UserData.swift b/ios-app/app/Business/Credentials/UserData.swift index 3213925c..3c77255f 100644 --- a/ios-app/app/Business/Credentials/UserData.swift +++ b/ios-app/app/Business/Credentials/UserData.swift @@ -25,15 +25,17 @@ class UserData: ObservableObject { @Published var humanName: String? = nil @Published var password: String = "" @Published var loggedIn: Bool = false + @Published var agreedToS: Bool = false var filledIn : Bool { get { return loginName != "" && password != "" } } let keyChain = KeychainSwift() - private init(loginName: String? = nil, password: String? = nil, humanName: String? = nil, loggedIn: Bool? = nil) { + private init(loginName: String? = nil, password: String? = nil, humanName: String? = nil, loggedIn: Bool? = nil, agreedToS: Bool? = nil) { self.loginName = loginName ?? keyChain.get(KeychainKeys.user.loginName) ?? self.loginName self.humanName = humanName ?? keyChain.get(KeychainKeys.user.humanName) ?? self.humanName self.password = password ?? keyChain.get(KeychainKeys.user.password) ?? self.password self.loggedIn = loggedIn ?? keyChain.getBool(KeychainKeys.user.loggedIn) ?? self.loggedIn + self.agreedToS = agreedToS ?? keyChain.getBool(KeychainKeys.user.agreedToS) ?? self.agreedToS os_log("initial load with name: %@", log: .userData, type: .info, "\(self.loginName)") } @@ -66,6 +68,16 @@ class UserData: ObservableObject { reset() } + func agreeToS() { + agreedToS = true + self.persist() + } + + func disagreeToS() { + agreedToS = false + self.persist() + } + func pairDevice() { if loggedIn { if !DeviceData.shared.created { @@ -123,6 +135,7 @@ class UserData: ObservableObject { keyChain.set(self.humanName!, forKey: KeychainKeys.user.humanName) keyChain.set(self.password, forKey: KeychainKeys.user.password) keyChain.set(self.loggedIn, forKey: KeychainKeys.user.loggedIn) + keyChain.set(self.agreedToS, forKey: KeychainKeys.user.agreedToS) LoginService.shared.toggle() os_log("persisted", log: .userData, type: .info) } @@ -132,6 +145,7 @@ class UserData: ObservableObject { humanName = "" password = "" loggedIn = false + agreedToS = false os_log("deleted", log: .userData, type: .info) persist() } diff --git a/ios-app/app/Business/DataManager/DataManager+CDLocationExtension.swift b/ios-app/app/Business/DataManager/DataManager+CDLocationExtension.swift new file mode 100644 index 00000000..d052ab6b --- /dev/null +++ b/ios-app/app/Business/DataManager/DataManager+CDLocationExtension.swift @@ -0,0 +1,80 @@ +// +// DataManager+CDLocationExtension.swift +// app +// +// Created by Tobias Stottrop on 18.02.20. +// Copyright © 2020 Marcus Handte. All rights reserved. +// + +import Foundation +import MowestaApi +import CoreData +import UIKit + +extension DataManager { + typealias MowestaState = MowestaApi.State + + struct Holder { + static var _processedLocation: CDLocation = CDLocation() + } + var processedLocation:CDLocation { + get { + return Holder._processedLocation + } + set(newValue) { + Holder._processedLocation = newValue + } + } + + func updateLocation(for city: City) -> CDLocation? { + guard let managedContext = getContext() else { return nil} + let location = CDLocation(context: managedContext, city: city) + self.processedLocation = location + WeatherAPI.getCityForecast(_id: location.id, completion: updateWeatherForecast) + + do { + try managedContext.save() + } catch let error as NSError { + print("Failed to update city! \(error): \(error.userInfo)") + return nil + } + return location + } + + func deleteAllLocations() { + guard let managedContext = getContext() else { return } + let fetchRequest: NSFetchRequest = CDLocation.fetchRequest() + do { + let items = try managedContext.fetch(fetchRequest) + for item in items { + managedContext.delete(item) + } + try managedContext.save() + } catch { + } + } + + func updateLocation(for state: MowestaState) -> CDLocation? { + guard let managedContext = getContext() else { return nil} + let location = CDLocation(context: managedContext, state: state) + do { + try managedContext.save() + } catch let error as NSError { + print("Failed to update State! \(error): \(error.userInfo)") + return nil + } + return location + } + +} + +#if DEBUG +extension DataManager { + static var locationMock: CDLocation { + let moc = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext + let cdlocation = CDLocation(context: moc) + cdlocation.id = 48264 + return cdlocation + } +} +#endif diff --git a/ios-app/app/Business/DataManager/DataManager+CDWeatherforecastExtension.swift b/ios-app/app/Business/DataManager/DataManager+CDWeatherforecastExtension.swift new file mode 100644 index 00000000..7db41f62 --- /dev/null +++ b/ios-app/app/Business/DataManager/DataManager+CDWeatherforecastExtension.swift @@ -0,0 +1,42 @@ +// +// DataManager+CDWeatherforecastExtension.swift +// app +// +// Created by Tobias Stottrop on 18.02.20. +// Copyright © 2020 Marcus Handte. All rights reserved. +// + +import Foundation +import MowestaApi +import CoreData + +extension DataManager { + func updateWeatherForecast(forecast: WeatherForecast?, error: Error?) { + if (error != nil) { + //maybe handle + } + if (forecast != nil) { + guard let managedContext = getContext() else { return} + if (self.processedLocation.forecast != nil) { + deleteForecast(self.processedLocation.forecast!) + } + + let cdWeatherForecast = CDWeatherForecast(context: managedContext, forecast: forecast!) + cdWeatherForecast.location = self.processedLocation + do { + try managedContext.save() + } catch let error as NSError { + print("Could not save. \(error), \(error.userInfo)") + } + } + } + + public func deleteForecast(_ forecast: CDWeatherForecast) { + guard let managedContext = getContext() else { return} + managedContext.delete(forecast) + } +} + +#if DEBUG + +#endif diff --git a/ios-app/app/Business/DataManager/DataManager.swift b/ios-app/app/Business/DataManager/DataManager.swift index 0d332e95..a2db5b0a 100644 --- a/ios-app/app/Business/DataManager/DataManager.swift +++ b/ios-app/app/Business/DataManager/DataManager.swift @@ -24,6 +24,7 @@ class DataManager { deleteAllDevices() deleteAllMeasurements() deleteAllPlacemarkLocations() + deleteAllLocations() } } diff --git a/ios-app/app/Business/Day.swift b/ios-app/app/Business/Day.swift index 2760608d..8b133e00 100644 --- a/ios-app/app/Business/Day.swift +++ b/ios-app/app/Business/Day.swift @@ -8,8 +8,9 @@ import Foundation import SwiftUI +import CoreData -struct Day { +struct Day : Hashable, Identifiable{ let id: Int let date: Date @@ -23,6 +24,16 @@ struct Day { return toDayArray(dates: result) } + static func getDayList(conditions: NSSet) -> [Day] { + var result = [Date]() + + for condition in conditions { + result = addDay(timestamp: Date(milliseconds: (condition as! CDWeatherCondition).time), days: result) + } + + return toDayArray(dates: result) + } + static func toDayArray(dates: [Date]) -> [Day] { var result = [Day]() let sortedDates = dates.sorted(by: { $0.compare($1) == .orderedDescending }) diff --git a/ios-app/app/Business/NavigationStack.swift b/ios-app/app/Business/NavigationStack.swift new file mode 100644 index 00000000..9787cde7 --- /dev/null +++ b/ios-app/app/Business/NavigationStack.swift @@ -0,0 +1,32 @@ +// +// NavigationStack.swift +// app +// +// Created by Tobias Stottrop on 04.03.20. +// Copyright © 2020 Marcus Handte. All rights reserved. +// + +import Foundation +import Combine + +class NavigationStack: ObservableObject { + let objectWillChange = ObservableObjectPublisher() + + @Published var list = [AuthState]() { + willSet { + objectWillChange.send() + } + } + + init(firstState: AuthState) { + self.push(state: firstState) + } + + public func push(state: AuthState) { + list.append(state) + } + public func pop() { + list.removeLast() + + } +} diff --git a/ios-app/app/Business/Services/BackgroundService.swift b/ios-app/app/Business/Services/BackgroundService.swift index ea91afca..b2d530c4 100644 --- a/ios-app/app/Business/Services/BackgroundService.swift +++ b/ios-app/app/Business/Services/BackgroundService.swift @@ -16,6 +16,7 @@ import CoreMotion class BackgroundService { private let measurementIdentifier = "com.mowesta.measurement" + private let forecastUpdateIdentifier = "com.mowesta.bg.forecast" static var shared = BackgroundService() private init() { } diff --git a/ios-app/app/Business/Services/WeatherForecast+BackgroundService.swift b/ios-app/app/Business/Services/WeatherForecast+BackgroundService.swift new file mode 100644 index 00000000..61c21e92 --- /dev/null +++ b/ios-app/app/Business/Services/WeatherForecast+BackgroundService.swift @@ -0,0 +1,59 @@ +// +// WeatherForecast+BackgroundService.swift +// app +// +// Created by Tobias Stottrop on 18.02.20. +// Copyright © 2020 Marcus Handte. All rights reserved. +// + +import Foundation +import BackgroundTasks +import UIKit +import CoreData +import MowestaApi + +class WeatherForecastService { + static var shared = WeatherForecastService() + private let identifier = "com.mowesta.bg.weatherforecast" + + private init() { } + + func registerWeatherforecastBackgroundService() { + BGTaskScheduler.shared.register(forTaskWithIdentifier: identifier, using: nil) { task in + self.handleWeatherforecastBackgroundTask(task: task as! BGAppRefreshTask) + } + } + + func scheduleWeatherforecastBackgroundService() { + let request = BGAppRefreshTaskRequest(identifier: identifier) + request.earliestBeginDate = Date(timeIntervalSinceNow: 3600) // App refresh every hour. + do { + try BGTaskScheduler.shared.submit(request) + } catch { + print("Could not schedule app refresh: \(error)") + } + } + + func handleWeatherforecastBackgroundTask(task: BGAppRefreshTask) { + scheduleWeatherforecastBackgroundService() + task.expirationHandler = { + task.setTaskCompleted(success: false) + } + do { + let appDelegate = UIApplication.shared.delegate as! AppDelegate; + let managedContext = appDelegate.persistentContainer.viewContext + let fetch = NSFetchRequest(entityName: "CDLocation") + let fetchedCDLocations = try managedContext.fetch(fetch) + + for location in fetchedCDLocations { + DataManager.shared.processedLocation = location + WeatherAPI.getCityForecast(_id: location.id, completion: DataManager.shared.updateWeatherForecast) + } + } catch { + NSLog("\(error)") + task.setTaskCompleted(success: true) + } + task.setTaskCompleted(success: true) + } +} + diff --git a/ios-app/app/CoreData/CDLocation+CoreDataClass.swift b/ios-app/app/CoreData/CDLocation+CoreDataClass.swift index 4439c707..275c7bb0 100644 --- a/ios-app/app/CoreData/CDLocation+CoreDataClass.swift +++ b/ios-app/app/CoreData/CDLocation+CoreDataClass.swift @@ -9,8 +9,45 @@ import Foundation import CoreData +import MowestaApi @objc(CDLocation) public class CDLocation: NSManagedObject { - + + convenience init(context: NSManagedObjectContext, city: MowestaApi.City) { + self.init(context: context) + self.capital = city.capital + self.creationTime = city.creationTime ?? -1 + self.id = city._id! + self.markedDeleted = city.deleted ?? false + self.modificationTime = city.modificationTime ?? -1 + self.population = Int64(city.population ?? -1) + self.timezone = city.timezone + self.type = city.type.rawValue + self.wikipedia = city.wikipedia ?? "" + + for (key, value) in city.names { + let cdNamesDictionary = CDNamesDictionary(context: context, key: key, value: value) + self.addToNames(cdNamesDictionary) + } + } + + convenience init(context: NSManagedObjectContext, state: MowestaApi.State) { + self.init(context: context) + self.capital = false + self.id = state._id! + self.creationTime = state.creationTime ?? -1 + self.markedDeleted = state.deleted ?? false + self.modificationTime = state.modificationTime ?? -1 + self.population = Int64(state.population ?? -1) + self.timezone = state.timezone + self.type = "STATE" + self.wikipedia = state.wikipedia ?? "" + + for (key, value) in state.names { + let cdNamesDictionary = CDNamesDictionary(context: context, key: key, value: value) + self.addToNames(cdNamesDictionary) + } + } + } diff --git a/ios-app/app/CoreData/CDNamesDictionary+CoreDataClass.swift b/ios-app/app/CoreData/CDNamesDictionary+CoreDataClass.swift index e40a95e6..f8551e35 100644 --- a/ios-app/app/CoreData/CDNamesDictionary+CoreDataClass.swift +++ b/ios-app/app/CoreData/CDNamesDictionary+CoreDataClass.swift @@ -12,5 +12,11 @@ import CoreData @objc(CDNamesDictionary) public class CDNamesDictionary: NSManagedObject { - + + convenience init (context: NSManagedObjectContext, key: String, value: String) { + self.init(context: context) + self.key = key + self.value = value + } + } diff --git a/ios-app/app/CoreData/CDWeatherCondition+CoreDataClass.swift b/ios-app/app/CoreData/CDWeatherCondition+CoreDataClass.swift new file mode 100644 index 00000000..42cf1b34 --- /dev/null +++ b/ios-app/app/CoreData/CDWeatherCondition+CoreDataClass.swift @@ -0,0 +1,34 @@ +// +// CDWeatherCondition+CoreDataClass.swift +// app +// +// Created by Tobias Stottrop on 17.02.20. +// Copyright © 2020 Marcus Handte. All rights reserved. +// +// + +import Foundation +import CoreData +import MowestaApi + +@objc(CDWeatherCondition) +public class CDWeatherCondition: NSManagedObject { + convenience init(context: NSManagedObjectContext, condition: WeatherCondition) { + self.init(context: context) + self.cloudCoverage = condition.cloudCoverage + self.cloudDepth = condition.cloudDepth + self.duration = Int64(condition.duration) + self.hour = Int64(condition.hour) + self.humidity = condition.humidity + self.precipitation = condition.precipitation + self.pressure = condition.pressure + self.snowDepth = condition.snowDepth + self.source = condition.source.rawValue + self.temperature = condition.temperature + self.time = condition.time + self.type = condition.getWeatherTypeImageName() + self.windDirection = condition.getWindDirectionImageName() + self.windSpeed = condition.windSpeed + //NSLog("condition temperature: \(condition.temperature) ::: coredata temperature: \(self.temperature)") + } +} diff --git a/ios-app/app/CoreData/CDWeatherCondition+CoreDataProperties.swift b/ios-app/app/CoreData/CDWeatherCondition+CoreDataProperties.swift new file mode 100644 index 00000000..31f1c2a9 --- /dev/null +++ b/ios-app/app/CoreData/CDWeatherCondition+CoreDataProperties.swift @@ -0,0 +1,36 @@ +// +// CDWeatherCondition+CoreDataProperties.swift +// app +// +// Created by Tobias Stottrop on 17.02.20. +// Copyright © 2020 Marcus Handte. All rights reserved. +// +// + +import Foundation +import CoreData + + +extension CDWeatherCondition { + + @nonobjc public class func fetchRequest() -> NSFetchRequest { + return NSFetchRequest(entityName: "CDWeatherCondition") + } + + @NSManaged public var cloudCoverage: Double + @NSManaged public var cloudDepth: Double + @NSManaged public var duration: Int64 + @NSManaged public var hour: Int64 + @NSManaged public var humidity: Double + @NSManaged public var precipitation: Double + @NSManaged public var pressure: Double + @NSManaged public var snowDepth: Double + @NSManaged public var source: String? + @NSManaged public var temperature: Double + @NSManaged public var time: Int64 + @NSManaged public var type: String? + @NSManaged public var windDirection: String? + @NSManaged public var windSpeed: Double + @NSManaged public var forecast: CDWeatherForecast? + +} diff --git a/ios-app/app/CoreData/CDWeatherForecast+CoreDataClass.swift b/ios-app/app/CoreData/CDWeatherForecast+CoreDataClass.swift new file mode 100644 index 00000000..ef411299 --- /dev/null +++ b/ios-app/app/CoreData/CDWeatherForecast+CoreDataClass.swift @@ -0,0 +1,33 @@ +// +// CDWeatherForecast+CoreDataClass.swift +// app +// +// Created by Tobias Stottrop on 17.02.20. +// Copyright © 2020 Marcus Handte. All rights reserved. +// +// + +import Foundation +import CoreData +import MowestaApi + +@objc(CDWeatherForecast) +public class CDWeatherForecast: NSManagedObject { + convenience init(context: NSManagedObjectContext, forecast: WeatherForecast) { + self.init(context: context) + self.creationTime = forecast.creationTime ?? -1 + self.id = forecast._id! + self.markedDeleted = forecast.deleted ?? false + self.modificationTime = forecast.modificationTime ?? -1 + self.plantCoverage = forecast.plantCoverage + self.soilType = forecast.soilType.rawValue + self.source = forecast.source.rawValue + self.surfaceHeight = forecast.surfaceHeight + + for condition in forecast.conditions { + let cdCondition = CDWeatherCondition(context: context, condition: condition) + self.addToConditions(cdCondition) + } + } + +} diff --git a/ios-app/app/CoreData/CDWeatherForecast+CoreDataProperties.swift b/ios-app/app/CoreData/CDWeatherForecast+CoreDataProperties.swift new file mode 100644 index 00000000..68487b5f --- /dev/null +++ b/ios-app/app/CoreData/CDWeatherForecast+CoreDataProperties.swift @@ -0,0 +1,49 @@ +// +// CDWeatherForecast+CoreDataProperties.swift +// app +// +// Created by Tobias Stottrop on 17.02.20. +// Copyright © 2020 Marcus Handte. All rights reserved. +// +// + +import Foundation +import CoreData + + +extension CDWeatherForecast { + + @nonobjc public class func fetchRequest() -> NSFetchRequest { + return NSFetchRequest(entityName: "CDWeatherForecast") + } + + + @NSManaged public var creationTime: Int64 + @NSManaged public var id: Int64 + @NSManaged public var markedDeleted: Bool + @NSManaged public var modificationTime: Int64 + @NSManaged public var plantCoverage: Double + @NSManaged public var soilType: String? + @NSManaged public var source: String? + @NSManaged public var surfaceHeight: Double + @NSManaged public var conditions: NSSet? + @NSManaged public var location: CDLocation? + +} + +// MARK: Generated accessors for conditions +extension CDWeatherForecast { + + @objc(addConditionsObject:) + @NSManaged public func addToConditions(_ value: CDWeatherCondition) + + @objc(removeConditionsObject:) + @NSManaged public func removeFromConditions(_ value: CDWeatherCondition) + + @objc(addConditions:) + @NSManaged public func addToConditions(_ values: NSSet) + + @objc(removeConditions:) + @NSManaged public func removeFromConditions(_ values: NSSet) + +} diff --git a/ios-app/app/Data/DailyPrediction.swift b/ios-app/app/Data/DailyPrediction.swift new file mode 100644 index 00000000..ddebd5c0 --- /dev/null +++ b/ios-app/app/Data/DailyPrediction.swift @@ -0,0 +1,30 @@ +// +// DailyPrediction.swift +// app +// +// Created by Tobias Stottrop on 04.03.20. +// Copyright © 2020 Marcus Handte. All rights reserved. +// + +import Foundation + +struct DailyPrediction : Hashable { + static func == (lhs: DailyPrediction, rhs: DailyPrediction) -> Bool { + return lhs.day.id == rhs.day.id && lhs.day.date == rhs.day.date && lhs.rawConditions.count == rhs.rawConditions.count && lhs.minTemperature == rhs.minTemperature && lhs.maxTemperature == rhs.maxTemperature && lhs.symbol == rhs.symbol + } + + + init(min: Double, max: Double, symbol: String, day: Day, rawConditions: [CDWeatherCondition]) { + self.minTemperature = min + self.maxTemperature = max + self.symbol = symbol + self.day = day + self.rawConditions = rawConditions + } + + var minTemperature: Double = -1 + var maxTemperature: Double = -1 + var symbol: String = "unknown" + var day: Day + var rawConditions: [CDWeatherCondition] = [CDWeatherCondition]() +} diff --git a/ios-app/app/Data/Environment/FavoriteLocations.swift b/ios-app/app/Data/Environment/FavoriteLocations.swift deleted file mode 100644 index 9e453e33..00000000 --- a/ios-app/app/Data/Environment/FavoriteLocations.swift +++ /dev/null @@ -1,54 +0,0 @@ -// -// FavoriteLocations.swift -// app -// -// Created by Sebastian Pobel on 06.01.20. -// Copyright © 2020 Marcus Handte. All rights reserved. -// - -import Foundation -import MowestaApi -import SwiftUI - -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]() { - willSet { - objectWillChange.send() - } - } - @Published var currentWeathers = [Int64 : CurrentWeatherData]() - @Published var weatherForecasts = [Int64 : WeatherForecast]() - - init(locations: [LocationHierarchy]) { - self.locations = locations - -// 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: {$0._id == location._id}) else { - locations.append(location) - WeatherAPI.getForecast(_id: location._id!, completion: self.addWeatherForecast) - return - } - locations.remove(at: pos) - } - - 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 - } - } - -} diff --git a/ios-app/app/Data/Environment/Mock/LocationMock.swift b/ios-app/app/Data/Environment/Mock/LocationMock.swift index 88c46539..fe17631e 100644 --- a/ios-app/app/Data/Environment/Mock/LocationMock.swift +++ b/ios-app/app/Data/Environment/Mock/LocationMock.swift @@ -28,7 +28,7 @@ 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 condition = WeatherCondition(source: WeatherCondition.Source.cosmoEurope, time: 0, hour: 0, duration: 0, type: WeatherCondition.ModelType.unknown, temperature: 0, windDirection: WeatherCondition.WindDirection.unknown, windSpeed: 0, cloudCoverage: 0, cloudDepth: 0, pressure: 0, precipitation: 0, snowDepth: 0, humidity: 0) 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]) @@ -38,6 +38,5 @@ func loadTestData() -> [City] { let bonnMowestaFavorite = SavedMowestaFavorites(id: 13334, type: "CITY") -let bonnCDLocation = CDLocation() let citiesData: [City] = loadTestData() diff --git a/ios-app/app/Data/Environment/Mock/WeatherMock.swift b/ios-app/app/Data/Environment/Mock/WeatherMock.swift new file mode 100644 index 00000000..e6b792aa --- /dev/null +++ b/ios-app/app/Data/Environment/Mock/WeatherMock.swift @@ -0,0 +1,1635 @@ +// +// ConditionMock.swift +// app +// +// Created by Tobias Stottrop on 19.02.20. +// Copyright © 2020 Marcus Handte. All rights reserved. +// + +import MowestaApi +import Foundation +import CoreData +import UIKit + + + +let decoder = JSONDecoder() +let appDelegate = UIApplication.shared.delegate as! AppDelegate + +let moc_condition_wolfsburg = try! decoder.decode(WeatherCondition.self, from: moc_condition_wolfsburg_json) +let moc_cd_condition_wolfsburg = CDWeatherCondition(context: appDelegate.persistentContainer.viewContext, condition: moc_condition_wolfsburg) +let moc_condition_empty = try! decoder.decode(WeatherCondition.self, from: moc_condition_empty_json) +let moc_weatherforecast_wolfsburg = try! decoder.decode(WeatherForecast.self, from: moc_weatherforecast_wolfsburg_json) +let moc_weatherforecast_empty = try! decoder.decode(WeatherForecast.self, from: moc_weatherforecast_empty_json) +let moc_location_wolfsburg = try! decoder.decode(City.self, from: moc_location_wolfsburg_json) +let moc_cd_location_wolfsburg = CDLocation(context: appDelegate.persistentContainer.viewContext, city: moc_location_wolfsburg) + +let moc_condition_wolfsburg_json = """ +{ + "source": "WEATHER_STATION", + "time": 1582106400000, + "hour": 10, + "duration": 1, + "type": "CLOUDY", + "temperature": 5.6, + "windDirection": "EAST", + "windSpeed": 5.792207427577444, + "cloudCoverage": 1, + "cloudDepth": 0.2634429931640625, + "pressure": 1003.9492578125, + "precipitation": 0, + "snowDepth": 0, + "humidity": 84.2 +} +""".data(using: .utf8)! + +let moc_condition_empty_json = """ +{ + "source": "ICON_GLOBAL", + "time": 0, + "hour": 0, + "duration": 0, + "type": "UNKNOWN", + "temperature": 0, + "windDirection": "UNKNOWN", + "windSpeed": 0, + "cloudCoverage": 0, + "cloudDepth": 0, + "pressure": 0, + "precipitation": 0, + "snowDepth": 0, + "humidity": 0 +} +""".data(using: .utf8)! + +let moc_location_wolfsburg_json = """ +{ + "id": 48264, + "creationTime": 1578754282174, + "modificationTime": 1580217419813, + "deleted": false, + "coordinate": { + "latitude": 52.4205588, + "longitude": 10.7861682 + }, + "timezone": "Europe/Berlin", + "capital": false, + "population": 122457, + "wikipedia": "de:Wolfsburg", + "type": "CITY", + "country": { + "id": 560, + "creationTime": 1578750581221, + "modificationTime": 1578750581221, + "deleted": false, + "coordinate": { + "latitude": 51.0834196, + "longitude": 10.4234469 + }, + "names": { + "fr": "Allemagne", + "en": "Germany", + "es": "Alemania", + "it": "Germania", + "local": "Deutschland" + } + }, + "state": { + "id": 1502, + "creationTime": 1578750732023, + "modificationTime": 1578750732023, + "deleted": false, + "coordinate": { + "latitude": 52.8398531, + "longitude": 9.075962 + }, + "timezone": "Europe/Berlin", + "population": 7918293, + "wikipedia": "de:Niedersachsen", + "country": { + "id": 560, + "creationTime": 1578750581221, + "modificationTime": 1578750581221, + "deleted": false, + "coordinate": { + "latitude": 51.0834196, + "longitude": 10.4234469 + }, + "names": { + "fr": "Allemagne", + "en": "Germany", + "es": "Alemania", + "it": "Germania", + "local": "Deutschland" + } + }, + "names": { + "de": "Niedersachsen", + "fr": "Basse-Saxe", + "acronym": "NDS", + "en": "Lower Saxony", + "es": "Baja Sajonia", + "local": "Niedersachsen" + } + }, + "names": { + "de": "Wolfsburg", + "es": "Wolfsburgo", + "local": "Wolfsburg" + } +} +""".data(using: .utf8)! + +let moc_weatherforecast_empty_json = """ +{ + "source": "ICON_GLOBAL", + "time": 0, + "hour": 0, + "duration": 0, + "type": "UNKNOWN", + "temperature": 0, + "windDirection": "UNKNOWN", + "windSpeed": 0, + "cloudCoverage": 0, + "cloudDepth": 0, + "pressure": 0, + "precipitation": 0, + "snowDepth": 0, + "humidity": 0 +} +""".data(using: .utf8)! + +let moc_weatherforecast_wolfsburg_json = """ +{ + "id": 20284235, + "creationTime": 1582092556252, + "modificationTime": 1582092556252, + "deleted": false, + "coordinate": { + "latitude": 52.41747683820171, + "longitude": 10.78632338622856 + }, + "source": "COSMO_EUROPE", + "surfaceHeight": 63.9375, + "plantCoverage": 44.21875, + "soilType": "LOAM", + "conditions": [ + { + "source": "ICON_EUROPE", + "time": 1582074000000, + "hour": 1, + "duration": 1, + "type": "CLOUDY", + "temperature": 5.456033325195335, + "windDirection": "NORTH_WEST", + "windSpeed": 6.2609192950265316, + "cloudCoverage": 1, + "cloudDepth": 0.41412353515625, + "pressure": 1005.218671875, + "precipitation": 0, + "snowDepth": 0, + "humidity": 71.42227172851562 + }, + { + "source": "ICON_EUROPE", + "time": 1582077600000, + "hour": 2, + "duration": 1, + "type": "CLOUDY", + "temperature": 5.585504150390648, + "windDirection": "NORTH_WEST", + "windSpeed": 6.340944676546795, + "cloudCoverage": 0.998931884765625, + "cloudDepth": 0.398773193359375, + "pressure": 1004.151484375, + "precipitation": 0, + "snowDepth": 0, + "humidity": 71.97617149353027 + }, + { + "source": "ICON_EUROPE", + "time": 1582081200000, + "hour": 3, + "duration": 1, + "type": "CLOUDY", + "temperature": 5.519448852539085, + "windDirection": "NORTH_WEST", + "windSpeed": 6.359455669321785, + "cloudCoverage": 0.89459228515625, + "cloudDepth": 0.2542724609375, + "pressure": 1003.212421875, + "precipitation": 0, + "snowDepth": 0, + "humidity": 73.80046463012695 + }, + { + "source": "COSMO_EUROPE", + "time": 1582084800000, + "hour": 4, + "duration": 1, + "type": "SLIGHT_RAIN_NOT_FREEZING", + "temperature": 5.543450927734398, + "windDirection": "NORTH_WEST", + "windSpeed": 5.139675818833487, + "cloudCoverage": 1, + "cloudDepth": 0.65399169921875, + "pressure": 1001.94265625, + "precipitation": 0.0657958984375, + "snowDepth": 0, + "humidity": 86.90749168395996 + }, + { + "source": "COSMO_EUROPE", + "time": 1582088400000, + "hour": 5, + "duration": 1, + "type": "SLIGHT_RAIN_NOT_FREEZING", + "temperature": 5.69666442871096, + "windDirection": "NORTH", + "windSpeed": 6.409837344209859, + "cloudCoverage": 1, + "cloudDepth": 0.5142059326171875, + "pressure": 1001.251484375, + "precipitation": 0.22021484375, + "snowDepth": 0, + "humidity": 86.19622039794922 + }, + { + "source": "COSMO_EUROPE", + "time": 1582092000000, + "hour": 6, + "duration": 1, + "type": "SLIGHT_RAIN_NOT_FREEZING", + "temperature": 5.560174560546898, + "windDirection": "NORTH_EAST", + "windSpeed": 5.481241582013575, + "cloudCoverage": 1, + "cloudDepth": 0.7780914306640625, + "pressure": 1001.019921875, + "precipitation": 1.0830078125, + "snowDepth": 0, + "humidity": 88.54544830322266 + }, + { + "source": "COSMO_EUROPE", + "time": 1582095600000, + "hour": 7, + "duration": 1, + "type": "SLIGHT_RAIN_NOT_FREEZING", + "temperature": 5.12134704589846, + "windDirection": "EAST", + "windSpeed": 4.629608205724116, + "cloudCoverage": 1, + "cloudDepth": 0.6564788818359375, + "pressure": 1001.682734375, + "precipitation": 0.09521484375, + "snowDepth": 0, + "humidity": 89.79855728149414 + }, + { + "source": "COSMO_EUROPE", + "time": 1582099200000, + "hour": 8, + "duration": 1, + "type": "SLIGHT_RAIN_NOT_FREEZING", + "temperature": 5.139703369140648, + "windDirection": "EAST", + "windSpeed": 5.314655728276746, + "cloudCoverage": 1, + "cloudDepth": 0.5438995361328125, + "pressure": 1002.1370703125, + "precipitation": 0.00732421875, + "snowDepth": 0, + "humidity": 89.44626998901367 + }, + { + "source": "COSMO_EUROPE", + "time": 1582102800000, + "hour": 9, + "duration": 1, + "type": "CLOUDY", + "temperature": 5.648980712890648, + "windDirection": "EAST", + "windSpeed": 6.1221555404205334, + "cloudCoverage": 1, + "cloudDepth": 0.361785888671875, + "pressure": 1003.015390625, + "precipitation": 0.005859375, + "snowDepth": 0, + "humidity": 84.94120216369629 + }, + { + "source": "COSMO_EUROPE", + "time": 1582106400000, + "hour": 10, + "duration": 1, + "type": "CLOUDY", + "temperature": 5.874414062500023, + "windDirection": "EAST", + "windSpeed": 5.792207427577444, + "cloudCoverage": 1, + "cloudDepth": 0.2634429931640625, + "pressure": 1003.9492578125, + "precipitation": 0, + "snowDepth": 0, + "humidity": 80.93421745300293 + }, + { + "source": "COSMO_EUROPE", + "time": 1582110000000, + "hour": 11, + "duration": 1, + "type": "CLOUDY", + "temperature": 5.939782714843773, + "windDirection": "EAST", + "windSpeed": 6.009828640246425, + "cloudCoverage": 0.9193115234375, + "cloudDepth": 0.0835418701171875, + "pressure": 1004.81828125, + "precipitation": 0.00341796875, + "snowDepth": 0, + "humidity": 80.04644393920898 + }, + { + "source": "COSMO_EUROPE", + "time": 1582113600000, + "hour": 12, + "duration": 1, + "type": "CLOUDY", + "temperature": 5.950280761718773, + "windDirection": "EAST", + "windSpeed": 6.803365720866897, + "cloudCoverage": 1, + "cloudDepth": 0.1098785400390625, + "pressure": 1005.284296875, + "precipitation": 0.0126953125, + "snowDepth": 0, + "humidity": 80.49825096130371 + }, + { + "source": "COSMO_EUROPE", + "time": 1582117200000, + "hour": 13, + "duration": 1, + "type": "CLOUDY", + "temperature": 5.986749267578148, + "windDirection": "EAST", + "windSpeed": 6.384645298603536, + "cloudCoverage": 1, + "cloudDepth": 0.05926513671875, + "pressure": 1005.4933203125, + "precipitation": 0.00390625, + "snowDepth": 0, + "humidity": 79.03084373474121 + }, + { + "source": "COSMO_EUROPE", + "time": 1582120800000, + "hour": 14, + "duration": 1, + "type": "CLOUDY", + "temperature": 5.744042968750023, + "windDirection": "EAST", + "windSpeed": 6.175531994454679, + "cloudCoverage": 1, + "cloudDepth": 0.2087860107421875, + "pressure": 1005.8605078125, + "precipitation": 0.13525390625, + "snowDepth": 0, + "humidity": 81.01663208007812 + }, + { + "source": "COSMO_EUROPE", + "time": 1582124400000, + "hour": 15, + "duration": 1, + "type": "SLIGHT_RAIN_NOT_FREEZING", + "temperature": 5.42725524902346, + "windDirection": "EAST", + "windSpeed": 5.659759445944336, + "cloudCoverage": 1, + "cloudDepth": 0.47344970703125, + "pressure": 1006.3723046875, + "precipitation": 1.01171875, + "snowDepth": 0, + "humidity": 84.71942710876465 + }, + { + "source": "COSMO_EUROPE", + "time": 1582128000000, + "hour": 16, + "duration": 1, + "type": "SLIGHT_RAIN_NOT_FREEZING", + "temperature": 5.241265869140648, + "windDirection": "SOUTH_EAST", + "windSpeed": 4.483503141239641, + "cloudCoverage": 1, + "cloudDepth": 0.53594970703125, + "pressure": 1007.2491015625, + "precipitation": 1.4033203125, + "snowDepth": 0, + "humidity": 86.30967712402344 + }, + { + "source": "COSMO_EUROPE", + "time": 1582131600000, + "hour": 17, + "duration": 1, + "type": "SLIGHT_RAIN_NOT_FREEZING", + "temperature": 5.275613403320335, + "windDirection": "EAST", + "windSpeed": 6.227867014754152, + "cloudCoverage": 1, + "cloudDepth": 0.325469970703125, + "pressure": 1008.1139453125, + "precipitation": 0.04345703125, + "snowDepth": 0, + "humidity": 84.82217788696289 + }, + { + "source": "COSMO_EUROPE", + "time": 1582135200000, + "hour": 18, + "duration": 1, + "type": "CLOUDY", + "temperature": 5.082482910156273, + "windDirection": "EAST", + "windSpeed": 5.958386858366127, + "cloudCoverage": 1, + "cloudDepth": 0.130462646484375, + "pressure": 1009.3580859375, + "precipitation": 0.00390625, + "snowDepth": 0, + "humidity": 86.05939292907715 + }, + { + "source": "COSMO_EUROPE", + "time": 1582138800000, + "hour": 19, + "duration": 1, + "type": "PARTLY_CLOUDY", + "temperature": 4.83930358886721, + "windDirection": "EAST", + "windSpeed": 5.1922261476716525, + "cloudCoverage": 0.6859130859375, + "cloudDepth": 0.084991455078125, + "pressure": 1010.0103515625, + "precipitation": 0, + "snowDepth": 0, + "humidity": 87.04720306396484 + }, + { + "source": "COSMO_EUROPE", + "time": 1582142400000, + "hour": 20, + "duration": 1, + "type": "MAINLY_CLEAR", + "temperature": 4.07599792480471, + "windDirection": "EAST", + "windSpeed": 5.150081996800846, + "cloudCoverage": 0, + "cloudDepth": 0.0241241455078125, + "pressure": 1010.4622265625, + "precipitation": 0, + "snowDepth": 0, + "humidity": 88.76189804077148 + }, + { + "source": "COSMO_EUROPE", + "time": 1582146000000, + "hour": 21, + "duration": 1, + "type": "CLOUDY", + "temperature": 3.8089691162109602, + "windDirection": "NORTH_EAST", + "windSpeed": 4.274725918307746, + "cloudCoverage": 0.78546142578125, + "cloudDepth": 0.042236328125, + "pressure": 1010.8474609375, + "precipitation": 0, + "snowDepth": 0, + "humidity": 86.27692413330078 + }, + { + "source": "COSMO_EUROPE", + "time": 1582149600000, + "hour": 22, + "duration": 1, + "type": "CLOUDY", + "temperature": 3.4313903808593977, + "windDirection": "NORTH_EAST", + "windSpeed": 4.6379035666338675, + "cloudCoverage": 1, + "cloudDepth": 0.05035400390625, + "pressure": 1011.3108203125, + "precipitation": 0, + "snowDepth": 0, + "humidity": 86.75990867614746 + }, + { + "source": "COSMO_EUROPE", + "time": 1582153200000, + "hour": 23, + "duration": 1, + "type": "MAINLY_CLEAR", + "temperature": 2.2276702880859602, + "windDirection": "NORTH_EAST", + "windSpeed": 3.6594106419966974, + "cloudCoverage": 0, + "cloudDepth": 0.002838134765625, + "pressure": 1011.3955859375, + "precipitation": 0, + "snowDepth": 0, + "humidity": 91.63332939147949 + }, + { + "source": "COSMO_EUROPE", + "time": 1582156800000, + "hour": 24, + "duration": 1, + "type": "CLEAR_SKY", + "temperature": 1.5166717529297102, + "windDirection": "NORTH", + "windSpeed": 3.4978024762043383, + "cloudCoverage": 0, + "cloudDepth": 0.0015869140625, + "pressure": 1011.3038671875, + "precipitation": 0, + "snowDepth": 0, + "humidity": 92.6738338470459 + }, + { + "source": "COSMO_EUROPE", + "time": 1582160400000, + "hour": 25, + "duration": 1, + "type": "CLEAR_SKY", + "temperature": 1.2381683349609602, + "windDirection": "NORTH", + "windSpeed": 3.4708708487997892, + "cloudCoverage": 0, + "cloudDepth": 0, + "pressure": 1011.28828125, + "precipitation": 0, + "snowDepth": 0, + "humidity": 92.02642250061035 + }, + { + "source": "COSMO_EUROPE", + "time": 1582164000000, + "hour": 26, + "duration": 1, + "type": "MAINLY_CLEAR", + "temperature": 0.7972351074218977, + "windDirection": "NORTH", + "windSpeed": 3.082793244304234, + "cloudCoverage": 0, + "cloudDepth": 0, + "pressure": 1011.3551953125, + "precipitation": 0, + "snowDepth": 0, + "humidity": 93.76829719543457 + }, + { + "source": "COSMO_EUROPE", + "time": 1582167600000, + "hour": 27, + "duration": 1, + "type": "CLOUDY", + "temperature": 1.1245208740234602, + "windDirection": "NORTH_WEST", + "windSpeed": 4.000704293125587, + "cloudCoverage": 1, + "cloudDepth": 0.076416015625, + "pressure": 1011.160859375, + "precipitation": 0.0009765625, + "snowDepth": 0, + "humidity": 90.59975624084473 + }, + { + "source": "COSMO_EUROPE", + "time": 1582171200000, + "hour": 28, + "duration": 1, + "type": "CLOUDY", + "temperature": 1.7546325683593977, + "windDirection": "NORTH_WEST", + "windSpeed": 3.749131470713348, + "cloudCoverage": 1, + "cloudDepth": 0.23443603515625, + "pressure": 1010.6548046875, + "precipitation": 0.015625, + "snowDepth": 0, + "humidity": 88.8022346496582 + }, + { + "source": "COSMO_EUROPE", + "time": 1582174800000, + "hour": 29, + "duration": 1, + "type": "CLOUDY", + "temperature": 2.5115295410156477, + "windDirection": "NORTH_WEST", + "windSpeed": 4.034886271267635, + "cloudCoverage": 1, + "cloudDepth": 0.618072509765625, + "pressure": 1009.8656640625, + "precipitation": 0.1044921875, + "snowDepth": 0, + "humidity": 87.7183837890625 + }, + { + "source": "COSMO_EUROPE", + "time": 1582178400000, + "hour": 30, + "duration": 1, + "type": "SLIGHT_RAIN_NOT_FREEZING", + "temperature": 2.9111267089843977, + "windDirection": "NORTH_WEST", + "windSpeed": 3.925425603512353, + "cloudCoverage": 1, + "cloudDepth": 0.734832763671875, + "pressure": 1009.4992578125, + "precipitation": 0.1572265625, + "snowDepth": 0, + "humidity": 89.22097969055176 + }, + { + "source": "COSMO_EUROPE", + "time": 1582182000000, + "hour": 31, + "duration": 1, + "type": "SLIGHT_RAIN_NOT_FREEZING", + "temperature": 3.4095397949218977, + "windDirection": "NORTH_WEST", + "windSpeed": 4.304024680244695, + "cloudCoverage": 1, + "cloudDepth": 0.90032958984375, + "pressure": 1009.19859375, + "precipitation": 0.12109375, + "snowDepth": 0, + "humidity": 88.95926666259766 + }, + { + "source": "COSMO_EUROPE", + "time": 1582185600000, + "hour": 32, + "duration": 1, + "type": "SLIGHT_RAIN_NOT_FREEZING", + "temperature": 3.8850952148437727, + "windDirection": "NORTH_WEST", + "windSpeed": 4.175687997742917, + "cloudCoverage": 1, + "cloudDepth": 0.964935302734375, + "pressure": 1008.9816796875, + "precipitation": 0.3046875, + "snowDepth": 0, + "humidity": 89.23978042602539 + }, + { + "source": "COSMO_EUROPE", + "time": 1582189200000, + "hour": 33, + "duration": 1, + "type": "SLIGHT_RAIN_NOT_FREEZING", + "temperature": 4.420526123046898, + "windDirection": "NORTH_WEST", + "windSpeed": 4.635830581400284, + "cloudCoverage": 1, + "cloudDepth": 0.939178466796875, + "pressure": 1008.488515625, + "precipitation": 0.244140625, + "snowDepth": 0, + "humidity": 89.68277168273926 + }, + { + "source": "COSMO_EUROPE", + "time": 1582192800000, + "hour": 34, + "duration": 1, + "type": "SLIGHT_RAIN_NOT_FREEZING", + "temperature": 5.016229248046898, + "windDirection": "NORTH_WEST", + "windSpeed": 5.029357830753283, + "cloudCoverage": 1, + "cloudDepth": 0.947479248046875, + "pressure": 1008.1994921875, + "precipitation": 0.193359375, + "snowDepth": 0, + "humidity": 89.17593574523926 + }, + { + "source": "COSMO_EUROPE", + "time": 1582196400000, + "hour": 35, + "duration": 1, + "type": "SLIGHT_RAIN_NOT_FREEZING", + "temperature": 5.480157470703148, + "windDirection": "NORTH_WEST", + "windSpeed": 4.7872685200841305, + "cloudCoverage": 1, + "cloudDepth": 0.84014892578125, + "pressure": 1007.571015625, + "precipitation": 0.01171875, + "snowDepth": 0, + "humidity": 89.23464012145996 + }, + { + "source": "COSMO_EUROPE", + "time": 1582200000000, + "hour": 36, + "duration": 1, + "type": "CLOUDY", + "temperature": 6.341882324218773, + "windDirection": "NORTH_WEST", + "windSpeed": 5.307765256624442, + "cloudCoverage": 1, + "cloudDepth": 0.60833740234375, + "pressure": 1006.7878515625, + "precipitation": 0.001953125, + "snowDepth": 0, + "humidity": 87.41841697692871 + }, + { + "source": "COSMO_EUROPE", + "time": 1582203600000, + "hour": 37, + "duration": 1, + "type": "CLOUDY", + "temperature": 7.007379150390648, + "windDirection": "NORTH", + "windSpeed": 5.207485512117354, + "cloudCoverage": 1, + "cloudDepth": 0.35577392578125, + "pressure": 1006.164453125, + "precipitation": 0, + "snowDepth": 0, + "humidity": 86.68857002258301 + }, + { + "source": "COSMO_EUROPE", + "time": 1582207200000, + "hour": 38, + "duration": 1, + "type": "CLOUDY", + "temperature": 7.458428955078148, + "windDirection": "NORTH", + "windSpeed": 5.003616736500052, + "cloudCoverage": 1, + "cloudDepth": 0.282562255859375, + "pressure": 1005.855, + "precipitation": 0, + "snowDepth": 0, + "humidity": 84.49654769897461 + }, + { + "source": "COSMO_EUROPE", + "time": 1582210800000, + "hour": 39, + "duration": 1, + "type": "CLOUDY", + "temperature": 7.663873291015648, + "windDirection": "NORTH_WEST", + "windSpeed": 5.159640919008241, + "cloudCoverage": 1, + "cloudDepth": 0.210784912109375, + "pressure": 1005.046484375, + "precipitation": 0.00390625, + "snowDepth": 0, + "humidity": 84.4157829284668 + }, + { + "source": "COSMO_EUROPE", + "time": 1582214400000, + "hour": 40, + "duration": 1, + "type": "CLOUDY", + "temperature": 7.532708740234398, + "windDirection": "NORTH_WEST", + "windSpeed": 5.320772778756206, + "cloudCoverage": 1, + "cloudDepth": 0.304779052734375, + "pressure": 1004.38875, + "precipitation": 0.005859375, + "snowDepth": 0, + "humidity": 85.42841911315918 + }, + { + "source": "COSMO_EUROPE", + "time": 1582218000000, + "hour": 41, + "duration": 1, + "type": "CLOUDY", + "temperature": 7.301354980468773, + "windDirection": "NORTH_WEST", + "windSpeed": 5.285650558952531, + "cloudCoverage": 1, + "cloudDepth": 0.296295166015625, + "pressure": 1003.5246875, + "precipitation": 0.021484375, + "snowDepth": 0, + "humidity": 84.48069953918457 + }, + { + "source": "COSMO_EUROPE", + "time": 1582221600000, + "hour": 42, + "duration": 1, + "type": "CLOUDY", + "temperature": 7.213098144531273, + "windDirection": "NORTH_WEST", + "windSpeed": 5.501447951836196, + "cloudCoverage": 1, + "cloudDepth": 0.287200927734375, + "pressure": 1002.8666796875, + "precipitation": 0, + "snowDepth": 0, + "humidity": 85.13760185241699 + }, + { + "source": "COSMO_EUROPE", + "time": 1582225200000, + "hour": 43, + "duration": 1, + "type": "PARTLY_CLOUDY", + "temperature": 7.176843261718773, + "windDirection": "NORTH_WEST", + "windSpeed": 6.280659341614211, + "cloudCoverage": 0.565460205078125, + "cloudDepth": 0.062164306640625, + "pressure": 1001.8870703125, + "precipitation": 0, + "snowDepth": 0, + "humidity": 85.85517501831055 + }, + { + "source": "COSMO_EUROPE", + "time": 1582228800000, + "hour": 44, + "duration": 1, + "type": "CLOUDY", + "temperature": 7.066278076171898, + "windDirection": "NORTH_WEST", + "windSpeed": 6.2898537293861345, + "cloudCoverage": 1, + "cloudDepth": 0.2220458984375, + "pressure": 1001.0618359375, + "precipitation": 0.091796875, + "snowDepth": 0, + "humidity": 85.43330192565918 + }, + { + "source": "COSMO_EUROPE", + "time": 1582232400000, + "hour": 45, + "duration": 1, + "type": "SLIGHT_RAIN_NOT_FREEZING", + "temperature": 7.036187744140648, + "windDirection": "NORTH_WEST", + "windSpeed": 7.2057140700112186, + "cloudCoverage": 1, + "cloudDepth": 0.474609375, + "pressure": 999.5887109375, + "precipitation": 0.314453125, + "snowDepth": 0, + "humidity": 86.05430221557617 + }, + { + "source": "COSMO_EUROPE", + "time": 1582236000000, + "hour": 46, + "duration": 1, + "type": "SLIGHT_RAIN_NOT_FREEZING", + "temperature": 7.030541992187523, + "windDirection": "NORTH", + "windSpeed": 7.882565205774747, + "cloudCoverage": 1, + "cloudDepth": 0.66558837890625, + "pressure": 999.1022265625, + "precipitation": 0.59375, + "snowDepth": 0, + "humidity": 87.29712295532227 + }, + { + "source": "COSMO_EUROPE", + "time": 1582239600000, + "hour": 47, + "duration": 1, + "type": "SLIGHT_RAIN_NOT_FREEZING", + "temperature": 5.375604248046898, + "windDirection": "EAST", + "windSpeed": 7.031090755931855, + "cloudCoverage": 1, + "cloudDepth": 0.598388671875, + "pressure": 1002.0277734375, + "precipitation": 0.541015625, + "snowDepth": 0, + "humidity": 85.62540340423584 + }, + { + "source": "ICON_EUROPE", + "time": 1582243200000, + "hour": 48, + "duration": 1, + "type": "SLIGHT_RAIN_NOT_FREEZING", + "temperature": 4.61536560058596, + "windDirection": "EAST", + "windSpeed": 9.408181826350738, + "cloudCoverage": 0.799774169921875, + "cloudDepth": 0.23760986328125, + "pressure": 1002.74421875, + "precipitation": 0.23828125, + "snowDepth": 0, + "humidity": 82.03206729888916 + }, + { + "source": "ICON_EUROPE", + "time": 1582246800000, + "hour": 49, + "duration": 1, + "type": "RAIN_SHOWER_SLIGHT", + "temperature": 3.9479003906250227, + "windDirection": "EAST", + "windSpeed": 8.02497981161178, + "cloudCoverage": 1, + "cloudDepth": 0.1483154296875, + "pressure": 1004.41640625, + "precipitation": 0.0234375, + "snowDepth": 0, + "humidity": 83.74258518218994 + }, + { + "source": "ICON_EUROPE", + "time": 1582250400000, + "hour": 50, + "duration": 1, + "type": "CLOUDY", + "temperature": 3.7913604736328352, + "windDirection": "EAST", + "windSpeed": 8.11302920535599, + "cloudCoverage": 0.75738525390625, + "cloudDepth": 0.0955810546875, + "pressure": 1005.773046875, + "precipitation": 0.005859375, + "snowDepth": 0, + "humidity": 74.14488220214844 + }, + { + "source": "ICON_EUROPE", + "time": 1582254000000, + "hour": 51, + "duration": 1, + "type": "PARTLY_CLOUDY", + "temperature": 3.7349945068359602, + "windDirection": "EAST", + "windSpeed": 7.463257247634742, + "cloudCoverage": 0.548248291015625, + "cloudDepth": 0.05560302734375, + "pressure": 1007.0249609375, + "precipitation": 0.009765625, + "snowDepth": 0, + "humidity": 72.56699562072754 + }, + { + "source": "ICON_EUROPE", + "time": 1582257600000, + "hour": 52, + "duration": 1, + "type": "PARTLY_CLOUDY", + "temperature": 3.6250091552734602, + "windDirection": "EAST", + "windSpeed": 7.618331098336812, + "cloudCoverage": 0.607086181640625, + "cloudDepth": 0.057586669921875, + "pressure": 1008.359375, + "precipitation": 0.013671875, + "snowDepth": 0, + "humidity": 73.25185108184814 + }, + { + "source": "ICON_EUROPE", + "time": 1582261200000, + "hour": 53, + "duration": 1, + "type": "PARTLY_CLOUDY", + "temperature": 3.5047698974609602, + "windDirection": "NORTH_EAST", + "windSpeed": 7.399443444946646, + "cloudCoverage": 0, + "cloudDepth": 0.05426025390625, + "pressure": 1009.511015625, + "precipitation": 0, + "snowDepth": 0, + "humidity": 73.86746597290039 + }, + { + "source": "ICON_EUROPE", + "time": 1582264800000, + "hour": 54, + "duration": 1, + "type": "PARTLY_CLOUDY", + "temperature": 3.3240295410156477, + "windDirection": "NORTH_EAST", + "windSpeed": 7.176583622638809, + "cloudCoverage": 0.035491943359375, + "cloudDepth": 0.040863037109375, + "pressure": 1010.48515625, + "precipitation": 0, + "snowDepth": 0, + "humidity": 75.04189682006836 + }, + { + "source": "ICON_EUROPE", + "time": 1582268400000, + "hour": 55, + "duration": 1, + "type": "PARTLY_CLOUDY", + "temperature": 3.4767700195312727, + "windDirection": "NORTH_EAST", + "windSpeed": 7.197519464516448, + "cloudCoverage": 0.632080078125, + "cloudDepth": 0.061279296875, + "pressure": 1012.0751171875, + "precipitation": 0, + "snowDepth": 0, + "humidity": 76.11064147949219 + }, + { + "source": "ICON_EUROPE", + "time": 1582272000000, + "hour": 56, + "duration": 1, + "type": "PARTLY_CLOUDY", + "temperature": 4.047814941406273, + "windDirection": "NORTH_EAST", + "windSpeed": 6.983266803576521, + "cloudCoverage": 0.577789306640625, + "cloudDepth": 0.056732177734375, + "pressure": 1013.190390625, + "precipitation": 0.001953125, + "snowDepth": 0, + "humidity": 75.54522800445557 + }, + { + "source": "ICON_EUROPE", + "time": 1582275600000, + "hour": 57, + "duration": 1, + "type": "PARTLY_CLOUDY", + "temperature": 4.681573486328148, + "windDirection": "NORTH_EAST", + "windSpeed": 7.253131282577595, + "cloudCoverage": 0.55474853515625, + "cloudDepth": 0.0643463134765625, + "pressure": 1013.9261328125, + "precipitation": 0, + "snowDepth": 0, + "humidity": 73.55618095397949 + }, + { + "source": "ICON_EUROPE", + "time": 1582279200000, + "hour": 58, + "duration": 1, + "type": "PARTLY_CLOUDY", + "temperature": 5.905267333984398, + "windDirection": "EAST", + "windSpeed": 8.73607378883157, + "cloudCoverage": 0.656890869140625, + "cloudDepth": 0.0599517822265625, + "pressure": 1014.537421875, + "precipitation": 0, + "snowDepth": 0, + "humidity": 68.3897008895874 + }, + { + "source": "ICON_EUROPE", + "time": 1582282800000, + "hour": 59, + "duration": 1, + "type": "PARTLY_CLOUDY", + "temperature": 6.843988037109398, + "windDirection": "EAST", + "windSpeed": 8.080565852610478, + "cloudCoverage": 0.421875, + "cloudDepth": 0.0472412109375, + "pressure": 1015.2880859375, + "precipitation": 0, + "snowDepth": 0, + "humidity": 62.876797676086426 + }, + { + "source": "ICON_EUROPE", + "time": 1582286400000, + "hour": 60, + "duration": 1, + "type": "CLOUDY", + "temperature": 7.28174743652346, + "windDirection": "EAST", + "windSpeed": 7.848156685418886, + "cloudCoverage": 0.8521728515625, + "cloudDepth": 0.1002197265625, + "pressure": 1015.296484375, + "precipitation": 0, + "snowDepth": 0, + "humidity": 60.676093101501465 + }, + { + "source": "ICON_EUROPE", + "time": 1582290000000, + "hour": 61, + "duration": 1, + "type": "CLOUDY", + "temperature": 7.19788513183596, + "windDirection": "EAST", + "windSpeed": 7.958626525781047, + "cloudCoverage": 1, + "cloudDepth": 0.294464111328125, + "pressure": 1015.35140625, + "precipitation": 0, + "snowDepth": 0, + "humidity": 58.86859130859375 + }, + { + "source": "ICON_EUROPE", + "time": 1582293600000, + "hour": 62, + "duration": 1, + "type": "CLOUDY", + "temperature": 7.519448852539085, + "windDirection": "EAST", + "windSpeed": 7.264683867453523, + "cloudCoverage": 1, + "cloudDepth": 0.16400146484375, + "pressure": 1015.544375, + "precipitation": 0, + "snowDepth": 0, + "humidity": 57.0074405670166 + }, + { + "source": "ICON_EUROPE", + "time": 1582297200000, + "hour": 63, + "duration": 1, + "type": "PARTLY_CLOUDY", + "temperature": 7.44635925292971, + "windDirection": "NORTH_EAST", + "windSpeed": 6.348729165177829, + "cloudCoverage": 0, + "cloudDepth": 0.016571044921875, + "pressure": 1015.7067578125, + "precipitation": 0, + "snowDepth": 0, + "humidity": 59.64937496185303 + }, + { + "source": "ICON_EUROPE", + "time": 1582300800000, + "hour": 64, + "duration": 1, + "type": "CLOUDY", + "temperature": 7.002709960937523, + "windDirection": "NORTH_EAST", + "windSpeed": 5.235427140176048, + "cloudCoverage": 0.69482421875, + "cloudDepth": 0.1011505126953125, + "pressure": 1015.651953125, + "precipitation": 0, + "snowDepth": 0, + "humidity": 64.6013879776001 + }, + { + "source": "ICON_EUROPE", + "time": 1582304400000, + "hour": 65, + "duration": 1, + "type": "CLOUDY", + "temperature": 6.123712158203148, + "windDirection": "NORTH_EAST", + "windSpeed": 4.802467007372629, + "cloudCoverage": 0.5889892578125, + "cloudDepth": 0.047088623046875, + "pressure": 1015.2789453125, + "precipitation": 0, + "snowDepth": 0, + "humidity": 70.22301387786865 + }, + { + "source": "ICON_EUROPE", + "time": 1582308000000, + "hour": 66, + "duration": 1, + "type": "CLOUDY", + "temperature": 5.884881591796898, + "windDirection": "NORTH_EAST", + "windSpeed": 5.1333521259656605, + "cloudCoverage": 0.964111328125, + "cloudDepth": 0.1331329345703125, + "pressure": 1015.1667578125, + "precipitation": 0, + "snowDepth": 0, + "humidity": 69.96502304077148 + }, + { + "source": "ICON_EUROPE", + "time": 1582311600000, + "hour": 67, + "duration": 1, + "type": "CLOUDY", + "temperature": 5.802163696289085, + "windDirection": "NORTH", + "windSpeed": 5.362272038686753, + "cloudCoverage": 1, + "cloudDepth": 0.18682861328125, + "pressure": 1014.9219921875, + "precipitation": 0, + "snowDepth": 0, + "humidity": 71.84583568572998 + }, + { + "source": "ICON_EUROPE", + "time": 1582315200000, + "hour": 68, + "duration": 1, + "type": "CLOUDY", + "temperature": 5.832009887695335, + "windDirection": "NORTH", + "windSpeed": 5.312617445023059, + "cloudCoverage": 1, + "cloudDepth": 0.2536773681640625, + "pressure": 1014.9343359375, + "precipitation": 0, + "snowDepth": 0, + "humidity": 71.63979911804199 + }, + { + "source": "ICON_EUROPE", + "time": 1582318800000, + "hour": 69, + "duration": 1, + "type": "CLOUDY", + "temperature": 5.921609497070335, + "windDirection": "NORTH", + "windSpeed": 5.616762177448687, + "cloudCoverage": 1, + "cloudDepth": 0.324371337890625, + "pressure": 1014.8356640625, + "precipitation": 0, + "snowDepth": 0, + "humidity": 69.59465789794922 + }, + { + "source": "ICON_EUROPE", + "time": 1582322400000, + "hour": 70, + "duration": 1, + "type": "CLOUDY", + "temperature": 5.854882812500023, + "windDirection": "NORTH", + "windSpeed": 6.455896989613617, + "cloudCoverage": 1, + "cloudDepth": 0.2362213134765625, + "pressure": 1014.068515625, + "precipitation": 0, + "snowDepth": 0, + "humidity": 67.04736423492432 + }, + { + "source": "ICON_EUROPE", + "time": 1582326000000, + "hour": 71, + "duration": 1, + "type": "CLOUDY", + "temperature": 5.57642517089846, + "windDirection": "NORTH", + "windSpeed": 6.892169287353283, + "cloudCoverage": 0.461578369140625, + "cloudDepth": 0.0794525146484375, + "pressure": 1012.4749609375, + "precipitation": 0, + "snowDepth": 0, + "humidity": 64.83550834655762 + }, + { + "source": "ICON_EUROPE", + "time": 1582329600000, + "hour": 72, + "duration": 1, + "type": "CLOUDY", + "temperature": 5.445169067382835, + "windDirection": "NORTH", + "windSpeed": 7.073366022266183, + "cloudCoverage": 1, + "cloudDepth": 0.252166748046875, + "pressure": 1011.4680078125, + "precipitation": 0, + "snowDepth": 0, + "humidity": 64.8010368347168 + }, + { + "source": "ICON_EUROPE", + "time": 1582333200000, + "hour": 73, + "duration": 1, + "type": "CLOUDY", + "temperature": 5.443933105468773, + "windDirection": "NORTH", + "windSpeed": 7.186693454283655, + "cloudCoverage": 0.7508544921875, + "cloudDepth": 0.135345458984375, + "pressure": 1011.120625, + "precipitation": 0, + "snowDepth": 0, + "humidity": 65.19682884216309 + }, + { + "source": "ICON_EUROPE", + "time": 1582336800000, + "hour": 74, + "duration": 1, + "type": "CLOUDY", + "temperature": 5.14307556152346, + "windDirection": "NORTH", + "windSpeed": 7.108064325198071, + "cloudCoverage": 0.704925537109375, + "cloudDepth": 0.125335693359375, + "pressure": 1009.7385546875, + "precipitation": 0, + "snowDepth": 0, + "humidity": 67.68143653869629 + }, + { + "source": "ICON_EUROPE", + "time": 1582340400000, + "hour": 75, + "duration": 1, + "type": "CLOUDY", + "temperature": 4.852883911132835, + "windDirection": "NORTH", + "windSpeed": 7.206421447503431, + "cloudCoverage": 0.341400146484375, + "cloudDepth": 0.03741455078125, + "pressure": 1008.5263671875, + "precipitation": 0, + "snowDepth": 0, + "humidity": 70.21164894104004 + }, + { + "source": "ICON_EUROPE", + "time": 1582344000000, + "hour": 76, + "duration": 1, + "type": "CLOUDY", + "temperature": 4.70673522949221, + "windDirection": "NORTH", + "windSpeed": 7.333119201005621, + "cloudCoverage": 0.787384033203125, + "cloudDepth": 0.1987457275390625, + "pressure": 1007.5005859375, + "precipitation": 0.23828125, + "snowDepth": 0, + "humidity": 71.41692733764648 + }, + { + "source": "ICON_EUROPE", + "time": 1582347600000, + "hour": 77, + "duration": 1, + "type": "SLIGHT_RAIN_NOT_FREEZING", + "temperature": 4.621179199218773, + "windDirection": "NORTH", + "windSpeed": 7.988178016662432, + "cloudCoverage": 1, + "cloudDepth": 0.52972412109375, + "pressure": 1005.875859375, + "precipitation": 0.328125, + "snowDepth": 0, + "humidity": 74.46730041503906 + }, + { + "source": "ICON_EUROPE", + "time": 1582351200000, + "hour": 78, + "duration": 3, + "type": "SLIGHT_RAIN_NOT_FREEZING", + "temperature": 4.477655029296898, + "windDirection": "NORTH", + "windSpeed": 8.991064584189703, + "cloudCoverage": 0.925201416015625, + "cloudDepth": 0.2941741943359375, + "pressure": 1004.7434375, + "precipitation": 0.35546875, + "snowDepth": 0, + "humidity": 76.36370372772217 + }, + { + "source": "ICON_EUROPE", + "time": 1582362000000, + "hour": 81, + "duration": 3, + "type": "CLOUDY", + "temperature": 5.536340332031273, + "windDirection": "NORTH", + "windSpeed": 9.746842294939912, + "cloudCoverage": 1, + "cloudDepth": 0.260589599609375, + "pressure": 1003.450703125, + "precipitation": 0.09765625, + "snowDepth": 0, + "humidity": 76.17162132263184 + }, + { + "source": "ICON_EUROPE", + "time": 1582372800000, + "hour": 84, + "duration": 3, + "type": "CLOUDY", + "temperature": 8.398797607421898, + "windDirection": "NORTH_EAST", + "windSpeed": 8.717114303604117, + "cloudCoverage": 1, + "cloudDepth": 0.497161865234375, + "pressure": 1003.261484375, + "precipitation": 0.4453125, + "snowDepth": 0, + "humidity": 76.58806610107422 + }, + { + "source": "ICON_EUROPE", + "time": 1582383600000, + "hour": 87, + "duration": 3, + "type": "RAIN_SHOWER_SLIGHT", + "temperature": 8.19776306152346, + "windDirection": "EAST", + "windSpeed": 8.554506495823622, + "cloudCoverage": 0.976959228515625, + "cloudDepth": 0.2940826416015625, + "pressure": 1004.0562109375, + "precipitation": 0.51171875, + "snowDepth": 0, + "humidity": 78.56856918334961 + }, + { + "source": "ICON_EUROPE", + "time": 1582394400000, + "hour": 90, + "duration": 3, + "type": "CLOUDY", + "temperature": 7.650064086914085, + "windDirection": "EAST", + "windSpeed": 7.694203326836782, + "cloudCoverage": 0.657379150390625, + "cloudDepth": 0.1304931640625, + "pressure": 1005.7823046875, + "precipitation": 0.09375, + "snowDepth": 0, + "humidity": 65.59254789352417 + }, + { + "source": "ICON_EUROPE", + "time": 1582405200000, + "hour": 93, + "duration": 3, + "type": "CLOUDY", + "temperature": 7.26966247558596, + "windDirection": "EAST", + "windSpeed": 6.480638924511119, + "cloudCoverage": 0.993865966796875, + "cloudDepth": 0.184967041015625, + "pressure": 1006.295703125, + "precipitation": 0.1484375, + "snowDepth": 0, + "humidity": 72.07868003845215 + }, + { + "source": "ICON_EUROPE", + "time": 1582416000000, + "hour": 96, + "duration": 3, + "type": "CLOUDY", + "temperature": 7.33106384277346, + "windDirection": "EAST", + "windSpeed": 7.00092940463385, + "cloudCoverage": 0.87896728515625, + "cloudDepth": 0.22344970703125, + "pressure": 1007.2784375, + "precipitation": 0, + "snowDepth": 0, + "humidity": 74.30420875549316 + }, + { + "source": "ICON_EUROPE", + "time": 1582426800000, + "hour": 99, + "duration": 3, + "type": "PARTLY_CLOUDY", + "temperature": 7.144250488281273, + "windDirection": "EAST", + "windSpeed": 7.458231378305742, + "cloudCoverage": 0, + "cloudDepth": 0.029510498046875, + "pressure": 1006.995625, + "precipitation": 0.171875, + "snowDepth": 0, + "humidity": 78.91228008270264 + }, + { + "source": "ICON_EUROPE", + "time": 1582437600000, + "hour": 102, + "duration": 3, + "type": "SLIGHT_RAIN_NOT_FREEZING", + "temperature": 6.412881469726585, + "windDirection": "NORTH_EAST", + "windSpeed": 5.747903846369714, + "cloudCoverage": 0, + "cloudDepth": 0.13128662109375, + "pressure": 1005.40921875, + "precipitation": 1.8359375, + "snowDepth": 0, + "humidity": 86.54897022247314 + }, + { + "source": "ICON_EUROPE", + "time": 1582448400000, + "hour": 105, + "duration": 3, + "type": "SLIGHT_RAIN_NOT_FREEZING", + "temperature": 7.238458251953148, + "windDirection": "NORTH", + "windSpeed": 4.39687667564416, + "cloudCoverage": 0.966888427734375, + "cloudDepth": 0.678558349609375, + "pressure": 1001.7380078125, + "precipitation": 4.5078125, + "snowDepth": 0, + "humidity": 91.06858539581299 + }, + { + "source": "ICON_EUROPE", + "time": 1582459200000, + "hour": 108, + "duration": 3, + "type": "SLIGHT_RAIN_NOT_FREEZING", + "temperature": 11.224114990234398, + "windDirection": "NORTH_EAST", + "windSpeed": 10.750425099103504, + "cloudCoverage": 0.8968505859375, + "cloudDepth": 0.405364990234375, + "pressure": 996.81453125, + "precipitation": 2.30859375, + "snowDepth": 0, + "humidity": 90.17226219177246 + }, + { + "source": "ICON_EUROPE", + "time": 1582470000000, + "hour": 111, + "duration": 3, + "type": "SLIGHT_RAIN_NOT_FREEZING", + "temperature": 12.025308227539085, + "windDirection": "EAST", + "windSpeed": 11.182452244027852, + "cloudCoverage": 1, + "cloudDepth": 0.46600341796875, + "pressure": 996.5350390625, + "precipitation": 3.859375, + "snowDepth": 0, + "humidity": 89.19748973846436 + }, + { + "source": "ICON_EUROPE", + "time": 1582480800000, + "hour": 114, + "duration": 3, + "type": "SLIGHT_RAIN_NOT_FREEZING", + "temperature": 11.765313720703148, + "windDirection": "EAST", + "windSpeed": 9.421301771931196, + "cloudCoverage": 1, + "cloudDepth": 0.7510986328125, + "pressure": 998.096953125, + "precipitation": 3.54296875, + "snowDepth": 0, + "humidity": 90.33589839935303 + }, + { + "source": "ICON_EUROPE", + "time": 1582491600000, + "hour": 117, + "duration": 3, + "type": "SLIGHT_RAIN_NOT_FREEZING", + "temperature": 10.894387817382835, + "windDirection": "SOUTH_EAST", + "windSpeed": 7.761788226414812, + "cloudCoverage": 0.926666259765625, + "cloudDepth": 0.461090087890625, + "pressure": 999.9401171875, + "precipitation": 2.4296875, + "snowDepth": 0, + "humidity": 90.03968715667725 + } + ] +} +""".data(using: .utf8)! diff --git a/ios-app/app/Data/Environment/NewFavoriteLocations.swift b/ios-app/app/Data/Environment/NewFavoriteLocations.swift index b98405c6..4e526890 100644 --- a/ios-app/app/Data/Environment/NewFavoriteLocations.swift +++ b/ios-app/app/Data/Environment/NewFavoriteLocations.swift @@ -15,12 +15,13 @@ import CoreData class NewFavoriteLocation: ObservableObject { typealias MowestaState = MowestaApi.State - let objectWillChange = ObservableObjectPublisher() - static var shared: NewFavoriteLocation = NewFavoriteLocation() + //let objectWillChange = ObservableObjectPublisher() + public static let shared = NewFavoriteLocation() private static var identifier: String = "com.mowesta.favorites" private var currentPorcessedLocation: CDLocation? - let appDelegate = UIApplication.shared.delegate as! AppDelegate; + + private let appDelegate = UIApplication.shared.delegate as! AppDelegate; @Published var savedFavorites: [SavedMowestaFavorites] { didSet { @@ -54,6 +55,11 @@ class NewFavoriteLocation: ObservableObject { managedContext.delete(location) } + public func deleteForecast(_ forecast: CDWeatherForecast) { + let managedContext = appDelegate.persistentContainer.viewContext + managedContext.delete(forecast) + } + public func deleteLocation(_ location: LocationHierarchy) { // TODO Delete on CD guard let index = try? self.savedFavorites.firstIndex(where: {$0.id == location._id}) @@ -64,7 +70,14 @@ class NewFavoriteLocation: ObservableObject { } public func update(_ location: CDLocation) { - WeatherAPI.getForecast(_id: location.id, completion: self.addWeatherForecast) + //NSLog("called update Location") + currentPorcessedLocation = location + /* if (location.forecast != nil) + { + deleteForecast(location.forecast!) + }*/ + DataManager.shared.processedLocation = location + WeatherAPI.getCityForecast(_id: location.id, completion: DataManager.shared.updateWeatherForecast) } public func deleteLocation(at index: Int) { @@ -84,34 +97,12 @@ class NewFavoriteLocation: ObservableObject { //maybe handle } if (city != nil) { - let managedContext = appDelegate.persistentContainer.viewContext - let addloc = CDLocation(context: managedContext) - addloc.capital = city?.capital ?? false - addloc.creationTime = city?.creationTime ?? 0 - addloc.id = city!._id! - addloc.markedDeleted = city?.deleted ?? false - addloc.modificationTime = city?.modificationTime ?? 0 - addloc.population = Int64(city?.population ?? 0) - addloc.timezone = city?.timezone ?? "+0" - addloc.type = city!.type.rawValue - addloc.wikipedia = city?.wikipedia ?? "" - - for (key, value) in city!.names { - createCDNamesDictionary(for: key, with: value, in: addloc) - } - - do { - try managedContext.save() - currentPorcessedLocation = addloc - WeatherAPI.getForecast(_id: addloc.id, completion: self.addWeatherForecast) - } catch let error as NSError { - print("Could not save. \(error), \(error.userInfo)") - } + DataManager.shared.updateLocation(for: city!) } } private func createCDWeatherCondition(for condidtion: WeatherCondition, in forecast: CDWeatherForecast) -> CDWeatherCondition { - let managedContext = appDelegate.persistentContainer.viewContext + let managedContext = appDelegate.persistentContainer.viewContext let cond = CDWeatherCondition(context: managedContext) cond.cloudCoverage = condidtion.cloudCoverage cond.cloudDepth = condidtion.cloudDepth @@ -137,73 +128,16 @@ class NewFavoriteLocation: ObservableObject { named.key = key named.value = value named.location = location - NSLog(named.description); + //NSLog(named.description); return named } - private func addWeatherForecast(forecast: WeatherForecast?, error: Error?) { - if (error != nil) { - //maybe handle - } - if (forecast != nil) { - //get Context - let managedContext = appDelegate.persistentContainer.viewContext - let fore = CDWeatherForecast(context: managedContext) - fore.creationTime = forecast?.creationTime ?? 0 - fore.id = forecast!._id! - fore.markedDeleted = forecast?.deleted ?? false - fore.modificationTime = forecast?.modificationTime ?? 0 - fore.plantCoverage = forecast?.plantCoverage ?? 0 - fore.soilType = forecast?.soilType.rawValue ?? "" - fore.source = forecast?.source.rawValue ?? "" - fore.surfaceHeight = forecast?.surfaceHeight ?? 0 - fore.location = currentPorcessedLocation - currentPorcessedLocation?.forecast = fore - - for condition in forecast!.conditions { - createCDWeatherCondition(for: condition, in: fore) - } - - - do { - try managedContext.save() - self.objectWillChange.send() - // NSLog(currentPorcessedLocation?.forecast?.conditions?.description ?? "") - - } catch let error as NSError { - print("Could not save. \(error), \(error.userInfo)") - } - - - } - - - } - private func addLocation(state: MowestaState?, error: Error?) { if (error != nil) { //maybe handle } if (state != nil) { - let managedContext = appDelegate.persistentContainer.viewContext - let addloc = CDLocation(context: managedContext) - addloc.capital = false - addloc.id = state!._id! - addloc.creationTime = state?.creationTime ?? 0 - addloc.markedDeleted = state?.deleted ?? false - addloc.modificationTime = state?.modificationTime ?? 0 - addloc.population = Int64(state?.population ?? 0) - addloc.timezone = state?.timezone ?? "+0" - addloc.type = "STATE" - addloc.wikipedia = state?.wikipedia ?? "" - - do { - try managedContext.save() - currentPorcessedLocation = addloc - WeatherAPI.getForecast(_id: addloc.id, completion: self.addWeatherForecast) - } catch let error as NSError { - print("Could not save. \(error), \(error.userInfo)") - } + DataManager.shared.updateLocation(for: state!) } } @@ -229,22 +163,22 @@ class NewFavoriteLocation: ObservableObject { public func toggleLocation(_ location: CDLocation) { if let index = savedFavorites.firstIndex(where: { $0.id == location.id}) { - // TODO Delete on CD - savedFavorites.remove(at: index) - } else { - + // TODO Delete on CD + savedFavorites.remove(at: index) + } else { + switch location.type { - case LocationHierarchy.ModelType.city.rawValue: - LocationAPI.getCity(_id: location.id, completion: self.addLocation) - case LocationHierarchy.ModelType.state.rawValue: + case LocationHierarchy.ModelType.city.rawValue: + LocationAPI.getCity(_id: location.id, completion: self.addLocation) + case LocationHierarchy.ModelType.state.rawValue: LocationAPI.getState(_id: location.id, completion: self.addLocation) case LocationHierarchy.ModelType.country.rawValue: break default: - break + break } savedFavorites.append(SavedMowestaFavorites(id: location.id, type: location.type!)) - } - } + } + } } class SavedMowestaFavorites: Codable, Identifiable { diff --git a/ios-app/app/Data/LocationsExtensions.swift b/ios-app/app/Data/LocationsExtensions.swift index f6dd8ee8..e7919af3 100644 --- a/ios-app/app/Data/LocationsExtensions.swift +++ b/ios-app/app/Data/LocationsExtensions.swift @@ -21,29 +21,6 @@ enum Language : String { case DEFAULT } -extension City : Hashable, LocationName { - - public static func == (lhs: City, rhs: City) -> Bool { - return lhs._id == rhs._id - } - - public func hash(into hasher: inout Hasher) { - hasher.combine(names) - 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 { public static func == (lhs: State, rhs: State) -> Bool { diff --git a/ios-app/app/Data/User/UserData.swift b/ios-app/app/Data/User/UserData.swift new file mode 100644 index 00000000..38060d48 --- /dev/null +++ b/ios-app/app/Data/User/UserData.swift @@ -0,0 +1,140 @@ +// +// UserData.swift +// app +// +// Created by Sebastian Pobel on 16.12.19. +// Copyright © 2019 Marcus Handte. All rights reserved. +// + +import Foundation +import KeychainSwift +import MowestaApi + +/* + This class provides user information like name and password. + This credentials are needed for accessing mowesta server. + As this information must be kept secret, it is encrypted and secured in the keychain. + @author Sebastian.Pobel + */ +class UserData: ObservableObject { + + static let shared = UserData() + + @Published var loginName: String = "" + @Published var humanName: String? = nil + @Published var password: String = "" + @Published var loggedIn: Bool = false + @Published var agreedToS: Bool = false + + let keyChain = KeychainSwift() + + private init(loginName: String? = nil, password: String? = nil, humanName: String? = nil, loggedIn: Bool? = nil, agreedToS: Bool? = nil) { + self.loginName = loginName ?? keyChain.get(PropertyKey.user.loginName) ?? self.loginName + self.humanName = humanName ?? keyChain.get(PropertyKey.user.humanName) ?? self.humanName + self.password = password ?? keyChain.get(PropertyKey.user.password) ?? self.password + self.loggedIn = loggedIn ?? keyChain.getBool(PropertyKey.user.loggedIn) ?? self.loggedIn + self.agreedToS = loggedIn ?? keyChain.getBool(PropertyKey.user.agreedToS) ?? self.agreedToS + NSLog("load user \(self.loginName)") + } + + func login(onSuccess: @escaping () -> Void, onError: @escaping () -> Void) { + NSLog("try login user") + // 1. no usercredentials? + if (loginName == "" || password == "") { + return onError() + } + // 2. set credentials for user login + SwaggerApi.shared.loginUser(self) + // 3. test if credentials are ok + UserAPI.getCurrentUser(completion: { + self.didLogin(user: $0, error: $1, onSuccess: onSuccess, onError: onError) + }) + } + + func agreeToS() { + self.agreedToS = true + self.persist() + } + + func disagreeToS() { + self.agreedToS = false + self.persist() + } + + func logout() { + NSLog("user logout") + DataManager.shared.deleteAllDevices() + SwaggerApi.shared.logoutUser() + self.reset() + } + + func pairDevice() { + if loggedIn && DeviceData.shared.created { + DeviceAPI.setCurrentDeviceUser(completion: {d, err in + if let error = err { + NSLog("\(error)") + } + DataManager.shared.loadDevicesFromServer() + }) + } + } + + func register(registration: UserRegistration, onSuccess: @escaping () -> Void, onError: @escaping () -> Void) { + UserAPI.registerUser(body: registration, completion: { + self.didLogin(user: $0, error: $1, onSuccess: onSuccess, onError: onError) + }) + } + + private func didLogin(user: User?, error: Error?, onSuccess: @escaping () -> Void, onError: @escaping () -> Void) { + if let u = user { + self.humanName = u.name + self.loggedIn = true + self.persist() + + NSLog("user login successful") + onSuccess() + DataManager.shared.loadDevicesFromServer() + return + } else { + SwaggerApi.shared.logoutUser() + if error != nil { + NSLog("\(error!)") + onError() + } + } + } + + private func persist() { + keyChain.set(self.loginName, forKey: PropertyKey.user.loginName) + keyChain.set(self.humanName!, forKey: PropertyKey.user.humanName) + keyChain.set(self.password, forKey: PropertyKey.user.password) + keyChain.set(self.loggedIn, forKey: PropertyKey.user.loggedIn) + keyChain.set(self.agreedToS, forKey: PropertyKey.user.agreedToS) + + NSLog("persisted user \(self.loginName)") + } + + private func reset() { + keyChain.delete(PropertyKey.user.loginName) + keyChain.delete(PropertyKey.user.humanName) + keyChain.delete(PropertyKey.user.password) + keyChain.delete(PropertyKey.user.loggedIn) + keyChain.delete(PropertyKey.user.agreedToS) + loginName = "" + humanName = nil + password = "" + loggedIn = false + agreedToS = false + + NSLog("reseted user") + } +} + +#if DEBUG +extension UserData { + static let mockLoggedOut = UserData(loggedIn: false) + static let mockLoggedIn = UserData(loggedIn: true) + static let mockEmpty = UserData() + static let adminUser = UserData(loginName: "admin", password: "admin", humanName: "Administrator", loggedIn: true) +} +#endif diff --git a/ios-app/app/Extensions/City+Extension.swift b/ios-app/app/Extensions/City+Extension.swift new file mode 100644 index 00000000..88aaf4fa --- /dev/null +++ b/ios-app/app/Extensions/City+Extension.swift @@ -0,0 +1,43 @@ +// +// City+Extension.swift +// app +// +// Created by Tobias Stottrop on 30.01.20. +// Copyright © 2020 Marcus Handte. All rights reserved. +// + +import Foundation +import MowestaApi + +extension City : Hashable, LocationName { + + public static func == (lhs: City, rhs: City) -> Bool { + return lhs._id == rhs._id + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(names) + hasher.combine(coordinate.longitude) + hasher.combine(coordinate.latitude) + } + + func getSubName() -> String { + var subname = "" + if (self.state != nil) { + subname.append(contentsOf: (state?.getName())!) + subname.append(contentsOf: " · ") + } + subname.append(contentsOf: self.country.getName()) + return subname; + } + + public func getMillisecondsFromGMT() -> Int { + NSLog("The timezone: \(self.timezone)") + switch self.timezone { + case "+1": + return 3600 * 1000 + default: + return 0 + } + } +} diff --git a/ios-app/app/Extensions/Coordinate+Extensions.swift b/ios-app/app/Extensions/Coordinate+Extensions.swift new file mode 100644 index 00000000..67be8419 --- /dev/null +++ b/ios-app/app/Extensions/Coordinate+Extensions.swift @@ -0,0 +1,31 @@ +// +// CoordinateExtensions.swift +// app +// +// Created by Sebastian Pobel on 27.01.20. +// Copyright © 2020 Marcus Handte. All rights reserved. +// + +import Foundation +import MowestaApi + +extension Coordinate: Hashable { + + public func equal2dezimals(coordinate: Coordinate) -> Bool { + return self.twoDezimals() == coordinate.twoDezimals() + } + + public func twoDezimals() -> Coordinate { + Coordinate(latitude: Double(round(100 * self.latitude) / 100), longitude: Double(round(100 * self.longitude) / 100)) + } + + public static func == (lhs: Coordinate, rhs: Coordinate) -> Bool { + return lhs.longitude == rhs.longitude + && lhs.latitude == rhs.latitude + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(longitude) + hasher.combine(latitude) + } +} diff --git a/ios-app/app/Extensions/DateExtensions.swift b/ios-app/app/Extensions/Date+Extensions.swift similarity index 100% rename from ios-app/app/Extensions/DateExtensions.swift rename to ios-app/app/Extensions/Date+Extensions.swift diff --git a/ios-app/app/Extensions/DeviceOsExtension.swift b/ios-app/app/Extensions/DeviceOs+Extension.swift similarity index 100% rename from ios-app/app/Extensions/DeviceOsExtension.swift rename to ios-app/app/Extensions/DeviceOs+Extension.swift diff --git a/ios-app/app/Extensions/Double+Extension.swift b/ios-app/app/Extensions/Double+Extension.swift new file mode 100644 index 00000000..80e1d049 --- /dev/null +++ b/ios-app/app/Extensions/Double+Extension.swift @@ -0,0 +1,24 @@ +// +// Double+Extension.swift +// app +// +// Created by Tobias Stottrop on 30.01.20. +// Copyright © 2020 Marcus Handte. All rights reserved. +// + +import Foundation + +extension Double { + func round(to places: Int) -> Double { + let divisor = pow(10.0, Double(places)) + return (self * divisor).rounded() / divisor + } + + func removeZerosFromEnd() -> String { + let formatter = NumberFormatter() + let number = NSNumber(value: self) + formatter.minimumFractionDigits = 0 + formatter.maximumFractionDigits = 16 //maximum digits in Double after dot (maximum precision) + return String(formatter.string(from: number) ?? "") + } +} diff --git a/ios-app/app/Extensions/StringExtensions.swift b/ios-app/app/Extensions/String+Extensions.swift similarity index 100% rename from ios-app/app/Extensions/StringExtensions.swift rename to ios-app/app/Extensions/String+Extensions.swift diff --git a/ios-app/app/Extensions/UIDeviceExtensions.swift b/ios-app/app/Extensions/UIDevice+Extensions.swift similarity index 100% rename from ios-app/app/Extensions/UIDeviceExtensions.swift rename to ios-app/app/Extensions/UIDevice+Extensions.swift diff --git a/ios-app/app/Extensions/ViewExtensions.swift b/ios-app/app/Extensions/View+Extensions.swift similarity index 92% rename from ios-app/app/Extensions/ViewExtensions.swift rename to ios-app/app/Extensions/View+Extensions.swift index 01b7057c..c1cccf90 100644 --- a/ios-app/app/Extensions/ViewExtensions.swift +++ b/ios-app/app/Extensions/View+Extensions.swift @@ -32,6 +32,10 @@ extension View { func resignKeyboardOnDragGesture() -> some View { return modifier(ResignKeyboardOnDragGesture()) } + + func eraseToAnyView () -> AnyView { + AnyView(self) + } } extension Font { diff --git a/ios-app/app/ContentView.swift b/ios-app/app/MainTabView.swift similarity index 83% rename from ios-app/app/ContentView.swift rename to ios-app/app/MainTabView.swift index 134a6b30..b8c2139c 100644 --- a/ios-app/app/ContentView.swift +++ b/ios-app/app/MainTabView.swift @@ -8,7 +8,7 @@ import SwiftUI -struct ContentView: View { +struct MainTabView: View { @UIState private var selectedTab = 1 var body: some View { @@ -26,14 +26,14 @@ struct ContentView: View { Group { Image(systemName: selectedTab == 1 ? "heart.fill" : "heart") - Text("Favorites") + Text("Favorite_NavigationBarTitle") }.font(Font.system(size: 25)) }.tag(1) SearchTab() .tabItem{ Group { Image(systemName: "magnifyingglass") - Text("Search") + Text("Search_NavigationBarTitle") }.font(Font.system(size: 25)) }.tag(2) } @@ -45,8 +45,8 @@ struct ContentView: View { struct ContentView_Previews : PreviewProvider { static var previews: some View { - ContentView() - .environmentObject(FavoriteLocations(locations: [locationEssen])) + MainTabView() + //.environmentObject(FavoriteLocations(locations: [locationEssen])) .environmentObject(UserData.mockEmpty) } } diff --git a/ios-app/app/Resources/Mowesta.xcdatamodeld/Mowesta.xcdatamodel/contents b/ios-app/app/Resources/Mowesta.xcdatamodeld/Mowesta.xcdatamodel/contents index 78b64656..a44266da 100644 --- a/ios-app/app/Resources/Mowesta.xcdatamodeld/Mowesta.xcdatamodel/contents +++ b/ios-app/app/Resources/Mowesta.xcdatamodeld/Mowesta.xcdatamodel/contents @@ -1,5 +1,5 @@ - + @@ -66,17 +66,17 @@ - - - - - - - - - + + + + + + + + + - + @@ -93,7 +93,7 @@ - + @@ -113,7 +113,7 @@ - + - \ No newline at end of file + diff --git a/ios-app/app/SceneDelegate.swift b/ios-app/app/SceneDelegate.swift index a7a814ab..6ce33cd5 100644 --- a/ios-app/app/SceneDelegate.swift +++ b/ios-app/app/SceneDelegate.swift @@ -14,7 +14,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? - let favorites = FavoriteLocations(locations: [locationEssen]) + //let favorites = FavoriteLocations(locations: [locationEssen]) func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. @@ -30,16 +30,18 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { // logout user if not possible due to wrong credentials // in fact of no connection 404 etc. we should show error screen to start later UserData.shared.login(onSuccess: {}, onError: {}) - + let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext // Create the SwiftUI view that provides the window content - let contentView = ContentView() - .environment(\.managedObjectContext, context) - .environmentObject(NewFavoriteLocation.shared) - .environmentObject(UserData.shared) - .environmentObject(DeviceData.shared) - .environmentObject(favorites) - + let state = NavigationStack(firstState: AuthState.ToSScreen) + let contentView = AppRootView() + .environment(\.managedObjectContext, context) + .environmentObject(NewFavoriteLocation.shared) + .environmentObject(UserData.shared) + .environmentObject(DeviceData.shared) + .environmentObject(state) + //.environmentObject(favorites) + // Use a UIHostingController as window root view controller. if let windowScene = scene as? UIWindowScene { let window = UIWindow(windowScene: windowScene) diff --git a/ios-app/app/View/Favorite/FavoriteDetail.swift b/ios-app/app/View/Favorite/FavoriteDetail.swift index b260cd6a..ce16afd3 100644 --- a/ios-app/app/View/Favorite/FavoriteDetail.swift +++ b/ios-app/app/View/Favorite/FavoriteDetail.swift @@ -10,25 +10,7 @@ import SwiftUI struct FavoriteDetail: View { @EnvironmentObject var favorites: NewFavoriteLocation - var location: CDLocation? - - - - private func getCurrentCDWeatherCondition() -> some View { - guard ((location?.forecast?.conditions) != nil) - else { - return FavoriteHeaderView() - } - for case let item as CDWeatherCondition in (location?.forecast!.conditions)! { - let epochInMS = Date().timeIntervalSince1970 * 1000; - let withGMT = epochInMS + (self.location?.getMillisecondsFromGMT() ?? 0 ) - if (Int64(withGMT) > item.time && Int64(withGMT) <= ((item.time + Int64(item.duration * 3600 * 1000)))) { - return FavoriteHeaderView(condition: item) - } - - } - return FavoriteHeaderView() - } + var location: CDLocation func getTodayView() -> some View { return FavoriteTodayView(location: location) @@ -41,57 +23,57 @@ struct FavoriteDetail: View { var body: some View { - ScrollView { - - VStack(alignment: .leading) { + ScrollView { + + VStack(alignment: .leading) { Text("Now") .font(.headline) .padding(10) Card { - self.getCurrentCDWeatherCondition() + FavoriteHeaderView(location: self.location) }.padding(10) - } - - VStack(alignment: .leading) { + } + + VStack(alignment: .leading) { Text("Today") .font(.headline) .padding(10) Card { self.getTodayView() }.padding(10) - } - + } - VStack(alignment: .leading) { + + VStack(alignment: .leading) { Text("Next Days") .font(.headline) .padding(10) Card { - self.getNextDaysView() + FavoritesNextDaysView(location: self.location) }.padding(10) - } } - - .navigationBarTitle(location?.getName() ?? "N/A") - .navigationBarItems(trailing: - VStack { - Button(action: { - if (self.location != nil) { - self.favorites.toggleLocation(self.location!) - } - }) { - Image(systemName: (self.favorites.savedFavorites.first(where: {$0.id == location?.id}) != nil) ? "heart.fill" : "heart") - .foregroundColor(Color.red) - .font(Font.system(size: 25)) + } + + .navigationBarTitle(location.getName() ?? "N/A") + .navigationBarItems(trailing: + VStack { + Button(action: { + if (self.location != nil) { + self.favorites.toggleLocation(self.location) } - }) - .onAppear(perform: self.fetch) + }) { + Image(systemName: (self.favorites.savedFavorites.first(where: {$0.id == location.id}) != nil) ? "heart.fill" : "heart") + .foregroundColor(Color.red) + .font(Font.system(size: 25)) + } + }) + .onAppear(perform: self.fetch) } private func fetch() { - if (location != nil) { - favorites.update(location!) - } + + // NSLog("FavoriteDetail: \(location)") + favorites.update(location) } } diff --git a/ios-app/app/View/Favorite/FavoriteHeaderView.swift b/ios-app/app/View/Favorite/FavoriteHeaderView.swift index 8fe7f8f9..2bf05f7c 100644 --- a/ios-app/app/View/Favorite/FavoriteHeaderView.swift +++ b/ios-app/app/View/Favorite/FavoriteHeaderView.swift @@ -5,46 +5,109 @@ // Created by Tobias Stottrop on 27.01.20. // Copyright © 2020 Marcus Handte. All rights reserved. // - import SwiftUI +import MowestaApi struct FavoriteHeaderView: View { - var condition: CDWeatherCondition? + var location: CDLocation + @UIState var condition: WeatherCondition = moc_condition_empty - func getDateAsString() -> String { - - let formatter = DateFormatter() - formatter.locale = Locale(identifier: "de_DE") - formatter.dateStyle = .medium - formatter.timeStyle = .short - + func getWeatherCondition(condition: WeatherCondition?, error: Error?) { if (condition != nil) { - let unixTime = Double(condition!.time)/1000 - let date = Date(timeIntervalSince1970: unixTime) - return formatter.string(from: date) + //NSLog("condition: \(condition)") + self.condition = condition! } - return formatter.string(from: Date()) + } + + func updateCondition() { + //NSLog("update condition: \(location.id)") + WeatherAPI.getCityCondition(_id: location.id, completion: getWeatherCondition) } var body: some View { - VStack(alignment: .leading) { - Text(getDateAsString()) + VStack (alignment: .leading) { HStack { + Image(systemName: condition.getWeatherTypeImageName()) Spacer() - HStack(alignment: .center, spacing: 16) { - Image(systemName: condition?.type ?? "questionmark") - .font(.largeTitle) - Text("\(String(Int(condition?.temperature ?? 0)))°") - .font(.largeTitle) - } - Spacer() + Text("Aktuelles Wetter") + .font(.title) + .bold() } - HStack { - Image(systemName: "wind") - Image(systemName: condition?.windDirection ?? "questionmark") Spacer() - Text("\(condition?.windSpeed ?? 0) km/h") - } + HStack { + Text("Temperatur") + .font(.subheadline) + .bold() + Spacer() + Text("\(condition.temperature.round(to: 0).removeZerosFromEnd())°C / \((condition.temperature*(9/5)+32).round(to: 0).removeZerosFromEnd())°F") + .font(.caption) + .bold() + } + HStack { + Text("Windstärke") + .font(.subheadline) + .bold() + Spacer() + Image(systemName: condition.getWindDirectionImageName()) + Text("\(condition.windSpeed.round(to: 0).removeZerosFromEnd()) m/s") + .font(.caption) + .bold() + } + HStack { + Text("Luftfeuchtigkeit") + .font(.subheadline) + .bold() + Spacer() + Text("\(condition.humidity.round(to: 0).removeZerosFromEnd()) %") + .font(.caption) + .bold() + } + HStack { + Text("Schneetiefe") + .font(.subheadline) + .bold() + Spacer() + Text("\(condition.snowDepth.round(to: 2).removeZerosFromEnd()) m") + .font(.caption) + .bold() + } + HStack { + Text("Wolkendichte") + .font(.subheadline) + .bold() + Spacer() + Text("\(condition.cloudCoverage.round(to: 2).removeZerosFromEnd()) %") + .font(.caption) + .bold() + } + HStack { + Text("Niederschlagsmenge") + .font(.subheadline) + .bold() + Spacer() + Text("\(condition.precipitation.round(to: 2).removeZerosFromEnd()) kg/hm²") + .font(.caption) + .bold() + } + HStack { + Text("Luftdruck") + .font(.subheadline) + .bold() + Spacer() + Text("\(condition.pressure.round(to: 2).removeZerosFromEnd()) hPa") + .font(.caption) + .bold() + } } + .padding() + .onAppear(perform: self.updateCondition) + } + +} + + +struct FavoriteHeaderView_Previews: PreviewProvider { + static var previews: some View { + FavoriteHeaderView(location: DataManager.locationMock, condition: moc_condition_wolfsburg) } } diff --git a/ios-app/app/View/Favorite/FavoriteList.swift b/ios-app/app/View/Favorite/FavoriteList.swift index d1f57d11..0b6b701f 100644 --- a/ios-app/app/View/Favorite/FavoriteList.swift +++ b/ios-app/app/View/Favorite/FavoriteList.swift @@ -8,54 +8,65 @@ import SwiftUI import MowestaApi +import SwiftUICharts struct FavoriteList: View { - @EnvironmentObject var favorites: FavoriteLocations - @EnvironmentObject var newFavoriteLocation: NewFavoriteLocation @FetchRequest( entity: CDLocation.entity(), sortDescriptors: [] ) var allLocations: FetchedResults - + @EnvironmentObject var favorites: NewFavoriteLocation + @EnvironmentObject var user: UserData + @UIState private var refreshing = false @UIState private var searchFavorites = false; + private var didSave = NotificationCenter.default.publisher(for: .NSManagedObjectContextDidSave) + private func deleteItem(at indexSet: IndexSet) { - self.favorites.locations.remove(atOffsets: indexSet) + favorites.deleteLocation(at: indexSet) } private func setFavoriteListItemView (for location: SavedMowestaFavorites) -> some View { let loc = allLocations.first(where: { $0.id == location.id }) - - return NavigationLink(destination: FavoriteDetail(location: loc)) {FavoriteListItemView(cdLocation: loc)} - + //NSLog("location: \(loc ?? nil)") + if (loc != nil) { + return NavigationLink(destination: FavoriteDetail(location: loc!)) {FavoriteListItemView(cdLocation: loc)} + } else { + return NavigationLink(destination: FavoriteDetail(location: moc_cd_location_wolfsburg)) {FavoriteListItemView(cdLocation: loc)} + } } var body: some View { - NavigationView { - - List { - ForEach(newFavoriteLocation.savedFavorites) { location in - self.setFavoriteListItemView(for: location) - + return NavigationView { + VStack { + if favorites.savedFavorites.count > 0 { + List { + ForEach(favorites.savedFavorites) { location in + self.setFavoriteListItemView(for: location) + + } + .onDelete(perform: favorites.deleteLocation) + .onMove(perform: favorites.move) + } + .listStyle(GroupedListStyle()) + } else { + FavoriteListEmptyView() } - .onDelete(perform: self.newFavoriteLocation.deleteLocation) - .onMove(perform: self.newFavoriteLocation.move) } - .listStyle(GroupedListStyle()) - .navigationBarTitle("Favorites", displayMode: .automatic) + .navigationBarTitle("Favorite_NavigationBarTitle", displayMode: .automatic) .navigationBarItems(leading: EditButton(), trailing: Button(action: { self.searchFavorites = true }){ - Text("Add") + Text("FVAdd") }) + }.sheet(isPresented: $searchFavorites) { FavoriteSearch(isPresented: self.$searchFavorites) .environmentObject(self.favorites) - .environmentObject(self.newFavoriteLocation) } } } @@ -63,8 +74,6 @@ struct FavoriteList: View { struct FavoriteList_Previews: PreviewProvider { static var previews: some View { FavoriteList() - .environmentObject(FavoriteLocations(locations: [locationEssen])) - .environmentObject(NewFavoriteLocation.shared) } } diff --git a/ios-app/app/View/Favorite/FavoriteListEmptyView.swift b/ios-app/app/View/Favorite/FavoriteListEmptyView.swift new file mode 100644 index 00000000..f04fb409 --- /dev/null +++ b/ios-app/app/View/Favorite/FavoriteListEmptyView.swift @@ -0,0 +1,125 @@ +// +// FavoriteListEmptyView.swift +// app +// +// Created by Tobias Stottrop on 05.03.20. +// Copyright © 2020 Marcus Handte. All rights reserved. +// + +import SwiftUI + +struct FavoriteListEmptyView: View { + var body: some View { + ZStack { + HStack{ + Spacer() + VStack { + Spacer() + Image(systemName: "cloud.fill") + .font(.system(size: 80)) + .padding(.trailing, 80) + .padding(.bottom, 30) + .opacity(0.2) + Spacer() + } + Spacer() + } + + HStack{ + Spacer() + VStack { + Spacer() + Image(systemName: "sun.haze") + .font(.system(size: 40)) + .padding(.leading, 120) + .padding(.top, 70) + .opacity(0.2) + Spacer() + } + Spacer() + } + + HStack{ + Spacer() + VStack { + Spacer() + Image(systemName: "moon.stars") + .font(.system(size: 25)) + .padding(.leading, 300) + .padding(.top, 50) + .opacity(0.2) + Spacer() + } + Spacer() + } + + HStack{ + Spacer() + VStack { + Spacer() + Text("FVNoContent") + .font(.headline) + .padding(.bottom, 150) + .opacity(0.4) + Spacer() + } + Spacer() + } + + HStack{ + Spacer() + VStack { + VStack { + Image(systemName: "arrow.turn.right.up") + Text("FVAddFavorie") + + } + .frame(minWidth: 0, maxWidth: 100) + .padding(.trailing, 5) + .opacity(0.2) + Spacer() + } + } + + HStack{ + Spacer() + VStack { + Spacer() + VStack { + Text("FVSearch") + Image(systemName: "arrow.down") + } + .frame(minWidth: 0, maxWidth: 120) + .padding(.trailing, 5) + .padding(.bottom, 15) + .opacity(0.2) + } + } + + HStack{ + + VStack { + Spacer() + VStack { + Text("FVStations") + Image(systemName: "arrow.down") + } + .frame(minWidth: 0, maxWidth: 120) + .padding(.leading, 15) + .padding(.bottom, 15) + .opacity(0.2) + } + Spacer() + + + + } + } + } +} + +struct FavoriteListEmptyView_Previews: PreviewProvider { + static var previews: some View { + FavoriteListEmptyView() + } +} diff --git a/ios-app/app/View/Favorite/FavoriteListItemView.swift b/ios-app/app/View/Favorite/FavoriteListItemView.swift index b28ef7f2..1f41dfd5 100644 --- a/ios-app/app/View/Favorite/FavoriteListItemView.swift +++ b/ios-app/app/View/Favorite/FavoriteListItemView.swift @@ -11,14 +11,13 @@ import CoreData struct FavoriteListItemView: View { var cdLocation: CDLocation? - let currentDate: Date = Date() - func getCurrentValues() -> some View { + + func setupView() -> some View { let content = HStack{ Image(systemName: "sun.min") Text("0") - } guard ((cdLocation?.forecast?.conditions) != nil) @@ -32,35 +31,31 @@ struct FavoriteListItemView: View { return HStack { Image(systemName: item.type!) Text("\(Int(item.temperature))°") - } - - } - } - - /*let startForecast = Date(timeIntervalSince1970: Double(item.time)) - let durationInMs = item.duration * 3600 * 1000 - let endForecast = Date(timeIntervalSince1970: Double(item.time + durationInMs)) - if (startForecast > currentDate && endForecast < currentDate) { - return HStack { - Image(systemName: item.type!) - Text("\(item.temperature)") } } - }*/ + } + + /*let startForecast = Date(timeIntervalSince1970: Double(item.time)) + let durationInMs = item.duration * 3600 * 1000 + let endForecast = Date(timeIntervalSince1970: Double(item.time + durationInMs)) + if (startForecast > currentDate && endForecast < currentDate) { + return HStack { + Image(systemName: item.type!) + Text("\(item.temperature)") + } + + } + }*/ return content; } var body: some View { HStack { - - Text(cdLocation?.getName() ?? "N/A") - Spacer() - getCurrentValues() - - + Text(cdLocation?.getName() ?? "N/A") + Spacer() + setupView() } } - } diff --git a/ios-app/app/View/Favorite/FavoriteNextDaysDayView.swift b/ios-app/app/View/Favorite/FavoriteNextDaysDayView.swift index 4708d8a8..68340212 100644 --- a/ios-app/app/View/Favorite/FavoriteNextDaysDayView.swift +++ b/ios-app/app/View/Favorite/FavoriteNextDaysDayView.swift @@ -9,21 +9,94 @@ import SwiftUI struct FavoriteNextDaysDayView: View { - var date: String - var temp: String - var type: String + var conditions: [CDWeatherCondition] var body: some View { - HStack { - Text(date) - Spacer() - Image(systemName: type) - Text(temp) + let sorted = conditions.sorted(by: { + $0.time < $1.time + }) + return List { + ForEach(sorted, id: \.hour) {cond in + Card { + VStack { + HStack{ + Text("\(Date(milliseconds: cond.time).localLongString):") + Spacer() + Image(systemName: cond.type ?? "unknown") + }.padding(.bottom) + + HStack { + Text("Temperature") + Spacer() + Text("\(cond.temperature.round(to: 0).removeZerosFromEnd())°C / \((cond.temperature*(9/5)+32).round(to: 0).removeZerosFromEnd())°F") + } + HStack { + Text("Cloud Coverage") + Spacer() + Text("\(cond.cloudCoverage.round(to: 2).removeZerosFromEnd())%") + } + HStack { + Text("Cloud Depth") + Spacer() + Text("\(cond.cloudDepth.round(to: 2).removeZerosFromEnd())%") + } + HStack { + Text("humidity") + Spacer() + Text("\(cond.humidity.round(to: 2).removeZerosFromEnd())%") + } + HStack { + Text("precipitation") + Spacer() + Text("\(cond.precipitation.round(to: 2).removeZerosFromEnd()) kg/hm²") + } + HStack { + Text("precipitation") + Spacer() + Text("\(cond.precipitation.round(to: 2).removeZerosFromEnd()) hPa") + } + HStack { + Text("pressure") + Spacer() + Text("\(cond.pressure.round(to: 2).removeZerosFromEnd()) hPa") + } + HStack { + Text("snowDepth") + Spacer() + Text("\(cond.snowDepth.round(to: 2).removeZerosFromEnd()) m") + } + HStack { + Text("windSpeed") + Spacer() + Image(systemName: cond.windDirection ?? "unknown") + Text("\(cond.windSpeed.round(to: 2).removeZerosFromEnd()) m/s") + } + } + }.padding(.bottom) + } } + .navigationBarTitle("Alle Vorhersagen") } } -struct FavoriteNextDaysDayView_Previews: PreviewProvider { - static var previews: some View { - FavoriteNextDaysDayView(date: "Montag,12:44 Uhr", temp: "22", type:"sun") - } -} +/* + self.cloudCoverage = condition.cloudCoverage + self.cloudDepth = condition.cloudDepth + self.duration = Int64(condition.duration) + self.hour = Int64(condition.hour) + self.humidity = condition.humidity + self.precipitation = condition.precipitation + self.pressure = condition.pressure + self.snowDepth = condition.snowDepth + self.source = condition.source.rawValue + self.temperature = condition.temperature + self.time = condition.time + self.type = condition.getWeatherTypeImageName() + self.windDirection = condition.getWindDirectionImageName() + self.windSpeed = condition.windSpeed + */ + +//struct FavoriteNextDaysDayView_Previews: PreviewProvider { +// static var previews: some View { +// FavoriteNextDaysDayView(date: "Montag,12:44 Uhr", temp: "22", type:"sun") +// } +//} diff --git a/ios-app/app/View/Favorite/FavoriteSearch.swift b/ios-app/app/View/Favorite/FavoriteSearch.swift index 8434a4f9..4a9a7f98 100644 --- a/ios-app/app/View/Favorite/FavoriteSearch.swift +++ b/ios-app/app/View/Favorite/FavoriteSearch.swift @@ -22,7 +22,7 @@ struct FavoriteSearch: View { 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) + .navigationBarTitle(Text("SVTitle"), displayMode: .inline) .navigationBarItems(trailing: Button(action: { self.isPresented = false }){ diff --git a/ios-app/app/View/Favorite/FavoriteSearchResultRow.swift b/ios-app/app/View/Favorite/FavoriteSearchResultRow.swift index df1c2f12..c4848cf0 100644 --- a/ios-app/app/View/Favorite/FavoriteSearchResultRow.swift +++ b/ios-app/app/View/Favorite/FavoriteSearchResultRow.swift @@ -11,9 +11,7 @@ import MowestaApi struct FavoriteSearchResultRow: View { var location: LocationHierarchy - - @EnvironmentObject var favorites: FavoriteLocations - @EnvironmentObject var newFavoriteLocation: NewFavoriteLocation + @EnvironmentObject var favorites: NewFavoriteLocation @UIState private var reload = false var delimeter: String { @@ -90,12 +88,11 @@ struct FavoriteSearchResultRow: View { } Button(action: { - self.newFavoriteLocation.toggleLocation(self.location) self.favorites.toggleLocation(self.location) self.reload = !self.reload }) { - Image(systemName: (newFavoriteLocation.savedFavorites.firstIndex(where: {$0.id == location._id}) != nil) ? "heart.fill" : "heart").foregroundColor(Color.red) - .font(Font.system(size: 25)) + Image(systemName: ( self.favorites.savedFavorites.firstIndex(where: {$0.id == location._id}) != nil) ? "heart.fill" : "heart").foregroundColor(Color.red) + .font(Font.system(size: 25)) } } @@ -112,7 +109,7 @@ struct FavoriteSearchResultRow_Previews: PreviewProvider { //FavoriteSearchResultRow(isPresented: .constant(true), location: locationNrw) //FavoriteSearchResultRow(isPresented: .constant(true), location: locationDeutschland) } - .environmentObject(FavoriteLocations(locations: [locationEssen])) + .environmentObject(NewFavoriteLocation()) .previewLayout(.fixed(width: 300, height:70)) } } diff --git a/ios-app/app/View/Favorite/FavoriteTodayView.swift b/ios-app/app/View/Favorite/FavoriteTodayView.swift index 8a2940c3..a14767a1 100644 --- a/ios-app/app/View/Favorite/FavoriteTodayView.swift +++ b/ios-app/app/View/Favorite/FavoriteTodayView.swift @@ -10,31 +10,50 @@ import SwiftUI struct FavoriteTodayView: View { var location: CDLocation? + private let date = Date() + private let calendar = Calendar.current func getSortedConditions() -> [CDWeatherCondition] { guard ((location?.forecast?.conditions) != nil) - else { - return [] - } + else { + return [] + } var content = (location?.forecast?.conditions as! Set).sorted(by: { $0.hour < $1.hour }) content.removeAll(where: {$0.hour > 24}) return content } + func displaySortetdCondition(cond: CDWeatherCondition) -> some View { + let currentHour = calendar.component(.hour, from: date) + + if (currentHour == cond.hour) { + return VStack(spacing: 8) { + Text("\(cond.hour) Uhr") + .font(.footnote) + Image(systemName: cond.type ?? "questionmark") + .font(.body) + Text("\(cond.temperature.round(to: 0).removeZerosFromEnd())°") + .font(.headline) + }.foregroundColor(Color("mowesta-green")).frame(width: 50).eraseToAnyView() + } else { + return VStack(spacing: 8) { + Text("\(cond.hour) Uhr") + .font(.footnote) + Image(systemName: cond.type ?? "questionmark") + .font(.body) + Text("\(String(Int(cond.temperature )))°") + .font(.headline) + }.frame(width: 50).eraseToAnyView() + } + } + var body: some View { ScrollView(.horizontal){ HStack(spacing: 8) { - ForEach(getSortedConditions(), id: \.hour) { cond in - VStack(spacing: 8) { - Text("\(cond.hour) Uhr") - .font(.footnote) - Image(systemName: cond.type ?? "questionmark") - .font(.body) - Text("\(String(Int(cond.temperature )))°") - .font(.headline) - }.frame(width: 40) - } + ForEach(getSortedConditions(), id: \.hour) { cond in + self.displaySortetdCondition(cond: cond) + } } } } diff --git a/ios-app/app/View/Favorite/FavoritesNextDaysView.swift b/ios-app/app/View/Favorite/FavoritesNextDaysView.swift index e3155896..14fac06b 100644 --- a/ios-app/app/View/Favorite/FavoritesNextDaysView.swift +++ b/ios-app/app/View/Favorite/FavoritesNextDaysView.swift @@ -10,6 +10,8 @@ import SwiftUI struct FavoritesNextDaysView: View { var location: CDLocation? + @UIState var dailyPredictions: [DailyPrediction] = [DailyPrediction]() + //@UIState var rawConditions = [Day : [CDWeatherCondition]]() func getDay(value: Int) -> String { switch value { @@ -32,16 +34,49 @@ struct FavoritesNextDaysView: View { } } + func mostFrequent(array: [CDWeatherCondition]) -> (value: String, count: Int)? { + var counts = [String: Int]() + + array.forEach { counts[$0.type ?? "unknown"] = (counts[$0.type ?? "unknown"] ?? 0) + 1 } + + if let (value, count) = counts.max(by: {$0.1 < $1.1}) { + return (value, count) + } + + // array was empty + return nil + } + + func getCurrentValues() { + let list = Day.getDayList(conditions: location?.forecast?.conditions ?? NSSet()) + + + for item in list { + let filtered = location?.forecast?.conditions?.filter { (Date(milliseconds:($0 as! CDWeatherCondition).time) > item.date) && (Date(milliseconds:($0 as! CDWeatherCondition).time ) < item.date.addingTimeInterval(86400))} + //rawConditions[item] = (filtered as! [CDWeatherCondition]) + + let highest = (filtered as! [CDWeatherCondition]).max { $0.temperature < $1.temperature }?.temperature ?? -1 + let lowest = (filtered as! [CDWeatherCondition]).max { $0.temperature > $1.temperature }?.temperature ?? -1 + let symbol = mostFrequent(array: (filtered as! [CDWeatherCondition]))?.value ?? "unknown" + + let prediction = DailyPrediction(min: lowest, max: highest, symbol: symbol, day: item, rawConditions: (filtered as! [CDWeatherCondition])) + + if (!dailyPredictions.contains(prediction)) { + dailyPredictions.append(DailyPrediction(min: lowest, max: highest, symbol: symbol, day: item, rawConditions: (filtered as! [CDWeatherCondition]))) + } + } + } + func groupedEpisodesByDay(_ episodes: [CDWeatherCondition]) -> [Date: [CDWeatherCondition]] { - let empty: [Date: [CDWeatherCondition]] = [:] - return episodes.reduce(into: empty) { acc, cur in - let unixTime = Double(cur.time)/1000 - let fromdate = Date(timeIntervalSince1970: unixTime) - let components = Calendar.current.dateComponents([.day], from: fromdate) - let date = Calendar.current.date(from: components)! - let existing = acc[date] ?? [] - acc[date] = existing + [cur] - } + let empty: [Date: [CDWeatherCondition]] = [:] + return episodes.reduce(into: empty) { acc, cur in + let unixTime = Double(cur.time)/1000 + let fromdate = Date(timeIntervalSince1970: unixTime) + let components = Calendar.current.dateComponents([.day], from: fromdate) + let date = Calendar.current.date(from: components)! + let existing = acc[date] ?? [] + acc[date] = existing + [cur] + } } func getDayOfWeek(_ today: Int64) -> String { @@ -57,18 +92,56 @@ struct FavoritesNextDaysView: View { func getDays() -> [CDWeatherCondition] { guard ((location?.forecast?.conditions) != nil) - else { - return [] - } + else { + return [] + } return (location?.forecast?.conditions as! Set).sorted(by: { $0.time < $1.time }) //print("\(groupedEpisodesByDay(content))" } var body: some View { - VStack { - ForEach(self.getDays(), id: \.self) {item in - FavoriteNextDaysDayView(date: self.getDayOfWeek(item.time), temp: "\(Int(item.temperature))°C", type: item.type ?? "questionmark") + //let keys = dailyPredictions.map{$0.key}.sorted(by: {$0.date < $1.date}) + //let values = dailyPredictions.map {$0.value} + //let days = Day.getDayList(conditions: location?.forecast?.conditions ?? NSSet()) + //NSLog("\(days)") + let sorted = dailyPredictions.sorted(by: {$0.day.date < $1.day.date}) + return VStack { + ForEach(sorted, id: \.self) { item in + NavigationLink(destination: FavoriteNextDaysDayView(conditions: item.rawConditions)) { + HStack{ + Text("\(item.day.date.localDayLongString)") + Spacer() + Text("\(item.minTemperature.round(to:0).removeZerosFromEnd())") + Text("\(item.maxTemperature.round(to:0).removeZerosFromEnd())") + Image(systemName: item.symbol) + } + } } - } + }.onAppear(perform: { + self.getCurrentValues() + }) + + /*return VStack { + ForEach(days, id: \.id) {index in + NavigationLink(destination: FavoriteNextDaysDayView(conditions: self.rawConditions[keys[index]])) { + HStack { + Text("\(keys[index].date.localDayShortString)") + Spacer() + Text("\(values[index].minTemperature)") + Text("\(values[index].maxTemperatur)") + Image("\(values[index].symbol)") + } + } + } + + ForEach(keys, id: \.self) { day in + NavigationLink(destination: FavoriteNextDaysDayView(conditions: self.rawConditions[day])) { + HStack{ + Text("\(self.dailyPredictions[day]!.maxTemperatur)") + Spacer() + Text("\(self.dailyPredictions[day]!.minTemperature)") + } + } + }*/ } } diff --git a/ios-app/app/View/Location/CityCurrentView.swift b/ios-app/app/View/Location/CityCurrentView.swift new file mode 100644 index 00000000..4c11827a --- /dev/null +++ b/ios-app/app/View/Location/CityCurrentView.swift @@ -0,0 +1,98 @@ +// +// CityCurrentView.swift +// app +// +// Created by Tobias Stottrop on 30.01.20. +// Copyright © 2020 Marcus Handte. All rights reserved. +// + +import SwiftUI +import MowestaApi + +struct CityCurrentView: View { + @Binding var currentWeatherCondition: WeatherCondition + + var body: some View { + VStack (alignment: .leading) { + HStack { + Image(systemName: currentWeatherCondition.getWeatherTypeImageName()) + Spacer() + Text("Aktuelles Wetter") + .font(.title) + .bold() + } + Spacer() + HStack { + Text("Temperatur") + .font(.subheadline) + .bold() + Spacer() + Text("\(Int(currentWeatherCondition.temperature))°C / \(Int((currentWeatherCondition.temperature*(9/5))+32))°F") + .font(.caption) + .bold() + } + HStack { + Text("Windstärke") + .font(.subheadline) + .bold() + Spacer() + Image(systemName: currentWeatherCondition.getWindDirectionImageName()) + Text("\(Int(currentWeatherCondition.windSpeed)) m/s") + .font(.caption) + .bold() + } + HStack { + Text("Luftfeuchtigkeit") + .font(.subheadline) + .bold() + Spacer() + Text("\(Int(currentWeatherCondition.humidity)) %") + .font(.caption) + .bold() + } + HStack { + Text("Schneetiefe") + .font(.subheadline) + .bold() + Spacer() + Text("\(currentWeatherCondition.snowDepth.round(to: 2)) m") + .font(.caption) + .bold() + } + HStack { + Text("Wolkendichte") + .font(.subheadline) + .bold() + Spacer() + Text("\(currentWeatherCondition.cloudCoverage.round(to: 2)) %") + .font(.caption) + .bold() + } + HStack { + Text("Niederschlagsmenge") + .font(.subheadline) + .bold() + Spacer() + Text("\(currentWeatherCondition.precipitation.rounded()) kg/hm²") + .font(.caption) + .bold() + } + HStack { + Text("Luftdruck") + .font(.subheadline) + .bold() + Spacer() + Text("\(currentWeatherCondition.pressure.round(to: 2)) hPa") + .font(.caption) + .bold() + } + } + .padding() + } +} + +struct CityCurrentView_Previews: PreviewProvider { + static var previews: some View { + CityCurrentView(currentWeatherCondition: .constant(condition)) + } +} diff --git a/ios-app/app/View/Location/CityDetail.swift b/ios-app/app/View/Location/CityDetail.swift index fd1d3de5..cc24bdff 100644 --- a/ios-app/app/View/Location/CityDetail.swift +++ b/ios-app/app/View/Location/CityDetail.swift @@ -8,78 +8,38 @@ import SwiftUI import MowestaApi +import MapKit +import SwiftUICharts struct CityDetail: View { - - @EnvironmentObject var favorites : FavoriteLocations - @UIState private var location: LocationHierarchy = locationEssen - @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 - } - + @Binding var location: City + @Binding var currentWeatherCondition: WeatherCondition + @UIState private var centerCoordinate = CLLocationCoordinate2D() var body: some View { - List { - Section(header: Text("Now")) { - LocationHeaderView(city: $city, weatherType: $current) - } - Section(header: Text("Today")) { - LocationDetailView(conditions: forecast.conditions) - } - Section(header: Text("Next days")) { - LocationForecastView() + ScrollView { + VStack { + LocationMapView(centerCoordinate: self.$location) + .frame(height: 300) + + Card { + CityCurrentView(currentWeatherCondition: self.$currentWeatherCondition) + } + .frame(height: 200) + .padding(.leading, 20) + .padding(.trailing, 20) + .padding(.bottom, 20) + .offset(y: -100) } } - } - - func updateWeather() { - favorites.currentWeathers[city._id!]?.temperature = 40 + .edgesIgnoringSafeArea(.top) } } struct CityDetail_Previews: PreviewProvider { static var previews: some View { - CityDetail() - //.environment(\.locale, .init(identifier: "de")) - .environmentObject(FavoriteLocations(locations: [locationEssen])) + CityDetail(location: .constant(essen), currentWeatherCondition: .constant(moc_condition_wolfsburg)) + //.environment(\.locale, .init(identifier: "de")) + // .environmentObject(FavoriteLocations(locations: [locationEssen])) } } diff --git a/ios-app/app/View/Location/FavoriteCity.swift b/ios-app/app/View/Location/FavoriteCity.swift index 407ced1f..377ec821 100644 --- a/ios-app/app/View/Location/FavoriteCity.swift +++ b/ios-app/app/View/Location/FavoriteCity.swift @@ -11,7 +11,7 @@ import MowestaApi struct FavoriteCity: View { var location: LocationHierarchy - @EnvironmentObject var favorites: FavoriteLocations + //@EnvironmentObject var favorites: FavoriteLocations var body: some View { VStack(spacing: 10){ @@ -20,25 +20,25 @@ struct FavoriteCity: View { .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) + Image(systemName: "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") + VStack{ Text("0°") .foregroundColor(Color.white) - .font( Font.system(size: 14)) - .opacity(0.5) - Text("33°C") - .foregroundColor(Color.white) - .font( Font.system(size: 14)) - .opacity(1) - } + .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) + } } } } @@ -47,10 +47,10 @@ struct FavoriteCity: View { 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)) + .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/View/Location/LocationDetail.swift b/ios-app/app/View/Location/LocationDetail.swift index 3d45a153..ef155a28 100644 --- a/ios-app/app/View/Location/LocationDetail.swift +++ b/ios-app/app/View/Location/LocationDetail.swift @@ -10,8 +10,54 @@ import SwiftUI import MowestaApi struct LocationDetail: View { - @EnvironmentObject var favorites : FavoriteLocations + typealias MowestaState = MowestaApi.State + + @EnvironmentObject var favorites : NewFavoriteLocation var location: LocationHierarchy + @UIState private var city: City = essen + @UIState private var mowestastate: MowestaState = nrwState + @UIState private var currentWeatherCondition: WeatherCondition = moc_condition_empty + + func getWeatherCondition(condition: WeatherCondition?, error: Error?) { + if (error != nil) { + // do something + } + if (condition != nil) { + self.currentWeatherCondition = condition! + } + } + + + func getCity(city: City?, error: Error?) { + if (error != nil) { + //maybe handle + } + if (city != nil) { + self.city = city! + WeatherAPI.getCityCondition(_id: city!._id!, completion: self.getWeatherCondition) + } + } + + func getState(state: MowestaState?, error: Error?) { + if (error != nil) { + self.mowestastate = state! + //maybe handle + } + if (state != nil) { + self.mowestastate = state! + } + } + + func loadData() { + switch location.type { + case .city: + LocationAPI.getCity(_id: self.location._id!, completion: self.getCity) + case .state: + LocationAPI.getState(_id: self.location._id!, completion: self.getState) + case.country: + break + } + } var body: some View { VStack { @@ -23,18 +69,20 @@ struct LocationDetail: View { Button(action: { self.favorites.toggleLocation(self.location) }) { - Image(systemName: favorites.locations.contains{ element in - return element == location - } ? "heart.fill" : "heart") - .font(Font.system(size: 25)) + Image(systemName: NewFavoriteLocation.shared.savedFavorites.contains{ element in + return element.id == location._id + } ? "heart.fill" : "heart") + .font(Font.system(size: 25)) + .foregroundColor(.red) } }) + .onAppear(perform: loadData) } @ViewBuilder func builder() -> some View { if (self.location.type == .city) { - CityDetail().setLocation(location) + CityDetail(location: self.$city, currentWeatherCondition: self.$currentWeatherCondition) } else if (self.location.type == .state) { StateDetail().setLocation(location) } else { @@ -46,6 +94,6 @@ struct LocationDetail: View { struct LocationDetail_Previews: PreviewProvider { static var previews: some View { LocationDetail(location: locationEssen) - .environmentObject(FavoriteLocations(locations: [locationEssen])) + .environmentObject(NewFavoriteLocation.shared) } } diff --git a/ios-app/app/View/Location/LocationMapView.swift b/ios-app/app/View/Location/LocationMapView.swift new file mode 100644 index 00000000..929a9bc0 --- /dev/null +++ b/ios-app/app/View/Location/LocationMapView.swift @@ -0,0 +1,47 @@ +// +// LocationMapView.swift +// app +// +// Created by Tobias Stottrop on 30.01.20. +// Copyright © 2020 Marcus Handte. All rights reserved. +// + +import SwiftUI +import MapKit +import MowestaApi + +struct LocationMapView: UIViewRepresentable { + @Binding var centerCoordinate: City + + func makeUIView(context: Context) -> MKMapView { + MKMapView(frame: .zero) + } + + func updateUIView(_ view: MKMapView, context: Context) { + // create coordinate for pin + let coordinate = CLLocationCoordinate2D( + latitude: centerCoordinate.coordinate.latitude, longitude: centerCoordinate.coordinate.longitude) + + // create pin with city-name + let annotation = MKPointAnnotation() + annotation.title = "\(centerCoordinate.getName())" + annotation.subtitle = "\(centerCoordinate.getSubName())" + annotation.coordinate = coordinate + + // create a span to be shown by a region + let span = MKCoordinateSpan(latitudeDelta: 1.0, longitudeDelta: 1.0) + + // alter latitude that pin appears in upper third + // coordinate.latitude -= view.region.span.latitudeDelta * 0.2; + + let region = MKCoordinateRegion(center: coordinate, span: span) + view.setRegion(region, animated: true) + view.addAnnotation(annotation) + } +} + +struct LocationMapView_Previews: PreviewProvider { + static var previews: some View { + LocationMapView(centerCoordinate: .constant(essen)) + } +} diff --git a/ios-app/app/View/ToS/BackgroundServiceView.swift b/ios-app/app/View/ToS/BackgroundServiceView.swift new file mode 100644 index 00000000..707b3df5 --- /dev/null +++ b/ios-app/app/View/ToS/BackgroundServiceView.swift @@ -0,0 +1,101 @@ +// +// BackgroundServiceView.swift +// app +// +// Created by Tobias Stottrop on 04.03.20. +// Copyright © 2020 Marcus Handte. All rights reserved. +// + +import SwiftUI + +struct BackgroundServiceView: View { + @EnvironmentObject var state: NavigationStack + @Binding var agreedBGMeasurement: Bool + var body: some View { + NavigationView { + VStack { + Text("TVAskBackground").padding(.top, 20) + Spacer() + + HStack(spacing: 0) { + Button(action: { + self.toggleAgreedBGMeasurement() + }){ Image(systemName: agreedBGMeasurement ? "checkmark.square" : "square") + .foregroundColor(Color("mowesta-orange")) } + .padding(.trailing, 10) + Text("TVBGCheckBody") + .foregroundColor(.gray) + }.padding(.bottom) + + Spacer() + + ZStack { + HStack { + Button(action: { + self.state.pop() + }) { + Image(systemName: "chevron.left") + Text("TVBack") + } + Spacer() + } + + HStack { + Spacer() + + Circle() + .fill(Color("mowesta-green")) + .opacity(0.5) + .frame(width: 5, height: 5) + + Circle() + .fill(Color("mowesta-green")) + .frame(width: 5, height: 5) + .opacity(0.5) + + Circle() + .fill(Color("mowesta-green")) + .frame(width: 5, height: 5) + .opacity(0.5) + + Circle() + .fill(Color("mowesta-green")) + .frame(width: 5, height: 5) + + Spacer() + } + + HStack { + Spacer() + Button(action: { + self.state.push(state: AuthState.Finished) + }) { + HStack { + Text("TVFinished") + .fontWeight(.semibold) + Image(systemName: "arrow.turn.up.right") + } + .padding() + .foregroundColor(.white) + .background(Color("mowesta-green")) + .cornerRadius(40) + .animation(.default) + } + } + } + } + .navigationBarTitle("TVLocationTitle") + .padding() + } + } + + func toggleAgreedBGMeasurement() { + agreedBGMeasurement = !agreedBGMeasurement + } +} + +struct BackgroundServiceView_Previews: PreviewProvider { + static var previews: some View { + BackgroundServiceView(agreedBGMeasurement: .constant(false)) + } +} diff --git a/ios-app/app/View/ToS/LocationServiceView.swift b/ios-app/app/View/ToS/LocationServiceView.swift new file mode 100644 index 00000000..3444c6f0 --- /dev/null +++ b/ios-app/app/View/ToS/LocationServiceView.swift @@ -0,0 +1,91 @@ +// +// LocationServiceView.swift +// app +// +// Created by Tobias Stottrop on 03.03.20. +// Copyright © 2020 Marcus Handte. All rights reserved. +// + +import SwiftUI + +struct LocationServiceView: View { + @EnvironmentObject var state: NavigationStack + @Binding var agreedBGMeasurement: Bool + var body: some View { + NavigationView { + VStack { + Text("TVLocationBody").padding(.top, 20) + + Spacer() + + ZStack { + HStack { + Button(action: { + self.state.pop() + }) { + Image(systemName: "chevron.left") + Text("TVBack") + } + Spacer() + } + + HStack { + Spacer() + + Circle() + .fill(Color("mowesta-green")) + .opacity(0.5) + .frame(width: 5, height: 5) + + Circle() + .fill(Color("mowesta-green")) + .frame(width: 5, height: 5) + .opacity(0.5) + + Circle() + .fill(Color("mowesta-green")) + .frame(width: 5, height: 5) + + Circle() + .fill(Color("mowesta-green")) + .opacity(0.5) + .frame(width: 5, height: 5) + + Spacer() + } + + HStack { + Spacer() + Button(action: { + LocationService.shared.askUser() + self.state.push(state: AuthState.BackgroundScreen) + }) { + HStack { + Text("TVNext") + .fontWeight(.semibold) + Image(systemName: "chevron.right") + } + .padding() + .foregroundColor(.white) + .background(Color("mowesta-green")) + .cornerRadius(40) + .animation(.default) + } + } + } + } + .padding() + .navigationBarTitle("TVAlmost") + } + } + + func toggleAgreedBGMeasurement() { + agreedBGMeasurement = !agreedBGMeasurement + } +} + +struct LocationServiceView_Previews: PreviewProvider { + static var previews: some View { + LocationServiceView(agreedBGMeasurement: .constant(false)) + } +} diff --git a/ios-app/app/View/ToS/LoginView.swift b/ios-app/app/View/ToS/LoginView.swift new file mode 100644 index 00000000..9caa1717 --- /dev/null +++ b/ios-app/app/View/ToS/LoginView.swift @@ -0,0 +1,186 @@ +// +// LoginView.swift +// app +// +// Created by Tobias Stottrop on 02.03.20. +// Copyright © 2020 Marcus Handte. All rights reserved. +// + +import SwiftUI +import MowestaApi + +struct LoginView: View { + @EnvironmentObject var user: UserData + @EnvironmentObject var state: NavigationStack + + @Binding var showProgress: Bool + @UIState private var alertWrongCredentials = false + + @Binding var loginName: String + @Binding var password: String + + var body: some View { + NavigationView { + VStack() { + + VStack{ + TextField("AccountName", text: self.$loginName) + .padding() + .foregroundColor(Color("mowesta-orange")) + .background(Color("mowesta-textfield")) + .cornerRadius(10) + .textContentType(.username) + + SecureField("password", text: self.$password) + .padding() + .foregroundColor(Color("mowesta-orange")) + .background(Color("mowesta-textfield")) + .cornerRadius(10) + .textContentType(.password) + + HStack { + Spacer() + Button(action: { + self.state.push(state: .RegistrationScreen) + }) { + Text("No account?") + } + } + + HStack { + Spacer() + Button(action: { + self.resetPwd() + + }) { + Text("Forgot password?") + } + } + + HStack { + Spacer() + Button(action: { + self.state.push(state: .LocationScreen) + + }) { + HStack { + Text("TVSkip") + .font(.footnote) + Image(systemName: "chevron.right") + .font(.footnote) + } + .foregroundColor(.gray) + } + } + + }.padding() + + Spacer() + + ZStack { + HStack { + + Button(action: { + self.state.pop() + }) { + Image(systemName: "chevron.left") + Text("TVBack") + } + Spacer() + } + + HStack { + Spacer() + + Circle() + .fill(Color("mowesta-green")) + .opacity(0.5) + .frame(width: 5, height: 5) + + Circle() + .fill(Color("mowesta-green")) + .frame(width: 5, height: 5) + + Circle() + .fill(Color("mowesta-green")) + .opacity(0.5) + .frame(width: 5, height: 5) + + Circle() + .fill(Color("mowesta-green")) + .opacity(0.5) + .frame(width: 5, height: 5) + + Spacer() + } + + HStack { + Spacer() + + Button(action: { + self.login() + }) { + HStack { + Text("TVLogin") + .fontWeight(.semibold) + Image(systemName: "chevron.right") + } + .padding() + .foregroundColor(.white) + .background(buttonColor) + .cornerRadius(40) + .animation(.default) + }.disabled(!(loginName.count > 3 && password.count > 3)) + } + } + .padding() + .navigationBarTitle("TVLogin") + } + } + .alert(isPresented: self.$alertWrongCredentials) { + Alert(title: Text("Username or password is wrong.")) + } + + } + + var buttonColor: Color { + return loginName.count > 3 && password.count > 3 ? Color("mowesta-green") : .gray + } + + func resetPwd() { + let alert = MoWeStaAlert(title: "ResetPassword", message: "EnterAccount") + alert.addTextField(placeholder: "AccountName", inputText: self.loginName) + alert.addOkAction(onOk: { textFields in + if let loginName = textFields?[0].text { + UserAPI.resetUser(login: loginName) { _,_ in + let succesAlert = MoWeStaAlert(title: "MailSent", message: "SentMail") + succesAlert.addOkAction() + succesAlert.fire() + } + } + }) + alert.addCancelAction() + alert.fire() + } + + func login() { + NSLog("login called"); + showProgress = true + user.loginName = loginName + user.password = password + user.login(onSuccess: { self.showProgress = false; self.state.push(state: .LocationScreen) }, + onError: { self.showProgress = false + self.alertWrongCredentials = true }) + } + +} + +struct LoginView_Previews: PreviewProvider { + static var previews: some View { + Group { + Login(showProgress: .constant(false), showRegister: .constant(true)) + .environmentObject(UserData.adminUser) + } + .previewLayout(.fixed(width: 300, height: 400)) + } +} diff --git a/ios-app/app/View/ToS/RegistrationView.swift b/ios-app/app/View/ToS/RegistrationView.swift new file mode 100644 index 00000000..961f8bb5 --- /dev/null +++ b/ios-app/app/View/ToS/RegistrationView.swift @@ -0,0 +1,144 @@ +// +// RegistrationView.swift +// app +// +// Created by Tobias Stottrop on 02.03.20. +// Copyright © 2020 Marcus Handte. All rights reserved. +// + +import SwiftUI +import MowestaApi + +struct RegistrationView: View { + @EnvironmentObject var state: NavigationStack + @EnvironmentObject var user: UserData + @Binding var showProgress: Bool + @Binding var name: String + @Binding var mail: String + @Binding var loginName: String + @Binding var password: String + + @UIState private var alertWrongCredentials = false + + var buttonColor: Color { + return loginName.count > 3 && password.count > 3 && name.count > 3 && mail.count > 5 ? Color("mowesta-green") : .gray + } + + + var body: some View { + NavigationView { + VStack { + TextField("name", text: self.$name) + .padding() + .foregroundColor(Color("mowesta-orange")) + .background(Color("mowesta-textfield")) + .cornerRadius(10) + .textContentType(.name) + + TextField("mail", text: self.$mail) + .padding() + .foregroundColor(Color("mowesta-orange")) + .background(Color("mowesta-textfield")) + .cornerRadius(10) + .textContentType(.emailAddress) + + TextField("AccountName", text: self.$loginName) + .padding() + .foregroundColor(Color("mowesta-orange")) + .background(Color("mowesta-textfield")) + .cornerRadius(10) + .textContentType(.username) + + SecureField("password", text: self.$password) + .padding() + .foregroundColor(Color("mowesta-orange")) + .background(Color("mowesta-textfield")) + .cornerRadius(10) + .textContentType(.newPassword) + + Spacer() + + ZStack { + HStack { + + Button(action: { + self.state.pop() + }) { + Image(systemName: "chevron.left") + Text("TVBack") + } + Spacer() + } + + HStack { + Spacer() + + Circle() + .fill(Color("mowesta-green")) + .opacity(0.5) + .frame(width: 5, height: 5) + + Circle() + .fill(Color("mowesta-green")) + .frame(width: 5, height: 5) + + Circle() + .fill(Color("mowesta-green")) + .opacity(0.5) + .frame(width: 5, height: 5) + + Circle() + .fill(Color("mowesta-green")) + .opacity(0.5) + .frame(width: 5, height: 5) + + Spacer() + } + + HStack { + Spacer() + Button(action: { + self.register() + }) { + HStack { + Text("TVRegistration") + .fontWeight(.semibold) + Image(systemName: "chevron.right") + } + .padding() + .foregroundColor(.white) + .background(buttonColor) + .cornerRadius(40) + .animation(.default) + }.disabled(!(loginName.count > 3 && password.count > 3 && name.count > 3 && mail.count > 5)) + } + } + } + .alert(isPresented: self.$alertWrongCredentials) { + Alert(title: Text("Registration not possible with that credentials.")) + } + .padding() + .navigationBarTitle("TVRegistration") + } + } + + + + func register() { + self.showProgress = true + let userReg = UserRegistration(password: self.password, login: self.loginName, name: self.name, email: self.mail) + user.register(registration: userReg, + onSuccess: { self.showProgress = false; self.state.push(state: .LocationScreen) }, + onError: { self.showProgress = false + self.alertWrongCredentials = true } + ) + + } +} + + +struct RegistrationView_Previews: PreviewProvider { + static var previews: some View { + RegistrationView(showProgress: .constant(false), name: .constant("Tobi"), mail: .constant("tobi@mail.de"), loginName: .constant("Tobi"), password: .constant("***")) + } +} diff --git a/ios-app/app/View/ToS/TermsOfServiceView.swift b/ios-app/app/View/ToS/TermsOfServiceView.swift new file mode 100644 index 00000000..594f8287 --- /dev/null +++ b/ios-app/app/View/ToS/TermsOfServiceView.swift @@ -0,0 +1,163 @@ +// +// TermsOfServiceView.swift +// app +// +// Created by Tobias Stottrop on 02.03.20. +// Copyright © 2020 Marcus Handte. All rights reserved. +// + +import SwiftUI +import Foundation + +struct TermsOfServiceView: View { + @EnvironmentObject var user: UserData + @EnvironmentObject var state: NavigationStack + @Binding var agreedToS: Bool + @Binding var agreedDSGVO: Bool + var agreedBoth: Bool { + return agreedToS && agreedDSGVO + } + + private let tos_url: String = "https://www.mowesta.com/terms-of-service/" + private let privacy_url: String = "https://www.uni-due.de/en/privacy-policy.php" + + var body: some View { + NavigationView { + VStack(alignment: .leading) { + Text("TVAgreement").padding(.top, 20) + Spacer() + HStack(spacing: 0) { + Button(action: { + self.toggleDSGVO() + + }){ + Image(systemName: agreedDSGVO ? "checkmark.square" : "square") + .foregroundColor(Color("mowesta-orange")) + + } + .padding(.trailing, 10) + + Text("TVPrivacy0") + .foregroundColor(.gray) + Text("TVPrivacy1") + .foregroundColor(Color("mowesta-orange")) + .underline() + .onTapGesture { + let url = URL.init(string: self.privacy_url) + guard let privacyUrl = url, UIApplication.shared.canOpenURL(privacyUrl) else { return } + UIApplication.shared.open(privacyUrl) + } + Text("TVPrivacy2") + .foregroundColor(.gray) + + + }.padding(.bottom) + + HStack(spacing: 0) { + Button(action: { + self.toggleToS() + }){ + Image(systemName: agreedToS ? "checkmark.square" : "square") + .foregroundColor(Color("mowesta-orange")) } + .padding(.trailing, 10) + + Text("TVToS0") + .foregroundColor(.gray) + Text("TVToS1") + .foregroundColor(Color("mowesta-orange")) + .underline() + .onTapGesture { + let url = URL.init(string: self.tos_url) + guard let tosUrl = url, UIApplication.shared.canOpenURL(tosUrl) else { return } + UIApplication.shared.open(tosUrl) + } + Text("TVToS2") + .foregroundColor(.gray) + + + } + Spacer() + + ZStack { + HStack { + + Button(action: { + self.cancelAgreement() + }) { + Text("TVCancel") + } + Spacer() + } + + HStack { + Spacer() + + Circle() + .fill(Color("mowesta-green")) + .frame(width: 5, height: 5) + + Circle() + .fill(Color("mowesta-green")) + .frame(width: 5, height: 5) + .opacity(0.5) + + Circle() + .fill(Color("mowesta-green")) + .opacity(0.5) + .frame(width: 5, height: 5) + + Circle() + .fill(Color("mowesta-green")) + .opacity(0.5) + .frame(width: 5, height: 5) + + Spacer() + } + + HStack { + Spacer() + + Button(action: { + self.state.push(state: AuthState.LoginScreen) + }) { + HStack { + Text("TVNext") + .fontWeight(.semibold) + Image(systemName: "chevron.right") + } + .padding() + .foregroundColor(.white) + .background(buttonColor) + .cornerRadius(40) + .animation(.default) + }.disabled(!agreedBoth) + } + } + } + .padding() + .navigationBarTitle("TVWelcome") + } + } + + var buttonColor: Color { + return agreedBoth ? Color("mowesta-green") : .gray + } + + func cancelAgreement() { + let alert = MoWeStaAlert(title: "TVCancelHeadline", message: "TVCancelBody") + alert.addOkAction(onOk: {_ in + exit(0) + }) + alert.addCancelAction() + alert.fire() + } + + func toggleToS(){agreedToS = !agreedToS} + func toggleDSGVO(){agreedDSGVO = !agreedDSGVO} +} + +struct TermsOfServiceView_Previews: PreviewProvider { + static var previews: some View { + TermsOfServiceView(agreedToS: .constant(false), agreedDSGVO: .constant(false)) + } +} diff --git a/ios-app/app/View/ToS/TermsRootView.swift b/ios-app/app/View/ToS/TermsRootView.swift new file mode 100644 index 00000000..33cb1633 --- /dev/null +++ b/ios-app/app/View/ToS/TermsRootView.swift @@ -0,0 +1,82 @@ +// +// TermsRootView.swift +// app +// +// Created by Tobias Stottrop on 02.03.20. +// Copyright © 2020 Marcus Handte. All rights reserved. +// + +import SwiftUI + +struct TermsRootView: View { + @EnvironmentObject var state: NavigationStack + @EnvironmentObject var user: UserData + @UIState private var aligment = Alignment.leading + + @UIState var agreedToS: Bool = false + @UIState var agreedDSGVO: Bool = false + @UIState var agreedBGMeasurement: Bool = false + + @UIState private var loginName = "" + @UIState private var password = "" + @UIState private var name = "" + @UIState private var mail = "" + + @UIState var showProgress: Bool = false + + fileprivate func CurrentView() -> some View { + switch state.list.last { + case .ToSScreen: + return TermsOfServiceView(agreedToS: $agreedToS, agreedDSGVO: $agreedDSGVO).eraseToAnyView().environmentObject(state) + case .LoginScreen: + return LoginView(showProgress: $showProgress, loginName: $loginName, password: $password).eraseToAnyView().environmentObject(state) + case .RegistrationScreen: + return RegistrationView(showProgress: $showProgress, name: $name, mail: $mail, loginName: $loginName, password: $password).eraseToAnyView().environmentObject(state) + case .LocationScreen: + return LocationServiceView(agreedBGMeasurement: $agreedBGMeasurement).eraseToAnyView().environmentObject(state) + case .none: + return TermsOfServiceView(agreedToS: $agreedToS, agreedDSGVO: $agreedDSGVO).eraseToAnyView().environmentObject(state) + case .BackgroundScreen: + return BackgroundServiceView(agreedBGMeasurement: $agreedBGMeasurement).eraseToAnyView().environmentObject(state) + case .Finished: + if (agreedBGMeasurement) { + DeviceData.shared.bgMeasurement = true + } else { DeviceData.shared.bgMeasurement = false } + user.agreeToS() + return TermsOfServiceView(agreedToS: $agreedToS, agreedDSGVO: $agreedDSGVO).eraseToAnyView().environmentObject(state) + } + } + var body: some View { + Loading(isShowing: self.$showProgress, infoText: "Processing...") { + GeometryReader { geometry in + self.CurrentView() + .animation(.easeIn) + .frame(width: geometry.size.width, height: geometry.size.height, alignment: self.aligment) + .onAppear { + withAnimation() { + switch self.state.list.last { + case .ToSScreen: + fallthrough + case .none: + self.aligment = Alignment.leading + case .BackgroundScreen: + self.aligment = Alignment.trailing + case .LocationScreen: + fallthrough + case .RegistrationScreen: + fallthrough + default: + self.aligment = Alignment.center + } + } + } + } + } + } +} + +struct TermsRootView_Previews: PreviewProvider { + static var previews: some View { + TermsRootView() + } +} diff --git a/ios-app/app/View/WeatherStation/WeatherStationsTab.swift b/ios-app/app/View/WeatherStation/WeatherStationsTab.swift index f752ee1a..ceef1518 100644 --- a/ios-app/app/View/WeatherStation/WeatherStationsTab.swift +++ b/ios-app/app/View/WeatherStation/WeatherStationsTab.swift @@ -15,6 +15,18 @@ struct WeatherStationsTab: View { @FetchRequest(fetchRequest: CDevice.fetchRequestWithout(id: DeviceData.shared.idInt64)) var devices: FetchedResults @UIState private var showLoginView = false + func alertResetApplication() { + let alert = MoWeStaAlert(title: "TVResetAppTitle", message: "TVResetAppBody") + alert.addOkAction(onOk: {_ in + NewFavoriteLocation.shared.savedFavorites = [] + DataManager.shared.deleteAllData() + UserData.shared.logout() + UserData.shared.disagreeToS() + }) + alert.addCancelAction() + alert.fire() + } + var body: some View { NavigationView { List { @@ -37,14 +49,16 @@ struct WeatherStationsTab: View { } .listStyle(GroupedListStyle()) .navigationBarTitle("WVWeatherStations") - .navigationBarItems(trailing: Button(action: { self.showLoginView.toggle() }) { Image(systemName: self.user.loggedIn ? "person.crop.circle.badge.checkmark" : "person.crop.circle.badge.plus") + .navigationBarItems(leading: Button(action: { self.alertResetApplication()}) { Image(systemName: "trash") + .font(Font.system(size: 24)) + }, trailing: Button(action: { self.showLoginView.toggle() }) { Image(systemName: self.user.loggedIn ? "person.crop.circle.badge.checkmark" : "person.crop.circle.badge.plus") .font(Font.system(size: 25)) }) - .environment(\.horizontalSizeClass, .regular) - .sheet(isPresented: self.$showLoginView, content: { - AccountView() - .environmentObject(self.user) - }) + .environment(\.horizontalSizeClass, .regular) + .sheet(isPresented: self.$showLoginView, content: { + AccountView() + .environmentObject(self.user) + }) } } } diff --git a/ios-app/app/de.lproj/Localizable.strings b/ios-app/app/de.lproj/Localizable.strings index bb7f56b5..7d75d5b0 100644 --- a/ios-app/app/de.lproj/Localizable.strings +++ b/ios-app/app/de.lproj/Localizable.strings @@ -7,6 +7,8 @@ */ "Cancel" = "Abbrechen"; +"Done" = "Fertig"; +"Stationen" = "Stationen"; /* Account View */ "Hello %@" = "Hallo %@"; @@ -31,6 +33,8 @@ /* Search View */ "SVSearchLocations" = "Suche Orte"; +"Search_NavigationBarTitle" = "Suchen"; +"SVTitle" = "Favoriten hinzufügen"; /* Favorites View */ "Favorite_NavigationBarTitle" = "Favoriten"; @@ -108,3 +112,42 @@ "MVModel" = "Modell"; "MVDevice" = "Hardwareversion"; "MVOs" = "Softwareversion"; + +/* ToS View */ +"TVWelcome" = "Hallo!"; +"TVAgreement" = "Wir heißen dich herzlich willkommen bei MoWeSta, deiner neuen Wetter-App. Um unsere Services nutzen zu können, musst du unseren Nutzungsbedingungen und unserer Datenschutzverordnung zustimmen."; +"TVPrivacy0" = "Ich habe die "; +"TVPrivacy1" = "DSGVO-Hinweise"; +"TVPrivacy2" = " gelesen."; +"TVToS0" = "Ich habe die "; +"TVToS1" = "Nutzungsbedingungen"; +"TVToS2" = " gelesen."; +"TVNext" = "Weiter"; +"TVCancel" = "Abbrechen"; +"TVCancelHeadline" = "Zustimmung benötigt"; +"TVCancelBody" = "Für die Nutzung dieser App musst du den Nutzungsbedingungen und der Datenschutzverordnung zustimmen. Bei Bestätigung dieses Dialoges wird die App geschlossen."; + +"TVRegistration" = "Registrieren"; +"TVRegistrationBack" = "Zurück"; +"TVAlmost" = "Fast fertig!"; + +"TVResetAppTitle" = "Möchtest du wirklich die App zurücksetzen?"; +"TVResetAppBody" = "Dadurch gehen Daten dauerhaft verloren. Bei dem nächsten Start wird ei Applikation wieder mit der Begrüßung gestartet. Dadurch wird dein Account nicht gelöscht, sondern lediglich ausgeloggt."; + +"TVLogin" = "Login"; +"TVBack" = "Zurück"; +"TVSkip" = "Überspringen"; + +"TVLocationBody" = "Die App benötigt, um optimal zu funktionieren, Zugriff auf deine Positionsdaten. Bitte bestätige dies in der folgenden Benachrichtigung."; + +"TVLocationTitle" = "Noch eine Sekunde!"; +"TVAskBackground" = "Die App besitzt die Möglichkeit, Wetterspezifische Daten auszulesen und diese im Hintergrund an unsere Server für die Auswertung durch den Deutschen Wetterdienst zu senden. Dadurch wird ermöglicht, die Genauigkeit von Wettervorhersagen zu verbessern. Bitte bestötige, dass du mit der Sendung dieser Daten im Hintergrund einverstanden bist."; +"TVBGCheckBody" = "Ich bin damit einverstanden, dass im Hintergrund Wetterspezifische Daten gesendet werden."; + +"TVFinished" = "Fertig👌"; + +"FVNoContent" = "Wie es aussieht, hast du noch keine Favoriten angelegt!"; +"FVAddFavorie" = "Füge doch hier deinen ersten Favoriten hinzu!"; +"FVSearch" = "Oder schaue dir erstmal ein paar Ortschaften an.."; +"FVStations" = "Hier kannst du dir deinen Account ansehen, deine Geräte verwalten und dir deine Messungen anschauen."; +"FVAdd" = "Hinzufügen"; diff --git a/ios-app/app/en.lproj/Localizable.strings b/ios-app/app/en.lproj/Localizable.strings index 16d3c3f2..e34eaa1c 100644 --- a/ios-app/app/en.lproj/Localizable.strings +++ b/ios-app/app/en.lproj/Localizable.strings @@ -7,6 +7,8 @@ */ "Cancel" = "Cancel"; +"Done" = "Done"; +"Stationen" = "Stations"; /* Account View */ "Hello %@" = "Hello %@"; @@ -31,6 +33,8 @@ /* Search View */ "SVSearchLocations" = "Search Locations"; +"Search_NavigationBarTitle" = "Search"; +"SVTitle" = "Add Favorite"; /* Favorites View */ "Favorite_NavigationBarTitle" = "Favorites"; @@ -108,3 +112,43 @@ "MVModel" = "Model"; "MVDevice" = "Hardware Version"; "MVOs" = "Software Version"; + +/* ToS View */ +"TVWelcome" = "Hello!"; +"TVAgreement" = "We welcome you to MoWeSta, your new weather app. To use our services you have to agree to our terms of use and our privacy policy."; +"TVPrivacy0" = "I have read the "; +"TVPrivacy1" = "privacy policy"; +"TVPrivacy2" = "."; +"TVToS0" = "I have read the "; +"TVToS1" = "terms and conditions"; +"TVToS2" = "."; +"TVNext" = "Next"; +"TVCancel" = "Cancel"; +"TVCancelHeadline" = "Agreement is needed"; +"TVCancelBody" = "In order to use this app, you must agree to the terms of use and privacy policy. If you confirm this dialog the app will be closed."; + +"TVRegistration" = "Register"; +"TVRegistrationBack" = "Back"; +"TVAlmost" = "Nearly finished!"; + +"TVResetAppTitle" = "You really want to reset the app?"; +"TVResetAppBody" = "As a result, data is permanently lost. The next time the application is started, it will be restarted with the greeting. This will not delete your account, but only log you out."; + +"TVLogin" = "Login"; +"TVBack" = "Back"; +"TVSkip" = "Skip"; + +"TVLocationTitle" = "Just one Second!"; +"TVLocationBody" = "The app needs access to your location data to work optimally. Please confirm this in the following notification"; + +"TVAskBackground" = "The app has the possibility to read weather specific data and send them to our servers for evaluation by the German Weather Service. This makes it possible to improve the accuracy of weather forecasts. Please confirm that you agree with the sending of this data in the background."; +"TVBGCheckBody" = "I agree that weather specific data is sent in the background."; + +"TVFinished" = "Finished👌"; + +"FVNoContent" = "It looks like you haven't created any favorites yet!"; +"FVAddFavorie" = "You can add favorites here!"; +"FVSearch" = "Or check out some places first.."; +"FVStations" = "Here you can view your account, manage your devices and view your measurements."; +"FVAdd" = "Add"; +