Skip to content

Commit

Permalink
Added Preview functionality and UI updates
Browse files Browse the repository at this point in the history
This commit introduces a new `Preview` functionality, including a `PreviewPage` and `PreviewViewModel`. The `PreviewPage` includes a `Grid` layout with a `NavigationBar` and a `ScrollViewer`. The `PreviewViewModel` includes a `Parameter` property. The `App.cs` file has been updated to register the new `DataViewMap` and route for `Preview`.

Several UI changes have been made in `MainPage.xaml`, including the addition of new namespaces and elements, and updates to existing elements. New methods for handling tap events have been added in `MainPage.xaml.cs`.

In `MainViewModel.cs`, a new `isPreview` field and `IsPreviewAvailable` property have been added, and several methods and commands have been updated or added. A new `PreviewViewModel` class has been added in `SecondViewModel.cs`.

In `ClassToXaml.csproj`, several SVG icons and the `PreviewPage.xaml` file have been removed from various item groups, and the SVG icons have been updated to never copy to the output directory. A new SVG icon, `store.svg`, has been added.
  • Loading branch information
avikeid2007 committed May 27, 2024
1 parent 6b02616 commit 8b25dfa
Show file tree
Hide file tree
Showing 9 changed files with 361 additions and 65 deletions.
4 changes: 3 additions & 1 deletion ClassToXaml/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ private static void RegisterRoutes(IViewRegistry views, IRouteRegistry routes)
views.Register(
new ViewMap(ViewModel: typeof(ShellViewModel)),
new ViewMap<MainPage, MainViewModel>(),
new ViewMap<SecondPage, SecondViewModel>()
new ViewMap<SecondPage, SecondViewModel>(),
new DataViewMap<PreviewPage, PreviewViewModel, string>()
);

routes.Register(
Expand All @@ -45,6 +46,7 @@ private static void RegisterRoutes(IViewRegistry views, IRouteRegistry routes)
{
new RouteMap("Main", View: views.FindByViewModel<MainViewModel>()),
new RouteMap("Second", View: views.FindByViewModel<SecondViewModel>()),
new RouteMap("Preview", View: views.FindByViewModel<PreviewViewModel>()),
}
)
);
Expand Down
1 change: 1 addition & 0 deletions ClassToXaml/Assets/Icons/store.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 57 additions & 0 deletions ClassToXaml/ClassToXaml.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,61 @@
<ItemGroup>
<UnoDspImportColors Include="Styles\*.zip" Generator="Xaml" />
</ItemGroup>


<ItemGroup>
<None Remove="Assets\Icons\icons8-microsoft-store-40.svg" />
<None Remove="Assets\Icons\store.svg" />
<None Remove="Presentation\PreviewPage.xaml" />
</ItemGroup>


<ItemGroup>
<UpToDateCheckInput Remove="Presentation\PreviewPage.xaml" />
</ItemGroup>


<ItemGroup>
<AdditionalFiles Remove="Presentation\PreviewPage.xaml" />
</ItemGroup>


<ItemGroup>
<Content Remove="Assets\Icons\icons8-microsoft-store-40.svg" />
<Content Remove="Assets\Icons\store.svg" />
</ItemGroup>


<ItemGroup>
<UnoImage Update="Assets\Icons\icons8-microsoft-store-40.svg">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</UnoImage>
</ItemGroup>


<ItemGroup>
<UnoImage Update="Assets\Icons\store.svg">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</UnoImage>
</ItemGroup>


<ItemGroup>
<UnoImage Remove="Assets\Icons\icons8-microsoft-store-40.svg" />
</ItemGroup>


<ItemGroup>
<UnoImage Remove="Assets\Icons\store.svg" />
</ItemGroup>


<ItemGroup>
<UnoImage Remove="Assets\Icons\icons8-microsoft-store-40.svg" />
</ItemGroup>


<ItemGroup>
<UnoImage Remove="Assets\Icons\store.svg" />
</ItemGroup>
</Project>
192 changes: 134 additions & 58 deletions ClassToXaml/Presentation/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:ClassToXaml.Presentation"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:uen="using:Uno.Extensions.Navigation.UI"
xmlns:um="using:Uno.Material"
xmlns:utu="using:Uno.Toolkit.UI"
xmlns:wasm="http://uno.ui/wasm"
xmlns:win="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Background="{ThemeResource BackgroundBrush}"
NavigationCacheMode="Required">
NavigationCacheMode="Required"
mc:Ignorable="wasm">

<Grid utu:SafeArea.Insets="VisibleBounds">
<Grid.RowDefinitions>
Expand All @@ -24,6 +28,7 @@
Grid.ColumnSpan="2"
Margin="0,0,0,4"
Content="Class To XAML(UWP, WinUI, WPF, MAUI)" />

