Skip to content

Commit

Permalink
Bringing touch-effect up to date with main (CommunityToolkit#1383)
Browse files Browse the repository at this point in the history
* Popup v6 windows (CommunityToolkit#1086)

Co-authored-by: Brandon Minnick <13558917+brminnick@users.noreply.github.com>
Co-authored-by: Pedro Jesus <pedrojesus.cefet@gmail.com>
Co-authored-by: Shaun Lawrence <shaunrlawrence@gmail.com>

* ♻️ [Housekeeping] Fixed  GravatarImageSourceTests.TestDefaultStream (CommunityToolkit#1335)

* [housekeeping] Automated PR to fix formatting errors (CommunityToolkit#1327)

* Fix popup margin on iOS (CommunityToolkit#1329)

* Bump NuGet.Protocol from 6.6.1 to 6.7.0 in /samples (CommunityToolkit#1330)

* Use fully qualified namespace for Color reference in TextToColorGenerator (CommunityToolkit#1332)

* Use fully qualified namespace for Color reference in TextToColorGenerator to prevent collisions

This change should prevent "ambiguous reference" error to occur when other packages are included in a MAUI project that provide their own Color objects

* added global prefix to be safer

---------

Co-authored-by: Pedro Jesus <pedrojesus.cefet@gmail.com>
Co-authored-by: Brandon Minnick <13558917+brminnick@users.noreply.github.com>

* Code cleanup and preparation for the next release (breaking changes) (CommunityToolkit#1324)

* Code cleanup and preparation for .net 8

* Update CompareConverter.shared.cs

* Revert global.json

* More CleanUps

* Remove redundant TrySetCanceled and rely on speech recognition result

* Update Formatting

---------

Co-authored-by: Brandon Minnick <13558917+brminnick@users.noreply.github.com>

* Fix Gestures on Popup on ios (CommunityToolkit#1342)

* Fix Gestures on Popup on ios

* don't query type cast directly

* Code for AddLogicalChild (.NET 8)

* reduce changes

* setting the parent fixes the BindingContext of the view

* Revert "setting the parent fixes the BindingContext of the view"

This reverts commit 0a64b56.

* reduce changes

* simplify code

* fixing build

* assigned Element to contentPage.Parent

---------

Co-authored-by: pedrojesus <pedrojesus.cefet@gmail.com>

* `global.json`: Change `"rollForward": "latestMajor",` -> `"rollForward": "latestFeature"`. (CommunityToolkit#1338)

Update global.json

* Bump Microsoft.NET.Test.Sdk from 17.7.0 to 17.7.1 in /samples (CommunityToolkit#1348)

Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.7.0 to 17.7.1.
- [Release notes](https://github.com/microsoft/vstest/releases)
- [Changelog](https://github.com/microsoft/vstest/blob/main/docs/releases.md)
- [Commits](microsoft/vstest@v17.7.0...v17.7.1)

---
updated-dependencies:
- dependency-name: Microsoft.NET.Test.Sdk
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* 632 bug avatar view clipping on windows (CommunityToolkit#1344)

* Resolves issue on Windows where the splash screen icon is not found.

* Resolves an issue with the 'Ratings' sample for AvatarView.

* Spaces and not tabs

* Spaces and not tabs

* Changed MauiImage to point to Images folder.

* Changed splash for Windows to be Resize=False

* Typo in name of MauiImage

* Try to prevent locking.

* Bump Microsoft.CodeAnalysis from 4.6.0 to 4.7.0 in /samples (CommunityToolkit#1355)

* Bump Microsoft.CodeAnalysis.CSharp.Workspaces from 4.6.0 to 4.7.0 in /samples (CommunityToolkit#1357)

* Bump FluentAssertions from 6.11.0 to 6.12.0 in /samples (CommunityToolkit#1365)

* fix  IconTintColorBehavior  for Windows (CommunityToolkit#1370)

fix  IconTintColorBehavior  for windows

Co-authored-by: Oleksii <sokol@managed-code.com>

* Add `MemoryAnalyzer` roslyn analyzer (CommunityToolkit#1371)

* Add NuGet Package + Update `WarningsAsErrors`

* Fix MA0002

* Fix `MauiDrawingView`

* Fix `MauiPopup`

* Fix Naming

* return `null` for nullable references

* Use Ternary Operator

* `dotnet format`

* iOS popup fix with Shell or TabbedPage (CommunityToolkit#1343)

* Fix Issue CommunityToolkit#1256


Better fix

* Fixed Popup on Multiple Level Pages (CommunityToolkit#822)

---------

Co-authored-by: Vladislav Antonyuk <33021114+VladislavAntonyuk@users.noreply.github.com>
Co-authored-by: Brandon Minnick <13558917+brminnick@users.noreply.github.com>

* [housekeeping] Automated PR to fix formatting errors (CommunityToolkit#1373)

* Bump Microsoft.NET.Test.Sdk from 17.7.1 to 17.7.2 in /samples (CommunityToolkit#1378)

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Vladislav Antonyuk <33021114+VladislavAntonyuk@users.noreply.github.com>
Co-authored-by: Brandon Minnick <13558917+brminnick@users.noreply.github.com>
Co-authored-by: Pedro Jesus <pedrojesus.cefet@gmail.com>
Co-authored-by: Shaun Lawrence <shaunrlawrence@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: cat0363 <125236133+cat0363@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Wolf <132034537+wolfgang-ironsoftware@users.noreply.github.com>
Co-authored-by: Thomas Stocker <thomas.stocker@gmail.com>
Co-authored-by: George Leithead <github@internetwideworld.com>
Co-authored-by: Sokol2001 <53799292+Sokol2001@users.noreply.github.com>
Co-authored-by: Oleksii <sokol@managed-code.com>
Co-authored-by: Andrey Onishchenko <100789522+cucumber-sp@users.noreply.github.com>
  • Loading branch information
14 people authored and Axemasta committed Mar 14, 2024
1 parent 194a039 commit c9efb8b
Show file tree
Hide file tree
Showing 22 changed files with 78 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8" ?>
<pages:BasePage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:pages="clr-namespace:CommunityToolkit.Maui.Sample.Pages"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8" ?>
<pages:BasePage x:Class="CommunityToolkit.Maui.Sample.Pages.Views.PopupPositionPage"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using CommunityToolkit.Maui.Sample.Models;
using CommunityToolkit.Maui.Sample.Models;
using CommunityToolkit.Maui.Sample.ViewModels.Views;
using CommunityToolkit.Maui.Sample.Views.Popups;
using CommunityToolkit.Maui.Views;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8" ?>
<mct:Popup xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CommunityToolkit.Maui.Sample.Views.Popups.XamlBindingPopup"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using CommunityToolkit.Maui.Core.Extensions;
using CommunityToolkit.Maui.Core.Extensions;
using CommunityToolkit.Maui.Core.Views;
using Microsoft.Maui.Handlers;
using Microsoft.Maui.Platform;
Expand Down
20 changes: 15 additions & 5 deletions src/CommunityToolkit.Maui.Core/Views/Alert/AlertView.macios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ namespace CommunityToolkit.Maui.Core.Views;
public class AlertView : UIView
{
readonly List<UIView> children = Enumerable.Empty<UIView>().ToList();
readonly WeakReference<UIView?> anchorViewReference = new(null);
readonly WeakReference<UIStackView?> containerReference = new(null);

/// <summary>
/// Parent UIView
Expand All @@ -22,19 +24,27 @@ public class AlertView : UIView
public FrozenSet<UIView> Children => children.ToFrozenSet();

/// <summary>
/// <see cref="UIView"/> on which Alert will appear. When null, <see cref="AlertView"/> will appear at bottom of screen.
/// <see cref="AlertViewVisualOptions"/>
/// </summary>
public UIView? AnchorView { get; set; }
public AlertViewVisualOptions VisualOptions { get; } = new();

/// <summary>
/// <see cref="AlertViewVisualOptions"/>
/// <see cref="UIView"/> on which Alert will appear. When null, <see cref="AlertView"/> will appear at bottom of screen.
/// </summary>
public AlertViewVisualOptions VisualOptions { get; } = new();
public UIView? AnchorView
{
get => anchorViewReference.TryGetTarget(out var anchorView) ? anchorView : null;
set => anchorViewReference.SetTarget(value);
}

/// <summary>
/// Container of <see cref="AlertView"/>
/// </summary>
protected UIStackView? Container { get; set; }
protected UIStackView? Container
{
get => containerReference.TryGetTarget(out var container) ? container : null;
set => containerReference.SetTarget(value);
}

/// <summary>
/// Dismisses the Popup from the screen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
using Android.Views;
using CommunityToolkit.Maui.Core.Extensions;
using Microsoft.Maui.Platform;
using AColor = Android.Graphics.Color;
using APaint = Android.Graphics.Paint;
using APath = Android.Graphics.Path;
using AView = Android.Views.View;

namespace CommunityToolkit.Maui.Core.Views;

Expand All @@ -26,6 +22,7 @@ protected override void Dispose(bool disposing)
if (disposing)
{
currentPath.Dispose();
proxy?.Dispose();
}

base.Dispose(disposing);
Expand Down Expand Up @@ -80,7 +77,7 @@ public override bool OnTouchEvent(MotionEvent? e)
public void Initialize()
{
Drawable = new DrawingViewDrawable(this);
Lines.CollectionChanged += OnLinesCollectionChanged;
proxy = new(this);
}

void Redraw()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public override void TouchesCancelled(NSSet touches, UIEvent? evt)
public void Initialize()
{
Drawable = new DrawingViewDrawable(this);
Lines.CollectionChanged += OnLinesCollectionChanged;
proxy = new(this);
}

/// <inheritdoc/>
Expand All @@ -58,6 +58,7 @@ protected override void Dispose(bool disposing)
if (disposing)
{
currentPath.Dispose();
proxy?.Dispose();
}

base.Dispose(disposing);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.ObjectModel;
using System.Collections.ObjectModel;
using CommunityToolkit.Maui.Core.Extensions;

namespace CommunityToolkit.Maui.Core.Views;
Expand All @@ -9,11 +9,13 @@ namespace CommunityToolkit.Maui.Core.Views;
public partial class MauiDrawingView
{
readonly WeakEventManager weakEventManager = new();
readonly WeakReference<Action<ICanvas, RectF>?> drawActionReference = new(null);

bool isDrawing;
PointF previousPoint;
PathF currentPath = new();
MauiDrawingLine? currentLine;
MauiDrawingViewProxy? proxy;
Paint paint = new SolidPaint(DrawingViewDefaults.BackgroundColor);

/// <summary>
Expand Down Expand Up @@ -80,7 +82,11 @@ public event EventHandler<MauiOnDrawingEventArgs> Drawing
/// <summary>
/// Used to draw any shape on the canvas
/// </summary>
public Action<ICanvas, RectF>? DrawAction { get; set; }
public Action<ICanvas, RectF>? DrawAction
{
get => drawActionReference.TryGetTarget(out var drawAction) ? drawAction : null;
set => drawActionReference.SetTarget(value);
}

/// <summary>
/// Drawable background
Expand Down Expand Up @@ -204,7 +210,7 @@ void ClearPath()
currentPath = new PathF();
}

class DrawingViewDrawable : IDrawable
sealed class DrawingViewDrawable : IDrawable
{
readonly MauiDrawingView drawingView;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public MauiDrawingView() : base(null)
public void Initialize()
{
Drawable = new DrawingViewDrawable(this);
Lines.CollectionChanged += OnLinesCollectionChanged;
proxy = new(this);
}

/// <inheritdoc />
Expand All @@ -29,6 +29,7 @@ protected override void Dispose(bool disposing)
if (disposing)
{
currentPath.Dispose();
proxy?.Dispose();
TouchEvent -= OnTouch;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void Initialize()
System.Diagnostics.Trace.WriteLine("DrawingView requires Windows 10.0.18362 or higher.");
}

Lines.CollectionChanged += OnLinesCollectionChanged;
proxy = new(this);
}

/// <inheritdoc />
Expand All @@ -49,6 +49,7 @@ protected virtual void Dispose(bool disposing)
if (disposing)
{
currentPath.Dispose();
proxy?.Dispose();
}

isDisposed = true;
Expand Down
29 changes: 18 additions & 11 deletions src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.macios.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Maui.ApplicationModel;
using Microsoft.Maui.Handlers;

Expand All @@ -10,6 +10,7 @@ namespace CommunityToolkit.Maui.Core.Views;
public class MauiPopup : UIViewController
{
readonly IMauiContext mauiContext;
readonly WeakReference<UIViewController?> viewControllerReference = new(null);

/// <summary>
/// Constructor of <see cref="MauiPopup"/>.
Expand All @@ -31,7 +32,11 @@ public MauiPopup(IMauiContext mauiContext)
/// </summary>
public IPopup? VirtualView { get; private set; }

internal UIViewController? ViewController { get; private set; }
internal UIViewController? ViewController
{
get => viewControllerReference.TryGetTarget(out var viewController) ? viewController : null;
set => viewControllerReference.SetTarget(value);
}

/// <summary>
/// Method to update the Popup's size.
Expand Down Expand Up @@ -207,22 +212,14 @@ void SetView(UIView view, PageHandler control)

void SetPresentationController()
{
var popOverDelegate = new PopoverDelegate();
popOverDelegate.PopoverDismissedEvent += HandlePopoverDelegateDismissed;
var popOverDelegate = new PopoverDelegate(this);

UIPopoverPresentationController presentationController = (UIPopoverPresentationController)(PresentationController ?? throw new InvalidOperationException($"{nameof(PresentationController)} cannot be null."));
presentationController.SourceView = ViewController?.View ?? throw new InvalidOperationException($"{nameof(ViewController.View)} cannot be null.");

presentationController.Delegate = popOverDelegate;
}

[MemberNotNull(nameof(VirtualView))]
void HandlePopoverDelegateDismissed(object? sender, UIPresentationController e)
{
_ = VirtualView ?? throw new InvalidOperationException($"{nameof(VirtualView)} cannot be null.");
VirtualView.Handler?.Invoke(nameof(IPopup.OnDismissedByTappingOutsideOfPopup));
}

void AddToCurrentPageViewController(UIViewController viewController)
{
viewController.PresentViewController(this, true, null);
Expand All @@ -232,12 +229,22 @@ sealed class PopoverDelegate : UIPopoverPresentationControllerDelegate
{
readonly WeakEventManager popoverDismissedEventManager = new();

public PopoverDelegate(MauiPopup mauiPopup)
{
this.mauiPopup = new(mauiPopup);
PopoverDismissedEvent += HandlePopoverDelegateDismissed;
}

public event EventHandler<UIPresentationController> PopoverDismissedEvent
{
add => popoverDismissedEventManager.AddEventHandler(value);
remove => popoverDismissedEventManager.RemoveEventHandler(value);
}

MauiPopup MauiPopup => mauiPopup.TryGetTarget(out var virtualView)
? virtualView
: throw new ObjectDisposedException(nameof(MauiPopup));

public override UIModalPresentationStyle GetAdaptivePresentationStyle(UIPresentationController forPresentationController) =>
UIModalPresentationStyle.None;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using CommunityToolkit.Maui.Core.Handlers;
using CommunityToolkit.Maui.Core.Handlers;
using Microsoft.Maui.Platform;
using Microsoft.Maui.Primitives;
using Microsoft.UI.Xaml;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@
<None Include="..\CommunityToolkit.Maui.MediaElement.Analyzers.CodeFixes\bin\$(Configuration)\netstandard2.0\CommunityToolkit.Maui.MediaElement.Analyzers.CodeFixes.dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false"/>
</ItemGroup>

<ItemGroup>
<PackageReference Include="MemoryAnalyzers" Version="0.1.0-beta.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup Condition="$(TargetFramework.Contains('-android'))">
<PackageReference Include="Xam.Plugins.Android.ExoPlayer" Version="[2.19.1,)"/>
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.Transformer" Version="[2.19.1,)"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using CommunityToolkit.Maui.Extensions;
using CommunityToolkit.Maui.Extensions;
using CommunityToolkit.Maui.Views;
using Microsoft.UI;
using Microsoft.UI.Windowing;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Text;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using CommunityToolkit.Maui.ImageSources;
using CommunityToolkit.Maui.ImageSources;
using FluentAssertions;
using Xunit;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Diagnostics;
using System.Diagnostics;
using ObjCRuntime;
using UIKit;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.ComponentModel;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;

Expand Down
2 changes: 1 addition & 1 deletion src/CommunityToolkit.Maui/Views/Popup/Popup.shared.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using CommunityToolkit.Maui.Core;
using CommunityToolkit.Maui.Core;
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Controls.StyleSheets;
using LayoutAlignment = Microsoft.Maui.Primitives.LayoutAlignment;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Runtime.CompilerServices;
using System.Runtime.CompilerServices;
using CommunityToolkit.Maui.Core;
using Microsoft.Maui.Controls.Platform;
using Microsoft.Maui.Platform;
Expand Down

0 comments on commit c9efb8b

Please sign in to comment.