Skip to content

Commit

Permalink
chore: Improve Uno Islands sample
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed May 13, 2022
1 parent d9b8a46 commit ab9a883
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 10 deletions.
19 changes: 16 additions & 3 deletions src/SamplesApp/UnoIslands.Shared/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,21 @@
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<StackPanel Background="#FAFAFA" Padding="20">
<Grid Padding="20">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="128" />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Name}" Style="{ThemeResource HeaderTextBlockStyle}" />
<Button Content="{Binding Phone}" />
</StackPanel>
<Image Grid.Column="1" Source="{Binding ImageUrl}" />
<StackPanel Grid.Row="1">
<TextBlock Text="{Binding Address}" />
<HyperlinkButton Content="{Binding Email}" NavigateUri="{Binding EmailUrl}" Grid.Row="1" />
<TextBlock Text="{Binding Phone}" />
</StackPanel>
</Grid>
</Page>
3 changes: 3 additions & 0 deletions src/SamplesApp/UnoIslands.Shared/UnoIslands.Shared.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,7 @@
<_Globbed_Content Include="$(MSBuildThisFileDirectory)Assets/**/*.*" Exclude="@(Content)" />
<Content Include="@(_Globbed_Content)" />
</ItemGroup>
<ItemGroup>
<Folder Include="$(MSBuildThisFileDirectory)Assets\Images\" />
</ItemGroup>
</Project>
8 changes: 4 additions & 4 deletions src/SamplesApp/UnoIslands.WPF/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ namespace UnoIslands.Skia.Wpf
{
public class MainWindowViewModel : INotifyPropertyChanged
{
private DataItem _selectedItem = null;
private PersonViewModel _selectedItem = null;

public MainWindowViewModel()
{
using var stream = typeof(MainWindowViewModel).Assembly.GetManifestResourceStream("UnoIslands.Skia.Wpf.TestData.json");
using var textStream = new StreamReader(stream);
Data = JsonConvert.DeserializeObject<DataItem[]>(textStream.ReadToEnd());
Data = JsonConvert.DeserializeObject<PersonViewModel[]>(textStream.ReadToEnd());
}

public DataItem[] Data { get; }
public PersonViewModel[] Data { get; }

public DataItem SelectedItem
public PersonViewModel SelectedItem
{
get => _selectedItem;
set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace UnoIslands.Skia.Wpf
{
public class DataItem
public class PersonViewModel
{
public string Name { get; set; }

Expand All @@ -21,5 +21,9 @@ public class DataItem
public string Region { get; set; }

public string Country { get; set; }

public string EmailUrl => "mailto:" + Email;

public string ImageUrl => $"https://www.gravatar.com/avatar/{Name.GetHashCode()}?s=128&d=identicon&r=PG";
}
}
2 changes: 1 addition & 1 deletion src/SamplesApp/UnoIslands.WPF/TestData.json
Original file line number Diff line number Diff line change
Expand Up @@ -449,4 +449,4 @@
"region": "Møre og Romsdal",
"country": "Turkey"
}
]
]
2 changes: 1 addition & 1 deletion src/Uno.UI.Runtime.Skia.Wpf/Islands/WpfIslandsHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void CreateApp(WinUI.ApplicationInitializationCallbackParams _)
Windows.UI.Core.CoreDispatcher.DispatchOverride = d => dispatcher.BeginInvoke(d);
Windows.UI.Core.CoreDispatcher.HasThreadAccessOverride = dispatcher.CheckAccess;

WinUI.Application.Start(CreateApp, args);
WinUI.Application.Start(CreateApp);

WpfApplication.Current.Activated += Current_Activated;
WpfApplication.Current.Deactivated += Current_Deactivated;
Expand Down

0 comments on commit ab9a883

Please sign in to comment.