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

Merge main into net8.0 #17419

Merged
merged 17 commits into from
Sep 17, 2023
Merged
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
fa4dafc
Removed references to GraphicsTester.Skia.Tizen from Maui-dev and Mau…
dustin-wojciechowski Sep 13, 2023
96073eb
Enable requesting the full preview size on iOS drag shadow & iOS and …
tj-devel709 Sep 13, 2023
64d964a
Wait for parent to get set before realizing titleview (#17360)
PureWeen Sep 14, 2023
e348ed4
[create-pull-request] automated change (#17362)
github-actions[bot] Sep 14, 2023
b26f515
Make the taps work on all platforms (#17325)
hartez Sep 14, 2023
fb88a50
Added integration test for maui blazor maccatalyst codesign verificat…
dustin-wojciechowski Sep 14, 2023
76d80c8
[C] Replace value with same specificity (#17365)
StephaneDelcroix Sep 14, 2023
8ab6da9
Enable Mac Catalyst Controls Device Tests in CI (#17229)
jfversluis Sep 14, 2023
aad88d6
[C] Port the specificity concept to Bindings (#17215)
StephaneDelcroix Sep 14, 2023
1825d26
Revert changes to setting context and add tests (#17348)
PureWeen Sep 14, 2023
bf9c127
Remove macOS as that is not installed by default (#17379)
mattleibow Sep 14, 2023
db17cb8
Increase timeouts to 4 hours (#17386)
mattleibow Sep 15, 2023
42a9d5f
Bump the aspnetcore group with 7 updates (#17345)
dependabot[bot] Sep 15, 2023
ff140e5
[create-pull-request] automated change (#17388)
github-actions[bot] Sep 15, 2023
671bf15
[X] fix CollectionItems enumeration (#17364)
StephaneDelcroix Sep 15, 2023
8144b8b
passing test for #16960 (#17397)
StephaneDelcroix Sep 15, 2023
2fa8665
Merge branch 'main' into dev/main-into-net8.0
mattleibow Sep 15, 2023
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
Prev Previous commit
Next Next commit
Enable requesting the full preview size on iOS drag shadow & iOS and …
…Windows Samples (#17282)

* Enable requesting the full preview size on iOS drag shadow

* Add in windows drag and drop sample

* Move itemssource class into main class

---------

Co-authored-by: TJ Lambert (HE/HIM/HIS) <[email protected]>
  • Loading branch information
tj-devel709 and TJ Lambert (HE/HIM/HIS) authored Sep 13, 2023
commit 96073eb5761b654fb87a9965c5196a41dcd50858
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Pages.WindowsDragAndDropCustomization"
Title="Drag and Drop Windows Platform-Specific">
<Grid Margin="20" RowDefinitions="290,*">

<Border Margin="15" Grid.Row="0">
<StackLayout>
<Label Text="Drag and Drop the items below" FontSize="Large" FontAttributes="Bold"/>
<CollectionView x:Name="CollectionView1">
<CollectionView.ItemTemplate>
<DataTemplate>
<Label Text="{Binding Name}" Background="LightGray" HeightRequest="30" HorizontalOptions="Fill" Margin="3">
<Label.GestureRecognizers>
<DragGestureRecognizer />
</Label.GestureRecognizers>
</Label>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</StackLayout>
</Border>

<TableView Intent="Settings" Grid.Row="1" >
<TableRoot>
<TableSection Title="Drag Customization">

<ViewCell>
<Grid ColumnDefinitions="3*,*" VerticalOptions="Center" Margin="10,0,5,0">
<Label Text="Show Glyph" VerticalTextAlignment="Center" Grid.Column="0"/>
<Switch HorizontalOptions="End" x:Name="ShowGlyphSwitch" IsToggled="True" Grid.Column="1"/>
</Grid>
</ViewCell>

<ViewCell>
<Grid ColumnDefinitions="3*,*" VerticalOptions="Center" Margin="10,0,5,0">
<Label Text="Custom Caption" VerticalTextAlignment="Center" Grid.Column="0"/>
<Entry HorizontalOptions="End" WidthRequest="300" Placeholder="Copy" x:Name="CustomCaptionEntry" Grid.Column="1"/>
</Grid>
</ViewCell>

<ViewCell>
<Grid ColumnDefinitions="3*,*" VerticalOptions="Center" Margin="10,0,5,0">
<Label Text="Show Caption" VerticalTextAlignment="Center" Grid.Column="0"/>
<Switch HorizontalOptions="End" x:Name="ShowCaptionSwitch" IsToggled="True" Grid.Column="1"/>
</Grid>
</ViewCell>

<ViewCell>
<Grid ColumnDefinitions="3*,*" VerticalOptions="Center" Margin="10,0,5,0">
<Label Text="Show Content" VerticalTextAlignment="Center" Grid.Column="0"/>
<Switch HorizontalOptions="End" x:Name="ShowContentSwitch" Grid.Column="1" IsToggled="True"/>
</Grid>
</ViewCell>
</TableSection>

</TableRoot>
</TableView>
<Grid.GestureRecognizers>
<DropGestureRecognizer DragOver="DropGestureRecognizer_DragOver" />
</Grid.GestureRecognizers>
</Grid>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System;
using Maui.Controls.Sample.ViewModels;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.PlatformConfiguration;
using Microsoft.Maui.Controls.PlatformConfiguration.WindowsSpecific;

namespace Maui.Controls.Sample.Pages
{
public partial class WindowsDragAndDropCustomization : ContentPage
{
public WindowsDragAndDropCustomization()
{
InitializeComponent();

CollectionView1.ItemsSource = new NameObject[]
{
new NameObject ("First Item"),
new NameObject ("Second Item"),
new NameObject ("Third Item"),
new NameObject ("Fourth Item"),
new NameObject ("Fifth Item"),
new NameObject ("Sixth Item"),
};
}

void DropGestureRecognizer_DragOver(System.Object sender, Microsoft.Maui.Controls.DragEventArgs e)
{
#if WINDOWS
var dragUI = e.PlatformArgs.DragEventArgs.DragUIOverride;
dragUI.IsCaptionVisible = ShowCaptionSwitch.IsToggled;
dragUI.IsGlyphVisible = ShowGlyphSwitch.IsToggled;
dragUI.IsContentVisible = ShowContentSwitch.IsToggled;

dragUI.Caption = string.IsNullOrEmpty (CustomCaptionEntry.Text) ? "Copy" : CustomCaptionEntry.Text;
#endif
}

public class NameObject
{
public NameObject(string name)
{
Name = name;
}

public string Name { get; set; }
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Pages.iOSDragAndDropRequestFullSize"
Title="Drag and Drop iOS Platform-Specific">
<Grid Margin="20" RowDefinitions="300,*">

<Border Margin="15" Grid.Row="0">
<StackLayout>
<Label Text="Drag and Drop the items below" FontSize="Large" FontAttributes="Bold"/>
<CollectionView x:Name="CollectionView1">
<CollectionView.ItemTemplate>
<DataTemplate>
<Entry Text="{Binding Name}">
<Entry.GestureRecognizers>
<DragGestureRecognizer DragStarting="DragGestureRecognizer_DragStarting" />
<DropGestureRecognizer DragOver="DropGestureRecognizer_DragOver" />
</Entry.GestureRecognizers>
</Entry>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</StackLayout>
</Border>

<TableView Intent="Settings" Grid.Row="1" >
<TableRoot>
<TableSection Title="Drag size option">
<ViewCell>
<Grid ColumnDefinitions="3*,*" VerticalOptions="Center" Margin="10,0,5,0">
<Label Text="Request Full-Sized Drag Previews" VerticalTextAlignment="Center" Grid.Column="0"/>
<Switch HorizontalOptions="End" x:Name="fullSizedSwitch" Toggled="FullSized_Switch_Toggled" Grid.Column="1"/>
</Grid>
</ViewCell>
</TableSection>

<TableSection Title="Content Options">
<ViewCell>
<Grid ColumnDefinitions="3*,*" VerticalOptions="Center" Margin="10,0,5,0">
<Label Text="Use drawn image" VerticalTextAlignment="Center" Grid.Column="0"/>
<Switch HorizontalOptions="End" x:Name="drawnImageSwitch" Toggled="Drawn_Switch_Toggled" Grid.Column="1"/>
</Grid>
</ViewCell>

<ViewCell>
<Grid ColumnDefinitions="3*,*" VerticalOptions="Center" Margin="10,0,5,0">
<Label Text="Use dotnet bot image" VerticalTextAlignment="Center" Grid.Column="0"/>
<Switch HorizontalOptions="End" x:Name="dotnetBotImageSwitch" Toggled="DotnetBot_Switch_Toggled" Grid.Column="1"/>
</Grid>
</ViewCell>
</TableSection>
<TableSection Title="Drop Types">
<ViewCell>
<Grid ColumnDefinitions="3*,*" VerticalOptions="Center" Margin="10,0,5,0">
<Label Text="UIDropProposal - Copy" VerticalTextAlignment="Center" Grid.Column="0"/>
<Switch HorizontalOptions="End" x:Name="copySwitch" IsToggled="True" Toggled="Copy_Switch_Toggled" Grid.Column="1"/>
</Grid>
</ViewCell>

<ViewCell>
<Grid ColumnDefinitions="3*,*" VerticalOptions="Center" Margin="10,0,5,0">
<Label Text="UIDropProposal - Move" VerticalTextAlignment="Center" Grid.Column="0"/>
<Switch HorizontalOptions="End" x:Name="moveSwitch" Toggled="Move_Switch_Toggled" Grid.Column="1"/>
</Grid>
</ViewCell>

<ViewCell>
<Grid ColumnDefinitions="3*,*" VerticalOptions="Center" Margin="10,0,5,0">
<Label Text="UIDropProposal - Forbidden" VerticalTextAlignment="Center" Grid.Column="0"/>
<Switch HorizontalOptions="End" x:Name="forbiddenSwitch" Toggled="Forbidden_Switch_Toggled" Grid.Column="1"/>
</Grid>
</ViewCell>

</TableSection>
</TableRoot>
</TableView>
</Grid>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
using System;
using Maui.Controls.Sample.ViewModels;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.PlatformConfiguration;
using Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;

namespace Maui.Controls.Sample.Pages
{
public partial class iOSDragAndDropRequestFullSize : ContentPage
{
public iOSDragAndDropRequestFullSize()
{
InitializeComponent();

CollectionView1.ItemsSource = new NameObject[]
{
new NameObject ("First Item"),
new NameObject ("Second Item"),
new NameObject ("Third Item"),
new NameObject ("Fourth Item"),
new NameObject ("Fifth Item"),
new NameObject ("Sixth Item"),
};

// Changing the drag preview is not observed working the same as in iOS
#if MACCATALYST
fullSizedSwitch.IsEnabled = false;
drawnImageSwitch.IsEnabled = false;
dotnetBotImageSwitch.IsEnabled = false;
#endif
}

void DragGestureRecognizer_DragStarting(System.Object sender, Microsoft.Maui.Controls.DragStartingEventArgs e)
{
#if IOS || MACCATALYST
if (drawnImageSwitch.IsToggled)
{
Func<UIKit.UIDragPreview> action = () =>
{
var previewParameters = new UIKit.UIDragPreviewParameters();
var funkyPath = new UIKit.UIBezierPath();
funkyPath.MoveTo(new CoreGraphics.CGPoint(0, 0));
funkyPath.AddLineTo(new CoreGraphics.CGPoint(300, 0));
funkyPath.AddLineTo(new CoreGraphics.CGPoint(225, 150));
funkyPath.AddLineTo(new CoreGraphics.CGPoint(300, 300));
funkyPath.AddLineTo(new CoreGraphics.CGPoint(0, 300));
funkyPath.ClosePath();
previewParameters.VisiblePath = funkyPath;

return new UIKit.UIDragPreview(e.PlatformArgs.Sender, previewParameters);
};

e.PlatformArgs.SetPreviewProvider(action);
}

else if (dotnetBotImageSwitch.IsToggled)
{
Func<UIKit.UIDragPreview> action = () =>
{
var image = UIKit.UIImage.FromFile("dotnet_bot.png");

UIKit.UIImageView imageView = new UIKit.UIImageView(image);
imageView.ContentMode = UIKit.UIViewContentMode.Center;
imageView.Frame = new CoreGraphics.CGRect(0, 0, 250, 250);

return new UIKit.UIDragPreview(imageView);
};

e.PlatformArgs.SetPreviewProvider(action);
}


e.PlatformArgs.SetPrefersFullSizePreviews((interaction, session) => { return fullSizedSwitch.IsToggled; });
#endif
}

void Drawn_Switch_Toggled(object sender, ToggledEventArgs e)
{
if (e.Value)
dotnetBotImageSwitch.IsToggled = false;
}

void DotnetBot_Switch_Toggled(object sender, ToggledEventArgs e)
{
if (e.Value)
drawnImageSwitch.IsToggled = false;
}

void DropGestureRecognizer_DragOver(System.Object sender, Microsoft.Maui.Controls.DragEventArgs e)
{
#if IOS || MACCATALYST
if (copySwitch.IsToggled)
e.PlatformArgs.SetDropProposal(new UIKit.UIDropProposal(UIKit.UIDropOperation.Copy));
else if (moveSwitch.IsToggled)
e.PlatformArgs.SetDropProposal(new UIKit.UIDropProposal(UIKit.UIDropOperation.Move));
else if (forbiddenSwitch.IsToggled)
e.PlatformArgs.SetDropProposal(new UIKit.UIDropProposal(UIKit.UIDropOperation.Forbidden));
#endif
}

void FullSized_Switch_Toggled(object sender, ToggledEventArgs e)
{
}

void Copy_Switch_Toggled(object sender, ToggledEventArgs e)
{
if (e.Value)
{
moveSwitch.IsToggled = false;
forbiddenSwitch.IsToggled = false;
}
}

void Move_Switch_Toggled(object sender, ToggledEventArgs e)
{
if (e.Value)
{
copySwitch.IsToggled = false;
forbiddenSwitch.IsToggled = false;
}
}

void Forbidden_Switch_Toggled(object sender, ToggledEventArgs e)
{
if (e.Value)
{
moveSwitch.IsToggled = false;
copySwitch.IsToggled = false;
}
}

public class NameObject
{
public NameObject(string name)
{
Name = name;
}

public string Name { get; set; }
}
}



}
Original file line number Diff line number Diff line change
@@ -60,6 +60,9 @@ protected override IEnumerable<SectionModel> CreateItems()
new SectionModel(typeof(iOSFlyoutPage), "FlyoutPage Shadow",
"This platform-specific controls whether the detail page of a FlyoutPage has shadow applied to it, when revealing the flyout page."),

new SectionModel(typeof(iOSDragAndDropRequestFullSize), "Drag and Drop Gesture Recognizer Platform-Specific",
"This iOS platform-specific controls whether to request full-sized drag shadows and the UIDropProposal types."),

new SectionModel(typeof(iOSHideHomeIndicatorPage), "Hide Home Indicator",
"This iOS platform-specific sets the visibility of the home indicator on a Page."),

@@ -123,6 +126,9 @@ protected override IEnumerable<SectionModel> CreateItems()
new SectionModel(typeof(WindowsCollapseWidthAdjusterPage), "FlyoutPage Navigation Bar",
"This WinUI platform-specific is used to collapse the navigation bar on a FlyoutPage."),

new SectionModel(typeof(WindowsDragAndDropCustomization), "Drag and Drop Gesture Recognizer Platform-Specific",
"This WinUI platform-specific displays drag and drop customization such as custom drag gylph and text."),

new SectionModel(typeof(WindowsListViewPage), "ListView Selection Mode",
"This WinUI platform-specific controls whether items in a ListView can respond to tap gestures, and hence whether the native ListView fires the ItemClick or Tapped event."),

Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@ public class PlatformDragStartingEventArgs
internal Foundation.NSItemProvider? ItemProvider { get; private set; }
internal Func<UIKit.UIDragPreview?>? PreviewProvider { get; private set; }
internal UIKit.UIDragItem[]? DragItems { get; private set; }
internal Func<UIKit.UIDragInteraction, UIKit.IUIDragSession, bool>? PrefersFullSizePreviews { get; private set; }

internal PlatformDragStartingEventArgs(UIKit.UIView? sender, UIKit.UIDragInteraction dragInteraction,
UIKit.IUIDragSession dragSession)
@@ -71,6 +72,21 @@ public void SetDragItems(UIKit.UIDragItem[] dragItems)
DragItems = dragItems;
}

/// <summary>
/// Sets the func that requests to keep drag previews full-sized when dragging begins.
/// </summary>
/// <param name="prefersFullSizePreviews">Func that returns whether to request full size previews.</param>
/// <remarks>
/// The default behavior on iOS is to reduce the size of the drag shadow if not requested here.
/// Even if requested, it is up to the system whether or not to fulfill the request.
/// This method exists inside <see cref="PlatformDragStartingEventArgs"/> since the preview must
/// have this value set when dragging begins.
/// </remarks>
public void SetPrefersFullSizePreviews(Func<UIKit.UIDragInteraction, UIKit.IUIDragSession, bool>? prefersFullSizePreviews)
{
PrefersFullSizePreviews = prefersFullSizePreviews;
}

#elif ANDROID
/// <summary>
/// Gets the native view attached to the event.
Loading