diff --git a/maui/src/PullToRefresh/SfPullToRefresh.cs b/maui/src/PullToRefresh/SfPullToRefresh.cs index e7d8fb6f..e88c23e9 100644 --- a/maui/src/PullToRefresh/SfPullToRefresh.cs +++ b/maui/src/PullToRefresh/SfPullToRefresh.cs @@ -360,7 +360,7 @@ public SfPullToRefresh() Children.Add(_progressCircleView); ClipToBounds = true; ThemeElement.InitializeThemeResources(this, "SfPullToRefreshTheme"); - + // Ensures the refreshing animation starts if IsRefreshing was set via global styles. if (this.IsRefreshing && !this.ActualIsRefreshing) { @@ -1327,6 +1327,16 @@ internal bool CancelPulling() RaisePullingCancelled(); return true; } + + /// + /// Gets and Updates the previousBounds. + /// + /// Returns the rect based on Previous height passed in arrange pass to pull to refresh. + internal Rect GetAndUpdateWithPreviousBounds() + { + return new Rect(this.Bounds.X, this.Bounds.Y, this.Bounds.Width, this.Bounds.Height); + } + #endregion #region Private Methods @@ -1782,15 +1792,16 @@ void RaiseRefreshedEvent(object sender) // Included condition for battery saver logic for android platform. HideSfProgressCircleView(); - var canAnimate = TransitionMode == PullToRefreshTransitionType.Push; -#if ANDROID - canAnimate = Battery.Default.EnergySaverStatus is not EnergySaverStatus.On; -#endif - ArrangePullableContent(GetBounds(), canAnimate); + var canAnimate = this.TransitionMode == PullToRefreshTransitionType.Push && !(DeviceInfo.Platform == DevicePlatform.Android && Battery.Default.EnergySaverStatus == EnergySaverStatus.On); + if (this.TransitionMode == PullToRefreshTransitionType.Push) + { + this.ArrangePullableContent(this.GetAndUpdateWithPreviousBounds(), canAnimate); + } + (this as IView).InvalidateMeasure(); - if (Refreshed is not null) + if (this.Refreshed != null) { - Refreshed(this, EventArgs.Empty); + this.Refreshed(this, EventArgs.Empty); } } @@ -1833,18 +1844,17 @@ async void Rotate() } catch { -#if WINDOWS + if (DeviceInfo.Platform != DevicePlatform.Android && DeviceInfo.Platform != DevicePlatform.iOS) + { #if NET10_0_OR_GREATER - await PullableContent.TranslateToAsync(0, RefreshViewHeight * 2, 300); - await ProgressCircleView.TranslateToAsync((Width / 2) - (RefreshViewWidth / 2), RefreshViewHeight / 1.5, 250); + await this.PullableContent.TranslateToAsync(0, this.RefreshViewHeight * 2, 300); + await this.ProgressCircleView.TranslateToAsync((this.Width / 2) - (this.RefreshViewWidth / 2), this.RefreshViewHeight / 1.5, 250); #else - const int contentLength = 300; - const int circleViewLength = 250; - await PullableContent.LayoutTo(new Rect(0, RefreshViewHeight * 2, Width, Height - (RefreshViewHeight * 2)), contentLength).ConfigureAwait(true); - await ProgressCircleView.LayoutTo(new Rect((Width / 2) - (RefreshViewWidth / 2), RefreshViewHeight / 1.5, RefreshViewWidth, RefreshViewHeight), circleViewLength).ConfigureAwait(true); -#endif - HideSfProgressCircleView(); + await this.PullableContent.LayoutTo(new Rect(0, this.RefreshViewHeight * 2, this.Width, this.Height - (this.RefreshViewHeight * 2)), 300).ConfigureAwait(true); + await this.ProgressCircleView.LayoutTo(new Rect((this.Width / 2) - (this.RefreshViewWidth / 2), this.RefreshViewHeight / 1.5, this.RefreshViewWidth, this.RefreshViewHeight), 250).ConfigureAwait(true); #endif + this.HideSfProgressCircleView(); + } } _isCircleRotating = false;