forked from the49ltd/The49.Maui.BottomSheet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove generator (temporarily), as Rider does not like it.
- Loading branch information
Showing
10 changed files
with
82 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,43 @@ | ||
using Maui.BindableProperty.Generator.Core; | ||
namespace The49.Maui.BottomSheet; | ||
|
||
namespace The49.Maui.BottomSheet; | ||
#if ANDROID | ||
using AView = Android.Views.View; | ||
#elif IOS | ||
using UIKit; | ||
#endif | ||
|
||
public partial class AnchorDetent: Detent | ||
public class AnchorDetent: Detent | ||
{ | ||
double _height = 0; | ||
#pragma warning disable CS0169 | ||
[AutoBindable] | ||
readonly VisualElement anchor; | ||
#pragma warning restore CS0169 | ||
public static readonly BindableProperty AnchorProperty = BindableProperty.Create(nameof(Anchor), typeof(VisualElement), typeof(AnchorDetent)); | ||
|
||
public VisualElement Anchor | ||
{ | ||
get => (VisualElement)GetValue(AnchorProperty); | ||
set => SetValue(AnchorProperty, value); | ||
} | ||
|
||
double _height; | ||
|
||
public override double GetHeight(BottomSheet page, double maxSheetHeight) | ||
{ | ||
UpdateHeight(page, maxSheetHeight); | ||
if (Anchor == null) | ||
throw new Exception("Could not update Detent height: Anchor is not set"); | ||
|
||
#if ANDROID | ||
var p = ((AView)Anchor.Handler.PlatformView).GetLocationOnScreen(); | ||
var r = ((AView)page.Handler.PlatformView).GetLocationOnScreen(); | ||
|
||
var offset = p - r; | ||
_height = offset.Height / DeviceDisplay.MainDisplayInfo.Density; | ||
|
||
#elif IOS | ||
var pageView = (UIView)page.Handler.PlatformView; | ||
var targetView = (UIView)Anchor.Handler.PlatformView; | ||
var targetOrigin = targetView.Superview.ConvertPointToView(targetView.Frame.Location, pageView); | ||
|
||
_height = targetOrigin.Y; | ||
#endif | ||
|
||
return _height; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.