Skip to content

Commit

Permalink
Merge pull request #844 from unoplatform/dev/erli/828-CardView
Browse files Browse the repository at this point in the history
chore: Update CardView to Uno.Sdk 5.4
  • Loading branch information
agneszitte authored Oct 7, 2024
2 parents daf90e4 + 1bb9161 commit 64b2b97
Show file tree
Hide file tree
Showing 13 changed files with 133 additions and 159 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;
using Microsoft.Extensions.Logging;
using Uno.Resizetizer;

namespace CardViewMigration;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
using CardViewMigration.Controls;
using CardViewMigration.Controls;
using Microsoft.UI;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Media.Imaging;
using System;

namespace CardViewMigration;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<Page
x:Class="CardViewMigration.CardViewCodePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:CardViewMigration"
xmlns:utu="using:Uno.Toolkit.UI"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
utu:SafeArea.Insets="Top">
<Page x:Class="CardViewMigration.CardViewCodePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:CardViewMigration"
xmlns:utu="using:Uno.Toolkit.UI"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
utu:SafeArea.Insets="Top">
</Page>
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,20 @@
the "Microsoft.Windows.SDK.BuildTools" package above, and the "revision" version number
must be the highest found in https://www.nuget.org/packages/Microsoft.Windows.SDK.NET.Ref.
-->
<!-- <WindowsSdkPackageVersion>10.0.22621.28</WindowsSdkPackageVersion> -->

<!-- Uno Platform 5.4 has been updated to use WinAppSDK 1.6, which necessitates a temporary version adjustment until newer versions of .NET 8 SDKs are released. -->
<!-- Comment this WindowsSdkPackageVersion line again once .NET SDK version 8.0.403 or later is available. -->
<!-- For more details, refer to: https://aka.platform.uno/migrate-from-previous#uno-platform-54 -->
<WindowsSdkPackageVersion>10.0.19041.38</WindowsSdkPackageVersion>

<!--
UnoFeatures let's you quickly add and manage implicit package references based on the features you want to use.
https://aka.platform.uno/singleproject-features
-->
<UnoFeatures>
Toolkit
Toolkit;
Mvvm;
</UnoFeatures>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,41 @@
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Grid utu:SafeArea.Insets="Top">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Button x:Name="BackButton"
Grid.Row="0"
Click="{x:Bind GoBack}"
Style="{StaticResource NavigationBackButtonNormalStyle}"
VerticalAlignment="Top"
IsEnabled="{x:Bind Frame.CanGoBack, Mode=OneWay}"
ToolTipService.ToolTip="Back" />
<ScrollViewer Grid.Row="1">
<StackPanel Spacing="20">
<controls:CardView BorderBrush="DarkGray"
CardTitle="Slavko Vlasic"
CardDescription="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla elit dolor, convallis non interdum."
IconBackgroundBrush="SlateGray"
IconImageSource="ms-appx:///Assets/user.png" />
<controls:CardView BorderBrush="DarkGray"
CardTitle="Carolina Pena"
CardDescription="Phasellus eu convallis mi. In tempus augue eu dignissim fermentum. Morbi ut lacus vitae eros lacinia."
IconBackgroundBrush="SlateGray"
IconImageSource="ms-appx:///Assets/user.png" />
<controls:CardView BorderBrush="DarkGray"
CardTitle="Wade Blanks"
CardDescription="Aliquam sagittis, odio lacinia fermentum dictum, mi erat scelerisque erat, quis aliquet arcu."
IconBackgroundBrush="SlateGray"
IconImageSource="ms-appx:///Assets/user.png" />
<controls:CardView BorderBrush="DarkGray"
CardTitle="Colette Quint"
CardDescription="In pellentesque odio eget augue elementum lobortis. Sed augue massa, rhoncus eu nisi vitae, egestas."
IconBackgroundBrush="SlateGray"
IconImageSource="ms-appx:///Assets/user.png" />
</StackPanel>
</ScrollViewer>
<Grid utu:SafeArea.Insets="Top">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Button x:Name="BackButton"
Grid.Row="0"
Click="{x:Bind GoBack}"
Style="{StaticResource NavigationBackButtonNormalStyle}"
VerticalAlignment="Top"
IsEnabled="{x:Bind Frame.CanGoBack, Mode=OneWay}"
ToolTipService.ToolTip="Back" />
<ScrollViewer Grid.Row="1">
<StackPanel Spacing="20">
<controls:CardView BorderBrush="DarkGray"
CardTitle="Slavko Vlasic"
CardDescription="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla elit dolor, convallis non interdum."
IconBackgroundBrush="SlateGray"
IconImageSource="ms-appx:///Assets/user.png" />
<controls:CardView BorderBrush="DarkGray"
CardTitle="Carolina Pena"
CardDescription="Phasellus eu convallis mi. In tempus augue eu dignissim fermentum. Morbi ut lacus vitae eros lacinia."
IconBackgroundBrush="SlateGray"
IconImageSource="ms-appx:///Assets/user.png" />
<controls:CardView BorderBrush="DarkGray"
CardTitle="Wade Blanks"
CardDescription="Aliquam sagittis, odio lacinia fermentum dictum, mi erat scelerisque erat, quis aliquet arcu."
IconBackgroundBrush="SlateGray"
IconImageSource="ms-appx:///Assets/user.png" />
<controls:CardView BorderBrush="DarkGray"
CardTitle="Colette Quint"
CardDescription="In pellentesque odio eget augue elementum lobortis. Sed augue massa, rhoncus eu nisi vitae, egestas."
IconBackgroundBrush="SlateGray"
IconImageSource="ms-appx:///Assets/user.png" />
</StackPanel>
</ScrollViewer>
</Grid>
</Page>
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Microsoft.UI.Xaml.Controls;

// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238

namespace CardViewMigration;

/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class CardViewXamlPage : Page
{
public CardViewXamlPage()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<Page
x:Class="CardViewMigration.ControlTemplatePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:CardViewMigration"
xmlns:utu="using:Uno.Toolkit.UI"
xmlns:controls="using:CardViewMigration.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Page x:Class="CardViewMigration.ControlTemplatePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:CardViewMigration"
xmlns:utu="using:Uno.Toolkit.UI"
xmlns:controls="using:CardViewMigration.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Page.Resources>
<ResourceDictionary>
Expand All @@ -29,8 +28,7 @@
HorizontalAlignment="Center"
VerticalAlignment="Center" />
<StackPanel Grid.Column="1">
<TextBlock Text="{TemplateBinding CardTitle}"
FontWeight="Bold" />
<TextBlock Text="{TemplateBinding CardTitle}" FontWeight="Bold" />
<TextBlock Text="{TemplateBinding CardDescription}" TextWrapping="WrapWholeWords" />
</StackPanel>
</Grid>
Expand All @@ -49,19 +47,19 @@
ToolTipService.ToolTip="Back"/>

<TextBlock Text="A standard CardView control is suitable for grid layouts:"
TextWrapping="WrapWholeWords"
Foreground="Red"
Margin="0,0,0,10" />
TextWrapping="WrapWholeWords"
Foreground="Red"
Margin="0,0,0,10" />
<controls:CardView BorderBrush="DarkGray"
CardTitle="Slavko Vlasic"
CardDescription="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla elit dolor, convallis non interdum."
IconBackgroundBrush="SlateGray"
IconImageSource="ms-appx:///Assets/user.png"/>
<TextBlock Text="A ControlTemplate overrides the standard view, creating a more compact view suitable for lists:"
FontStyle="Italic"
Foreground="Red"
TextWrapping="WrapWholeWords"
Margin="0,0,0,10" />
FontStyle="Italic"
Foreground="Red"
TextWrapping="WrapWholeWords"
Margin="0,0,0,10" />
<controls:CardView BorderBrush="DarkGray"
CardTitle="Carolina Pena"
CardDescription="Phasellus eu convallis mi. In tempus augue eu dignissim fermentum. Morbi ut lacus vitae eros lacinia."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
using Microsoft.UI.Xaml.Controls;


// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238

namespace CardViewMigration;

/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class ControlTemplatePage : Page
{
public ControlTemplatePage()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<ContentControl
x:Class="CardViewMigration.Controls.CardView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:CardViewMigration.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
BorderThickness="1"
BorderBrush="Gray"
d:DesignHeight="300"
d:DesignWidth="400">
<ContentControl x:Class="CardViewMigration.Controls.CardView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:CardViewMigration.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
BorderThickness="1"
BorderBrush="Gray"
d:DesignHeight="300"
d:DesignWidth="400">

<Border x:Name="CardBorder" DataContext="{x:Bind}"
Background="{Binding CardBrush}"
BorderBrush="{Binding BorderBrush}"
<Border x:Name="CardBorder"
DataContext="{x:Bind}"
Background="{Binding CardBrush}"
BorderBrush="{Binding BorderBrush}"
BorderThickness="{Binding BorderThickness}"
CornerRadius="5"
Padding="8"
VerticalAlignment="Center"
HorizontalAlignment="Center">
CornerRadius="5"
Padding="8"
VerticalAlignment="Center"
HorizontalAlignment="Center">
<Border.Shadow>
<ThemeShadow />
</Border.Shadow>
Expand All @@ -33,35 +33,35 @@
<ColumnDefinition Width="200" />
</Grid.ColumnDefinitions>
<Border BorderBrush="{Binding BorderBrush, FallbackValue='Black'}"
Background="{Binding IconBackgroundBrush, FallbackValue='Gray'}"
CornerRadius="38"
Height="60"
Width="60"
HorizontalAlignment="Center"
VerticalAlignment="Center">
Background="{Binding IconBackgroundBrush, FallbackValue='Gray'}"
CornerRadius="38"
Height="60"
Width="60"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<Image Source="{Binding IconImageSource}"
Margin="-20"
Width="60"
Height="60"
Stretch="UniformToFill"/>
</Border>
<TextBlock Grid.Column="1"
Text="{Binding CardTitle, FallbackValue='Card Title'}"
FontWeight="Bold"
FontSize="20"
Text="{Binding CardTitle, FallbackValue='Card Title'}"
FontWeight="Bold"
FontSize="20"
VerticalAlignment="Center"
HorizontalTextAlignment="Start" />
HorizontalTextAlignment="Start" />
<Rectangle Grid.Row="1"
Grid.ColumnSpan="2"
Fill="{Binding BorderBrush, FallbackValue='Black'}"
Height="2"
HorizontalAlignment="Stretch" />
Grid.ColumnSpan="2"
Fill="{Binding BorderBrush, FallbackValue='Black'}"
Height="2"
HorizontalAlignment="Stretch" />
<TextBlock Grid.Row="2"
Grid.ColumnSpan="2"
Text="{Binding CardDescription, FallbackValue='Card description text.'}"
Grid.ColumnSpan="2"
Text="{Binding CardDescription, FallbackValue='Card description text.'}"
TextWrapping="WrapWholeWords"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch" />
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch" />
</Grid>
</Border>
</ContentControl>
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
<Page
x:Class="CardViewMigration.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:CardViewMigration"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Page x:Class="CardViewMigration.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:CardViewMigration"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Grid HorizontalAlignment="Center" MinWidth="200">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Button Grid.Row="0" Content="CardView XAML&#x0d;&#x0a;Create CardView items with XAML."
Command="{Binding NavigateCommand}"
CommandParameter="CardViewMigration.CardViewXamlPage" />
<Button Grid.Row="1" Content="CardView Code&#x0d;&#x0a;Create CardView items with code."
Command="{Binding NavigateCommand}"
CommandParameter="CardViewMigration.CardViewCodePage" />
<Button Grid.Row="2" Content="CardView ControlTemplate&#x0d;&#x0a;Use a ControlTemplate to change control appearance."
Command="{Binding NavigateCommand}"
CommandParameter="CardViewMigration.ControlTemplatePage" />
<Button Grid.Row="0"
Content="CardView XAML&#x0d;&#x0a;Create CardView items with XAML."
Command="{Binding NavigateCommand}"
CommandParameter="CardViewMigration.CardViewXamlPage" />
<Button Grid.Row="1"
Content="CardView Code&#x0d;&#x0a;Create CardView items with code."
Command="{Binding NavigateCommand}"
CommandParameter="CardViewMigration.CardViewCodePage" />
<Button Grid.Row="2"
Content="CardView ControlTemplate&#x0d;&#x0a;Use a ControlTemplate to change control appearance."
Command="{Binding NavigateCommand}"
CommandParameter="CardViewMigration.ControlTemplatePage" />
</Grid>
</Page>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,4 @@
See https://aka.platform.uno/using-uno-sdk for more information.
See https://aka.platform.uno/using-uno-sdk#implicit-packages for more information regarding the Implicit Packages.
-->
<ItemGroup>
<PackageVersion Include="CommunityToolkit.Mvvm" Version="8.2.2" />
</ItemGroup>
</Project>
Loading

0 comments on commit 64b2b97

Please sign in to comment.