This commit is contained in:
@@ -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 = "<group>"; };
|
||||
2C16332C283A27D600F78CEE /* AppUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppUITestsLaunchTests.swift; sourceTree = "<group>"; };
|
||||
2C369C6528888E6800B5AFB2 /* StationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StationView.swift; sourceTree = "<group>"; };
|
||||
2C369C6728889EAE00B5AFB2 /* ErrorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ErrorView.swift; sourceTree = "<group>"; };
|
||||
2C865E392842719F00F1A89A /* ios-api */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = "ios-api"; path = "../ios-api"; sourceTree = "<group>"; };
|
||||
2C865E3C2842850800F1A89A /* HideableTabView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HideableTabView.swift; sourceTree = "<group>"; };
|
||||
2C865E3E28428ED600F1A89A /* TextBindings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextBindings.swift; sourceTree = "<group>"; };
|
||||
@@ -86,12 +100,21 @@
|
||||
2CA28200283E201B00D4A05A /* KeyChain.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeyChain.swift; sourceTree = "<group>"; };
|
||||
2CA28201283E201B00D4A05A /* UserDefault.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserDefault.swift; sourceTree = "<group>"; };
|
||||
2CA28202283E201B00D4A05A /* AppInfo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppInfo.swift; sourceTree = "<group>"; };
|
||||
2CA4E7502887CB9800B901ED /* CountryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CountryView.swift; sourceTree = "<group>"; };
|
||||
2CA4E7522887CBA300B901ED /* StateView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StateView.swift; sourceTree = "<group>"; };
|
||||
2CA4E7542887D18D00B901ED /* GeojsonConverter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GeojsonConverter.swift; sourceTree = "<group>"; };
|
||||
2CA4E756288826DA00B901ED /* PlaceMapView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaceMapView.swift; sourceTree = "<group>"; };
|
||||
2CAC431A287F1C8F0088C9FD /* ApiHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApiHeader.swift; sourceTree = "<group>"; };
|
||||
2CAC431C287F399F0088C9FD /* CollectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionView.swift; sourceTree = "<group>"; };
|
||||
2CB9AA522881AC0C00E9B888 /* FavoriteExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoriteExtensions.swift; sourceTree = "<group>"; };
|
||||
2CB9AA552882CD3600E9B888 /* lib-leafless */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = "lib-leafless"; path = "../ios-locoslab/lib-leafless"; sourceTree = "<group>"; };
|
||||
2CD7E0BE2884402500F9CE57 /* WeatherConditionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherConditionView.swift; sourceTree = "<group>"; };
|
||||
2CD7E0BE2884402500F9CE57 /* WeatherViews.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherViews.swift; sourceTree = "<group>"; };
|
||||
2CD7E0C02884415A00F9CE57 /* CityForecastView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CityForecastView.swift; sourceTree = "<group>"; };
|
||||
2CD7E0C228849FF900F9CE57 /* WeatherAggregates.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherAggregates.swift; sourceTree = "<group>"; };
|
||||
2CD7E0C428856C3500F9CE57 /* PageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PageView.swift; sourceTree = "<group>"; };
|
||||
2CD7E0C628857A7900F9CE57 /* CustomizeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomizeView.swift; sourceTree = "<group>"; };
|
||||
2CD7E0C82885A0F700F9CE57 /* CityVideoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CityVideoView.swift; sourceTree = "<group>"; };
|
||||
2CD7E0CC2885AD7D00F9CE57 /* RemoteImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoteImageView.swift; sourceTree = "<group>"; };
|
||||
2CE5E85F287ECB98006B8CDF /* ProgressViews.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressViews.swift; sourceTree = "<group>"; };
|
||||
2CEB0280283EB09B00DF3151 /* Database.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Database.xcdatamodel; sourceTree = "<group>"; };
|
||||
2CEB02822840C50700DF3151 /* TermsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TermsView.swift; sourceTree = "<group>"; };
|
||||
@@ -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 = "<group>";
|
||||
@@ -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 = "<group>";
|
||||
@@ -252,6 +283,7 @@
|
||||
2CF8D6252843D0DB008FB7D0 /* ImageBindings.swift */,
|
||||
2CF8D62728440E05008FB7D0 /* DataBindings.swift */,
|
||||
2CB9AA522881AC0C00E9B888 /* FavoriteExtensions.swift */,
|
||||
2CD7E0C228849FF900F9CE57 /* WeatherAggregates.swift */,
|
||||
);
|
||||
path = Model;
|
||||
sourceTree = "<group>";
|
||||
@@ -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 = "<group>";
|
||||
@@ -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 */
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"preserves-vector-representation" : true
|
||||
"preserves-vector-representation" : true,
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"preserves-vector-representation" : true
|
||||
"preserves-vector-representation" : true,
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"preserves-vector-representation" : true
|
||||
"preserves-vector-representation" : true,
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"preserves-vector-representation" : true
|
||||
"preserves-vector-representation" : true,
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"preserves-vector-representation" : true
|
||||
"preserves-vector-representation" : true,
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"preserves-vector-representation" : true
|
||||
"preserves-vector-representation" : true,
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"preserves-vector-representation" : true
|
||||
"preserves-vector-representation" : true,
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"preserves-vector-representation" : true
|
||||
"preserves-vector-representation" : true,
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"preserves-vector-representation" : true
|
||||
"preserves-vector-representation" : true,
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"preserves-vector-representation" : true
|
||||
"preserves-vector-representation" : true,
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"preserves-vector-representation" : true
|
||||
"preserves-vector-representation" : true,
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"preserves-vector-representation" : true
|
||||
"preserves-vector-representation" : true,
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="25" width="25" viewBox="0 0 48 48"><path d="M4 40v-4.5h4.3V11q0-1.2.9-2.1.9-.9 2.1-.9h31v3h-31v24.5H23V40Zm23.95 0q-.8 0-1.375-.6T26 37.8V15.95q0-.8.575-1.375T27.95 14h13.6q1 0 1.725.575.725.575.725 1.375V37.8q0 1-.725 1.6-.725.6-1.725.6ZM29 35.5h12V17H29Z"/></svg>
|
||||
|
After Width: | Height: | Size: 313 B |
@@ -10,6 +10,7 @@
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"preserves-vector-representation" : true
|
||||
"preserves-vector-representation" : true,
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"preserves-vector-representation" : true
|
||||
"preserves-vector-representation" : true,
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"preserves-vector-representation" : true
|
||||
"preserves-vector-representation" : true,
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"preserves-vector-representation" : true
|
||||
"preserves-vector-representation" : true,
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"preserves-vector-representation" : true
|
||||
"preserves-vector-representation" : true,
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"preserves-vector-representation" : true
|
||||
"preserves-vector-representation" : true,
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"preserves-vector-representation" : true
|
||||
"preserves-vector-representation" : true,
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"preserves-vector-representation" : true
|
||||
"preserves-vector-representation" : true,
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"preserves-vector-representation" : true
|
||||
"preserves-vector-representation" : true,
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"preserves-vector-representation" : true
|
||||
"preserves-vector-representation" : true,
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"preserves-vector-representation" : true
|
||||
"preserves-vector-representation" : true,
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"preserves-vector-representation" : true
|
||||
"preserves-vector-representation" : true,
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"preserves-vector-representation" : true
|
||||
"preserves-vector-representation" : true,
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"preserves-vector-representation" : true
|
||||
"preserves-vector-representation" : true,
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"preserves-vector-representation" : true
|
||||
"preserves-vector-representation" : true,
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"preserves-vector-representation" : true
|
||||
"preserves-vector-representation" : true,
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"preserves-vector-representation" : true
|
||||
"preserves-vector-representation" : true,
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="22" width="22" viewBox="0 0 48 48"><path d="M24 24q0-4.55 3.225-7.775Q30.45 13 35 13q4.55 0 7.775 3.225Q46 19.45 46 24ZM13 35q-4.55 0-7.775-3.225Q2 28.55 2 24h22q0 4.55-3.225 7.775Q17.55 35 13 35Zm11-11q-4.55 0-7.775-3.225Q13 17.55 13 13q0-4.55 3.225-7.775Q19.45 2 24 2Zm0 22V24q4.55 0 7.775 3.225Q35 30.45 35 35q0 4.55-3.225 7.775Q28.55 46 24 46Z"/></svg>
|
||||
|
After Width: | Height: | Size: 404 B |
@@ -10,6 +10,7 @@
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"preserves-vector-representation" : true
|
||||
"preserves-vector-representation" : true,
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"preserves-vector-representation" : true
|
||||
"preserves-vector-representation" : true,
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"preserves-vector-representation" : true
|
||||
"preserves-vector-representation" : true,
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"preserves-vector-representation" : true
|
||||
"preserves-vector-representation" : true,
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ struct ContentView: View {
|
||||
NavigationView {
|
||||
LoginView()
|
||||
}
|
||||
.navigationViewStyle(StackNavigationViewStyle())
|
||||
} else {
|
||||
NavigationView {
|
||||
DrawerView()
|
||||
|
||||
@@ -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? {
|
||||
|
||||
@@ -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: "")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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)!)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
//
|
||||
// RemoteImageView.swift
|
||||
// App
|
||||
//
|
||||
// Created by Marcus Handte on 18.07.22.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
|
||||
struct RemoteImageView<Placeholder: View, ConfiguredImage: View>: 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()
|
||||
}
|
||||
}
|
||||
@@ -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<Any> = Array<Any>()
|
||||
var next: Array<Any>? = nil
|
||||
if let c = geometry?.coordinates as? Array<Any> {
|
||||
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<Any> {
|
||||
next = x
|
||||
} else if let x = c[0] as? Array<Any> {
|
||||
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<Any>, _ 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<Any> {
|
||||
result.append(contentsOf: GeojsonConverter.extract(y, count - 1))
|
||||
} else if let y = a as? Array<Any> {
|
||||
result.append(contentsOf: GeojsonConverter.extract(y, count - 1))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if let firstCodable = array.first as? AnyCodable, let first = firstCodable.value as? Array<Any> {
|
||||
let coords = GeojsonConverter.ring(from: first)
|
||||
if !coords.isEmpty {
|
||||
result.append(coords)
|
||||
}
|
||||
} else if let first = array.first as? Array<Any> {
|
||||
let coords = GeojsonConverter.ring(from: first)
|
||||
if !coords.isEmpty {
|
||||
result.append(coords)
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static func ring(from first: Array<Any>) -> [Coordinate] {
|
||||
var coords: [Coordinate] = []
|
||||
first.forEach({ a in
|
||||
if let c = a as? Array<Any> {
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -13,15 +13,34 @@ import class MoWeStaApi.WeatherForecast
|
||||
struct CityForecastView: View {
|
||||
|
||||
let city: City
|
||||
let forecast: WeatherForecast
|
||||
|
||||
let aggregate: WeatherAggregate
|
||||
let page: Binding<Int>
|
||||
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Int>
|
||||
|
||||
init(city: City, videos: WeatherVideos, page: Binding<Int>) {
|
||||
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()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+173
-73
@@ -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<Any> {
|
||||
coords.forEach { v in
|
||||
if let c = v as? Array<Any> {
|
||||
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 {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -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<Bool>
|
||||
|
||||
var body: some View {
|
||||
Toggle(isOn: enabled) {
|
||||
HStack {
|
||||
Image(image)
|
||||
Text(label)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
struct CustomizeView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
NavigationView {
|
||||
CustomizeView()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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..<x.count {
|
||||
if x[i].count != y[i].count {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
return a == nil && b == nil
|
||||
}
|
||||
|
||||
|
||||
/// Creates an color from an RGB value (0-255).
|
||||
///
|
||||
/// - parameters:
|
||||
/// - r: The red component.
|
||||
/// - g: The green component.
|
||||
/// - b: The blue component.
|
||||
func createColor(_ r: Int, _ g: Int, _ b: Int) -> 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)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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$@";
|
||||
|
||||
|
||||
@@ -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$@";
|
||||
|
||||
|
||||
/*
|
||||
<string name="format_temperature_both" translatable="false">%.1f<small>\u00A0°C</small> / %.1f<small>\u00A0°F</small></string>
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user