diff --git a/UniSky/Controls/Compose/ComposeSheet.xaml.cs b/UniSky/Controls/Compose/ComposeSheet.xaml.cs index 411e6f3..0937783 100644 --- a/UniSky/Controls/Compose/ComposeSheet.xaml.cs +++ b/UniSky/Controls/Compose/ComposeSheet.xaml.cs @@ -51,10 +51,6 @@ public bool Not(bool b, bool a) private void OnShowing(IOverlayControl sender, OverlayShowingEventArgs e) { - var inputPane = InputPane.GetForCurrentView(); - inputPane.Showing += OnInputPaneShowing; - inputPane.Hiding += OnInputPaneHiding; - if (Window.Current.Content is FrameworkElement element) { element.AllowDrop = true; @@ -76,10 +72,6 @@ private void OnShowing(IOverlayControl sender, OverlayShowingEventArgs e) private void OnHidden(IOverlayControl sender, RoutedEventArgs args) { - var inputPane = InputPane.GetForCurrentView(); - inputPane.Showing -= OnInputPaneShowing; - inputPane.Hiding -= OnInputPaneHiding; - if (Window.Current.Content is FrameworkElement element) { element.AllowDrop = false; @@ -119,22 +111,6 @@ private async void OnHiding(IOverlayControl sender, OverlayHidingEventArgs e) } } - private void OnInputPaneShowing(InputPane sender, InputPaneVisibilityEventArgs args) - { - if (ActualWidth > 620) return; - - ContentGrid.Padding = new Thickness(0, 0, 0, args.OccludedRect.Height); - args.EnsuredFocusedElementInView = true; - } - - private void OnInputPaneHiding(InputPane sender, InputPaneVisibilityEventArgs args) - { - if (ActualWidth > 620) return; - - ContentGrid.Padding = new Thickness(0, 0, 0, args.OccludedRect.Height); - args.EnsuredFocusedElementInView = true; - } - private void HandleDrag(object sender, DragEventArgs e) { if (e.DataView.Contains(StandardDataFormats.Bitmap) || diff --git a/UniSky/Controls/Sheet/SheetControl.cs b/UniSky/Controls/Sheet/SheetControl.cs index 1479dd5..a665be8 100644 --- a/UniSky/Controls/Sheet/SheetControl.cs +++ b/UniSky/Controls/Sheet/SheetControl.cs @@ -1,8 +1,10 @@ -using System.Windows.Input; +using System; +using System.Windows.Input; using CommunityToolkit.Mvvm.Input; using Microsoft.Toolkit.Uwp.UI.Extensions; using UniSky.Controls.Overlay; using UniSky.Services; +using Windows.Foundation; using Windows.UI.ViewManagement; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; @@ -131,16 +133,16 @@ protected override void OnApplyTemplate() Controller.SafeAreaService.SafeAreaUpdated += OnSafeAreaUpdated; Controller.SafeAreaService.SetTitleBar(titleBarDragArea); - var inputPane = InputPane.GetForCurrentView(); - inputPane.Showing += OnInputPaneShowing; - inputPane.Hiding += OnInputPaneHiding; - this.SizeChanged += OnSizeChanged; } else { VisualStateManager.GoToState(this, "Standard", false); } + + var inputPane = InputPane.GetForCurrentView(); + inputPane.Showing += OnInputPaneShowing; + inputPane.Hiding += OnInputPaneHiding; } private void OnSizeChanged(object sender, SizeChangedEventArgs e) @@ -151,15 +153,21 @@ private void OnSizeChanged(object sender, SizeChangedEventArgs e) private void OnInputPaneShowing(InputPane sender, InputPaneVisibilityEventArgs args) { - var ButtonsGrid = (Grid)this.FindDescendantByName("ButtonsGrid"); - ButtonsGrid.Margin = new Thickness(0, 0, 0, args.OccludedRect.Height); + var transform2 = this.TransformToVisual(Window.Current.Content); + var transformed2 = transform2.TransformBounds(new Rect(new Point(0, 0), this.RenderSize)); + if (args.OccludedRect.Height == 0) + return; + + var height = Math.Max(0, transformed2.Bottom - args.OccludedRect.Top); + this.Margin = new Thickness(0, 0, 0, height); + args.EnsuredFocusedElementInView = true; } private void OnInputPaneHiding(InputPane sender, InputPaneVisibilityEventArgs args) { - var ButtonsGrid = (Grid)this.FindDescendantByName("ButtonsGrid"); - ButtonsGrid.Margin = new Thickness(0, 0, 0, args.OccludedRect.Height); + this.Margin = new Thickness(0, 0, 0, 0); + args.EnsuredFocusedElementInView = true; }