-
Notifications
You must be signed in to change notification settings - Fork 742
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: CoreApplication EnteredBackground and LeavingBackground events
- Loading branch information
1 parent
712fe9a
commit e461b69
Showing
2 changed files
with
66 additions
and
70 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,59 +1,85 @@ | ||
#pragma warning disable 108 // new keyword hiding | ||
#pragma warning disable 114 // new keyword hiding | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using Uno.Helpers.Theming; | ||
|
||
namespace Windows.ApplicationModel.Core | ||
namespace Windows.ApplicationModel.Core; | ||
|
||
public partial class CoreApplication | ||
{ | ||
public partial class CoreApplication | ||
private static CoreApplicationView _currentView; | ||
private static List<CoreApplicationView> _views; | ||
|
||
static CoreApplication() | ||
{ | ||
private static CoreApplicationView _currentView; | ||
private static List<CoreApplicationView> _views; | ||
_currentView = new CoreApplicationView(); | ||
} | ||
|
||
public static event global::System.EventHandler<object> Resuming; | ||
/// <summary> | ||
/// Occurs when an app is resuming. | ||
/// </summary> | ||
public static event EventHandler<object> Resuming; | ||
|
||
public static event global::System.EventHandler<global::Windows.ApplicationModel.SuspendingEventArgs> Suspending; | ||
/// <summary> | ||
/// Occurs when the app is suspending. | ||
/// </summary> | ||
public static event EventHandler<SuspendingEventArgs> Suspending; | ||
|
||
static CoreApplication() | ||
{ | ||
_currentView = new CoreApplicationView(); | ||
} | ||
/// <summary> | ||
/// Fired when the app enters the running in the background state. | ||
/// </summary> | ||
public static event EventHandler<EnteredBackgroundEventArgs> EnteredBackground; | ||
|
||
/// <summary> | ||
/// Fired just before application UI becomes visible. | ||
/// </summary> | ||
public static event EventHandler<LeavingBackgroundEventArgs> LeavingBackground; | ||
|
||
/// <summary> | ||
/// Raises the <see cref="Resuming"/> event | ||
/// </summary> | ||
internal static void RaiseResuming() | ||
=> Resuming?.Invoke(null, null); | ||
/// <summary> | ||
/// Raises the <see cref="Resuming"/> event. | ||
/// </summary> | ||
internal static void OnResuming() => Resuming?.Invoke(null, null); | ||
|
||
/// <summary> | ||
/// Raises the <see cref="Suspending"/> event | ||
/// </summary> | ||
internal static void RaiseSuspending(SuspendingEventArgs args) | ||
=> Suspending?.Invoke(null, args); | ||
/// <summary> | ||
/// Raises the <see cref="Suspending"/> event. | ||
/// </summary> | ||
/// <param name="args">Suspending event args.</param> | ||
internal static void OnSuspending(SuspendingEventArgs args) => Suspending?.Invoke(null, args); | ||
|
||
public static CoreApplicationView GetCurrentView() | ||
=> _currentView; | ||
/// <summary> | ||
/// Raises the <see cref="EnteredBackground"/> event. | ||
/// </summary> | ||
/// <param name="args">Entered background event args.</param> | ||
internal static void OnEnteredBackground(EnteredBackgroundEventArgs args) => EnteredBackground?.Invoke(null, args); | ||
|
||
public static global::Windows.ApplicationModel.Core.CoreApplicationView MainView | ||
=> _currentView; | ||
/// <summary> | ||
/// Raises the <see cref="LeavingBackground"/> event. | ||
/// </summary> | ||
/// <param name="args">Leaving background event args.</param> | ||
internal static void OnLeavingBackground(LeavingBackgroundEventArgs args) => LeavingBackground?.Invoke(null, args); | ||
|
||
public static IReadOnlyList<CoreApplicationView> Views | ||
public static CoreApplicationView GetCurrentView() => _currentView; | ||
|
||
public static CoreApplicationView MainView => _currentView; | ||
|
||
public static IReadOnlyList<CoreApplicationView> Views | ||
{ | ||
get | ||
{ | ||
get | ||
if (_views == null) | ||
{ | ||
if(_views == null) | ||
{ | ||
_views = new List<CoreApplicationView> { _currentView }; | ||
} | ||
|
||
return _views; | ||
_views = new List<CoreApplicationView> { _currentView }; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// This property is kept in sync with the Application.RequestedTheme to enable | ||
/// native UI elements in non Uno.UWP to resolve the currently set Application theme. | ||
/// </summary> | ||
internal static SystemTheme RequestedTheme { get; set; } | ||
return _views; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// This property is kept in sync with the Application.RequestedTheme to enable | ||
/// native UI elements in non Uno.UWP to resolve the currently set Application theme. | ||
/// </summary> | ||
internal static SystemTheme RequestedTheme { get; set; } | ||
} |
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