From adf60f289b1c9fb7cb829efdf3112fd3961a5277 Mon Sep 17 00:00:00 2001 From: Marcus Handte Date: Wed, 20 Jul 2022 23:34:43 +0200 Subject: [PATCH] Backup ios app. --- ios-app/app.xcodeproj/project.pbxproj | 59 +++- .../icon_barometer.imageset/Contents.json | 3 +- .../icon_cloud.imageset/Contents.json | 3 +- .../icon_cloudy.imageset/Contents.json | 3 +- .../icon_day_cloudy.imageset/Contents.json | 3 +- .../icon_day_fog.imageset/Contents.json | 3 +- .../icon_day_rain.imageset/Contents.json | 3 +- .../icon_day_rain_mix.imageset/Contents.json | 3 +- .../icon_day_showers.imageset/Contents.json | 3 +- .../icon_day_snow.imageset/Contents.json | 3 +- .../icon_day_sprinkle.imageset/Contents.json | 3 +- .../icon_day_sunny.imageset/Contents.json | 3 +- .../Contents.json | 3 +- .../icon_devices.imageset/Contents.json | 16 ++ .../icon_devices.imageset/icon_devices.svg | 1 + .../icon_humidity.imageset/Contents.json | 3 +- .../icon_night_clear.imageset/Contents.json | 3 +- .../icon_night_cloudy.imageset/Contents.json | 3 +- .../icon_night_fog.imageset/Contents.json | 3 +- .../icon_night_rain.imageset/Contents.json | 3 +- .../Contents.json | 3 +- .../icon_night_showers.imageset/Contents.json | 3 +- .../icon_night_snow.imageset/Contents.json | 3 +- .../Contents.json | 3 +- .../Contents.json | 3 +- .../icon_rain.imageset/Contents.json | 3 +- .../icon_rain_mix.imageset/Contents.json | 3 +- .../icon_raindrop.imageset/Contents.json | 3 +- .../icon_raindrops.imageset/Contents.json | 3 +- .../icon_snow.imageset/Contents.json | 3 +- .../Contents.json | 3 +- .../icon_sprinkle.imageset/Contents.json | 3 +- .../icon_station.imageset/Contents.json | 16 ++ .../icon_station.imageset/icon_station.svg | 1 + .../icon_storm_showers.imageset/Contents.json | 3 +- .../icon_thermometer.imageset/Contents.json | 3 +- .../icon_thunderstorm.imageset/Contents.json | 3 +- .../Contents.json | 3 +- ios-app/app/ContentView.swift | 1 + ios-app/app/Model/AppState.swift | 10 + ios-app/app/Model/DataBindings.swift | 29 +- ios-app/app/Model/TextBindings.swift | 46 +++ ios-app/app/Model/WeatherAggregates.swift | 263 ++++++++++++++++++ ios-app/app/Ui/ButtonStyles.swift | 6 +- ios-app/app/Ui/ErrorView.swift | 57 ++++ ios-app/app/Ui/HideableTabView.swift | 61 ++-- ios-app/app/Ui/PageView.swift | 64 +++++ ios-app/app/Ui/RemoteImageView.swift | 63 +++++ ios-app/app/Util/GeojsonConverter.swift | 94 +++++++ ios-app/app/View/CityForecastView.swift | 33 ++- ios-app/app/View/CityInfoView.swift | 67 ++++- ios-app/app/View/CityVideoView.swift | 258 +++++++++++++++++ ios-app/app/View/CityView.swift | 246 +++++++++++----- ios-app/app/View/CountryView.swift | 178 ++++++++++++ ios-app/app/View/CustomizeView.swift | 97 +++++++ ios-app/app/View/DrawerView.swift | 60 +++- ios-app/app/View/FavoritesView.swift | 5 +- ios-app/app/View/PlaceMapView.swift | 179 ++++++++++++ ios-app/app/View/SearchView.swift | 63 +++-- ios-app/app/View/StateView.swift | 23 ++ ios-app/app/View/StationView.swift | 23 ++ ios-app/app/View/WeatherConditionView.swift | 95 ------- ios-app/app/View/WeatherViews.swift | 209 ++++++++++++++ ios-app/app/de.lproj/Localizable.strings | 29 +- ios-app/app/en.lproj/Localizable.strings | 29 +- .../lib-leafless/Classes/MapView.swift | 8 +- 66 files changed, 2165 insertions(+), 323 deletions(-) create mode 100644 ios-app/app/Assets.xcassets/icon_devices.imageset/Contents.json create mode 100644 ios-app/app/Assets.xcassets/icon_devices.imageset/icon_devices.svg create mode 100644 ios-app/app/Assets.xcassets/icon_station.imageset/Contents.json create mode 100644 ios-app/app/Assets.xcassets/icon_station.imageset/icon_station.svg create mode 100644 ios-app/app/Model/WeatherAggregates.swift create mode 100644 ios-app/app/Ui/ErrorView.swift create mode 100644 ios-app/app/Ui/PageView.swift create mode 100644 ios-app/app/Ui/RemoteImageView.swift create mode 100644 ios-app/app/Util/GeojsonConverter.swift create mode 100644 ios-app/app/View/CityVideoView.swift create mode 100644 ios-app/app/View/CountryView.swift create mode 100644 ios-app/app/View/CustomizeView.swift create mode 100644 ios-app/app/View/PlaceMapView.swift create mode 100644 ios-app/app/View/StateView.swift create mode 100644 ios-app/app/View/StationView.swift delete mode 100644 ios-app/app/View/WeatherConditionView.swift create mode 100644 ios-app/app/View/WeatherViews.swift diff --git a/ios-app/app.xcodeproj/project.pbxproj b/ios-app/app.xcodeproj/project.pbxproj index 9f4fe50d..562b1d39 100644 --- a/ios-app/app.xcodeproj/project.pbxproj +++ b/ios-app/app.xcodeproj/project.pbxproj @@ -14,6 +14,8 @@ 2C163321283A27D600F78CEE /* AppTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C163320283A27D600F78CEE /* AppTests.swift */; }; 2C16332B283A27D600F78CEE /* AppUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C16332A283A27D600F78CEE /* AppUITests.swift */; }; 2C16332D283A27D600F78CEE /* AppUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C16332C283A27D600F78CEE /* AppUITestsLaunchTests.swift */; }; + 2C369C6628888E6800B5AFB2 /* StationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C369C6528888E6800B5AFB2 /* StationView.swift */; }; + 2C369C6828889EAE00B5AFB2 /* ErrorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C369C6728889EAE00B5AFB2 /* ErrorView.swift */; }; 2C865E3B284271C800F1A89A /* MoWeStaApi in Frameworks */ = {isa = PBXBuildFile; productRef = 2C865E3A284271C800F1A89A /* MoWeStaApi */; }; 2C865E3D2842850800F1A89A /* HideableTabView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C865E3C2842850800F1A89A /* HideableTabView.swift */; }; 2C865E3F28428ED600F1A89A /* TextBindings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C865E3E28428ED600F1A89A /* TextBindings.swift */; }; @@ -23,11 +25,21 @@ 2CA28203283E201B00D4A05A /* KeyChain.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CA28200283E201B00D4A05A /* KeyChain.swift */; }; 2CA28204283E201B00D4A05A /* UserDefault.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CA28201283E201B00D4A05A /* UserDefault.swift */; }; 2CA28205283E201B00D4A05A /* AppInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CA28202283E201B00D4A05A /* AppInfo.swift */; }; + 2CA4E74F2885E62500B901ED /* LocosLabLeafles in Frameworks */ = {isa = PBXBuildFile; productRef = 2CA4E74E2885E62500B901ED /* LocosLabLeafles */; }; + 2CA4E7512887CB9800B901ED /* CountryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CA4E7502887CB9800B901ED /* CountryView.swift */; }; + 2CA4E7532887CBA300B901ED /* StateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CA4E7522887CBA300B901ED /* StateView.swift */; }; + 2CA4E7552887D18D00B901ED /* GeojsonConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CA4E7542887D18D00B901ED /* GeojsonConverter.swift */; }; + 2CA4E757288826DA00B901ED /* PlaceMapView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CA4E756288826DA00B901ED /* PlaceMapView.swift */; }; 2CAC431B287F1C8F0088C9FD /* ApiHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CAC431A287F1C8F0088C9FD /* ApiHeader.swift */; }; 2CAC431D287F399F0088C9FD /* CollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CAC431C287F399F0088C9FD /* CollectionView.swift */; }; 2CB9AA532881AC0C00E9B888 /* FavoriteExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CB9AA522881AC0C00E9B888 /* FavoriteExtensions.swift */; }; - 2CD7E0BF2884402500F9CE57 /* WeatherConditionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CD7E0BE2884402500F9CE57 /* WeatherConditionView.swift */; }; + 2CD7E0BF2884402500F9CE57 /* WeatherViews.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CD7E0BE2884402500F9CE57 /* WeatherViews.swift */; }; 2CD7E0C12884415A00F9CE57 /* CityForecastView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CD7E0C02884415A00F9CE57 /* CityForecastView.swift */; }; + 2CD7E0C328849FF900F9CE57 /* WeatherAggregates.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CD7E0C228849FF900F9CE57 /* WeatherAggregates.swift */; }; + 2CD7E0C528856C3500F9CE57 /* PageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CD7E0C428856C3500F9CE57 /* PageView.swift */; }; + 2CD7E0C728857A7900F9CE57 /* CustomizeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CD7E0C628857A7900F9CE57 /* CustomizeView.swift */; }; + 2CD7E0C92885A0F700F9CE57 /* CityVideoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CD7E0C82885A0F700F9CE57 /* CityVideoView.swift */; }; + 2CD7E0CD2885AD7D00F9CE57 /* RemoteImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CD7E0CC2885AD7D00F9CE57 /* RemoteImageView.swift */; }; 2CE5E860287ECB98006B8CDF /* ProgressViews.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CE5E85F287ECB98006B8CDF /* ProgressViews.swift */; }; 2CEB0281283EB09B00DF3151 /* Database.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 2CEB027F283EB09B00DF3151 /* Database.xcdatamodeld */; }; 2CEB02862840C50700DF3151 /* TermsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CEB02822840C50700DF3151 /* TermsView.swift */; }; @@ -77,6 +89,8 @@ 2C163326283A27D600F78CEE /* AppUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AppUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 2C16332A283A27D600F78CEE /* AppUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppUITests.swift; sourceTree = ""; }; 2C16332C283A27D600F78CEE /* AppUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppUITestsLaunchTests.swift; sourceTree = ""; }; + 2C369C6528888E6800B5AFB2 /* StationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StationView.swift; sourceTree = ""; }; + 2C369C6728889EAE00B5AFB2 /* ErrorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ErrorView.swift; sourceTree = ""; }; 2C865E392842719F00F1A89A /* ios-api */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = "ios-api"; path = "../ios-api"; sourceTree = ""; }; 2C865E3C2842850800F1A89A /* HideableTabView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HideableTabView.swift; sourceTree = ""; }; 2C865E3E28428ED600F1A89A /* TextBindings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextBindings.swift; sourceTree = ""; }; @@ -86,12 +100,21 @@ 2CA28200283E201B00D4A05A /* KeyChain.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeyChain.swift; sourceTree = ""; }; 2CA28201283E201B00D4A05A /* UserDefault.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserDefault.swift; sourceTree = ""; }; 2CA28202283E201B00D4A05A /* AppInfo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppInfo.swift; sourceTree = ""; }; + 2CA4E7502887CB9800B901ED /* CountryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CountryView.swift; sourceTree = ""; }; + 2CA4E7522887CBA300B901ED /* StateView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StateView.swift; sourceTree = ""; }; + 2CA4E7542887D18D00B901ED /* GeojsonConverter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GeojsonConverter.swift; sourceTree = ""; }; + 2CA4E756288826DA00B901ED /* PlaceMapView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaceMapView.swift; sourceTree = ""; }; 2CAC431A287F1C8F0088C9FD /* ApiHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApiHeader.swift; sourceTree = ""; }; 2CAC431C287F399F0088C9FD /* CollectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionView.swift; sourceTree = ""; }; 2CB9AA522881AC0C00E9B888 /* FavoriteExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoriteExtensions.swift; sourceTree = ""; }; 2CB9AA552882CD3600E9B888 /* lib-leafless */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = "lib-leafless"; path = "../ios-locoslab/lib-leafless"; sourceTree = ""; }; - 2CD7E0BE2884402500F9CE57 /* WeatherConditionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherConditionView.swift; sourceTree = ""; }; + 2CD7E0BE2884402500F9CE57 /* WeatherViews.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherViews.swift; sourceTree = ""; }; 2CD7E0C02884415A00F9CE57 /* CityForecastView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CityForecastView.swift; sourceTree = ""; }; + 2CD7E0C228849FF900F9CE57 /* WeatherAggregates.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherAggregates.swift; sourceTree = ""; }; + 2CD7E0C428856C3500F9CE57 /* PageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PageView.swift; sourceTree = ""; }; + 2CD7E0C628857A7900F9CE57 /* CustomizeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomizeView.swift; sourceTree = ""; }; + 2CD7E0C82885A0F700F9CE57 /* CityVideoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CityVideoView.swift; sourceTree = ""; }; + 2CD7E0CC2885AD7D00F9CE57 /* RemoteImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoteImageView.swift; sourceTree = ""; }; 2CE5E85F287ECB98006B8CDF /* ProgressViews.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressViews.swift; sourceTree = ""; }; 2CEB0280283EB09B00DF3151 /* Database.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Database.xcdatamodel; sourceTree = ""; }; 2CEB02822840C50700DF3151 /* TermsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TermsView.swift; sourceTree = ""; }; @@ -117,6 +140,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 2CA4E74F2885E62500B901ED /* LocosLabLeafles in Frameworks */, 2C865E3B284271C800F1A89A /* MoWeStaApi in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -221,6 +245,7 @@ 2CA28201283E201B00D4A05A /* UserDefault.swift */, 2CF8D62928440FE4008FB7D0 /* UnitConverter.swift */, 2CAC431A287F1C8F0088C9FD /* ApiHeader.swift */, + 2CA4E7542887D18D00B901ED /* GeojsonConverter.swift */, ); path = Util; sourceTree = ""; @@ -238,8 +263,14 @@ 2C865E402842999600F1A89A /* CityView.swift */, 2C865E42284393DA00F1A89A /* CityInfoView.swift */, 2CD7E0C02884415A00F9CE57 /* CityForecastView.swift */, + 2CD7E0C82885A0F700F9CE57 /* CityVideoView.swift */, + 2CA4E7502887CB9800B901ED /* CountryView.swift */, + 2CA4E7522887CBA300B901ED /* StateView.swift */, 2CAC431C287F399F0088C9FD /* CollectionView.swift */, - 2CD7E0BE2884402500F9CE57 /* WeatherConditionView.swift */, + 2CD7E0BE2884402500F9CE57 /* WeatherViews.swift */, + 2CD7E0C628857A7900F9CE57 /* CustomizeView.swift */, + 2CA4E756288826DA00B901ED /* PlaceMapView.swift */, + 2C369C6528888E6800B5AFB2 /* StationView.swift */, ); path = View; sourceTree = ""; @@ -252,6 +283,7 @@ 2CF8D6252843D0DB008FB7D0 /* ImageBindings.swift */, 2CF8D62728440E05008FB7D0 /* DataBindings.swift */, 2CB9AA522881AC0C00E9B888 /* FavoriteExtensions.swift */, + 2CD7E0C228849FF900F9CE57 /* WeatherAggregates.swift */, ); path = Model; sourceTree = ""; @@ -263,6 +295,9 @@ 2CEB02832840C50700DF3151 /* ButtonStyles.swift */, 2C865E3C2842850800F1A89A /* HideableTabView.swift */, 2CE5E85F287ECB98006B8CDF /* ProgressViews.swift */, + 2CD7E0C428856C3500F9CE57 /* PageView.swift */, + 2CD7E0CC2885AD7D00F9CE57 /* RemoteImageView.swift */, + 2C369C6728889EAE00B5AFB2 /* ErrorView.swift */, ); path = Ui; sourceTree = ""; @@ -285,6 +320,7 @@ name = App; packageProductDependencies = ( 2C865E3A284271C800F1A89A /* MoWeStaApi */, + 2CA4E74E2885E62500B901ED /* LocosLabLeafles */, ); productName = App; productReference = 2C163307283A27D300F78CEE /* MoWeSta.app */; @@ -407,16 +443,26 @@ 2C865E3F28428ED600F1A89A /* TextBindings.swift in Sources */, 2CB9AA532881AC0C00E9B888 /* FavoriteExtensions.swift in Sources */, 2C865E412842999600F1A89A /* CityView.swift in Sources */, + 2CA4E7512887CB9800B901ED /* CountryView.swift in Sources */, + 2CA4E757288826DA00B901ED /* PlaceMapView.swift in Sources */, 2C163314283A27D600F78CEE /* Persistence.swift in Sources */, 2CF8D6262843D0DB008FB7D0 /* ImageBindings.swift in Sources */, + 2CA4E7552887D18D00B901ED /* GeojsonConverter.swift in Sources */, 2CAC431B287F1C8F0088C9FD /* ApiHeader.swift in Sources */, + 2C369C6628888E6800B5AFB2 /* StationView.swift in Sources */, + 2CD7E0C528856C3500F9CE57 /* PageView.swift in Sources */, 2CD7E0C12884415A00F9CE57 /* CityForecastView.swift in Sources */, 2CEB02862840C50700DF3151 /* TermsView.swift in Sources */, 2CA28204283E201B00D4A05A /* UserDefault.swift in Sources */, + 2CD7E0C728857A7900F9CE57 /* CustomizeView.swift in Sources */, 2CFC0F18284219C600E597DC /* DrawerView.swift in Sources */, 2CEB0281283EB09B00DF3151 /* Database.xcdatamodeld in Sources */, + 2CD7E0CD2885AD7D00F9CE57 /* RemoteImageView.swift in Sources */, + 2CD7E0C92885A0F700F9CE57 /* CityVideoView.swift in Sources */, + 2CD7E0C328849FF900F9CE57 /* WeatherAggregates.swift in Sources */, 2CA28203283E201B00D4A05A /* KeyChain.swift in Sources */, 2CA281FF283E1D2F00D4A05A /* AppState.swift in Sources */, + 2C369C6828889EAE00B5AFB2 /* ErrorView.swift in Sources */, 2CA28205283E201B00D4A05A /* AppInfo.swift in Sources */, 2C865E3D2842850800F1A89A /* HideableTabView.swift in Sources */, 2CEB029F2840E7FA00DF3151 /* ViewExtensions.swift in Sources */, @@ -424,9 +470,10 @@ 2C16330D283A27D300F78CEE /* ContentView.swift in Sources */, 2CF8D62A28440FE4008FB7D0 /* UnitConverter.swift in Sources */, 2CEB02872840C50700DF3151 /* ButtonStyles.swift in Sources */, + 2CA4E7532887CBA300B901ED /* StateView.swift in Sources */, 2CAC431D287F399F0088C9FD /* CollectionView.swift in Sources */, 2CFC0F1A284219D400E597DC /* SearchView.swift in Sources */, - 2CD7E0BF2884402500F9CE57 /* WeatherConditionView.swift in Sources */, + 2CD7E0BF2884402500F9CE57 /* WeatherViews.swift in Sources */, 2C865E43284393DA00F1A89A /* CityInfoView.swift in Sources */, 2CFC0F1C28421A0300E597DC /* FavoritesView.swift in Sources */, 2CF8D62828440E05008FB7D0 /* DataBindings.swift in Sources */, @@ -782,6 +829,10 @@ isa = XCSwiftPackageProductDependency; productName = MoWeStaApi; }; + 2CA4E74E2885E62500B901ED /* LocosLabLeafles */ = { + isa = XCSwiftPackageProductDependency; + productName = LocosLabLeafles; + }; /* End XCSwiftPackageProductDependency section */ /* Begin XCVersionGroup section */ diff --git a/ios-app/app/Assets.xcassets/icon_barometer.imageset/Contents.json b/ios-app/app/Assets.xcassets/icon_barometer.imageset/Contents.json index bcda981a..129507cb 100644 --- a/ios-app/app/Assets.xcassets/icon_barometer.imageset/Contents.json +++ b/ios-app/app/Assets.xcassets/icon_barometer.imageset/Contents.json @@ -10,6 +10,7 @@ "version" : 1 }, "properties" : { - "preserves-vector-representation" : true + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" } } diff --git a/ios-app/app/Assets.xcassets/icon_cloud.imageset/Contents.json b/ios-app/app/Assets.xcassets/icon_cloud.imageset/Contents.json index 0298ea58..d45569af 100644 --- a/ios-app/app/Assets.xcassets/icon_cloud.imageset/Contents.json +++ b/ios-app/app/Assets.xcassets/icon_cloud.imageset/Contents.json @@ -10,6 +10,7 @@ "version" : 1 }, "properties" : { - "preserves-vector-representation" : true + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" } } diff --git a/ios-app/app/Assets.xcassets/icon_cloudy.imageset/Contents.json b/ios-app/app/Assets.xcassets/icon_cloudy.imageset/Contents.json index d527e383..689edb0b 100644 --- a/ios-app/app/Assets.xcassets/icon_cloudy.imageset/Contents.json +++ b/ios-app/app/Assets.xcassets/icon_cloudy.imageset/Contents.json @@ -10,6 +10,7 @@ "version" : 1 }, "properties" : { - "preserves-vector-representation" : true + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" } } diff --git a/ios-app/app/Assets.xcassets/icon_day_cloudy.imageset/Contents.json b/ios-app/app/Assets.xcassets/icon_day_cloudy.imageset/Contents.json index f43745bd..86fb2bcc 100644 --- a/ios-app/app/Assets.xcassets/icon_day_cloudy.imageset/Contents.json +++ b/ios-app/app/Assets.xcassets/icon_day_cloudy.imageset/Contents.json @@ -10,6 +10,7 @@ "version" : 1 }, "properties" : { - "preserves-vector-representation" : true + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" } } diff --git a/ios-app/app/Assets.xcassets/icon_day_fog.imageset/Contents.json b/ios-app/app/Assets.xcassets/icon_day_fog.imageset/Contents.json index 42b6d895..d2f64eb0 100644 --- a/ios-app/app/Assets.xcassets/icon_day_fog.imageset/Contents.json +++ b/ios-app/app/Assets.xcassets/icon_day_fog.imageset/Contents.json @@ -10,6 +10,7 @@ "version" : 1 }, "properties" : { - "preserves-vector-representation" : true + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" } } diff --git a/ios-app/app/Assets.xcassets/icon_day_rain.imageset/Contents.json b/ios-app/app/Assets.xcassets/icon_day_rain.imageset/Contents.json index e4b5d734..e68a0b2c 100644 --- a/ios-app/app/Assets.xcassets/icon_day_rain.imageset/Contents.json +++ b/ios-app/app/Assets.xcassets/icon_day_rain.imageset/Contents.json @@ -10,6 +10,7 @@ "version" : 1 }, "properties" : { - "preserves-vector-representation" : true + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" } } diff --git a/ios-app/app/Assets.xcassets/icon_day_rain_mix.imageset/Contents.json b/ios-app/app/Assets.xcassets/icon_day_rain_mix.imageset/Contents.json index e015667b..05eadc71 100644 --- a/ios-app/app/Assets.xcassets/icon_day_rain_mix.imageset/Contents.json +++ b/ios-app/app/Assets.xcassets/icon_day_rain_mix.imageset/Contents.json @@ -10,6 +10,7 @@ "version" : 1 }, "properties" : { - "preserves-vector-representation" : true + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" } } diff --git a/ios-app/app/Assets.xcassets/icon_day_showers.imageset/Contents.json b/ios-app/app/Assets.xcassets/icon_day_showers.imageset/Contents.json index 64e1cbbc..726b5a67 100644 --- a/ios-app/app/Assets.xcassets/icon_day_showers.imageset/Contents.json +++ b/ios-app/app/Assets.xcassets/icon_day_showers.imageset/Contents.json @@ -10,6 +10,7 @@ "version" : 1 }, "properties" : { - "preserves-vector-representation" : true + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" } } diff --git a/ios-app/app/Assets.xcassets/icon_day_snow.imageset/Contents.json b/ios-app/app/Assets.xcassets/icon_day_snow.imageset/Contents.json index 12329f5b..f46352ce 100644 --- a/ios-app/app/Assets.xcassets/icon_day_snow.imageset/Contents.json +++ b/ios-app/app/Assets.xcassets/icon_day_snow.imageset/Contents.json @@ -10,6 +10,7 @@ "version" : 1 }, "properties" : { - "preserves-vector-representation" : true + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" } } diff --git a/ios-app/app/Assets.xcassets/icon_day_sprinkle.imageset/Contents.json b/ios-app/app/Assets.xcassets/icon_day_sprinkle.imageset/Contents.json index 39de9866..78ba8ff9 100644 --- a/ios-app/app/Assets.xcassets/icon_day_sprinkle.imageset/Contents.json +++ b/ios-app/app/Assets.xcassets/icon_day_sprinkle.imageset/Contents.json @@ -10,6 +10,7 @@ "version" : 1 }, "properties" : { - "preserves-vector-representation" : true + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" } } diff --git a/ios-app/app/Assets.xcassets/icon_day_sunny.imageset/Contents.json b/ios-app/app/Assets.xcassets/icon_day_sunny.imageset/Contents.json index bc9a783a..5cb0ea27 100644 --- a/ios-app/app/Assets.xcassets/icon_day_sunny.imageset/Contents.json +++ b/ios-app/app/Assets.xcassets/icon_day_sunny.imageset/Contents.json @@ -10,6 +10,7 @@ "version" : 1 }, "properties" : { - "preserves-vector-representation" : true + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" } } diff --git a/ios-app/app/Assets.xcassets/icon_day_thunderstorm.imageset/Contents.json b/ios-app/app/Assets.xcassets/icon_day_thunderstorm.imageset/Contents.json index 8665738a..0d1bbf3d 100644 --- a/ios-app/app/Assets.xcassets/icon_day_thunderstorm.imageset/Contents.json +++ b/ios-app/app/Assets.xcassets/icon_day_thunderstorm.imageset/Contents.json @@ -10,6 +10,7 @@ "version" : 1 }, "properties" : { - "preserves-vector-representation" : true + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" } } diff --git a/ios-app/app/Assets.xcassets/icon_devices.imageset/Contents.json b/ios-app/app/Assets.xcassets/icon_devices.imageset/Contents.json new file mode 100644 index 00000000..eac6a146 --- /dev/null +++ b/ios-app/app/Assets.xcassets/icon_devices.imageset/Contents.json @@ -0,0 +1,16 @@ +{ + "images" : [ + { + "filename" : "icon_devices.svg", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" + } +} diff --git a/ios-app/app/Assets.xcassets/icon_devices.imageset/icon_devices.svg b/ios-app/app/Assets.xcassets/icon_devices.imageset/icon_devices.svg new file mode 100644 index 00000000..7765138f --- /dev/null +++ b/ios-app/app/Assets.xcassets/icon_devices.imageset/icon_devices.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ios-app/app/Assets.xcassets/icon_humidity.imageset/Contents.json b/ios-app/app/Assets.xcassets/icon_humidity.imageset/Contents.json index 2652089d..fefa0070 100644 --- a/ios-app/app/Assets.xcassets/icon_humidity.imageset/Contents.json +++ b/ios-app/app/Assets.xcassets/icon_humidity.imageset/Contents.json @@ -10,6 +10,7 @@ "version" : 1 }, "properties" : { - "preserves-vector-representation" : true + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" } } diff --git a/ios-app/app/Assets.xcassets/icon_night_clear.imageset/Contents.json b/ios-app/app/Assets.xcassets/icon_night_clear.imageset/Contents.json index e396ea08..2541d518 100644 --- a/ios-app/app/Assets.xcassets/icon_night_clear.imageset/Contents.json +++ b/ios-app/app/Assets.xcassets/icon_night_clear.imageset/Contents.json @@ -10,6 +10,7 @@ "version" : 1 }, "properties" : { - "preserves-vector-representation" : true + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" } } diff --git a/ios-app/app/Assets.xcassets/icon_night_cloudy.imageset/Contents.json b/ios-app/app/Assets.xcassets/icon_night_cloudy.imageset/Contents.json index a14de09b..8126ff2d 100644 --- a/ios-app/app/Assets.xcassets/icon_night_cloudy.imageset/Contents.json +++ b/ios-app/app/Assets.xcassets/icon_night_cloudy.imageset/Contents.json @@ -10,6 +10,7 @@ "version" : 1 }, "properties" : { - "preserves-vector-representation" : true + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" } } diff --git a/ios-app/app/Assets.xcassets/icon_night_fog.imageset/Contents.json b/ios-app/app/Assets.xcassets/icon_night_fog.imageset/Contents.json index 8ac4e3ca..58b2c9ba 100644 --- a/ios-app/app/Assets.xcassets/icon_night_fog.imageset/Contents.json +++ b/ios-app/app/Assets.xcassets/icon_night_fog.imageset/Contents.json @@ -10,6 +10,7 @@ "version" : 1 }, "properties" : { - "preserves-vector-representation" : true + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" } } diff --git a/ios-app/app/Assets.xcassets/icon_night_rain.imageset/Contents.json b/ios-app/app/Assets.xcassets/icon_night_rain.imageset/Contents.json index e57a30a7..f84d5e00 100644 --- a/ios-app/app/Assets.xcassets/icon_night_rain.imageset/Contents.json +++ b/ios-app/app/Assets.xcassets/icon_night_rain.imageset/Contents.json @@ -10,6 +10,7 @@ "version" : 1 }, "properties" : { - "preserves-vector-representation" : true + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" } } diff --git a/ios-app/app/Assets.xcassets/icon_night_rain_mix.imageset/Contents.json b/ios-app/app/Assets.xcassets/icon_night_rain_mix.imageset/Contents.json index 60875c29..2d1f4efe 100644 --- a/ios-app/app/Assets.xcassets/icon_night_rain_mix.imageset/Contents.json +++ b/ios-app/app/Assets.xcassets/icon_night_rain_mix.imageset/Contents.json @@ -10,6 +10,7 @@ "version" : 1 }, "properties" : { - "preserves-vector-representation" : true + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" } } diff --git a/ios-app/app/Assets.xcassets/icon_night_showers.imageset/Contents.json b/ios-app/app/Assets.xcassets/icon_night_showers.imageset/Contents.json index 5c7fdd26..da58cc70 100644 --- a/ios-app/app/Assets.xcassets/icon_night_showers.imageset/Contents.json +++ b/ios-app/app/Assets.xcassets/icon_night_showers.imageset/Contents.json @@ -10,6 +10,7 @@ "version" : 1 }, "properties" : { - "preserves-vector-representation" : true + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" } } diff --git a/ios-app/app/Assets.xcassets/icon_night_snow.imageset/Contents.json b/ios-app/app/Assets.xcassets/icon_night_snow.imageset/Contents.json index e0da0bdd..8a39c4df 100644 --- a/ios-app/app/Assets.xcassets/icon_night_snow.imageset/Contents.json +++ b/ios-app/app/Assets.xcassets/icon_night_snow.imageset/Contents.json @@ -10,6 +10,7 @@ "version" : 1 }, "properties" : { - "preserves-vector-representation" : true + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" } } diff --git a/ios-app/app/Assets.xcassets/icon_night_sprinkle.imageset/Contents.json b/ios-app/app/Assets.xcassets/icon_night_sprinkle.imageset/Contents.json index 109953d2..fce29dba 100644 --- a/ios-app/app/Assets.xcassets/icon_night_sprinkle.imageset/Contents.json +++ b/ios-app/app/Assets.xcassets/icon_night_sprinkle.imageset/Contents.json @@ -10,6 +10,7 @@ "version" : 1 }, "properties" : { - "preserves-vector-representation" : true + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" } } diff --git a/ios-app/app/Assets.xcassets/icon_night_thunderstorm.imageset/Contents.json b/ios-app/app/Assets.xcassets/icon_night_thunderstorm.imageset/Contents.json index 48b72b31..6d349f28 100644 --- a/ios-app/app/Assets.xcassets/icon_night_thunderstorm.imageset/Contents.json +++ b/ios-app/app/Assets.xcassets/icon_night_thunderstorm.imageset/Contents.json @@ -10,6 +10,7 @@ "version" : 1 }, "properties" : { - "preserves-vector-representation" : true + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" } } diff --git a/ios-app/app/Assets.xcassets/icon_rain.imageset/Contents.json b/ios-app/app/Assets.xcassets/icon_rain.imageset/Contents.json index c8757c65..1874acac 100644 --- a/ios-app/app/Assets.xcassets/icon_rain.imageset/Contents.json +++ b/ios-app/app/Assets.xcassets/icon_rain.imageset/Contents.json @@ -10,6 +10,7 @@ "version" : 1 }, "properties" : { - "preserves-vector-representation" : true + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" } } diff --git a/ios-app/app/Assets.xcassets/icon_rain_mix.imageset/Contents.json b/ios-app/app/Assets.xcassets/icon_rain_mix.imageset/Contents.json index 4fae2039..ca063ff2 100644 --- a/ios-app/app/Assets.xcassets/icon_rain_mix.imageset/Contents.json +++ b/ios-app/app/Assets.xcassets/icon_rain_mix.imageset/Contents.json @@ -10,6 +10,7 @@ "version" : 1 }, "properties" : { - "preserves-vector-representation" : true + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" } } diff --git a/ios-app/app/Assets.xcassets/icon_raindrop.imageset/Contents.json b/ios-app/app/Assets.xcassets/icon_raindrop.imageset/Contents.json index 5c12ad5d..7d6d2272 100644 --- a/ios-app/app/Assets.xcassets/icon_raindrop.imageset/Contents.json +++ b/ios-app/app/Assets.xcassets/icon_raindrop.imageset/Contents.json @@ -10,6 +10,7 @@ "version" : 1 }, "properties" : { - "preserves-vector-representation" : true + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" } } diff --git a/ios-app/app/Assets.xcassets/icon_raindrops.imageset/Contents.json b/ios-app/app/Assets.xcassets/icon_raindrops.imageset/Contents.json index e0e3ada3..07bc7c5d 100644 --- a/ios-app/app/Assets.xcassets/icon_raindrops.imageset/Contents.json +++ b/ios-app/app/Assets.xcassets/icon_raindrops.imageset/Contents.json @@ -10,6 +10,7 @@ "version" : 1 }, "properties" : { - "preserves-vector-representation" : true + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" } } diff --git a/ios-app/app/Assets.xcassets/icon_snow.imageset/Contents.json b/ios-app/app/Assets.xcassets/icon_snow.imageset/Contents.json index f6ea2b77..f4118010 100644 --- a/ios-app/app/Assets.xcassets/icon_snow.imageset/Contents.json +++ b/ios-app/app/Assets.xcassets/icon_snow.imageset/Contents.json @@ -10,6 +10,7 @@ "version" : 1 }, "properties" : { - "preserves-vector-representation" : true + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" } } diff --git a/ios-app/app/Assets.xcassets/icon_snowflake_cold.imageset/Contents.json b/ios-app/app/Assets.xcassets/icon_snowflake_cold.imageset/Contents.json index 0bfaa5d5..34494cbd 100644 --- a/ios-app/app/Assets.xcassets/icon_snowflake_cold.imageset/Contents.json +++ b/ios-app/app/Assets.xcassets/icon_snowflake_cold.imageset/Contents.json @@ -10,6 +10,7 @@ "version" : 1 }, "properties" : { - "preserves-vector-representation" : true + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" } } diff --git a/ios-app/app/Assets.xcassets/icon_sprinkle.imageset/Contents.json b/ios-app/app/Assets.xcassets/icon_sprinkle.imageset/Contents.json index edca3cc4..3de1a91b 100644 --- a/ios-app/app/Assets.xcassets/icon_sprinkle.imageset/Contents.json +++ b/ios-app/app/Assets.xcassets/icon_sprinkle.imageset/Contents.json @@ -10,6 +10,7 @@ "version" : 1 }, "properties" : { - "preserves-vector-representation" : true + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" } } diff --git a/ios-app/app/Assets.xcassets/icon_station.imageset/Contents.json b/ios-app/app/Assets.xcassets/icon_station.imageset/Contents.json new file mode 100644 index 00000000..9ff6c9f8 --- /dev/null +++ b/ios-app/app/Assets.xcassets/icon_station.imageset/Contents.json @@ -0,0 +1,16 @@ +{ + "images" : [ + { + "filename" : "icon_station.svg", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" + } +} diff --git a/ios-app/app/Assets.xcassets/icon_station.imageset/icon_station.svg b/ios-app/app/Assets.xcassets/icon_station.imageset/icon_station.svg new file mode 100644 index 00000000..edfe3f3f --- /dev/null +++ b/ios-app/app/Assets.xcassets/icon_station.imageset/icon_station.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ios-app/app/Assets.xcassets/icon_storm_showers.imageset/Contents.json b/ios-app/app/Assets.xcassets/icon_storm_showers.imageset/Contents.json index 620a53f2..89f624f4 100644 --- a/ios-app/app/Assets.xcassets/icon_storm_showers.imageset/Contents.json +++ b/ios-app/app/Assets.xcassets/icon_storm_showers.imageset/Contents.json @@ -10,6 +10,7 @@ "version" : 1 }, "properties" : { - "preserves-vector-representation" : true + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" } } diff --git a/ios-app/app/Assets.xcassets/icon_thermometer.imageset/Contents.json b/ios-app/app/Assets.xcassets/icon_thermometer.imageset/Contents.json index b1e4b071..20b1484d 100644 --- a/ios-app/app/Assets.xcassets/icon_thermometer.imageset/Contents.json +++ b/ios-app/app/Assets.xcassets/icon_thermometer.imageset/Contents.json @@ -10,6 +10,7 @@ "version" : 1 }, "properties" : { - "preserves-vector-representation" : true + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" } } diff --git a/ios-app/app/Assets.xcassets/icon_thunderstorm.imageset/Contents.json b/ios-app/app/Assets.xcassets/icon_thunderstorm.imageset/Contents.json index 643adaf7..be5de71c 100644 --- a/ios-app/app/Assets.xcassets/icon_thunderstorm.imageset/Contents.json +++ b/ios-app/app/Assets.xcassets/icon_thunderstorm.imageset/Contents.json @@ -10,6 +10,7 @@ "version" : 1 }, "properties" : { - "preserves-vector-representation" : true + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" } } diff --git a/ios-app/app/Assets.xcassets/icon_wind_direction.imageset/Contents.json b/ios-app/app/Assets.xcassets/icon_wind_direction.imageset/Contents.json index 31590d43..309b333a 100644 --- a/ios-app/app/Assets.xcassets/icon_wind_direction.imageset/Contents.json +++ b/ios-app/app/Assets.xcassets/icon_wind_direction.imageset/Contents.json @@ -10,6 +10,7 @@ "version" : 1 }, "properties" : { - "preserves-vector-representation" : true + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" } } diff --git a/ios-app/app/ContentView.swift b/ios-app/app/ContentView.swift index a3feade3..bf480133 100644 --- a/ios-app/app/ContentView.swift +++ b/ios-app/app/ContentView.swift @@ -23,6 +23,7 @@ struct ContentView: View { NavigationView { LoginView() } + .navigationViewStyle(StackNavigationViewStyle()) } else { NavigationView { DrawerView() diff --git a/ios-app/app/Model/AppState.swift b/ios-app/app/Model/AppState.swift index af5af2c7..50a8d42f 100644 --- a/ios-app/app/Model/AppState.swift +++ b/ios-app/app/Model/AppState.swift @@ -28,6 +28,16 @@ public class AppState: ObservableObject { // The device token used to upload data @UserDefault("token", defaultValue: "") var token: String + @UserDefault("precipitation", defaultValue: true) var precipitation: Bool { willSet { objectWillChange.send() }} + @UserDefault("windSpeed", defaultValue: true) var windSpeed: Bool { willSet { objectWillChange.send() }} + @UserDefault("cloudCoverage", defaultValue: true) var cloudCoverage: Bool { willSet { objectWillChange.send() }} + @UserDefault("humidity", defaultValue: true) var humidity: Bool { willSet { objectWillChange.send() }} + @UserDefault("snowDepth", defaultValue: true) var snowDepth: Bool { willSet { objectWillChange.send() }} + @UserDefault("pressure", defaultValue: true) var pressure: Bool { willSet { objectWillChange.send() }} + @UserDefault("unitSystem", defaultValue: .both) var unitSystem: UnitSystem { willSet { objectWillChange.send() }} + @UserDefault("temperatureUnit", defaultValue: .both) var temperatureUnit: TemperatureUnit { willSet { objectWillChange.send() }} + + private var loadedDevice: Device? = nil var device: Device? { diff --git a/ios-app/app/Model/DataBindings.swift b/ios-app/app/Model/DataBindings.swift index da2c039f..416bfe92 100644 --- a/ios-app/app/Model/DataBindings.swift +++ b/ios-app/app/Model/DataBindings.swift @@ -9,13 +9,13 @@ import Foundation import SwiftUI import MoWeStaApi -public enum UnitSystem { +public enum UnitSystem: Codable { case si case imperial case both } -public enum TemperatureUnit { +public enum TemperatureUnit: Codable { case celsius case fahrenheit case both @@ -29,7 +29,7 @@ public class DataBindings { case .celsius: return "format_temperature_celsius \(value)" case .fahrenheit: - return "format_temperature_celsius \(UnitConverter.celsiusToFahrenheit(value))" + return "format_temperature_fahrenheit \(UnitConverter.celsiusToFahrenheit(value))" case .both: return "format_temperature_both \(value) \(UnitConverter.celsiusToFahrenheit(value))" } @@ -128,10 +128,7 @@ public class DataBindings { formatter.locale = Locale.current formatter.dateFormat = format.stringValue if let tz = timezone, let zone = TimeZone(identifier: tz) { - print("TZ ok") formatter.timeZone = zone - } else { - print("TZ not ok \(timezone)") } return formatter.string(from: Date(timeIntervalSince1970: time)) } @@ -161,10 +158,9 @@ public class DataBindings { public static func getWeekday(_ timestamp: Int64, _ timezone: String?) -> String { let now = Date() - let tomorrow = getDate(Int64(Calendar.current.date(byAdding: .day, value: 1, to: now)!.timeIntervalSince1970 * 1000), "UTC") - let yesterday = getDate(Int64(Calendar.current.date(byAdding: .day, value: -1, to: now)!.timeIntervalSince1970 * 1000), "UTC") - let today = getDate(Int64(now.timeIntervalSince1970 * 1000), "UTC") - print("\(yesterday) \(today) \(tomorrow)") + let tomorrow = getDate(Int64(Calendar.current.date(byAdding: .day, value: 1, to: now)!.timeIntervalSince1970 * 1000), nil) + let yesterday = getDate(Int64(Calendar.current.date(byAdding: .day, value: -1, to: now)!.timeIntervalSince1970 * 1000), nil) + let today = getDate(Int64(now.timeIntervalSince1970 * 1000), nil) let date = getDate(timestamp, timezone) if date == tomorrow { return NSLocalizedString("date_tomorrow", comment: "") @@ -183,4 +179,17 @@ public class DataBindings { } } + public static func getInterval(_ timestamp: Int64, _ timezone: String?) -> String { + let hour = getHour(timestamp, timezone) + if hour < 6 { + return NSLocalizedString("label_night", comment: "") + } else if hour < 12 { + return NSLocalizedString("label_morning", comment: "") + } else if hour < 18 { + return NSLocalizedString("label_afternoon", comment: "") + } else { + return NSLocalizedString("label_evening", comment: "") + } + } + } diff --git a/ios-app/app/Model/TextBindings.swift b/ios-app/app/Model/TextBindings.swift index 87ea9cdb..c3117d37 100644 --- a/ios-app/app/Model/TextBindings.swift +++ b/ios-app/app/Model/TextBindings.swift @@ -11,6 +11,7 @@ import SwiftUI import class MoWeStaApi.City import class MoWeStaApi.LocationHierarchy import class MoWeStaApi.WeatherCondition +import class MoWeStaApi.WeatherVideo import class MoWeStaApi.State import class MoWeStaApi.Country @@ -74,6 +75,15 @@ public class TextBindings { } return string } + + public static func getRegionName(_ city: City) -> String { + let name = getName(city.country.names, false)! + if let s = city.state { + return "\(getName(s.names, true)!), \(name)" + } else { + return name + } + } public static func getCityType(_ city: City) -> LocalizedStringKey { switch (city.type) { @@ -184,5 +194,41 @@ public class TextBindings { } } + public static func getUnitSystem(_ value: UnitSystem) -> LocalizedStringKey { + switch (value) { + case .imperial: + return "customize_system_imperial" + case .si: + return "customize_system_standard" + case .both: + return "customize_system_both" + } + } + + public static func getTemperatureUnit(_ value: TemperatureUnit) -> LocalizedStringKey { + switch (value) { + case .celsius: + return "customize_temperature_celsius" + case .fahrenheit: + return "customize_temperature_fahrenheit" + case .both: + return "customize_temperature_both" + } + } + + public static func getVideoType(_ value: WeatherVideo.ModelType) -> LocalizedStringKey { + switch value { + case .pressure: + return "video_type_pressure" + case .precipitation: + return "video_type_precipitation" + case .cloud: + return "video_type_cloud" + case .temperature: + return "video_type_temperature" + case .wind: + return "video_type_wind" + } + } } diff --git a/ios-app/app/Model/WeatherAggregates.swift b/ios-app/app/Model/WeatherAggregates.swift new file mode 100644 index 00000000..cd176f47 --- /dev/null +++ b/ios-app/app/Model/WeatherAggregates.swift @@ -0,0 +1,263 @@ +// +// WeatherAggregates.swift +// App +// +// Created by Marcus Handte on 17.07.22. +// + +import Foundation +import class MoWeStaApi.WeatherCondition +import SwiftUI + + +struct WeatherSummary: Identifiable { + let id = UUID() + let title: LocalizedStringKey + let subtitle: LocalizedStringKey + let min: WeatherCondition + let max: WeatherCondition + + init?(title: LocalizedStringKey, subtitle: LocalizedStringKey, conditions: [WeatherCondition]) { + self.title = title + self.subtitle = subtitle + if let f = conditions.first { + min = f.copy() + max = f.copy() + for c in conditions { + min.cloudCoverage = Swift.min(min.cloudCoverage, c.cloudCoverage) + min.windSpeed = Swift.min(min.windSpeed, c.windSpeed) + if (min.windSpeed == c.windSpeed) { + min.windDirection = c.windDirection + } + min.temperature = Swift.min(min.temperature, c.temperature) + min.snowDepth = Swift.min(min.snowDepth, c.snowDepth) + min.pressure = Swift.min(min.pressure, c.pressure) + min.precipitation = Swift.min(min.precipitation, c.precipitation) + min.humidity = Swift.min(min.humidity, c.humidity) + min.cloudDepth = Swift.min(min.cloudDepth, c.cloudDepth) + min.type = mini(min.type, c.type) + min.source = mini(min.source, c.source) + + max.cloudCoverage = Swift.max(max.cloudCoverage, c.cloudCoverage) + max.windSpeed = Swift.max(max.windSpeed, c.windSpeed) + if (max.windSpeed == c.windSpeed) { + max.windDirection = c.windDirection + } + max.temperature = Swift.max(max.temperature, c.temperature) + max.snowDepth = Swift.max(max.snowDepth, c.snowDepth) + max.pressure = Swift.max(max.pressure, c.pressure) + max.precipitation = Swift.max(max.precipitation, c.precipitation) + max.humidity = Swift.max(max.humidity, c.humidity) + max.cloudDepth = Swift.max(max.cloudDepth, c.cloudDepth) + max.type = maxi(max.type, c.type) + max.source = maxi(max.source, c.source) + } + } else { + return nil + } + } + + private func mini(_ a: WeatherCondition.Source, _ b: WeatherCondition.Source) -> WeatherCondition.Source { + let ra = getRank(a) + let rb = getRank(b) + if ra < 0 { + return b + } + if rb < 0 { + return a + } + return (ra < rb) ? a : b + } + + private func maxi(_ a: WeatherCondition.Source, _ b: WeatherCondition.Source) -> WeatherCondition.Source { + let ra = getRank(a) + let rb = getRank(b) + if ra < 0 { + return b + } + if rb < 0 { + return a + } + return (ra > rb) ? a : b + } + + private func mini(_ a: WeatherCondition.ModelType, _ b: WeatherCondition.ModelType) -> WeatherCondition.ModelType { + let ra = getRank(a) + let rb = getRank(b) + if ra < 0 { + return b + } + if rb < 0 { + return a + } + return (ra < rb) ? a : b + } + + private func maxi(_ a: WeatherCondition.ModelType, _ b: WeatherCondition.ModelType) -> WeatherCondition.ModelType { + let ra = getRank(a) + let rb = getRank(b) + if ra < 0 { + return b + } + if rb < 0 { + return a + } + return (ra > rb) ? a : b + } + + private func getRank(_ source: WeatherCondition.Source) -> Int { + switch (source) { + case .iconGlobal: + return 2; + case .iconEurope: + return 1; + case .cosmoEurope: + return 0; + case .weatherStation: + return -1; + } + } + + private func getRank(_ type: WeatherCondition.ModelType) -> Int { + switch (type) { + case .clearSky: + return 0 + case .mainlyClear: + return 1 + case .partlyCloudy: + return 2 + case .cloudy: + return 3 + case .fog: + return 4 + case .fogDepositingRime: + return 5 + case .slightDrizzle: + return 6 + case .slightRainNotFreezing: + return 7 + case .rainShowerSlight: + return 8 + case .drizzleFreezingSlight: + return 9 + case .rainFreezingSlight: + return 10 + case .slightFallOfSnowflakes: + return 11 + case .snowShowerSlight: + return 12 + case .moderateDrizzle: + return 13 + case .heavyDrizzle: + return 14 + case .moderateRainNotFreezing: + return 15 + case .snowGrains: + return 16 + case .moderateFallOfSnowflakes: + return 17 + case .heavyRainNotFreezing: + return 18 + case .drizzleFreezingModerateHeavy: + return 19 + case .heavyFallOfSnowflakes: + return 20 + case .rainShowerModerateHeavy: + return 21 + case .rainFreezingModerateHeavy: + return 22 + case .snowShowerModerateHeavy: + return 23 + case .rainShowerViolent: + return 24 + case .thunderstormSlightModerate: + return 25 + case .thunderstormHailHeavy: + return 26 + default: + return -1 + } + } + +} + +extension WeatherCondition { + func copy() -> WeatherCondition { + return WeatherCondition(cloudCoverage: cloudCoverage, cloudDepth: cloudDepth, duration: duration, hour: hour, humidity: humidity, precipitation: precipitation, pressure: pressure, snowDepth: snowDepth, source: source, temperature: temperature, time: time, type: type, windDirection: windDirection, windSpeed: windSpeed) + } +} + +struct WeatherEntry: Identifiable { + let id = UUID() + let title: LocalizedStringKey + let subtitle: LocalizedStringKey + let condition: WeatherCondition +} + + +public class WeatherAggregate { + + var hours: [WeatherEntry] = [] + var times: [WeatherSummary] = [] + var days: [WeatherSummary] = [] + + init(_ conditions: [WeatherCondition], _ timezone: String?) { + let input = conditions.sorted { a, b in + return a.time < b.time + } + var times: [[WeatherCondition]] = [] + var days: [[WeatherCondition]] = [] + var currentDay: [WeatherCondition] = [] + var currentTime: [WeatherCondition] = [] + for w in input { + let title = LocalizedStringKey("format_title \(DataBindings.getWeekday(w.time, timezone))") + let subtitle = LocalizedStringKey("format_title \(DataBindings.getTime(w.time, timezone)) \(DataBindings.getDate(w.time, timezone))") + hours.append(WeatherEntry(title: title, subtitle: subtitle , condition: w)) + if let c = currentDay.first { + if DataBindings.getDate(c.time, timezone) == DataBindings.getDate(w.time, timezone) { + currentDay.append(w) + } else { + days.append(currentDay) + currentDay = [ w ] + times.append(currentTime) + currentTime = [] + } + } else { + currentDay.append(w) + } + if let c = currentTime.first { + if DataBindings.getInterval(c.time, timezone) == DataBindings.getInterval(w.time, timezone) { + currentTime.append(w) + } else { + times.append(currentTime) + currentTime = [ w ] + } + } else { + currentTime.append(w) + } + } + if (!currentDay.isEmpty) { + days.append(currentDay) + } + if (!currentTime.isEmpty) { + times.append(currentTime) + } + for d in days { + if let first = d.first { + let title = LocalizedStringKey("format_title \(DataBindings.getWeekday(first.time, timezone))") + let subtitle = LocalizedStringKey("label_full_day") + self.days.append(WeatherSummary(title: title, subtitle: subtitle, conditions: d)!) + } + } + for t in times { + if let first = t.first { + let title = LocalizedStringKey("format_title \(DataBindings.getWeekday(first.time, timezone))") + let subtitle = LocalizedStringKey("format_title \(DataBindings.getInterval(first.time, timezone))") + self.times.append(WeatherSummary(title: title, subtitle: subtitle, conditions: t)!) + } + } + } + +} + + diff --git a/ios-app/app/Ui/ButtonStyles.swift b/ios-app/app/Ui/ButtonStyles.swift index 19f48b04..1cbd836d 100644 --- a/ios-app/app/Ui/ButtonStyles.swift +++ b/ios-app/app/Ui/ButtonStyles.swift @@ -12,16 +12,20 @@ struct MaterialButtonStyle: ButtonStyle { /// The background color let color: Color + let foreground: Color + /// A flag to indicate whether the button is disabled. let disabled: Bool; init(disabled: Bool) { self.color = Color.accentColor + self.foreground = Color.black self.disabled = disabled } init(color: Color, disabled: Bool) { self.color = color + self.foreground = Color.white self.disabled = disabled } @@ -33,7 +37,7 @@ struct MaterialButtonStyle: ButtonStyle { configuration .label .font(.body.smallCaps()) - .foregroundColor((configuration.isPressed && !disabled) ? .gray : .white) + .foregroundColor((configuration.isPressed && !disabled) ? .gray : foreground) .frame(maxWidth:.infinity) .padding(8) .background(disabled ? Color.gray : color) diff --git a/ios-app/app/Ui/ErrorView.swift b/ios-app/app/Ui/ErrorView.swift new file mode 100644 index 00000000..2c6898ab --- /dev/null +++ b/ios-app/app/Ui/ErrorView.swift @@ -0,0 +1,57 @@ +// +// ErrorView.swift +// App +// +// Created by Marcus Handte on 20.07.22. +// + +import SwiftUI + +struct ErrorView: View { + + let action: (() -> Void)? + @State var opacity: Double = 0.0 + + var body: some View { + HStack { + Text("snackbar_error") + .font(.body) + .frame(maxWidth: .infinity) + .foregroundColor(.white) + .multilineTextAlignment(.center) + if let a = action { + Button(action: a) { + Text("snackbar_reload") + } + .buttonStyle(MaterialButtonStyle(disabled: false)) + .frame(width: 100) + .padding(.leading, 10) + } + } + .padding(10) + .background( + RoundedRectangle(cornerRadius: 6) + .foregroundColor(Color("PrimaryColor"))) + .padding(10) + .opacity(opacity) + .animation(.easeIn(duration: 0.5), value: opacity) + .onAppear() { + opacity = 1 + } + .onDisappear() { + opacity = 0 + } + + } +} + +struct ErrorView_Previews: PreviewProvider { + static var previews: some View { + VStack { + Spacer() + ErrorView() { + + } + } + } +} diff --git a/ios-app/app/Ui/HideableTabView.swift b/ios-app/app/Ui/HideableTabView.swift index e8e0b18c..cf3bb4ca 100644 --- a/ios-app/app/Ui/HideableTabView.swift +++ b/ios-app/app/Ui/HideableTabView.swift @@ -50,7 +50,7 @@ extension EnvironmentValues { struct HideableTabItem: Identifiable { let id: Int let text: LocalizedStringKey - let image: String + let image: Image @ViewBuilder let builder: () -> AnyView } @@ -60,46 +60,59 @@ struct HideableTabView: View { let tag: String @EnvironmentObject var tabViewState: TabViewState @State var selected: Int = 0; + let insets: EdgeInsets; private let builder: () -> [HideableTabItem] - init(_ tag: String, _ builder: @escaping () -> [HideableTabItem]) { + init(_ tag: String, _ insets: EdgeInsets, _ builder: @escaping () -> [HideableTabItem]) { self.tag = tag self.builder = builder + self.insets = insets } var body: some View { let content = builder() - VStack { + VStack(spacing: 0) { + HStack(spacing: 0) { + Spacer() + .frame(width: insets.leading) ForEach(content, id: \.id) { c in if c.id == selected { c.builder() } } - if !tabViewState.isHidden(view: tag) { - Spacer() - HStack { - ForEach(content, id: \.id) { - c in - Button(action: { selected = c.id }) { - VStack { - Image(systemName: c.image) - .opacity(c.id == selected ? 1 : 0.5) - .font(.title2) - .padding(1) - Text(c.text) - .font(.caption2) - .opacity(c.id == selected ? 1 : 0.5) - .lineLimit(1) - } - .frame(minWidth: 0, maxWidth: .infinity) - } - } - } - } + Spacer() + .frame(width: insets.leading) } + if !tabViewState.isHidden(view: tag) { + HStack { + Spacer() + .frame(width: insets.leading) + ForEach(content, id: \.id) { + c in + Button(action: { selected = c.id }) { + VStack { + c.image + .foregroundColor(c.id == selected ? Color.accentColor : Color.white) + .font(.title2) + .padding(1) + Text(c.text) + .foregroundColor(c.id == selected ? Color.accentColor : Color.white) + .font(c.id == selected ? .system(size: 10).bold() : .system(size: 10)) + .lineLimit(1) + } + .frame(minWidth: 0, maxWidth: .infinity) + }.buttonStyle(NullButtonStyle()) + } + Spacer() + .frame(width: insets.trailing) + } + .padding([.top, .bottom], 4) + .background(Color("PrimaryColor")) + } + } } diff --git a/ios-app/app/Ui/PageView.swift b/ios-app/app/Ui/PageView.swift new file mode 100644 index 00000000..e8af7158 --- /dev/null +++ b/ios-app/app/Ui/PageView.swift @@ -0,0 +1,64 @@ +// +// PagedView.swift +// App +// +// Created by Marcus Handte on 18.07.22. +// + +import SwiftUI + +struct PageItem: Identifiable { + let id: Int + var text: LocalizedStringKey + @ViewBuilder let builder: () -> AnyView +} + + +struct PageView: View { + + @State var pages: [PageItem] + @Binding var current: Int + + + var body: some View { + VStack(spacing: 0) { + if current < 0 || current >= pages.count { + EmptyView() + } else { + pages[current].builder() + } + Divider() + HStack(spacing: 0) { + ForEach(pages, id: \PageItem.id) { page in + Button(action: { + current = page.id + }) { + let t = Text(page.text) + .frame(alignment: .center) + .frame(maxWidth: .infinity) + .frame(minHeight: 40) + .lineLimit(1) + if page.id == current { + t + .font(.caption.bold()) + .background( + RoundedRectangle(cornerRadius: 4) + .foregroundColor(Color("PrimaryColor"))) + .foregroundColor(Color.accentColor) + } else { + t.font(.caption) + } + } + .frame(minHeight: 44) + .buttonStyle(NullButtonStyle()) + } + } + } + } +} + +struct PagedView_Previews: PreviewProvider { + static var previews: some View { + EmptyView() + } +} diff --git a/ios-app/app/Ui/RemoteImageView.swift b/ios-app/app/Ui/RemoteImageView.swift new file mode 100644 index 00000000..54695cd7 --- /dev/null +++ b/ios-app/app/Ui/RemoteImageView.swift @@ -0,0 +1,63 @@ +// +// RemoteImageView.swift +// App +// +// Created by Marcus Handte on 18.07.22. +// + +import Foundation +import SwiftUI + +struct RemoteImageView: View { + var url: URL + private let placeholder: () -> Placeholder + private let image: (Image) -> ConfiguredImage + + @ObservedObject var imageLoader: ImageLoaderService + @State var imageData: UIImage? + + init( + url: URL, + @ViewBuilder placeholder: @escaping () -> Placeholder, + @ViewBuilder image: @escaping (Image) -> ConfiguredImage + ) { + self.url = url + self.placeholder = placeholder + self.image = image + self.imageLoader = ImageLoaderService(url: url) + } + + @ViewBuilder private var imageContent: some View { + if let data = imageData { + image(Image(uiImage: data)) + } else { + placeholder() + } + } + + var body: some View { + imageContent + .onReceive(imageLoader.$image) { imageData in + self.imageData = imageData + } + } +} + +class ImageLoaderService: ObservableObject { + @Published var image: UIImage? = nil + + convenience init(url: URL) { + self.init() + loadImage(for: url) + } + + func loadImage(for url: URL) { + let task = URLSession.shared.dataTask(with: url) { data, _, _ in + guard let data = data else { return } + DispatchQueue.main.async { + self.image = UIImage(data: data) ?? nil + } + } + task.resume() + } +} diff --git a/ios-app/app/Util/GeojsonConverter.swift b/ios-app/app/Util/GeojsonConverter.swift new file mode 100644 index 00000000..03044669 --- /dev/null +++ b/ios-app/app/Util/GeojsonConverter.swift @@ -0,0 +1,94 @@ +// +// GeojsonConverter.swift - A utility to convert geojson boundaries to polylines. +// +// Created by Marcus Handte on 20.07.22. +// +import Foundation +import class MoWeStaApi.Geometry +import LocosLabGeometry +import AnyCodable + +/// A utility to extract coordinates from geojson boundaries. +public class GeojsonConverter { + + /// Returns the coordinates of the first (outer) ring found in the geometry. + /// + /// - parameters: + /// - of: The geometry to extract coordinates. + /// - returns: A (possibly empty) array of coordinates. + public static func coordinates(of geometry: Geometry?, simplify: Double) -> [[Coordinate]] { + var array: Array = Array() + var next: Array? = nil + if let c = geometry?.coordinates as? Array { + next = c + } + //print(geometry?.coordinates) + while next != nil { + if let c = next { + array.append(c) + if !c.isEmpty { + if let codable = c[0] as? AnyCodable, let x = codable.value as? Array { + next = x + } else if let x = c[0] as? Array { + next = x + } else { + next = nil + } + } else { + next = nil + } + } + } + var data: [[Coordinate]] = [] + if !array.isEmpty { + data.append(contentsOf: GeojsonConverter.extract(geometry!.coordinates!, array.count - 1)) + } + var result: [[Coordinate]] = [] + data.forEach() { cords in + result.append(Polylines.simplify(polyline: cords, deviation: simplify)) + } + return result + } + + public static func extract(_ array: Array, _ count: Int) -> [[Coordinate]] { + var result: [[Coordinate]] = [] + if count > 2 { + for a in array { + if let x = a as? AnyCodable, let y = x.value as? Array { + result.append(contentsOf: GeojsonConverter.extract(y, count - 1)) + } else if let y = a as? Array { + result.append(contentsOf: GeojsonConverter.extract(y, count - 1)) + } + } + } else { + if let firstCodable = array.first as? AnyCodable, let first = firstCodable.value as? Array { + let coords = GeojsonConverter.ring(from: first) + if !coords.isEmpty { + result.append(coords) + } + } else if let first = array.first as? Array { + let coords = GeojsonConverter.ring(from: first) + if !coords.isEmpty { + result.append(coords) + } + } + } + return result; + } + + public static func ring(from first: Array) -> [Coordinate] { + var coords: [Coordinate] = [] + first.forEach({ a in + if let c = a as? Array { + if c.count >= 2 { + if let long = c[0] as? Double, let lat = c[1] as? Double { + coords.append(Coordinate(longitude: long, latitude: lat)) + } + } + } + }) + return coords + } + + +} diff --git a/ios-app/app/View/CityForecastView.swift b/ios-app/app/View/CityForecastView.swift index 897d5a26..b379440e 100644 --- a/ios-app/app/View/CityForecastView.swift +++ b/ios-app/app/View/CityForecastView.swift @@ -13,15 +13,34 @@ import class MoWeStaApi.WeatherForecast struct CityForecastView: View { let city: City - let forecast: WeatherForecast - + let aggregate: WeatherAggregate + let page: Binding + var body: some View { - List(forecast.conditions, id: \WeatherCondition.time) { condition in - WeatherConditionView( - title: DataBindings.getWeekday(condition.time, city.timezone), - subtitle: DataBindings.getTime(condition.time, city.timezone), condition: condition, unitSystem: .both, temperatureUnit: .both) - } + PageView(pages: [ + /* + PageItem(id: 0, text: "city_info_gradient") { + AnyView(EmptyView()) + },*/ + PageItem(id: 0, text: "city_info_day") { + AnyView(List(aggregate.days) { summary in + WeatherSummaryView(title: summary.title, subtitle: summary.subtitle, summary: summary) + } + .listStyle(.plain) + ) + }, + PageItem(id: 1, text: "city_info_time") { + AnyView(List(aggregate.times) { summary in + WeatherSummaryView(title: summary.title, subtitle: summary.subtitle, summary: summary) + }.listStyle(.plain)) + }, + PageItem(id: 2, text: "city_info_hour") { + AnyView(List(aggregate.hours) { entry in + WeatherConditionView(title: entry.title, subtitle: entry.subtitle, condition: entry.condition) + }.listStyle(.plain)) + } + ], current: page) } } diff --git a/ios-app/app/View/CityInfoView.swift b/ios-app/app/View/CityInfoView.swift index f5d88f40..e0b14d9b 100644 --- a/ios-app/app/View/CityInfoView.swift +++ b/ios-app/app/View/CityInfoView.swift @@ -9,21 +9,21 @@ import SwiftUI import class MoWeStaApi.City import class MoWeStaApi.WeatherCondition import class MoWeStaApi.WeatherStation +import LocosLabGeometry struct CityInfoView: View { var city: City - var condition: WeatherCondition? + var condition: WeatherCondition var station: WeatherStation? + var boundary: [[Coordinate]]? var body: some View { ScrollView { VStack { - if let c = condition { - WeatherConditionView(title: NSLocalizedString("city_info_title" , comment: ""), subtitle: NSLocalizedString(TextBindings.getWeatherSource(c), comment: ""), condition: c, unitSystem: .both, temperatureUnit: .both) + WeatherConditionView(title: "city_info_title", subtitle: LocalizedStringKey(TextBindings.getWeatherSource(condition)), condition: condition) .padding() - Divider() - } + Divider() HStack { Image(systemName: "building.2") .resizable() @@ -38,16 +38,24 @@ struct CityInfoView: View { .frame(maxWidth: .infinity, alignment: .leading) } if let state = city.state, let stateName = TextBindings.getName(state.names, false) { - Text(verbatim: stateName) - .lineLimit(1) - .font(.body) - .frame(maxWidth: .infinity, alignment: .leading) + NavigationLink(destination: { + StateView(stateId: state.id!) + }) { + Text(verbatim: stateName) + .lineLimit(1) + .font(.body) + .frame(maxWidth: .infinity, alignment: .leading) + } } if let countryName = TextBindings.getName(city.country.names, false) { - Text(verbatim: countryName) - .lineLimit(1) - .font(.body) - .frame(maxWidth: .infinity, alignment: .leading) + NavigationLink(destination: { + CountryView(countryId: city.country.id!) + }) { + Text(verbatim: countryName) + .lineLimit(1) + .font(.body) + .frame(maxWidth: .infinity, alignment: .leading) + } } } }.padding() @@ -73,15 +81,44 @@ struct CityInfoView: View { }.padding([.top, .bottom], 1) } HStack { - Image(systemName: "clock") + Image(systemName: "map") .frame(width: 60) .font(.body) Text("label_timezone") Text(city.timezone) .frame(maxWidth: .infinity, alignment: .trailing) }.padding([.top, .bottom], 1) - + HStack { + let time = Int64(Date().timeIntervalSince1970 * 1000) + Image(systemName: "clock") + .frame(width: 60) + .font(.body) + Text("label_local_time") + Text("format_title \(DataBindings.getTime(time, city.timezone)) \(DataBindings.getDate(time, city.timezone))") + .frame(maxWidth: .infinity, alignment: .trailing) + }.padding([.top, .bottom], 1) + if let s = station { + HStack { + Image("icon_station") + .frame(width: 60) + .font(.body) + .opacity(0.9) + Text("label_station") + NavigationLink(destination: { + StationView(stationId: s.id!) + }) { + Text(s.name) + .frame(maxWidth: .infinity, alignment: .trailing) + } + }.padding([.top, .bottom], 1) + } }.padding() + Divider() + PlaceMapView(center: Coordinate(longitude: city.coordinate.longitude, latitude: city.coordinate.latitude), zoom: 13, boundary: boundary) + .frame(height: 200) + .frame(maxWidth: .infinity) + .clipShape(RoundedRectangle(cornerRadius: 6)) + .padding() } } } diff --git a/ios-app/app/View/CityVideoView.swift b/ios-app/app/View/CityVideoView.swift new file mode 100644 index 00000000..e0dc0aa5 --- /dev/null +++ b/ios-app/app/View/CityVideoView.swift @@ -0,0 +1,258 @@ +// +// CityVideoView.swift +// App +// +// Created by Marcus Handte on 18.07.22. +// + +import SwiftUI +import class MoWeStaApi.WeatherVideo +import class MoWeStaApi.City +import class LocosLabLeafless.MapProjection +import AVKit +import LocosLabLeafless + +struct CityVideoView: View { + + var city: City + var videos: WeatherVideos + var pages: [PageItem] = [] + var page: Binding + + init(city: City, videos: WeatherVideos, page: Binding) { + self.city = city + self.videos = videos + self.page = page + var id = 0 + if !videos.cosmoEurope.isEmpty { + pages.append(PageItem(id: id, text: "video_source_cosmo_europe") { + AnyView( + List(videos.cosmoEurope, id: \WeatherVideo.type) { video in + WeatherVideoImageView(city: city, video: video) + }.listStyle(.plain) + ) + }) + id += 1 + } + if !videos.iconEurope.isEmpty { + pages.append(PageItem(id: id, text: "video_source_icon_europe") { + AnyView( + List(videos.iconEurope, id: \WeatherVideo.type) { video in + WeatherVideoImageView(city: city, video: video) + }.listStyle(.plain) + ) + }) + id += 1 + } + if !videos.iconGlobal.isEmpty { + pages.append(PageItem(id: id, text: "video_source_icon_global") { + AnyView( + List(videos.iconGlobal, id: \WeatherVideo.type) { video in + WeatherVideoImageView(city: city, video: video) + }.listStyle(.plain) + ) + }) + id += 1 + } + } + + var body: some View { + PageView(pages: pages, current: page) + } +} + + +struct WeatherVideoImageView: View { + + let city: City + let video: WeatherVideo + + var body: some View { + ZStack { + VStack(alignment: .center) { + RemoteImageView(url: URL(string: video.preview)!, placeholder: { + Image(systemName: "film") + .resizable() + .aspectRatio(CGSize(width: 16, height: 9), contentMode: .fit) + .frame(maxWidth: .infinity) + .padding(32) + .background(Color.gray.opacity(0.2)) + .clipShape(RoundedRectangle(cornerRadius: 6)) + }, image: { image in + image + .resizable() + .aspectRatio(contentMode: .fit) + .frame(maxWidth: .infinity) + .clipShape(RoundedRectangle(cornerRadius: 6)) + }) + Text(TextBindings.getVideoType(video.type)) + } + NavigationLink(destination: WeatherVideoPlayerView(city: city, video: video)) { + EmptyView() + }.buttonStyle(PlainButtonStyle()) + } + } + +} + +struct WeatherVideoPlayerView: View { + + let player: AVPlayer + let city: City + let video: WeatherVideo + @State var seconds: Double = 0 + @State var observer: Any? + @State var day = "" + @State var time = "" + @State var legend = true + + init(city: City, video: WeatherVideo) { + self.city = city + self.video = video + self.player = AVPlayer(url: URL(string: video.url)!) + } + + func computeCityOffset(size: CGSize) -> (CGFloat, CGFloat) { + let sf = max(CGFloat(video.width) / size.width, CGFloat(video.height) / size.height) + let width = CGFloat(video.width) / sf + let height = CGFloat(video.height) / sf + + let projection = MapProjection() + let max = projection.project(longitude: video.northEast.longitude, latitude: video.northEast.latitude) + let min = projection.project(longitude: video.southWest.longitude, latitude: video.southWest.latitude) + let p = projection.project(longitude: city.coordinate.longitude, latitude: city.coordinate.latitude) + + let dx = p.x - min.x + let dy = p.y - min.y + let tx = max.x - min.x + let ty = max.y - min.y + + let px = dx / tx + let py = 1 - (dy / ty) + + let x = width * px + let y = height * py + + return (x, y) + } + + func ignoreSafeArea(size: CGSize) -> Bool { + return size.height > size.width + } + + func computeScaleDimensions(size: CGSize) -> (CGFloat, CGFloat, CGFloat, CGFloat) { + let sf = max(CGFloat(video.width) / size.width, CGFloat(video.height) / size.height) + let videoWidth = CGFloat(video.width) / sf + let videoHeight = CGFloat(video.height) / sf + + let labelWidth = size.width * 0.50 + let labelHeight = labelWidth / 10 + + if videoHeight + labelHeight + 10 < size.height { + return (videoWidth / 2, videoHeight + labelHeight / 2 + 8, labelWidth, labelHeight) + } else { + return (videoWidth / 2, videoHeight - 4 - labelHeight / 2, labelWidth, labelHeight) + } + } + + func computeLabelDimensions(size: CGSize) -> (CGFloat, CGFloat, CGFloat, CGFloat) { + let sf = max(CGFloat(video.width) / size.width, CGFloat(video.height) / size.height) + let videoWidth = CGFloat(video.width) / sf + let videoHeight = CGFloat(video.height) / sf + + let labelWidth = CGFloat(100) + let labelHeight = CGFloat(50) + + if videoHeight + labelHeight + 4 < size.height { + return (videoWidth - labelWidth / 2 - 4, -labelHeight / 2 - 4, labelWidth, labelHeight) + } else { + return (videoWidth - labelWidth / 2 - 4, labelHeight / 2 + 4 + 30, labelWidth, labelHeight) + } + } + + func updateLabelContent() { + let hps = Double(video.fph) / Double(video.fps) + let hours = seconds / hps + let timestamp = video.time + Int64(video.start + Int(round(hours))) * 60 * 60 * 1000 + day = DataBindings.getWeekday(timestamp, city.timezone) + time = DataBindings.getTime(timestamp, city.timezone) + } + + + + var body: some View { + GeometryReader { proxy in + let cityPosition = computeCityOffset(size: proxy.size) + let scaleDimensions = computeScaleDimensions(size: proxy.size) + let labelDimensions = computeLabelDimensions(size: proxy.size) + VideoPlayer(player: player) { + ZStack(alignment: .topLeading) { + Color.clear + RoundedRectangle(cornerRadius: 2) + .foregroundColor(.white) + .position(x: scaleDimensions.0, y: scaleDimensions.1 - 2) + .frame(width: scaleDimensions.2 + 8, height: scaleDimensions.3 + 4) + .opacity(legend ? 0.4 : 0) + RemoteImageView(url: URL(string: video.scale)!, placeholder: { EmptyView() }) { image in + image + .resizable() + .aspectRatio(contentMode: .fit) + .position(x: scaleDimensions.0, y: scaleDimensions.1) + .frame(width: scaleDimensions.2, height: scaleDimensions.3) + } + .opacity(legend ? 1 : 0) + Circle() + .strokeBorder(Color.accentColor, lineWidth: 2) + .position(x: cityPosition.0, y: cityPosition.1) + .frame(width: 10, height: 10) + RoundedRectangle(cornerRadius: 6) + .foregroundColor(Color.accentColor) + .frame(width: labelDimensions.2, height: labelDimensions.3, alignment: .center) + .position(x: labelDimensions.0, y: labelDimensions.1) + VStack { + Text(day).lineLimit(1).font(.caption) + .foregroundColor(.black) + Text(time).lineLimit(1).font(.caption) + .foregroundColor(.black) + } .frame(width: labelDimensions.2, height: labelDimensions.3, alignment: .center) + .position(x: labelDimensions.0, y: labelDimensions.1) + } + .frame(maxWidth: .infinity, maxHeight: .infinity) + .ignoresSafeArea() + } + .aspectRatio(CGSize(width: 16, height: 9), contentMode: .fit) + .frame(maxWidth: .infinity, maxHeight: .infinity) + .onAppear() { + observer = player.addPeriodicTimeObserver(forInterval: CMTime(seconds: 0.5, preferredTimescale: 600), queue: nil) { time in + seconds = time.seconds + updateLabelContent() + } + player.play() + } + .onDisappear() { + if let o = observer { + player.removeTimeObserver(o) + observer = nil + } + } + } + .toolbar() { + VStack { + Button(action: { + legend.toggle() + }) { + if legend { + Image(systemName: "minus.circle.fill") + } else { + Image(systemName: "minus.circle") + } + } + } + } + .navigationBarHidden(true) + .navigationBarTitleDisplayMode(.inline) + .ignoresSafeArea() + } + +} + diff --git a/ios-app/app/View/CityView.swift b/ios-app/app/View/CityView.swift index 3dbf410c..2f8bca81 100644 --- a/ios-app/app/View/CityView.swift +++ b/ios-app/app/View/CityView.swift @@ -6,6 +6,7 @@ // import SwiftUI +import MapKit import class MoWeStaApi.City import class MoWeStaApi.DefaultAPI import class MoWeStaApi.WeatherCondition @@ -13,7 +14,7 @@ import class MoWeStaApi.WeatherForecast import class MoWeStaApi.WeatherVideo import class MoWeStaApi.WeatherVideoPage import class MoWeStaApi.WeatherStation -import class MoWeStaApi.Geometry +import LocosLabGeometry import AnyCodable struct CityView: View { @@ -29,11 +30,16 @@ struct CityView: View { @State var condition: WeatherCondition? @State var station: WeatherStation? @State var forecast: WeatherForecast? - @State var videos: WeatherVideoPage? - @State var boundary: Geometry? + @State var aggregate: WeatherAggregate? + @State var videos: WeatherVideos? + @State var boundary: [[Coordinate]]? @State var city: City? @State var loading = 0 @State var failure = false + @State var customize = false + @State var videoPage = 0 + @State var forecastPage = 0 + // autocomputed value to display a loading bar at the bottom @State var showLoadingAnimation = false @@ -57,6 +63,7 @@ struct CityView: View { if let r = response { city = r cityName = TextBindings.getName(r.names, false) + updateAggregate() } else { failure = true } @@ -65,10 +72,10 @@ struct CityView: View { } if videos == nil { loading += 1 - DefaultAPI.getCityVideos(id: cityId) { + DefaultAPI.getLatestCityVideos(id: cityId) { response, error in if let r = response { - videos = r + videos = WeatherVideos(r) } else { failure = true } @@ -81,6 +88,7 @@ struct CityView: View { response, error in if let r = response { forecast = r + updateAggregate() } else { failure = true } @@ -118,106 +126,174 @@ struct CityView: View { if error != nil { failure = true } else { - boundary = response - if let g = boundary, let ring = g.coordinates?.first as? AnyCodable, let coords = ring.value as? Array { - coords.forEach { v in - if let c = v as? Array { - if (c.count >= 2) { - if let longitude = c[0] as? Double, let latitude = c[1] as? Double { - print("\(longitude) \(latitude)") - } - } - } - } - - } - + boundary = GeojsonConverter.coordinates(of: response, simplify: 20) } loading -= 1 } } } - @ViewBuilder func buildInfo() -> some View { - if let ct = city { - VStack(spacing: 0) { - CityInfoView(city: ct, condition: condition, station: station) - ProgressBarView(animating: $showLoadingAnimation) - .frame(height: 3) - } + private func updateAggregate() { + if let c = city, let f = forecast { + aggregate = WeatherAggregate(f.conditions, c.timezone) } else { - ProgressSpinnerView() + aggregate = nil + } + } + + private func openMaps(_ name: String, _ longitude: Double, _ latitude: Double) { + let coordinates = CLLocationCoordinate2DMake(latitude, longitude) + let regionSpan = MKCoordinateRegion(center: coordinates, latitudinalMeters: 5000, longitudinalMeters: 5000) + let options = [ + MKLaunchOptionsMapCenterKey: NSValue(mkCoordinate: regionSpan.center), + MKLaunchOptionsMapSpanKey: NSValue(mkCoordinateSpan: regionSpan.span) + ] + let placemark = MKPlacemark(coordinate: coordinates, addressDictionary: nil) + let mapItem = MKMapItem(placemark: placemark) + mapItem.name = name + mapItem.openInMaps(launchOptions: options) + } + + + @ViewBuilder func buildInfo() -> some View { + VStack(spacing: 0) { + if let ct = city, let co = condition { + VStack(spacing: 0) { + CityInfoView(city: ct, condition: co, station: station, boundary: boundary) + if (showLoadingAnimation) { + ProgressBarView(animating: $showLoadingAnimation) + .frame(height: 3) + } + } + } else if loading > 0 { + ProgressSpinnerView() + } + if loading == 0 && failure { + Spacer() + ErrorView() { + reload() + } + } } } @ViewBuilder func buildForecast() -> some View { - if let ct = city, let fc = forecast { - VStack(spacing: 0) { - CityForecastView(city: ct, forecast: fc) - ProgressBarView(animating: $showLoadingAnimation) - .frame(height: 3) + VStack(spacing: 0) { + if let ct = city, let a = aggregate { + CityForecastView(city: ct, aggregate: a, page: $forecastPage) + } else if loading > 0 { + ProgressSpinnerView() + } + if loading == 0 && failure { + Spacer() + ErrorView() { + reload() + } + } + } + } + + @ViewBuilder func buildVideo() -> some View { + VStack(spacing: 0) { + if let ct = city, let vids = videos { + CityVideoView(city: ct, videos: vids, page: $videoPage) + } else if loading > 0 { + ProgressSpinnerView() + } + if loading == 0 && failure { + Spacer() + ErrorView() { + reload() + } } - } else { - ProgressSpinnerView() } } var body: some View { - VStack { - HideableTabView("city") { - [ - HideableTabItem(id: 0, text: "city_info", image: "info") { - AnyView(buildInfo()) - }, - HideableTabItem(id: 1, text: "city_forecast", image: "calendar") { - AnyView(buildForecast()) - }, - HideableTabItem(id: 2, text: "city_video", image: "video") { - AnyView(EmptyView()) - } - ] - } + GeometryReader { proxy in + VStack(spacing: 0) { + HideableTabView("city", proxy.safeAreaInsets) { + [ + HideableTabItem(id: 0, text: "city_info", image: Image(systemName:"info.circle")) { + AnyView(buildInfo()) + }, + HideableTabItem(id: 1, text: "city_forecast", image: Image(systemName:"calendar")) { + AnyView(buildForecast()) + }, + HideableTabItem(id: 2, text: "city_video", image: Image(systemName:"film")) { + AnyView(buildVideo()) + } + ] + } + Color("PrimaryColor") + .frame(height: proxy.safeAreaInsets.bottom) + .frame(maxWidth: .infinity) + }.ignoresSafeArea(.all, edges: [.leading, .trailing, .bottom]) } .if((cityName != nil)) { v in v.navigationTitle(cityName!) } .toolbar() { - if let f = favorite { + HStack { Button(action: { - viewContext.delete(f) - try? viewContext.save() - reload() + customize.toggle() }) { - Image(systemName: "heart.slash") + Image(systemName: "gearshape") + .accessibilityHint("action_customize") } - } else { - Button(action: { - let fav = Favorite(context: viewContext) - fav.setLocationType(type: .city) - fav.identifier = cityId - fav.cityValue = city - fav.locationValue = city - fav.stationValue = station - fav.forecastValue = forecast - fav.conditionValue = condition - fav.added = true - viewContext.insert(fav) - try? viewContext.save() - reload() - }) { - Image(systemName: "heart") + if let f = favorite { + Button(action: { + viewContext.delete(f) + try? viewContext.save() + reload() + }) { + Image(systemName: "heart.slash") + } + } else { + Button(action: { + let fav = Favorite(context: viewContext) + fav.setLocationType(type: .city) + fav.identifier = cityId + fav.cityValue = city + fav.locationValue = city + fav.stationValue = station + fav.forecastValue = forecast + fav.conditionValue = condition + fav.added = true + viewContext.insert(fav) + try? viewContext.save() + reload() + }) { + Image(systemName: "heart") + } } + if let c = city, let name = TextBindings.getName(c.names, false) { + Button(action: { + openMaps(name, c.coordinate.longitude, c.coordinate.latitude) + }) { + Image(systemName: "map") + } + } + + } + } + .sheet(isPresented: $customize) { + NavigationView() { + CustomizeView() + .navigationBarItems(trailing: + Button(action: { + customize.toggle() + }) { + Text("customize_button_done") + } + ) } - - } .onAppear() { reload() - tabViewState.setHidden(view: "main", hidden: true) } - .onDisappear() { tabViewState.setHidden(view: "main", hidden: false)} .onChange(of: loading) { v in showLoadingAnimation = v > 0 } @@ -225,6 +301,30 @@ struct CityView: View { } +struct WeatherVideos { + + var cosmoEurope: [WeatherVideo] = [] + var iconEurope: [WeatherVideo] = [] + var iconGlobal: [WeatherVideo] = [] + + init(_ videos: [WeatherVideo]) { + for v in videos { + switch v.source { + case .cosmoEurope: + cosmoEurope.append(v) + case .iconEurope: + iconEurope.append(v) + case .iconGlobal: + iconGlobal.append(v) + default: + continue + } + } + } + + +} + struct CityView_Previews: PreviewProvider { diff --git a/ios-app/app/View/CountryView.swift b/ios-app/app/View/CountryView.swift new file mode 100644 index 00000000..b3fc736c --- /dev/null +++ b/ios-app/app/View/CountryView.swift @@ -0,0 +1,178 @@ +// +// CountryView.swift +// App +// +// Created by Marcus Handte on 20.07.22. +// + +import SwiftUI +import class MoWeStaApi.City +import class MoWeStaApi.Country +import class MoWeStaApi.DefaultAPI +import LocosLabGeometry + +struct CountryView: View { + + let countryId: Int64 + + @State var country: Country? = nil + @State var countryName: String? = nil + @State var boundary: [[Coordinate]]? = nil + @State var cities: [City] = [] + @State var loading = 0 + @State var failure = false + @State var offset = 0 + @State var total = -1 + + @State var showLoadingAnimation = false + + + func reload() { + if loading != 0 { + return + } + failure = false + if country == nil { + loading += 1 + DefaultAPI.getCountry(id: countryId) { + response, error in + if let _ = error { + self.failure = true + } else if let r = response { + country = r + countryName = TextBindings.getName(r.names, false) + } + loading -= 1 + } + } + if boundary == nil { + loading += 1 + DefaultAPI.getCountryBoundary(id: countryId, apiResponseQueue: DispatchQueue.global()) { + response, error in + var simplified: [[Coordinate]] = [] + if let r = response { + simplified = GeojsonConverter.coordinates(of: r, simplify: 150) + } + DispatchQueue.main.async { + if let _ = error { + self.failure = true + } else { + boundary = simplified + } + loading -= 1 + } + } + } + if total == -1 { + if cities.isEmpty { + loading += 1 + DefaultAPI.getCountryCities(id: countryId) { + response, error in + if let _ = error { + self.failure = true + } else if let r = response { + cities.append(contentsOf: r.elements) + total = r.total + offset += r.size + } + loading -= 1 + } + } + } + } + + func loadPage() { + if loading != 0 || failure || offset > total { + return + } + loading += 1 + DefaultAPI.getCountryCities(id: countryId, pageOffset: offset, pageSize: 50) { + response, error in + if let _ = error { + self.failure = true + } else if let r = response { + cities.append(contentsOf: r.elements) + total = r.total + offset += r.size + } + loading -= 1 + } + } + + + + var body: some View { + VStack { + if let c = country { + List() { + PlaceMapView(center: Coordinate(longitude: c.coordinate.longitude, latitude: c.coordinate.latitude), zoom: 4, boundary: boundary) + .frame(height: 200) + .frame(maxWidth: .infinity) + .clipShape(RoundedRectangle(cornerRadius: 6)) + ForEach(cities, id: \City.id) { city in + CityEntryView(city: city) + } + if !showLoadingAnimation && !failure && total > offset { + Button(action: { + loadPage() + }) { + Text("action_load_more") + .frame(maxWidth: .infinity) + .frame(alignment: .center) + } + } + } + Spacer() + ProgressBarView(animating: $showLoadingAnimation) + .frame(height: 3) + .frame(maxWidth: .infinity) + } else if showLoadingAnimation { + ProgressSpinnerView() + } + if failure && !showLoadingAnimation { + Spacer() + ErrorView() { + reload() + } + } + } + .if((countryName != nil)) { v in + v.navigationTitle(countryName!) + } + .onAppear() { + reload() + showLoadingAnimation = loading != 0 + } + .onChange(of: loading) { value in + showLoadingAnimation = value != 0 + } + } +} + +struct CityEntryView: View { + + let city: City + + var body: some View { + NavigationLink(destination: { CityView(city.id!) }) { + HStack { + Image(systemName: "building.2") + .font(.title) + .padding(.trailing, 2) + VStack(alignment:.leading) { + Text(TextBindings.getName(city.names, false)!) + .font(.body) + Text(TextBindings.getRegionName(city)) + .font(.caption) + } + }.padding(2) + } + } +} + + +struct CountryView_Previews: PreviewProvider { + static var previews: some View { + CountryView(countryId: 560) + } +} diff --git a/ios-app/app/View/CustomizeView.swift b/ios-app/app/View/CustomizeView.swift new file mode 100644 index 00000000..9e88f396 --- /dev/null +++ b/ios-app/app/View/CustomizeView.swift @@ -0,0 +1,97 @@ +// +// CustomizeView.swift +// App +// +// Created by Marcus Handte on 18.07.22. +// + +import SwiftUI + +struct CustomizeView: View { + + @ObservedObject var state: AppState + @State var unitSystem: UnitSystem + @State var temperatureUnit: TemperatureUnit + @State var precipitation: Bool + @State var windSpeed: Bool + @State var cloudCoverage: Bool + @State var humidity: Bool + @State var snowDepth: Bool + @State var pressure: Bool + + init() { + self.state = AppState.shared + self.unitSystem = AppState.shared.unitSystem + self.temperatureUnit = AppState.shared.temperatureUnit + self.precipitation = AppState.shared.precipitation + self.windSpeed = AppState.shared.windSpeed + self.cloudCoverage = AppState.shared.cloudCoverage + self.humidity = AppState.shared.humidity + self.snowDepth = AppState.shared.snowDepth + self.pressure = AppState.shared.pressure + } + + + var body: some View { + Form { + Section(header: Text("customize_section_units")) { + Picker("customize_hint_system", selection: $unitSystem) { + ForEach([ UnitSystem.si, UnitSystem.imperial, UnitSystem.both], id: \.self) { s in + Text(TextBindings.getUnitSystem(s)) + } + } + Picker("customize_hint_temperature", selection: $temperatureUnit) { + ForEach([ TemperatureUnit.celsius, TemperatureUnit.fahrenheit, TemperatureUnit.both], id: \.self) { t in + Text(TextBindings.getTemperatureUnit(t)) + } + } + } + Section(header: Text("customize_section_data")) { + CustomizeToggleView(image: "icon_raindrops", label: "label_precipitation", enabled: $precipitation) + CustomizeToggleView(image: "icon_wind_direction", label: "label_wind_speed", enabled: $windSpeed) + CustomizeToggleView(image: "icon_cloud", label: "label_cloud_coverage", enabled: $cloudCoverage) + CustomizeToggleView(image: "icon_humidity", label: "label_humidity", enabled: $humidity) + CustomizeToggleView(image: "icon_snowflake_cold", label: "label_snow_depth", enabled: $snowDepth) + CustomizeToggleView(image: "icon_barometer", label: "label_pressure", enabled: $pressure) + } + } + .onChange(of: unitSystem, perform: { state.unitSystem = $0 }) + .onChange(of: temperatureUnit, perform: { state.temperatureUnit = $0 }) + .onChange(of: precipitation, perform: { state.precipitation = $0 }) + .onChange(of: windSpeed, perform: { state.windSpeed = $0 }) + .onChange(of: cloudCoverage, perform: { state.cloudCoverage = $0 }) + .onChange(of: humidity, perform: { state.humidity = $0 }) + .onChange(of: snowDepth, perform: { state.snowDepth = $0 }) + .onChange(of: pressure, perform: { state.pressure = $0 }) + .navigationTitle(Text("action_customize")) + } + +} + +struct CustomizeToggleView: View { + + let image: String + let label: LocalizedStringKey + let enabled: Binding + + var body: some View { + Toggle(isOn: enabled) { + HStack { + Image(image) + Text(label) + } + } + } + +} + + + + +struct CustomizeView_Previews: PreviewProvider { + static var previews: some View { + NavigationView { + CustomizeView() + } + } +} diff --git a/ios-app/app/View/DrawerView.swift b/ios-app/app/View/DrawerView.swift index e5ca3671..bf45e190 100644 --- a/ios-app/app/View/DrawerView.swift +++ b/ios-app/app/View/DrawerView.swift @@ -8,19 +8,57 @@ import SwiftUI /// The drawer view with tabs at the bottom. struct DrawerView: View { + + + @ObservedObject var state = AppState.shared + @State var searchState = SearchState() + + + func buildDevicesTab() -> HideableTabItem { + if let c = state.credentials { + return HideableTabItem(id: 2, text: "navigation_devices", image: Image("icon_devices")) { + AnyView(VStack() { + EmptyView() + Spacer() + }) + } + } else { + return HideableTabItem(id: 2, text: "navigation_account", image: Image(systemName: "person.crop.circle")) { + AnyView(VStack() { + EmptyView() + Spacer() + }) + } + } + } + var body: some View { - HideableTabView("main") { - [ - HideableTabItem(id: 0, text: "navigation_favorites", image: "heart") { - AnyView(FavoritesView()) - }, - HideableTabItem(id: 1, text: "navigation_search", image: "magnifyingglass") { - AnyView(SearchView()) - }, - HideableTabItem(id: 2, text: "navigation_settings", image: "gear") { - AnyView(SettingsView()) + GeometryReader { proxy in + VStack(spacing: 0) { + HideableTabView("main", proxy.safeAreaInsets) { + [ + HideableTabItem(id: 0, text: "navigation_favorites", image: Image(systemName: "heart")) { + AnyView(FavoritesView()) + }, + HideableTabItem(id: 1, text: "navigation_stations", image: Image("icon_station")) { + AnyView(VStack() { + EmptyView() + Spacer() + }) + }, + buildDevicesTab(), + HideableTabItem(id: 4, text: "navigation_settings", image: Image(systemName: "gear")) { + AnyView(SettingsView()) + }, + HideableTabItem(id: 5, text: "navigation_search", image: Image(systemName: "magnifyingglass")) { + AnyView(SearchView(state: searchState)) + } + ] } - ] + Color("PrimaryColor") + .frame(height: proxy.safeAreaInsets.bottom) + .frame(maxWidth: .infinity) + }.ignoresSafeArea(.all, edges: [.bottom, .trailing, .leading]) } } } diff --git a/ios-app/app/View/FavoritesView.swift b/ios-app/app/View/FavoritesView.swift index 5f6aaf20..19668112 100644 --- a/ios-app/app/View/FavoritesView.swift +++ b/ios-app/app/View/FavoritesView.swift @@ -80,7 +80,7 @@ struct FavoriteCityView: View { Image(systemName: "building.2") .resizable() .aspectRatio(contentMode: .fit) - .frame(width: 40) + .frame(width: 40, height: 32) .padding(.trailing, 8) VStack(alignment: .leading) { if let name = TextBindings.getName(c.names, false) { @@ -117,9 +117,10 @@ struct FavoriteConditionView: View { if let c = condition { HStack { Image(ImageBindings.getWeatherIcon(c)) + .renderingMode(.template) .resizable() .aspectRatio(contentMode: .fit) - .frame(width: 40) + .frame(width: 40, height: 40) .padding(.trailing, 8) VStack(alignment: .leading) { Text(TextBindings.getWeatherType(c)) diff --git a/ios-app/app/View/PlaceMapView.swift b/ios-app/app/View/PlaceMapView.swift new file mode 100644 index 00000000..2306239e --- /dev/null +++ b/ios-app/app/View/PlaceMapView.swift @@ -0,0 +1,179 @@ +// +// MapView.swift +// App +// +// Created by Marcus Handte on 20.07.22. +// + +import SwiftUI +import Foundation +import LocosLabGeometry +import LocosLabLeafless + +/// The actual view that renders the map of a place with the optional boundaries +struct PlaceMapView: UIViewRepresentable { + + /// Dark mode or not + @Environment(\.colorScheme) var colorScheme + /// The initial center. + let center: Coordinate + // The initial zoom. + let zoom: Int + /// The boundary to render. + let boundary: [[Coordinate]]? + + /// Called to create the underlying UIKit view. + /// + /// - parameters: + /// - context: The context with the coordinator. + /// - returns: The map view. + func makeUIView(context: Context) -> MapView { + let v = MapView(frame:CGRect()) + let o = v.options + o.pinchToRotate = false + o.pinchToZoom = false + o.doubleTapZoom = false + o.dragToMove = false + v.options = o + v.setCenter(center: Coordinate(longitude: center.longitude, latitude: center.latitude)) + v.setZoom(zoom: zoom) + return v + } + + /// Creates a coordinator that holds the view state. + /// + /// - returns: The coordinator. + func makeCoordinator() -> PlaceMapCoordinator { + return PlaceMapCoordinator(self) + } + + /// Updates the view when the state changed. + /// + /// - parameters: + /// - uiView: The UiKit element with the map view. + /// - context: The context with the coordinator. + func updateUIView(_ uiView: MapView, context: Context) { + context.coordinator.update(uiView, self) + } + +} + +/// The coordinator that manages updates to the state of the underlying Leafless view. +class PlaceMapCoordinator { + + /// The current center + var center: Coordinate + // The current zoom + var zoom: Int + // The boundary that is rendered + var boundary: [[Coordinate]]? + // The polyline representing the boundary + var polylines: [Polyline] = [] + /// The current layer. + var tilelayer: TileLayer? + /// The color scheme of the layer. + var colorScheme: ColorScheme + + /// Creates a new coordinator and initializes the variables + /// + /// - parameters: + /// - mapView: The view to initialize the toggles. + init(_ mapView: PlaceMapView) { + self.center = mapView.center + self.zoom = mapView.zoom + self.colorScheme = mapView.colorScheme + + } + + /// Called to update the Leafless MapView on a change to the state of the view. + /// + /// - parameters: + /// - mapView: The map view to apply changes. + /// - placeMapView: The map view that has changed. + func update(_ mapView: MapView, _ placeMapView: PlaceMapView) { + if tilelayer == nil || colorScheme != placeMapView.colorScheme { + if let t = tilelayer { + _ = mapView.removeLayer(layer: t) + } + colorScheme = placeMapView.colorScheme + let url = colorScheme == .dark ? "https://www.mowesta.com/carta/tile/dark/{z}/{x}/{y}.png" : "https://www.mowesta.com/carta/tile/{z}/{x}/{y}.png" + let layerOptions = TileLayerOptions(url: url) + let tl = TileLayer(options: layerOptions) + mapView.addLayer(layer: tl); + tilelayer = tl + } + + + if !equals(placeMapView.boundary, boundary) { + if !polylines.isEmpty { + polylines.forEach({ p in + _ = mapView.removeShape(shape: p) + }) + polylines = [] + } + if let cs = placeMapView.boundary { + var cords: [Coordinate] = [] + cs.forEach({ b in + let options = PolylineOptions() + options.fillColor = UIColor(Color.accentColor) + options.fillOpacity = 0.7 + options.strokeCap = .round + options.strokeJoin = .round + options.strokeWidth = 3 + options.strokeOpacity = 0.9 + if placeMapView.colorScheme == .dark { + options.strokeColor = UIColor(Color.accentColor) + } else { + options.strokeColor = UIColor(Color("PrimaryColor")) + } + let p = Polyline(coordinates: b, options: options) + mapView.addShape(shape: p) + polylines.append(p) + cords.append(contentsOf: b) + }) + if !cords.isEmpty { + mapView.setViewport(bounds: Box(coordinates: cords), padding: MapPoint(x: 5, y: 5)) + } + } + } + if polylines.isEmpty && (center.latitude != placeMapView.center.latitude + || center.longitude != placeMapView.center.longitude + || zoom != placeMapView.zoom) { + mapView.setCenter(center: placeMapView.center) + mapView.setZoom(zoom: placeMapView.zoom) + } + self.center = placeMapView.center + self.zoom = placeMapView.zoom + self.boundary = placeMapView.boundary + } + + func equals(_ a: [[Coordinate]]?, _ b: [[Coordinate]]?) -> Bool { + if (a == nil && b != nil) || (a != nil && b == nil) { + return false + } + if let x = a, let y = b { + if x.count != y.count { + return false + } + for i in 0.. UIColor { + return UIColor(red: CGFloat(Float(Double(r) / 255.0)), green: CGFloat(Float(Double(g) / 255.0)), blue: CGFloat(Float(Double(b) / 255.0)), alpha: 1) + } + +} + diff --git a/ios-app/app/View/SearchView.swift b/ios-app/app/View/SearchView.swift index 48999b5b..0f2c8235 100644 --- a/ios-app/app/View/SearchView.swift +++ b/ios-app/app/View/SearchView.swift @@ -12,10 +12,7 @@ import class MoWeStaApi.DefaultAPI struct SearchView: View { - @State var searchTerm = "" - @State var requestId = 0 - @State var searchResult: LocationHierarchyPage? - @State var searchError = false + @ObservedObject var state: SearchState var body: some View { VStack { @@ -23,11 +20,11 @@ struct SearchView: View { HStack { Image(systemName: "magnifyingglass") .font(.body) - .foregroundColor(Color("PrimaryColor")) - TextField("action_search", text: $searchTerm) + .foregroundColor(.gray) + TextField("action_search", text: $state.searchTerm) .font(.body) .frame(maxWidth: .infinity) - .onChange(of: searchTerm) { _ in + .onChange(of: state.searchTerm) { _ in scheduleSearch(delay: 0.25) } } @@ -35,7 +32,7 @@ struct SearchView: View { .overlay(RoundedRectangle(cornerRadius: 6) .stroke(lineWidth: 2) .foregroundColor(Color.gray)) - if let r = searchResult { + if let r = state.searchResult { ForEach(r.elements, id: \.id) { element in SearchViewEntry(location: element) @@ -44,19 +41,16 @@ struct SearchView: View { }.listStyle(.plain) } .navigationTitle("navigation_search") - .onDisappear() { - requestId += 1 - } } func scheduleSearch(delay: Double) { - searchResult = nil - requestId += 1 - let request = requestId - let term = searchTerm + state.searchResult = nil + state.requestId += 1 + let request = state.requestId + let term = state.searchTerm if term.count > 1 { DispatchQueue.main.asyncAfter(deadline: .now() + delay) { - if request == requestId { + if request == state.requestId { executeSearch(request: request, term: term) } } @@ -64,11 +58,11 @@ struct SearchView: View { } func executeSearch(request: Int, term: String) { - DefaultAPI.searchLocations(language: getSearchLanguage(), term: searchTerm, pageSize: 40) { + DefaultAPI.searchLocations(language: getSearchLanguage(), term: state.searchTerm, pageSize: 40) { result, error in - if (request == requestId) { + if (request == state.requestId) { if let r = result { - searchResult = r; + state.searchResult = r; } } } @@ -89,25 +83,46 @@ struct SearchViewEntry: View { var location: LocationHierarchy var body: some View { - NavigationLink(destination: { CityView(location.id!) }) { + NavigationLink(destination: { + switch location.type { + case .country: + CountryView(countryId: location.id!) + default: + CityView(location.id!) + } + }) { HStack { + let name = TextBindings.getLocationName(location) + let region = TextBindings.getRegionName(location) Image(systemName: ImageBindings.getLocationIcon(location)) .font(.title) .padding(.trailing, 2) VStack(alignment:.leading) { - Text(TextBindings.getLocationName(location)) + Text(name) .font(.body) - Text(TextBindings.getRegionName(location)) - .font(.caption) + if region.count > 0 { + Text(region) + .font(.caption) + } } }.padding(2) } } +} + +class SearchState: ObservableObject { + + var searchTerm = "" { willSet { objectWillChange.send() }} + var requestId = 0 { willSet { objectWillChange.send() }} + var searchResult: LocationHierarchyPage? { willSet { objectWillChange.send() }} + var searchError = false { willSet { objectWillChange.send() }} } + + struct SearchView_Previews: PreviewProvider { static var previews: some View { - SearchView() + SearchView(state: SearchState()) } } diff --git a/ios-app/app/View/StateView.swift b/ios-app/app/View/StateView.swift new file mode 100644 index 00000000..688d34b2 --- /dev/null +++ b/ios-app/app/View/StateView.swift @@ -0,0 +1,23 @@ +// +// StateView.swift +// App +// +// Created by Marcus Handte on 20.07.22. +// + +import SwiftUI + +struct StateView: View { + + let stateId: Int64 + + var body: some View { + Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) + } +} + +struct StateView_Previews: PreviewProvider { + static var previews: some View { + StateView(stateId: 1803) + } +} diff --git a/ios-app/app/View/StationView.swift b/ios-app/app/View/StationView.swift new file mode 100644 index 00000000..d65f7843 --- /dev/null +++ b/ios-app/app/View/StationView.swift @@ -0,0 +1,23 @@ +// +// StationView.swift +// App +// +// Created by Marcus Handte on 20.07.22. +// + +import SwiftUI + +struct StationView: View { + + let stationId: Int64 + + var body: some View { + Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) + } +} + +struct StationView_Previews: PreviewProvider { + static var previews: some View { + StationView(stationId: 155225) + } +} diff --git a/ios-app/app/View/WeatherConditionView.swift b/ios-app/app/View/WeatherConditionView.swift deleted file mode 100644 index 6b604bd6..00000000 --- a/ios-app/app/View/WeatherConditionView.swift +++ /dev/null @@ -1,95 +0,0 @@ -// -// WeatherConditionView.swift -// App -// -// Created by Marcus Handte on 17.07.22. -// - -import Foundation -import SwiftUI -import class MoWeStaApi.WeatherCondition - -struct WeatherConditionView: View { - - let title: String - let subtitle: String - let condition: WeatherCondition - let unitSystem: UnitSystem - let temperatureUnit: TemperatureUnit - - - var body: some View { - VStack(spacing: 4) { - HStack { - Image(ImageBindings.getWeatherIcon(condition)) - .renderingMode(.template) - .resizable() - .aspectRatio(contentMode: .fit) - .frame(width: 40) - .padding([.leading, .trailing], 10) - VStack { - Text(title) - .font(.body) - .frame(maxWidth: .infinity, alignment: .leading) - Text(subtitle) - .font(.body) - .frame(maxWidth: .infinity, alignment: .leading) - } - } - - - Text(TextBindings.getWeatherType(condition)) - .font(.title) - .frame(maxWidth: .infinity) - WeatherDataView("icon_thermometer", "label_temperature", DataBindings.getTemperature(condition.temperature, temperatureUnit)) - WeatherDataView("icon_raindrops", "label_precipitation", DataBindings.getPrecipitation(condition.precipitation, unitSystem)) - WeatherDataView("icon_wind_direction", TextBindings.getWindDirection(condition.windDirection), DataBindings.getWindDirection(condition.windDirection), DataBindings.getWindSpeed(condition.windSpeed, unitSystem)) - WeatherDataView("icon_cloud", "label_cloud_coverage", DataBindings.getCloudCoverage(condition.cloudCoverage)) - WeatherDataView("icon_humidity", "label_humidity", DataBindings.getHumidity(condition.humidity)) - WeatherDataView("icon_snowflake_cold", "label_snow_depth", DataBindings.getSnow(condition.snowDepth, unitSystem)) - WeatherDataView("icon_barometer", "label_pressure", DataBindings.getPressure(condition.pressure, unitSystem)) - } - } -} - -struct WeatherDataView: View { - let image: String - let hint: LocalizedStringKey - let value: LocalizedStringKey - let angle: Angle - - init(_ image: String, _ hint: LocalizedStringKey, _ value: LocalizedStringKey) { - self.image = image - self.hint = hint - self.value = value - self.angle = Angle(degrees: 0) - } - - init(_ image: String, _ hint: LocalizedStringKey, _ angle: Angle, _ value: LocalizedStringKey) { - self.image = image - self.hint = hint - self.value = value - self.angle = angle - } - - - - var body: some View { - HStack { - Image(image) - .renderingMode(.template) - .resizable() - .aspectRatio(contentMode: .fit) - .help(hint) - .accessibilityHint(hint) - .frame(width: 60, height: 22) - .rotationEffect(angle) - Text(value) - .frame(maxWidth: .infinity, alignment: .trailing) - .lineLimit(1) - } - } - - -} - diff --git a/ios-app/app/View/WeatherViews.swift b/ios-app/app/View/WeatherViews.swift new file mode 100644 index 00000000..e22e9b35 --- /dev/null +++ b/ios-app/app/View/WeatherViews.swift @@ -0,0 +1,209 @@ +// +// WeatherConditionView.swift +// App +// +// Created by Marcus Handte on 17.07.22. +// + +import Foundation +import SwiftUI +import class MoWeStaApi.WeatherCondition + +struct WeatherConditionView: View { + + @ObservedObject var state = AppState.shared + let title: LocalizedStringKey + let subtitle: LocalizedStringKey + let condition: WeatherCondition + + + var body: some View { + VStack(spacing: 4) { + HStack { + Image(ImageBindings.getWeatherIcon(condition)) + .renderingMode(.template) + .resizable() + .aspectRatio(contentMode: .fit) + .frame(width: 40, height: 40) + .padding([.trailing], 10) + VStack { + Text(title) + .font(.body) + .frame(maxWidth: .infinity, alignment: .leading) + Text(subtitle) + .font(.body) + .frame(maxWidth: .infinity, alignment: .leading) + } + } + + + Text(TextBindings.getWeatherType(condition)) + .font(.title2) + .frame(maxWidth: .infinity) + WeatherDataView("icon_thermometer", "label_temperature", DataBindings.getTemperature(condition.temperature, state.temperatureUnit)) + if state.precipitation { + WeatherDataView("icon_raindrops", "label_precipitation", DataBindings.getPrecipitation(condition.precipitation, state.unitSystem)) + } + if state.windSpeed { + WeatherDataView("icon_wind_direction", TextBindings.getWindDirection(condition.windDirection), DataBindings.getWindDirection(condition.windDirection), DataBindings.getWindSpeed(condition.windSpeed, state.unitSystem)) + } + if state.cloudCoverage { + WeatherDataView("icon_cloud", "label_cloud_coverage", DataBindings.getCloudCoverage(condition.cloudCoverage)) + } + if state.humidity { + WeatherDataView("icon_humidity", "label_humidity", DataBindings.getHumidity(condition.humidity)) + } + if state.snowDepth { + WeatherDataView("icon_snowflake_cold", "label_snow_depth", DataBindings.getSnow(condition.snowDepth, state.unitSystem)) + } + if state.pressure { + WeatherDataView("icon_barometer", "label_pressure", DataBindings.getPressure(condition.pressure, state.unitSystem)) + } + }.padding([.top, .bottom], 4) + } +} + +struct WeatherDataView: View { + let image: String + let hint: LocalizedStringKey + let value: LocalizedStringKey + let angle: Angle + + init(_ image: String, _ hint: LocalizedStringKey, _ value: LocalizedStringKey) { + self.image = image + self.hint = hint + self.value = value + self.angle = Angle(degrees: 0) + } + + init(_ image: String, _ hint: LocalizedStringKey, _ angle: Angle, _ value: LocalizedStringKey) { + self.image = image + self.hint = hint + self.value = value + self.angle = angle + } + + + + var body: some View { + HStack { + Image(image) + .renderingMode(.template) + .resizable() + .aspectRatio(contentMode: .fit) + .help(hint) + .accessibilityHint(hint) + .frame(width: 40, height: 22) + .rotationEffect(angle) + Text(value) + .frame(maxWidth: .infinity, alignment: .trailing) + .lineLimit(1) + } + } + +} + + + +struct WeatherSummaryView: View { + + @ObservedObject var state = AppState.shared + let title: LocalizedStringKey + let subtitle: LocalizedStringKey + let summary: WeatherSummary + + + var body: some View { + VStack(spacing: 4) { + HStack { + Image(ImageBindings.getWeatherIcon(summary.min)) + .renderingMode(.template) + .resizable() + .aspectRatio(contentMode: .fit) + .frame(width: 40, height: 40) + Image(ImageBindings.getWeatherIcon(summary.max)) + .renderingMode(.template) + .resizable() + .aspectRatio(contentMode: .fit) + .frame(width: 40, height: 40) + .padding([.trailing], 10) + VStack { + Text(title) + .font(.body) + .frame(maxWidth: .infinity, alignment: .leading) + Text(subtitle) + .font(.body) + .frame(maxWidth: .infinity, alignment: .leading) + } + } + Text(TextBindings.getWeatherType(summary.max)) + .font(.title2) + .frame(maxWidth: .infinity) + WeatherDualView("icon_thermometer", "label_temperature", DataBindings.getTemperature(summary.min.temperature, state.temperatureUnit), DataBindings.getTemperature(summary.max.temperature, state.temperatureUnit)) + if state.precipitation { + WeatherDualView("icon_raindrops", "label_precipitation", DataBindings.getPrecipitation(summary.min.precipitation, state.unitSystem), DataBindings.getPrecipitation(summary.max.precipitation, state.unitSystem)) + } + if state.windSpeed { + WeatherDualView("icon_wind_direction", TextBindings.getWindDirection(summary.max.windDirection), DataBindings.getWindDirection(summary.max.windDirection), DataBindings.getWindSpeed(summary.min.windSpeed, state.unitSystem), DataBindings.getWindSpeed(summary.max.windSpeed, state.unitSystem)) + } + if state.cloudCoverage { + WeatherDualView("icon_cloud", "label_cloud_coverage", DataBindings.getCloudCoverage(summary.min.cloudCoverage), DataBindings.getCloudCoverage(summary.max.cloudCoverage)) + } + if state.humidity { + WeatherDualView("icon_humidity", "label_humidity", DataBindings.getHumidity(summary.min.humidity), DataBindings.getHumidity(summary.max.humidity)) + } + if state.snowDepth { + WeatherDualView("icon_snowflake_cold", "label_snow_depth", DataBindings.getSnow(summary.min.snowDepth, state.unitSystem), DataBindings.getSnow(summary.max.snowDepth, state.unitSystem)) + } + if state.pressure { + WeatherDualView("icon_barometer", "label_pressure", DataBindings.getPressure(summary.min.pressure, state.unitSystem), DataBindings.getPressure(summary.max.pressure, state.unitSystem)) + } + }.padding([.top, .bottom], 4) + } +} + +struct WeatherDualView: View { + let image: String + let hint: LocalizedStringKey + let min: LocalizedStringKey + let max: LocalizedStringKey + let angle: Angle + + init(_ image: String, _ hint: LocalizedStringKey, _ min: LocalizedStringKey, _ max: LocalizedStringKey) { + self.image = image + self.hint = hint + self.min = min + self.max = max + self.angle = Angle(degrees: 0) + } + + init(_ image: String, _ hint: LocalizedStringKey, _ angle: Angle, _ min: LocalizedStringKey, _ max: LocalizedStringKey) { + self.image = image + self.hint = hint + self.min = min + self.max = max + self.angle = angle + } + + + + var body: some View { + HStack { + Image(image) + .renderingMode(.template) + .resizable() + .aspectRatio(contentMode: .fit) + .help(hint) + .accessibilityHint(hint) + .frame(width: 40, height: 22) + .rotationEffect(angle) + Text(min) + .frame(maxWidth: .infinity, alignment: .trailing) + .lineLimit(2) + Text(max) + .frame(maxWidth: .infinity, alignment: .trailing) + .lineLimit(2) + } + } + +} diff --git a/ios-app/app/de.lproj/Localizable.strings b/ios-app/app/de.lproj/Localizable.strings index e14174bb..6700f904 100644 --- a/ios-app/app/de.lproj/Localizable.strings +++ b/ios-app/app/de.lproj/Localizable.strings @@ -245,18 +245,18 @@ "city_info_hour"="Stunde"; "label_station"="Wetterstation"; "label_full_day"="Gesamter Tag"; -"label_morning"="6 – 12 Uhr"; -"label_afternoon"="12 – 18 Uhr"; -"label_evening"="18 – 24 Uhr"; -"label_night"="0 – 6 Uhr"; +"label_morning"="6 - 12 Uhr"; +"label_afternoon"="12 - 18 Uhr"; +"label_evening"="18 - 24 Uhr"; +"label_night"="0 - 6 Uhr"; "date_today"="Heute"; "date_tomorrow"="Morgen"; "date_yesterday"="Gestern"; "stations_search_hint"="Station finden"; - "favorite_weather_in"="Wetter in %s"; +"action_load_more"="Mehr"; "action_search"="Wetter abrufen"; "action_favorite_add"="Zu Favoriten hinzufügen"; "action_favorite_remove"="Von Favoriten entfernen"; @@ -269,6 +269,9 @@ "action_system"="Einheitensystem auswählen"; +"customize_button_done"="Fertig"; +"customize_section_units"="Einheiten"; +"customize_section_data"="Daten"; "customize_hint_temperature"="Temperaturskala"; "customize_hint_system"="Einheitensystem"; @@ -280,8 +283,8 @@ "customize_system_standard"="SI"; "customize_system_imperial"="Britisch"; -"snackbar_error"="Fehler beim Laden der Daten."; -"snackbar_reload"="Neu\nladen"; +"snackbar_error"="Die Daten konnten nicht richtig geladen werden."; +"snackbar_reload"="Nochmal"; "terms_usage"="Nutzungsbedingungen"; "terms_privacy"="Datenschutzerklärung"; @@ -334,11 +337,11 @@ "format_pressure_si %lf"="%.1lf\U00A0hPA"; "format_pressure_imperial %lf"="%.3lf\U00A0psi"; "format_pressure_both %lf %lf"="%.1lf\U00A0hPA / %.3lf\U00A0psi"; -"format_wind_speed_si %lf"="%.0lf\U00A0km/h"; -"format_wind_speed_imperial %lf"="%.0lf\U00A0mph"; +"format_wind_speed_si %lf %lld"="%.0lf\U00A0km/h (BFT %lld)"; +"format_wind_speed_imperial %lf %lld"="%.0lf\U00A0mph (BFT %lld)"; "format_wind_speed_both %lf %lf"="%.0lf\U00A0km/h / %.0lf\U00A0mph"; -"format_precipitation_si %lf %d"="%.1lf\U00A0mm/h (BFT %d)"; -"format_precipitation_imperial %lf %d"="%.2lf\U00A0in/h (BFT %d)"; +"format_precipitation_si %lf"="%.1lf\U00A0mm/h"; +"format_precipitation_imperial %lf"="%.2lf\U00A0in/h"; "format_precipitation_both %lf %lf"="%.1lf\U00A0mm/h / %.2lf\U00A0in/h"; "format_snow_si %lf"="%.2lf\U00A0m"; "format_snow_imperial %lf"="%.2lf\U00A0ft"; @@ -348,3 +351,7 @@ "format_altitude_both %lf %lf"="%.0lf\U00A0m / %.0lf\U00A0ft"; "format_date"="dd.MM.yyyy"; "format_time"="HH:mm"; + +"format_title %@"="%1$@"; +"format_title %@ %@"="%1$@ | %2$@"; + diff --git a/ios-app/app/en.lproj/Localizable.strings b/ios-app/app/en.lproj/Localizable.strings index cf149404..574db733 100644 --- a/ios-app/app/en.lproj/Localizable.strings +++ b/ios-app/app/en.lproj/Localizable.strings @@ -250,10 +250,10 @@ "city_info_hour"="Hour"; "label_station"="Weather station"; "label_full_day"="Whole day"; -"label_morning"="6 – 12 AM"; -"label_afternoon"="0 – 6 PM"; -"label_evening"="6 – 12 PM"; -"label_night"="0 – 6 AM"; +"label_morning"="6 - 12 AM"; +"label_afternoon"="0 - 6 PM"; +"label_evening"="6 - 12 PM"; +"label_night"="0 - 6 AM"; "date_today"="Today"; "date_tomorrow"="Tomorrow"; "date_yesterday"="Yesterday"; @@ -262,6 +262,7 @@ "favorite_weather_in"="Weather in %s"; +"action_load_more"="More"; "action_search"="Retrieve weather"; "action_favorite_add"="Add to favorites"; "action_favorite_remove"="Remove from favorites"; @@ -273,7 +274,9 @@ "action_temperature"="Set temperature scale"; "action_system"="Set unit system"; - +"customize_button_done"="Done"; +"customize_section_units"="Units"; +"customize_section_data"="Data"; "customize_hint_temperature"="Temperature scale"; "customize_hint_system"="Unit system"; "customize_temperature_both"="°C / °F"; @@ -285,8 +288,8 @@ "customize_system_imperial"="Imperial"; -"snackbar_error"="Failed to load data."; -"snackbar_reload"="Reload"; +"snackbar_error"="The data could not be loaded correctly."; +"snackbar_reload"="Retry"; "terms_usage"="Terms of Service"; "terms_privacy"="Privacy Policy"; @@ -331,6 +334,7 @@ "advertise_more"="Read more…"; "advertise_title"="DAS FEST"; + "format_cloud_coverage %lf"="%.1lf\U00A0%%"; "format_humidity %lf"="%.1lf\U00A0%%"; "format_temperature_celsius %lf"="%.1lf\U00A0°C"; @@ -339,11 +343,11 @@ "format_pressure_si %lf"="%.1lf\U00A0hPA"; "format_pressure_imperial %lf"="%.3lf\U00A0psi"; "format_pressure_both %lf %lf"="%.1lf\U00A0hPA / %.3lf\U00A0psi"; -"format_wind_speed_si %lf"="%.0lf\U00A0km/h"; -"format_wind_speed_imperial %lf"="%.0lf\U00A0mph"; +"format_wind_speed_si %lf %lld"="%.0lf\U00A0km/h (BFT %lld)"; +"format_wind_speed_imperial %lf %lld"="%.0lf\U00A0mph (BFT %lld)"; "format_wind_speed_both %lf %lf"="%.0lf\U00A0km/h / %.0lf\U00A0mph"; -"format_precipitation_si %lf %d"="%.1lf\U00A0mm/h (BFT %d)"; -"format_precipitation_imperial %lf %d"="%.2lf\U00A0in/h (BFT %d)"; +"format_precipitation_si %lf"="%.1lf\U00A0mm/h"; +"format_precipitation_imperial %lf"="%.2lf\U00A0in/h"; "format_precipitation_both %lf %lf"="%.1lf\U00A0mm/h / %.2lf\U00A0in/h"; "format_snow_si %lf"="%.2lf\U00A0m"; "format_snow_imperial %lf"="%.2lf\U00A0ft"; @@ -354,6 +358,9 @@ "format_date"="MM/dd/yyyy"; "format_time"="hh:mm a"; +"format_title %@"="%1$@"; +"format_title %@ %@"="%1$@ | %2$@"; + /* %.1f<small>\u00A0°C</small> / %.1f<small>\u00A0°F</small> diff --git a/ios-locoslab/lib-leafless/Classes/MapView.swift b/ios-locoslab/lib-leafless/Classes/MapView.swift index 080e5542..06b4849e 100644 --- a/ios-locoslab/lib-leafless/Classes/MapView.swift +++ b/ios-locoslab/lib-leafless/Classes/MapView.swift @@ -698,15 +698,19 @@ public class MapProjection { public static let RADIUS: Double = 6378137.0 public static let MAX_LAT: Double = 85.0511287798 + + public init() { + + } - private func projectRaw(longitude: Double, latitude: Double) -> (Double, Double) { + public func projectRaw(longitude: Double, latitude: Double) -> (Double, Double) { let d = Double.pi / 180 let lat = max(min(MapProjection.MAX_LAT, latitude), -MapProjection.MAX_LAT) let sinx = sin(lat * d) return ( MapProjection.RADIUS * longitude * d, MapProjection.RADIUS * log((1 + sinx) / (1 - sinx)) / 2) } - private func unprojectRaw(x: Double, y: Double) -> (Double, Double) { + public func unprojectRaw(x: Double, y: Double) -> (Double, Double) { let d = 180 / Double.pi return (x * d / MapProjection.RADIUS, (2 * atan(exp(y / MapProjection.RADIUS)) - (Double.pi / 2)) * d) }