Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PopupViewer WinUI/UWP #589

Merged
merged 26 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
31ddf24
Set up v.next branch
dotMorten Jun 24, 2024
bdf1b27
Merge branch 'main' into v.next
Jun 27, 2024
4041e19
WPF/MAUI: FeatureForm attachments support (#581)
dotMorten Jul 1, 2024
75dcc16
Added missing trimming attribute
dotMorten Jul 5, 2024
9fdc58b
Merge remote-tracking branch 'origin/main' into v.next
Jul 9, 2024
9d1dfd8
Move code for getting parent to common location
dotMorten Jul 9, 2024
3c43b7c
Add null-check
dotMorten Jul 15, 2024
0673608
Improve app theming and theme testing
dotMorten Jul 15, 2024
ac1bc3e
Adds support for the barcode input field (#583)
dotMorten Jul 16, 2024
789e346
Added support to override URL clicks in PopupViewer (#584)
prathameshnarkhede Jul 16, 2024
4457d36
Add discard method to featureform that ensures the form is fully rese…
dotMorten Jul 17, 2024
ab0dbd7
Improve discards and avoiding cascading evaluations
dotMorten Jul 17, 2024
61dd609
Add barcode scanner example to maui sample using ZXing
dotMorten Jul 18, 2024
dd898db
Refetch attachment on discard
dotMorten Jul 22, 2024
3a5de8b
Fix null warning
dotMorten Jul 22, 2024
33e29d2
Add error border below text field (#585)
dotMorten Jul 22, 2024
2fc9789
BugFix: BasemapGallery fails to load default Basemaps in WPF (#586)
prathameshnarkhede Jul 25, 2024
b5e573c
Raise hyperlink event for field links
dotMorten Jul 26, 2024
d3a63b2
Port new PopupViewer to WinUI/UWP
dotMorten Jul 26, 2024
8f32475
Initial text formatting of popup viewer text
dotMorten Jul 30, 2024
6f023fc
Switch over to use UI elements to generate HTML rendering
dotMorten Jul 30, 2024
5ad0dc6
Merge remote-tracking branch 'origin/main' into popupviewer_winui
dotMorten Aug 1, 2024
d3a9b8d
Final cleanup
dotMorten Aug 1, 2024
e46fdbb
Fix scrollviewer getting in the way of content by ignoring padding on…
dotMorten Aug 2, 2024
3347c53
Improve flipview
dotMorten Aug 2, 2024
749dc30
UI tweaks for flipview
dotMorten Aug 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
GeoViewTapped="mapView_GeoViewTapped"/>
<toolkit:PopupViewer x:Name="popupViewer"
Grid.Column="1"
Padding="5"
Padding="10"
Width="300"
Visibility="Collapsed"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" />
VerticalAlignment="Stretch"
PopupAttachmentClicked="popupViewer_PopupAttachmentClicked"
HyperlinkClicked="popupViewer_LinkClicked" />
</Grid>
</Page>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Windows.UI.Popups;

// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
Expand All @@ -20,14 +21,10 @@ public sealed partial class PopupViewerSample : Page
public PopupViewerSample()
{
this.InitializeComponent();
Map.Loaded += (s, e) =>
{
Map.OperationalLayers.RemoveAt(0); // Remove secured layer
};
}

// Webmap configured with Popup
public Map Map { get; } = new Map(new Uri("https://www.arcgis.com/home/item.html?id=d4fe39d300c24672b1821fa8450b6ae2"));
public Map Map { get; } = new Map(new Uri("https://www.arcgis.com/home/item.html?id=9f3a674e998f461580006e626611f9ad"));

private async void mapView_GeoViewTapped(object sender, GeoViewInputEventArgs e)
{
Expand All @@ -43,11 +40,11 @@ private async void mapView_GeoViewTapped(object sender, GeoViewInputEventArgs e)
if (popup != null)
{
popupViewer.Visibility = Visibility.Visible;
popupViewer.PopupManager = new PopupManager(popup);
popupViewer.Popup = popup;
}
else
{
popupViewer.PopupManager = null;
popupViewer.Popup = null;
popupViewer.Visibility = Visibility.Collapsed;
}
}
Expand Down Expand Up @@ -116,5 +113,45 @@ private Mapping.Popups.Popup GetPopup(IEnumerable<IdentifyLayerResult> results)

return null;
}
private async void popupViewer_PopupAttachmentClicked(object sender, UI.Controls.PopupAttachmentClickedEventArgs e)
{
// Override the default attachment click behavior (which will download and save attachment)
if (!e.Attachment.IsLocal) // Attachment hasn't been downloaded
{
try
{
// Make first click just load the attachment (or cancel a loading operation). Otherwise fallback to default behavior
if (e.Attachment.LoadStatus == LoadStatus.NotLoaded)
{
e.Handled = true;
await e.Attachment.LoadAsync();
}
else if (e.Attachment.LoadStatus == LoadStatus.FailedToLoad)
{
e.Handled = true;
await e.Attachment.RetryLoadAsync();
}
else if (e.Attachment.LoadStatus == LoadStatus.Loading)
{
e.Handled = true;
e.Attachment.CancelLoad();
}
}
catch (OperationCanceledException) { }
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("Failed to download attachment", ex.Message);
}
}
}

private void popupViewer_LinkClicked(object sender, UI.Controls.HyperlinkClickedEventArgs e)
{
// Include below line if you want to prevent the default action
// e.Handled = true;

// Perform custom action when a link is clicked
System.Diagnostics.Debug.WriteLine(e.Uri);
}
}
}
111 changes: 65 additions & 46 deletions src/Toolkit/Toolkit.WPF/UI/Controls/PopupViewer/PopupViewer.Theme.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,62 +52,81 @@
</Setter.Value>
</Setter>
</Style>

<Style TargetType="{x:Type primitives:AttachmentThumbnailImage}" >
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type primitives:AttachmentThumbnailImage}">
<StackPanel Orientation="Horizontal">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="LoadedStates">
<VisualState x:Name="AttachmentLoading">
<Storyboard RepeatBehavior="Forever" >
<DoubleAnimation
Storyboard.TargetName="Icon"
Storyboard.TargetProperty="RenderTransform.Angle"
Duration="0:0:1" From="0" To="360" />
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Icon" Storyboard.TargetProperty="Text">
<DiscreteObjectKeyFrame KeyTime="0" Value="&#xE72C;"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="AttachmentLoaded">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Icon" Storyboard.TargetProperty="Text">
<DiscreteObjectKeyFrame KeyTime="0" Value="&#xF13E;"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="AttachmentFailedToLoad">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Icon" Storyboard.TargetProperty="Text">
<DiscreteObjectKeyFrame KeyTime="0" Value="&#xEA6A;"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="NotLoaded">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Icon" Storyboard.TargetProperty="Text">
<DiscreteObjectKeyFrame KeyTime="0" Value="&#xE896;"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="AttachmentIsLocal">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Icon" Storyboard.TargetProperty="Text">
<DiscreteObjectKeyFrame KeyTime="0" Value=""/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid Width="{TemplateBinding ThumbnailSize}" Height="{TemplateBinding ThumbnailSize}">
<TextBlock x:Name="Icon" FontFamily="Segoe MDL2 Assets" FontSize="18" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,0,5,0" Text="&#xE896;" RenderTransformOrigin=".5,.5">
<TextBlock.RenderTransform>
<RotateTransform />
</TextBlock.RenderTransform>
</TextBlock>
<Image x:Name="PART_Image" Stretch="UniformToFill" HorizontalAlignment="Center" VerticalAlignment="Center" />
</Grid>
<TextBlock Text="{Binding Name}" Margin="5" Cursor="Hand"/>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<Style TargetType="{x:Type primitives:AttachmentsPopupElementView}" >
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type primitives:AttachmentsPopupElementView}">
<StackPanel>
<StackPanel.Resources>
<Style TargetType="TextBlock" x:Key="DownloadIcon" xmlns:es="clr-namespace:Esri.ArcGISRuntime;assembly=Esri.ArcGISRuntime">
<Setter Property="FontFamily" Value="Segoe MDL2 Assets" />
<Setter Property="FontSize" Value="18" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="0,0,5,0" />
<Setter Property="Text" Value="&#xF13E;" />
<Setter Property="RenderTransformOrigin" Value=".5,.5" />
<Setter Property="RenderTransform">
<Setter.Value>
<RotateTransform />
</Setter.Value>
</Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding LoadStatus}" Value="{x:Static es:LoadStatus.Loading}">
<Setter Property="Text" Value="&#xE72C;"/>
<Setter Property="ToolTip" Value="Downloading"/>
<DataTrigger.EnterActions>
<BeginStoryboard Name="SpinnerStoryboard">
<Storyboard RepeatBehavior="Forever" >
<DoubleAnimation
Storyboard.TargetProperty="RenderTransform.Angle"
Duration="0:0:1" From="0" To="360" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<StopStoryboard BeginStoryboardName="SpinnerStoryboard" />
</DataTrigger.ExitActions>
</DataTrigger>
<DataTrigger Binding="{Binding LoadStatus}" Value="{x:Static es:LoadStatus.NotLoaded}">
<Setter Property="Text" Value="&#xE896;"/>
</DataTrigger>
<DataTrigger Binding="{Binding LoadStatus}" Value="{x:Static es:LoadStatus.FailedToLoad}">
<Setter Property="Text" Value="&#xEA6A;"/>
</DataTrigger>
<DataTrigger Binding="{Binding IsLocal}" Value="true">
<Setter Property="Text" Value="&#xF13E;"/>
</DataTrigger>
</Style.Triggers>
</Style>
</StackPanel.Resources>
<TextBlock Text="{Binding Title, Mode=OneWay}" Style="{StaticResource PopupViewerTitleStyle}" Visibility="{Binding Title, Converter={StaticResource PopupViewerVisibilityConverter}}" />
<TextBlock Text="{Binding Description, Mode=OneWay}" Style="{StaticResource PopupViewerCaptionStyle}" Visibility="{Binding Description, Converter={StaticResource PopupViewerVisibilityConverter}}" />
<ListView x:Name="AttachmentList" BorderThickness="0" SelectionMode="Single">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource DownloadIcon}"/>
<TextBlock Text="{Binding Name}" Margin="5" Cursor="Hand"/>
</StackPanel>
<primitives:AttachmentThumbnailImage Attachment="{Binding}" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

<ItemGroup>
<PackageReference Include="Esri.ArcGISRuntime.WinUI" Version="$(ArcGISRuntimePackageVersion)" Condition="Exists('$(SolutionDir)toolkit.props')!='true'"/>
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.0.0" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.4.230822000" />
</ItemGroup>

<Import Project="..\Toolkit\Esri.ArcGISRuntime.Toolkit.Shared.projitems" Label="Shared" />
Expand Down
Loading
Loading