Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Window Life Cycle * - fix benchmark stubs * - fix device tests * - keep reference to associated window * - fix window call * - fix window
- Loading branch information
Showing
33 changed files
with
683 additions
and
265 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
src/Compatibility/Core/src/AppHostBuilderExtensions.Android.cs
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using Microsoft.Maui.LifecycleEvents; | ||
using Microsoft.Maui.Hosting; | ||
using Microsoft.Maui.Controls.Compatibility; | ||
|
||
namespace Microsoft.Maui.Controls.Hosting | ||
{ | ||
public static partial class AppHostBuilderExtensions | ||
{ | ||
internal static IAppHostBuilder ConfigureCompatibilityLifecycleEvents(this IAppHostBuilder builder) => | ||
builder.ConfigureLifecycleEvents(events => events.AddAndroid(OnConfigureLifeCycle)); | ||
|
||
static void OnConfigureLifeCycle(IAndroidLifecycleBuilder android) | ||
{ | ||
android | ||
.OnApplicationCreating((app) => | ||
{ | ||
// This is the initial Init to set up any system services registered by | ||
// Forms.Init(). This happens in the Application's OnCreate - before | ||
// any UI has appeared. | ||
// This creates a dummy MauiContext that wraps the Application. | ||
var services = MauiApplication.Current.Services; | ||
var mauiContext = new MauiContext(services, app); | ||
var state = new ActivationState(mauiContext); | ||
Forms.Init(state, new InitializationOptions { Flags = InitializationFlags.SkipRenderers }); | ||
}) | ||
.OnMauiContextCreated((mauiContext) => | ||
{ | ||
// This is the final Init that sets up the real context from the activity. | ||
var state = new ActivationState(mauiContext); | ||
Forms.Init(state); | ||
}); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/Compatibility/Core/src/AppHostBuilderExtensions.Standard.cs
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Microsoft.Maui.Hosting; | ||
using Microsoft.Maui.LifecycleEvents; | ||
using System; | ||
|
||
namespace Microsoft.Maui.Controls.Hosting | ||
{ | ||
public static partial class AppHostBuilderExtensions | ||
{ | ||
internal static IAppHostBuilder ConfigureCompatibilityLifecycleEvents(this IAppHostBuilder builder) => | ||
builder; | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
src/Compatibility/Core/src/AppHostBuilderExtensions.Windows.cs
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#nullable enable | ||
using Microsoft.Maui.Controls.Compatibility.Platform.UWP; | ||
using Microsoft.Maui.Graphics.Win2D; | ||
using BoxRenderer = Microsoft.Maui.Controls.Compatibility.Platform.UWP.BoxViewBorderRenderer; | ||
using CellRenderer = Microsoft.Maui.Controls.Compatibility.Platform.UWP.TextCellRenderer; | ||
using Deserializer = Microsoft.Maui.Controls.Compatibility.Platform.UWP.WindowsSerializer; | ||
using ResourcesProvider = Microsoft.Maui.Controls.Compatibility.Platform.UWP.WindowsResourcesProvider; | ||
using StreamImagesourceHandler = Microsoft.Maui.Controls.Compatibility.Platform.UWP.StreamImageSourceHandler; | ||
using ImageLoaderSourceHandler = Microsoft.Maui.Controls.Compatibility.Platform.UWP.UriImageSourceHandler; | ||
using DefaultRenderer = Microsoft.Maui.Controls.Compatibility.Platform.UWP.DefaultRenderer; | ||
using Microsoft.Maui.LifecycleEvents; | ||
using Microsoft.Maui.Controls.Compatibility; | ||
using System; | ||
using Microsoft.Maui.Hosting; | ||
|
||
namespace Microsoft.Maui.Controls.Hosting | ||
{ | ||
public static partial class AppHostBuilderExtensions | ||
{ | ||
internal static IAppHostBuilder ConfigureCompatibilityLifecycleEvents(this IAppHostBuilder builder) => | ||
builder.ConfigureLifecycleEvents(events => events.AddWindows(OnConfigureLifeCycle)); | ||
|
||
static void OnConfigureLifeCycle(IWindowsLifecycleBuilder windows) | ||
{ | ||
windows.OnLaunching((app, args) => | ||
{ | ||
// This is the initial Init to set up any system services registered by | ||
// Forms.Init(). This happens before any UI has appeared. | ||
// This creates a dummy MauiContext. | ||
// We need to call this so the Window and Root Page can new up successfully | ||
// The dispatcher that's inside of Forms.Init needs to be setup before the initial | ||
// window and root page start creating. | ||
// Inside OnLaunched we grab the MauiContext that's on the window so we can have the correct | ||
// MauiContext inside Forms | ||
var services = MauiWinUIApplication.Current.Services; | ||
var mauiContext = new MauiContext(services); | ||
var state = new ActivationState(mauiContext, args); | ||
Forms.Init(state, new InitializationOptions { Flags = InitializationFlags.SkipRenderers }); | ||
}) | ||
.OnMauiContextCreated((mauiContext) => | ||
{ | ||
// This is the final Init that sets up the real context from the application. | ||
var state = new ActivationState(mauiContext); | ||
Forms.Init(state); | ||
}); | ||
} | ||
} | ||
} |
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
35 changes: 35 additions & 0 deletions
35
src/Compatibility/Core/src/AppHostBuilderExtensions.iOS.cs
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Microsoft.Maui.Hosting; | ||
using Microsoft.Maui.LifecycleEvents; | ||
using Microsoft.Maui.Controls.Compatibility; | ||
|
||
namespace Microsoft.Maui.Controls.Hosting | ||
{ | ||
public static partial class AppHostBuilderExtensions | ||
{ | ||
internal static IAppHostBuilder ConfigureCompatibilityLifecycleEvents(this IAppHostBuilder builder) => | ||
builder.ConfigureLifecycleEvents(events => events.AddiOS(OnConfigureLifeCycle)); | ||
|
||
static void OnConfigureLifeCycle(IiOSLifecycleBuilder iOS) | ||
{ | ||
iOS.WillFinishLaunching((app, options) => | ||
{ | ||
// This is the initial Init to set up any system services registered by | ||
// Forms.Init(). This happens before any UI has appeared. | ||
// This creates a dummy MauiContext. | ||
var services = MauiUIApplicationDelegate.Current.Services; | ||
var mauiContext = new MauiContext(services); | ||
var state = new ActivationState(mauiContext); | ||
Forms.Init(state, new InitializationOptions { Flags = InitializationFlags.SkipRenderers }); | ||
return true; | ||
}) | ||
.OnMauiContextCreated((mauiContext) => | ||
{ | ||
// This is the final Init that sets up the real context from the application. | ||
var state = new ActivationState(mauiContext); | ||
Forms.Init(state); | ||
}); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.