Skip to content

Commit b9d594b

Browse files
committed
Added country flag to country model
1 parent ebb6dd4 commit b9d594b

5 files changed

Lines changed: 44 additions & 2 deletions

File tree

sample/CountryData.Sample.MAUI/CountryData.Sample.MAUI.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ VisualStudioVersion = 17.0.31611.283
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CountryData.Sample.MAUI", "CountryData.Sample.MAUI\CountryData.Sample.MAUI.csproj", "{85496674-13D9-4D03-826C-D3DD419A5AD7}"
77
EndProject
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CountryData.Standard", "..\..\src\CountryData.Standard\CountryData.Standard.csproj", "{3A01EE67-5E2A-4722-A9A7-994239AF8F05}"
9+
EndProject
810
Global
911
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1012
Debug|Any CPU = Debug|Any CPU
@@ -17,6 +19,10 @@ Global
1719
{85496674-13D9-4D03-826C-D3DD419A5AD7}.Release|Any CPU.ActiveCfg = Release|Any CPU
1820
{85496674-13D9-4D03-826C-D3DD419A5AD7}.Release|Any CPU.Build.0 = Release|Any CPU
1921
{85496674-13D9-4D03-826C-D3DD419A5AD7}.Release|Any CPU.Deploy.0 = Release|Any CPU
22+
{3A01EE67-5E2A-4722-A9A7-994239AF8F05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23+
{3A01EE67-5E2A-4722-A9A7-994239AF8F05}.Debug|Any CPU.Build.0 = Debug|Any CPU
24+
{3A01EE67-5E2A-4722-A9A7-994239AF8F05}.Release|Any CPU.ActiveCfg = Release|Any CPU
25+
{3A01EE67-5E2A-4722-A9A7-994239AF8F05}.Release|Any CPU.Build.0 = Release|Any CPU
2026
EndGlobalSection
2127
GlobalSection(SolutionProperties) = preSolution
2228
HideSolutionNode = FALSE

sample/CountryData.Sample.MAUI/CountryData.Sample.MAUI/CountryData.Sample.MAUI.csproj

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
5-
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
4+
<TargetFrameworks>net6.0-android;net6.0-ios</TargetFrameworks>
65
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
76
<!-- <TargetFrameworks>$(TargetFrameworks);net6.0-tizen</TargetFrameworks> -->
87
<OutputType>Exe</OutputType>
@@ -48,4 +47,13 @@
4847
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
4948
</ItemGroup>
5049

50+
<ItemGroup>
51+
<PackageReference Include="ReactiveUI" Version="18.0.10" />
52+
<PackageReference Include="ReactiveUI.Fody" Version="18.0.10" />
53+
</ItemGroup>
54+
55+
<ItemGroup>
56+
<ProjectReference Include="..\..\..\src\CountryData.Standard\CountryData.Standard.csproj" />
57+
</ItemGroup>
58+
5159
</Project>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using CountryData.Standard;
2+
using ReactiveUI;
3+
using ReactiveUI.Fody.Helpers;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Collections.ObjectModel;
7+
using System.Linq;
8+
using System.Text;
9+
using System.Threading.Tasks;
10+
11+
namespace CountryData.Sample.MAUI.ViewModels
12+
{
13+
public class MainViewModel : ReactiveObject
14+
{
15+
[Reactive]
16+
ObservableCollection<Country> Countries { get; set; }
17+
18+
public MainViewModel()
19+
{
20+
Countries = new ObservableCollection<Country>();
21+
}
22+
}
23+
}

src/CountryData.Standard/Country.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ public class Country
66
{
77
public string CountryName { get; set; }
88
public string CountryShortCode { get; set; }
9+
public string CountryFlag { get; set; }
910
public List<Regions> Regions { get; set; }
1011
}
1112
}

src/CountryData.Standard/CountryHelper.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ public CountryHelper()
1515
{
1616
var json = GetJsonData(strFileName);
1717
_Countries = JsonConvert.DeserializeObject<List<Country>>(json);
18+
foreach (var country in _Countries)
19+
{
20+
country.CountryFlag = GetCountryEmojiFlag(country.CountryShortCode);
21+
}
1822
}
1923

2024
private string GetJsonData(string path)

0 commit comments

Comments
 (0)