<StackPanel
Grid.Column="1"
HorizontalAlignment="Right"
Expand All @@ -36,10 +41,89 @@
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE706;" />
</ToggleSwitch.OnContent>
</ToggleSwitch>
<!-- AppBarButton Path did render right svg path for wasm -->
<SymbolIcon
Width="20"
Height="20"
Margin="16,0"
Symbol="LikeDislike"
Tapped="SymbolIcon_Tapped"
ToolTipService.Placement="Mouse"
ToolTipService.ToolTip="Rate us at Microsoft Store" />
<!--<AppBarButton
Command="{x:Bind VM.StoreCommand}"
ToolTipService.Placement="Mouse"
ToolTipService.ToolTip="Open in Microsoft Store">-->

<Path
Width="20"
Height="20"
Margin="16,0"
VerticalAlignment="Center"
Data="M 11 3 L 9 5 L 9 9 L 3 9 L 3 27 C 3 28.093063 3.9069372 29 5 29 L 27 29 C 28.093063 29 29 28.093063 29 27 L 29 9 L 23 9 L 23 5 L 21 3 L 11 3 z M 11 5 L 21 5 L 21 9 L 11 9 L 11 5 z M 5 11 L 27 11 L 27 27 L 5 27 L 5 11 z M 11 14 L 11 18.5 L 15.5 18.5 L 15.5 14 L 11 14 z M 16.5 14 L 16.5 18.5 L 21 18.5 L 21 14 L 16.5 14 z M 11 19.5 L 11 24 L 15.5 24 L 15.5 19.5 L 11 19.5 z M 16.5 19.5 L 16.5 24 L 21 24 L 21 19.5 L 16.5 19.5 z"
Fill="{ThemeResource SystemBaseHighColor}"
Stretch="Uniform"
Tapped="Path_Tapped"
ToolTipService.Placement="Mouse"
ToolTipService.ToolTip="Open in Microsoft Store" />

<!--</AppBarButton>-->
<!--<AppBarButton
Command="{x:Bind VM.WebCommand}"
LabelPosition="Collapsed"
ToolTipService.Placement="Mouse"
ToolTipService.ToolTip="Open in Browser">-->

<win:SymbolIcon
Width="20"
Height="20"
Margin="16,0"
Symbol="Globe"
Tapped="SymbolIcon_Tapped_1"
ToolTipService.Placement="Mouse"
ToolTipService.ToolTip="Open in Browser" />
<!--</AppBarButton>-->
<!--<AppBarButton
Command="{x:Bind VM.GithubCommand}"
ToolTipService.Placement="Mouse"
ToolTipService.ToolTip="Open Github repo">-->
<Path
Width="20"
Height="20"
Margin="16,0"
VerticalAlignment="Center"
Data="M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"
Fill="{ThemeResource SystemBaseHighColor}"
Stretch="Uniform"
Tapped="Path_Tapped_1"
ToolTipService.Placement="Mouse"
ToolTipService.ToolTip="Open Github repo" />
<!--</AppBarButton>-->
<!--<AppBarButton
Command="{x:Bind VM.GoToSecond}"
LabelPosition="Collapsed"
ToolTipService.Placement="Mouse"
ToolTipService.ToolTip="Github">
<um:ControlExtensions.Icon>
<PathIcon Data="M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z" />
</um:ControlExtensions.Icon>
</AppBarButton>-->
<!--<AppBarButton
Command="{x:Bind VM.GoToSecond}"
LabelPosition="Collapsed"
ToolTipService.Placement="Mouse"
ToolTipService.ToolTip="Microsoft Store">
<um:ControlExtensions.Icon>
<PathIcon Data="M 11 3 L 9 5 L 9 9 L 3 9 L 3 27 C 3 28.093063 3.9069372 29 5 29 L 27 29 C 28.093063 29 29 28.093063 29 27 L 29 9 L 23 9 L 23 5 L 21 3 L 11 3 z M 11 5 L 21 5 L 21 9 L 11 9 L 11 5 z M 5 11 L 27 11 L 27 27 L 5 27 L 5 11 z M 11 14 L 11 18.5 L 15.5 18.5 L 15.5 14 L 11 14 z M 16.5 14 L 16.5 18.5 L 21 18.5 L 21 14 L 16.5 14 z M 11 19.5 L 11 24 L 15.5 24 L 15.5 19.5 L 11 19.5 z M 16.5 19.5 L 16.5 24 L 21 24 L 21 19.5 L 16.5 19.5 z" />
</um:ControlExtensions.Icon>
</AppBarButton>-->
<AppBarButton
Command="{x:Bind VM.GoToSecond}"
Icon="Setting"
LabelPosition="Collapsed" />
LabelPosition="Collapsed"
ToolTipService.Placement="Mouse"
ToolTipService.ToolTip="settings">
<SymbolIcon Symbol="Setting" />
</AppBarButton>
</StackPanel>
<TextBox
Grid.Row="1"
Expand All @@ -50,18 +134,39 @@
Header="Class Text( Only Public properties will be use for XAML)"
PlaceholderText="Class Text( Only Public properties will be use for XAML)"
Text="{x:Bind VM.InputText, Mode=TwoWay}" />
<Button

