-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from zxbmmmmmmmmm/refactor/provider/qweather-uwp
Refactor/provider/qweather uwp
- Loading branch information
Showing
45 changed files
with
1,047 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
209 changes: 209 additions & 0 deletions
209
FluentWeather.Uwp.QWeatherProvider/FluentWeather.Uwp.QWeatherProvider.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,209 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{47F2B7FC-1B81-4D69-B5BA-D1160532ED63}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>FluentWeather.Uwp.QWeatherProvider</RootNamespace> | ||
<AssemblyName>FluentWeather.Uwp.QWeatherProvider</AssemblyName> | ||
<DefaultLanguage>zh-CN</DefaultLanguage> | ||
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier> | ||
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.22621.0</TargetPlatformVersion> | ||
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion> | ||
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<LangVersion>latest</LangVersion> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<LangVersion>latest</LangVersion> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'"> | ||
<PlatformTarget>x86</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<OutputPath>bin\x86\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants> | ||
<NoWarn>;2008</NoWarn> | ||
<DebugType>full</DebugType> | ||
<UseVSHostingProcess>false</UseVSHostingProcess> | ||
<ErrorReport>prompt</ErrorReport> | ||
<LangVersion>latest</LangVersion> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'"> | ||
<PlatformTarget>x86</PlatformTarget> | ||
<OutputPath>bin\x86\Release\</OutputPath> | ||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants> | ||
<Optimize>true</Optimize> | ||
<NoWarn>;2008</NoWarn> | ||
<DebugType>pdbonly</DebugType> | ||
<UseVSHostingProcess>false</UseVSHostingProcess> | ||
<ErrorReport>prompt</ErrorReport> | ||
<LangVersion>latest</LangVersion> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'"> | ||
<PlatformTarget>ARM</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<OutputPath>bin\ARM\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants> | ||
<NoWarn>;2008</NoWarn> | ||
<DebugType>full</DebugType> | ||
<UseVSHostingProcess>false</UseVSHostingProcess> | ||
<ErrorReport>prompt</ErrorReport> | ||
<LangVersion>latest</LangVersion> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'"> | ||
<PlatformTarget>ARM</PlatformTarget> | ||
<OutputPath>bin\ARM\Release\</OutputPath> | ||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants> | ||
<Optimize>true</Optimize> | ||
<NoWarn>;2008</NoWarn> | ||
<DebugType>pdbonly</DebugType> | ||
<UseVSHostingProcess>false</UseVSHostingProcess> | ||
<ErrorReport>prompt</ErrorReport> | ||
<LangVersion>latest</LangVersion> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM64'"> | ||
<PlatformTarget>ARM64</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<OutputPath>bin\ARM64\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants> | ||
<NoWarn>;2008</NoWarn> | ||
<DebugType>full</DebugType> | ||
<UseVSHostingProcess>false</UseVSHostingProcess> | ||
<ErrorReport>prompt</ErrorReport> | ||
<LangVersion>latest</LangVersion> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM64'"> | ||
<PlatformTarget>ARM64</PlatformTarget> | ||
<OutputPath>bin\ARM64\Release\</OutputPath> | ||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants> | ||
<Optimize>true</Optimize> | ||
<NoWarn>;2008</NoWarn> | ||
<DebugType>pdbonly</DebugType> | ||
<UseVSHostingProcess>false</UseVSHostingProcess> | ||
<ErrorReport>prompt</ErrorReport> | ||
<LangVersion>latest</LangVersion> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"> | ||
<PlatformTarget>x64</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<OutputPath>bin\x64\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants> | ||
<NoWarn>;2008</NoWarn> | ||
<DebugType>full</DebugType> | ||
<UseVSHostingProcess>false</UseVSHostingProcess> | ||
<ErrorReport>prompt</ErrorReport> | ||
<LangVersion>latest</LangVersion> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> | ||
<PlatformTarget>x64</PlatformTarget> | ||
<OutputPath>bin\x64\Release\</OutputPath> | ||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants> | ||
<Optimize>true</Optimize> | ||
<NoWarn>;2008</NoWarn> | ||
<DebugType>pdbonly</DebugType> | ||
<UseVSHostingProcess>false</UseVSHostingProcess> | ||
<ErrorReport>prompt</ErrorReport> | ||
<LangVersion>latest</LangVersion> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<RestoreProjectStyle>PackageReference</RestoreProjectStyle> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="Views\SetTokenDialog.xaml.cs"> | ||
<DependentUpon>SetTokenDialog.xaml</DependentUpon> | ||
</Compile> | ||
<Compile Include="Helpers\WeatherTypeConverter.cs" /> | ||
<Compile Include="Mappers\AirConditionMapper.cs" /> | ||
<Compile Include="Mappers\DailyForecastItemMapper.cs" /> | ||
<Compile Include="Mappers\GeolocationMapper.cs" /> | ||
<Compile Include="Mappers\HourlyForecastItemMapper.cs" /> | ||
<Compile Include="Mappers\PrecipitationMapper.cs" /> | ||
<Compile Include="Mappers\TyphoonMapper.cs" /> | ||
<Compile Include="Mappers\WeatherIndicesMapper.cs" /> | ||
<Compile Include="Mappers\WeatherNowMapper.cs" /> | ||
<Compile Include="Mappers\WeatherWarningMapper.cs" /> | ||
<Compile Include="Models\QAirCondition.cs" /> | ||
<Compile Include="Models\QTyphoon.cs" /> | ||
<Compile Include="Models\QWeatherDailyForecast.cs" /> | ||
<Compile Include="Models\QWeatherHourlyForecast.cs" /> | ||
<Compile Include="Models\QWeatherIndices.cs" /> | ||
<Compile Include="Models\QWeatherNight.cs" /> | ||
<Compile Include="Models\QWeatherNow.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="QWeatherProvider.cs" /> | ||
<EmbeddedResource Include="Properties\FluentWeather.Uwp.QWeatherProvider.rd.xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="CommunityToolkit.Mvvm"> | ||
<Version>8.2.2</Version> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection"> | ||
<Version>8.0.0</Version> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform"> | ||
<Version>6.2.14</Version> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.UI.Xaml"> | ||
<Version>2.7.3</Version> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.Xaml.Behaviors.Uwp.Managed"> | ||
<Version>2.0.1</Version> | ||
</PackageReference> | ||
<PackageReference Include="QWeather"> | ||
<Version>1.0.1</Version> | ||
</PackageReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\FluentWeather.Abstraction\FluentWeather.Abstraction.csproj"> | ||
<Project>{0627214c-2da0-4b49-bb12-dc8c44014eee}</Project> | ||
<Name>FluentWeather.Abstraction</Name> | ||
</ProjectReference> | ||
<ProjectReference Include="..\FluentWeather.DIContainer\FluentWeather.DIContainer.csproj"> | ||
<Project>{15e289d2-4104-4889-b968-60d2c2efd806}</Project> | ||
<Name>FluentWeather.DIContainer</Name> | ||
</ProjectReference> | ||
<ProjectReference Include="..\FluentWeather.Uwp.Shared\FluentWeather.Uwp.Shared.csproj"> | ||
<Project>{23269c7b-0343-48b6-9909-505d667b0dbf}</Project> | ||
<Name>FluentWeather.Uwp.Shared</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<ItemGroup /> | ||
<ItemGroup> | ||
<Page Include="Views\SetTokenDialog.xaml"> | ||
<Generator>MSBuild:Compile</Generator> | ||
<SubType>Designer</SubType> | ||
</Page> | ||
</ItemGroup> | ||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' "> | ||
<VisualStudioVersion>14.0</VisualStudioVersion> | ||
</PropertyGroup> | ||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
56 changes: 56 additions & 0 deletions
56
FluentWeather.Uwp.QWeatherProvider/Helpers/WeatherTypeConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using FluentWeather.Abstraction.Models; | ||
using static FluentWeather.Abstraction.Models.WeatherCode; | ||
namespace FluentWeather.Uwp.QWeatherProvider.Helpers; | ||
|
||
|
||
public static class WeatherTypeConverter | ||
{ | ||
public static WeatherCode GetWeatherTypeByDescription(string description) | ||
{ | ||
description = description.ToLower(); | ||
if (description.Contains("晴") || description.Contains("Clear")) | ||
return Clear; | ||
if (description.Contains("阴") || description.Contains("Overcast")) | ||
return Overcast; | ||
if (description.Contains("小雨") || description.Contains("Light Rain")) | ||
return SlightRain; | ||
if (description.Contains("中雨") || description.Contains("Moderate Rain")) | ||
return ModerateRain; | ||
if (description.Contains("大雨") || description.Contains("Heavy Rain")) | ||
return HeavyRain; | ||
if (description.Contains("局部多云") || description.Contains("Partly Cloudy")) | ||
return PartlyCloudy; | ||
if (description.Contains("大部多云") || description.Contains("Cloudy")) | ||
return PartlyCloudy; | ||
if (description.Contains("少云") || description.Contains("Mainly Clear")) | ||
return MainlyClear; | ||
|
||
if (description.Contains("冰雹") || description.Contains("Hail")) | ||
return SlightHail; | ||
if (description.Contains("雷阵雨") || description.Contains("Thunder")) | ||
return HeavyThunderStorm; | ||
if(description.Contains("小雪") || description.Contains("Light Snow")) | ||
return SlightSnowFall; | ||
if (description.Contains("大雪") || description.Contains("Heavy Snow")) | ||
return HeavySnowFall; | ||
if (description.Contains("冻雨") || description.Contains("Freezing Rain")) | ||
return LightFreezingRain; | ||
|
||
if (description.Contains("雪") || description.Contains("Snow")) | ||
return ModerateSnowFall; | ||
if (description.Contains("雷") || description.Contains("Thunder")) | ||
return SlightOrModerateThunderstorm; | ||
if (description.Contains("雨") || description.Contains("Rain")) | ||
return ModerateRain; | ||
if (description.Contains("雾") || description.Contains("Fog")) | ||
return Fog; | ||
if (description.Contains("霾") || description.Contains("Haze")) | ||
return Haze; | ||
if (description.Contains("多云") || description.Contains("Cloud")) | ||
return PartlyCloudy; | ||
|
||
|
||
|
||
return Unknown; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
FluentWeather.Uwp.QWeatherProvider/Mappers/AirConditionMapper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using FluentWeather.Uwp.QWeatherProvider.Models; | ||
using QWeatherApi.ApiContracts; | ||
|
||
namespace FluentWeather.Uwp.QWeatherProvider.Mappers | ||
{ | ||
internal static class AirConditionMapper | ||
{ | ||
public static QAirCondition MapToQAirCondition(this AirConditionResponse.AirConditionItem item) | ||
{ | ||
return new QAirCondition | ||
{ | ||
Aqi = item.Aqi, | ||
AqiCategory = item.Category, | ||
AqiLevel = item.Level, | ||
CO= item.Co, | ||
SO2 = item.So2, | ||
NO2 = item.No2, | ||
O3 = item.O3, | ||
PM10 = item.Pm10, | ||
PM25 = item.Pm2p5, | ||
}; | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
FluentWeather.Uwp.QWeatherProvider/Mappers/DailyForecastItemMapper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using FluentWeather.Abstraction.Helpers; | ||
using FluentWeather.Uwp.QWeatherProvider.Models; | ||
using QWeatherApi.ApiContracts; | ||
|
||
namespace FluentWeather.Uwp.QWeatherProvider.Mappers; | ||
|
||
public static class DailyForecastItemMapper | ||
{ | ||
public static QWeatherDailyForecast MapToQWeatherDailyForecast(this WeatherDailyResponse.DailyForecastItem item) | ||
{ | ||
return new QWeatherDailyForecast | ||
{ | ||
WindDirection = UnitConverter.GetWindDirectionFromAngle(int.Parse(item.Wind360Day)), | ||
Description = item.TextDay, | ||
WindDirectionDescription = item.WindDirDay, | ||
WindScale = item.WindScaleDay, | ||
WindSpeed = item.WindSpeedDay, | ||
Humidity = item.Humidity, | ||
MaxTemperature = item.TempMax, | ||
MinTemperature = item.TempMin, | ||
Pressure = item.Pressure, | ||
Time = item.FxDate, | ||
Visibility = item.Vis, | ||
SunRise = item.Sunrise, | ||
SunSet = item.Sunset, | ||
CloudAmount = item.Cloud, | ||
|
||
WeatherNight = new QWeatherNight | ||
{ | ||
Description = item.TextNight, | ||
WindDirection = UnitConverter.GetWindDirectionFromAngle(item.Wind360Night), | ||
WindDirectionDescription = item.WindDirNight, | ||
WindScale = item.WindScaleNight, | ||
WindSpeed = item.WindSpeedNight, | ||
} | ||
}; | ||
} | ||
} |
Oops, something went wrong.