Skip to content

Commit

Permalink
dotnet format
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCodeTraveler committed Jan 17, 2025
1 parent a96fe61 commit e66f78e
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static void SetBarSize(bool isUsingSafeArea)
static void PlatformSetColor(Color color)
{
var uiColor = color.ToPlatform();

var statusBarTag = new IntPtr(38482);
foreach (var window in UIApplication.SharedApplication.Windows)
{
Expand All @@ -51,7 +51,7 @@ static void PlatformSetColor(Color color)
{
continue;
}

statusBar ??= new UIView(statusBarFrame.Value);
statusBar.Tag = statusBarTag;
statusBar.BackgroundColor = uiColor;
Expand All @@ -72,7 +72,7 @@ static void PlatformSetColor(Color color)
static CGRect GetStatusBarFrame(in UIWindow window, in bool isUsingSafeArea)
{
var statusBarFrame = UIApplication.SharedApplication.StatusBarFrame;

return isUsingSafeArea
? new CGRect(statusBarFrame.X, statusBarFrame.Y, statusBarFrame.Width, window.SafeAreaInsets.Top)
: statusBarFrame;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static void ShouldLoopPlayback(MediaElementHandler handler, MediaElement
handler.mediaManager?.UpdateShouldLoopPlayback();
}


protected override MauiMediaElement CreatePlatformView()
{
mediaManager ??= new(MauiContext ?? throw new InvalidOperationException($"{nameof(MauiContext)} cannot be null"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ protected override void OnVisibilityChanged(Android.Views.View changedView, [Gen
/// Releases the unmanaged resources used by the <see cref="MediaElement"/> and optionally releases the managed resources.
/// </summary>
/// <param name="disposing"><see langword="true"/> to release both managed and unmanaged resources; <see langword="false"/> to release only unmanaged resources.</param>

protected override void Dispose(bool disposing)
{
if (disposing)
Expand Down
29 changes: 11 additions & 18 deletions src/CommunityToolkit.Maui.MediaElement/Views/MediaManager.macios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ public partial class MediaManager : IDisposable
/// Creates the corresponding platform view of <see cref="MediaElement"/> on iOS and macOS.
/// </summary>
/// <returns>The platform native counterpart of <see cref="MediaElement"/>.</returns>

public (PlatformMediaElement Player, AVPlayerViewController PlayerViewController) CreatePlatformView()
{
Player = new();
Expand Down Expand Up @@ -132,7 +131,6 @@ public void Dispose()
Dispose(true);
GC.SuppressFinalize(this);
}


protected virtual partial void PlatformPlay()
{
Expand All @@ -144,12 +142,10 @@ protected virtual partial void PlatformPlay()
Player?.Play();
}


protected virtual partial void PlatformPause()
{
Player?.Pause();
}


protected virtual async partial Task PlatformSeek(TimeSpan position, CancellationToken token)
{
Expand Down Expand Up @@ -191,7 +187,6 @@ protected virtual async partial Task PlatformSeek(TimeSpan position, Cancellatio
MediaElement.SeekCompleted();
}


protected virtual partial void PlatformStop()
{
// There's no Stop method so pause the video and reset its position
Expand Down Expand Up @@ -384,7 +379,6 @@ protected virtual partial void PlatformUpdateShouldShowPlaybackControls()
PlayerViewController.ShowsPlaybackControls =
MediaElement.ShouldShowPlaybackControls;
}


protected virtual partial void PlatformUpdatePosition()
{
Expand Down Expand Up @@ -417,7 +411,6 @@ protected virtual partial void PlatformUpdatePosition()
MediaElement.Duration = MediaElement.Position = TimeSpan.Zero;
}
}


protected virtual partial void PlatformUpdateVolume()
{
Expand All @@ -433,7 +426,7 @@ protected virtual partial void PlatformUpdateVolume()
}
}


protected virtual partial void PlatformUpdateShouldKeepScreenOn()
{
if (Player is null)
Expand All @@ -443,7 +436,7 @@ protected virtual partial void PlatformUpdateShouldKeepScreenOn()
UIApplication.SharedApplication.IdleTimerDisabled = MediaElement.ShouldKeepScreenOn;
}


protected virtual partial void PlatformUpdateShouldMute()
{
if (Player is null)
Expand All @@ -463,7 +456,7 @@ protected virtual partial void PlatformUpdateShouldLoopPlayback()
/// Releases the unmanaged resources used by the <see cref="MediaManager"/> and optionally releases the managed resources.
/// </summary>
/// <param name="disposing"><see langword="true"/> to release both managed and unmanaged resources; <see langword="false"/> to release only unmanaged resources.</param>

protected virtual void Dispose(bool disposing)
{
if (disposing)
Expand Down Expand Up @@ -548,7 +541,7 @@ protected virtual void Dispose(bool disposing)
}
}


void AddStatusObservers()
{
if (Player is null)
Expand All @@ -563,7 +556,7 @@ void AddStatusObservers()
RateObserver = AVPlayer.Notifications.ObserveRateDidChange(RateChanged);
}


void VolumeChanged(NSObservedChange e)
{
if (Player is null)
Expand All @@ -578,7 +571,7 @@ void VolumeChanged(NSObservedChange e)
}
}


void MutedChanged(NSObservedChange e)
{
if (Player is null)
Expand Down Expand Up @@ -617,7 +610,7 @@ void DestroyPlayedToEndObserver()
PlayedToEndObserver?.Dispose();
}


void StatusChanged(NSObservedChange obj)
{
if (Player is null)
Expand All @@ -636,7 +629,7 @@ void StatusChanged(NSObservedChange obj)
MediaElement.CurrentStateChanged(newState);
}


void TimeControlStatusChanged(NSObservedChange obj)
{
if (Player is null || Player.Status is AVPlayerStatus.Unknown
Expand All @@ -658,7 +651,7 @@ void TimeControlStatusChanged(NSObservedChange obj)
MediaElement.CurrentStateChanged(newState);
}


void ErrorOccurred(object? sender, NSNotificationEventArgs args)
{
string message;
Expand All @@ -681,7 +674,7 @@ void ErrorOccurred(object? sender, NSNotificationEventArgs args)
}
}


void PlayedToEnd(object? sender, NSNotificationEventArgs args)
{
if (args.Notification.Object != PlayerViewController?.Player?.CurrentItem || Player is null)
Expand All @@ -707,7 +700,7 @@ void PlayedToEnd(object? sender, NSNotificationEventArgs args)
}
}


void RateChanged(object? sender, NSNotificationEventArgs args)
{
if (Player is null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public void ValidMaskWithUniqueUnmaskedCharacterTests(string? mask, char unmaske
}

[Fact]

public void AttachedToInvalidElementTest()
{
IReadOnlyList<VisualElement> invalidVisualElements =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ namespace CommunityToolkit.Maui.UnitTests.Behaviors;
public class MaxLengthReachedBehaviorTests() : BaseBehaviorTest<MaxLengthReachedBehavior, InputView>(new MaxLengthReachedBehavior(), new Entry())
{
[Fact]

public void ShouldExecuteCommandWhenMaxLengthHasBeenReached()
{
// arrange
Expand All @@ -23,7 +22,6 @@ public void ShouldExecuteCommandWhenMaxLengthHasBeenReached()
}

[Fact]

public void ShouldInvokeEventHandlerWhenMaxLengthHasBeenReached()
{
// arrange
Expand All @@ -39,7 +37,6 @@ public void ShouldInvokeEventHandlerWhenMaxLengthHasBeenReached()
}

[Fact]

public void ShouldExecuteCommandWithTextValueNoLargerThenMaxLength()
{
// arrange
Expand All @@ -56,7 +53,6 @@ public void ShouldExecuteCommandWithTextValueNoLargerThenMaxLength()
}

[Fact]

public void ShouldInvokeEventHandlerWithTextValueNoLargerThenMaxLength()
{
// arrange
Expand All @@ -73,7 +69,6 @@ public void ShouldInvokeEventHandlerWithTextValueNoLargerThenMaxLength()
}

[Fact]

public void ShouldNotExecuteCommandBeforeMaxLengthHasBeenReached()
{
// arrange
Expand All @@ -88,7 +83,6 @@ public void ShouldNotExecuteCommandBeforeMaxLengthHasBeenReached()
}

[Fact]

public void ShouldNotInvokeEventHandlerBeforeMaxLengthHasBeenReached()
{
// arrange
Expand All @@ -103,7 +97,6 @@ public void ShouldNotInvokeEventHandlerBeforeMaxLengthHasBeenReached()
}

[Fact]

public void ShouldDismissKeyboardWhenMaxLengthHasBeenReached()
{
// arrange
Expand All @@ -119,7 +112,6 @@ public void ShouldDismissKeyboardWhenMaxLengthHasBeenReached()
}

[Fact]

public void ShouldNotDismissKeyboardBeforeMaxLengthHasBeenReached()
{
// arrange
Expand All @@ -134,7 +126,6 @@ public void ShouldNotDismissKeyboardBeforeMaxLengthHasBeenReached()
}

[Fact]

public void ShouldNotDismissKeyboardWhenOptionSetToFalse()
{
// arrange
Expand All @@ -148,7 +139,6 @@ public void ShouldNotDismissKeyboardWhenOptionSetToFalse()
// assert
Assert.True(entry.IsFocused);
}


static Entry CreateEntry(int? maxLength = 2,
bool shouldDismissKeyboardAutomatically = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ namespace CommunityToolkit.Maui.UnitTests.Behaviors;
public class SetFocusOnEntryCompletedTests() : BaseBehaviorTest<SetFocusOnEntryCompletedBehavior, VisualElement>(new SetFocusOnEntryCompletedBehavior(), new View())
{
[Fact]

public void DoesNotSetFocusBeforeCompletion()
{
// arrange
Expand All @@ -22,7 +21,6 @@ public void DoesNotSetFocusBeforeCompletion()
}

[Fact]

public void SetsFocusWhenCompleted()
{
// arrange
Expand All @@ -36,7 +34,6 @@ public void SetsFocusWhenCompleted()
// assert
Assert.True(entry2.IsFocused);
}


static Entry CreateEntry(VisualElement? nextElement = null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ namespace CommunityToolkit.Maui.UnitTests.Behaviors;
public class UserStoppedTypingBehaviorTests() : BaseBehaviorTest<UserStoppedTypingBehavior, InputView>(new UserStoppedTypingBehavior(), new Entry())
{
[Fact(Timeout = (int)TestDuration.Short)]

public async Task ShouldExecuteCommandWhenTimeThresholdHasExpired()
{
// arrange
Expand All @@ -29,7 +28,6 @@ public async Task ShouldExecuteCommandWhenTimeThresholdHasExpired()
}

[Fact(Timeout = (int)TestDuration.Short)]

public async Task ShouldExecuteCommandWithSpecificParameterWhenSpecified()
{
// arrange
Expand All @@ -50,7 +48,6 @@ public async Task ShouldExecuteCommandWithSpecificParameterWhenSpecified()
}

[Fact(Timeout = (int)TestDuration.Short)]

public async Task ShouldNotExecuteCommandBeforeTimeThresholdHasExpired()
{
// arrange
Expand All @@ -75,7 +72,6 @@ public async Task ShouldNotExecuteCommandBeforeTimeThresholdHasExpired()
}

[Fact(Timeout = (int)TestDuration.Short)]

public async Task ShouldOnlyExecuteCommandOnceWhenTextChangedHasOccurredMultipleTimes()
{
// arrange
Expand All @@ -99,7 +95,6 @@ public async Task ShouldOnlyExecuteCommandOnceWhenTextChangedHasOccurredMultiple
}

[Fact(Timeout = (int)TestDuration.Short)]

public async Task ShouldDismissKeyboardWhenTimeThresholdHasExpired()
{
// arrange
Expand All @@ -124,7 +119,6 @@ void HandleEntryUnfocused(object? sender, FocusEventArgs e)
}

[Fact(Timeout = (int)TestDuration.Short)]

public async Task ShouldExecuteCommandWhenMinimumLengthThresholdHasBeenReached()
{
// arrange
Expand All @@ -148,7 +142,6 @@ public async Task ShouldExecuteCommandWhenMinimumLengthThresholdHasBeenReached()
}

[Fact(Timeout = (int)TestDuration.Long)]

public async Task ShouldNotExecuteCommandWhenMinimumLengthThresholdHasNotBeenReached()
{
// arrange
Expand Down Expand Up @@ -187,7 +180,6 @@ void HandleFocused(object? sender, FocusEventArgs e)
}

[Fact(Timeout = (int)TestDuration.Long)]

public async Task ShouldNotDismissKeyboardWhenMinimumLengthThresholdHasNotBeenReached()
{
// arrange
Expand Down Expand Up @@ -228,7 +220,6 @@ void HandleUnfocused(object? sender, FocusEventArgs e)
}

[Fact(Timeout = (int)TestDuration.Short)]

public async Task ShouldExecuteCommandImmediatelyWhenMinimumLengthThresholdHasNotBeenSet()
{
// arrange
Expand All @@ -247,7 +238,6 @@ public async Task ShouldExecuteCommandImmediatelyWhenMinimumLengthThresholdHasNo
// assert
Assert.True(commandHasBeenExecuted);
}


static Entry CreateEntryWithBehavior(int stoppedTypingTimeThreshold = 500,
int minimumLengthThreshold = 0,
Expand Down
Loading

0 comments on commit e66f78e

Please sign in to comment.