<utu:ChipGroup
Grid.Row="1"
Margin="8,10"
Margin="16,8"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Command="{x:Bind VM.ExampleCommand}"
Content="Example"
Style="{StaticResource SecondarySmallFabStyle}">
<um:ControlExtensions.Icon>
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE943;" />
</um:ControlExtensions.Icon>
</Button>
Style="{StaticResource AssistChipGroupStyle}">
<utu:Chip
Command="{x:Bind VM.ExampleCommand}"
CommandParameter="0"
Content="Single Class Example">
<utu:Chip.Icon>
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE943;" />
</utu:Chip.Icon>
</utu:Chip>
<utu:Chip
Command="{x:Bind VM.ExampleCommand}"
CommandParameter="1"
Content="Multiple Class Example">
<utu:Chip.Icon>
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE943;" />
</utu:Chip.Icon>
</utu:Chip>
<utu:Chip
Command="{x:Bind VM.ExampleCommand}"
CommandParameter="2"
Content="Json Example(Coming soon)"
IsEnabled="False">
<utu:Chip.Icon>
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE943;" />
</utu:Chip.Icon>
</utu:Chip>
</utu:ChipGroup>
<Grid
Grid.Row="1"
Grid.RowSpan="3"
Expand Down Expand Up @@ -203,7 +308,7 @@
Grid.Row="9"
Grid.Column="1"
Margin="8,0,0,0"
IsEnabled="{x:Bind VM.ForUWP}"
IsEnabled="{x:Bind VM.ForUWP, Mode=OneWay}"
IsOn="{x:Bind VM.IsUseXBind, Mode=TwoWay}"
OffContent=""
OnContent="" />
Expand Down Expand Up @@ -249,43 +354,6 @@
Grid.ColumnSpan="2"
PlaceholderText="Style For Combo Box"
Text="{x:Bind VM.StyleForCombo, Mode=TwoWay}" />
<!--<TextBlock
Grid.Row="11"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
FontSize="16"
FontWeight="Medium"
Text="More Settings:" />
<Button
Grid.Row="11"
Grid.Column="1"
Margin="8,0,0,0"
HorizontalAlignment="Center"
Command="{x:Bind VM.GoToSecond}"
Style="{StaticResource IconButtonStyle}">
<SymbolIcon Symbol="More" />
</Button>-->
<!--<TextBlock
Grid.Row="5"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
FontSize="16"
FontWeight="Medium"
Text="Use Calendar for dates" />
<ToggleSwitch
Grid.Row="5"
Grid.Column="1"
Margin="8,0,0,0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
IsOn="{Binding IsIncludeParameter, Mode=TwoWay}"
OffContent=""
OnContent="" />-->

</Grid>
<Grid Grid.Row="2">
<Grid.ColumnDefinitions>
Expand Down Expand Up @@ -316,14 +384,7 @@
<SymbolIcon Symbol="Copy" />
</um:ControlExtensions.Icon>
</Button>
<!--<Button
Grid.Column="2"
Height="60"
Margin="8,4"
HorizontalAlignment="Stretch"
Command="{Binding ExportCommand}"
Content="Export"
CornerRadius="4" />-->

<Button
Grid.Column="2"
Height="60"
Expand All @@ -345,5 +406,20 @@
VerticalAlignment="Stretch"
AcceptsReturn="True"
Text="{x:Bind VM.OutputText, Mode=TwoWay}" />
<win:StackPanel
Grid.Row="3"
Height="40"
Margin="16,8"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Visibility="{x:Bind VM.IsPreviewAvailable, Mode=OneWay}">
<utu:ChipGroup Style="{StaticResource AssistChipGroupStyle}">
<utu:Chip Command="{x:Bind VM.GoToPreview}" Content="XAML Preview available!">
<utu:Chip.Icon>
<SymbolIcon Symbol="PreviewLink" />
</utu:Chip.Icon>
</utu:Chip>
</utu:ChipGroup>
</win:StackPanel>
</Grid>
</Page>
21 changes: 21 additions & 0 deletions ClassToXaml/Presentation/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,25 @@ private void OnDarkModeToggleToggled(object sender, RoutedEventArgs e)
ser.SetThemeAsync(AppTheme.Dark);
}
}

private async void SymbolIcon_Tapped(object sender, Microsoft.UI.Xaml.Input.TappedRoutedEventArgs e)
{
await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-windows-store://review/?ProductId=9PM6HNH3LNG1"));
}

private async void Path_Tapped(object sender, Microsoft.UI.Xaml.Input.TappedRoutedEventArgs e)
{
await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-windows-store://pdp/?ProductId=9PM6HNH3LNG1"));
}

private async void SymbolIcon_Tapped_1(object sender, Microsoft.UI.Xaml.Input.TappedRoutedEventArgs e)
{
await Windows.System.Launcher.LaunchUriAsync(new Uri("http://classtoxaml.com"));

}

private async void Path_Tapped_1(object sender, Microsoft.UI.Xaml.Input.TappedRoutedEventArgs e)
{
await Windows.System.Launcher.LaunchUriAsync(new Uri("https://github.com/avikeid2007/ClassToXaml"));
}
}
Loading

0 comments on commit 8b25dfa

Please sign in to comment.