Skip to content

Commit faaba19

Browse files
committed
fix!: extended-splashscreen not working on skia-mobile
1 parent e0fb72a commit faaba19

File tree

8 files changed

+149
-809
lines changed

8 files changed

+149
-809
lines changed

doc/controls/ExtendedSplashScreen.md

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ uid: Toolkit.Controls.ExtendedSplashScreen
33
---
44
# ExtendedSplashScreen
55

6-
Represents a control, derived from [`LoadingView`](xref:Toolkit.Controls.LoadingView) that displays a view that replicates the appearance and behavior of the target platform's native application loading screen.
6+
Represents a control, derived from [`LoadingView`](xref:Toolkit.Controls.LoadingView) that displays a view that simulates the appearance and behavior of the target platform's native application loading screen.
77

88
Refer to [`LoadingView`](xref:Toolkit.Controls.LoadingView) for a list of inherited members.
99

@@ -20,30 +20,8 @@ A common use case for this control is to display an application loading element
2020
>
2121
> [!Video https://www.youtube-nocookie.com/embed/jMI4E2e9gYE]
2222
23-
## Properties
24-
25-
| Property | Type | Description | Value |
26-
|----------|------|-------------|---------------|
27-
| **Platforms** | `SplashScreenPlatform` | Gets or sets the platform(s) where extended splash screen should be used. This is a flag enumeration, which allows for combining multiple values eg: `"Android,iOS"` | Default value is **All**. Other possible values include **Android**, **iOS**, **Windows**, **WebAssembly**, **Skia**, and **None**. |
28-
| **SplashIsEnabled** | `bool` | Gets a value representing whether the current environment is to display this splash screen. | **True** if the current platform is included in the **Platforms** property, otherwise **false**. |
29-
30-
## Methods
31-
32-
| Method | Return Type | Description |
33-
|--------|-------------|-------------|
34-
| **Init** | `void` | Initializes the splash screen for the provided `Activity` instance. This static method should be invoked from the **OnCreate** override in `MainActivity`.<br/>**Note: This method only needs to be called on Android** |
35-
3623
## Usage
3724

38-
### Specify platforms to display splash screen
39-
40-
The following code snippet will only display the splash screen on Android and iOS by specifying a `SplashScreenPlatform` value for the `Platforms` property.
41-
42-
```xml
43-
<utu:ExtendedSplashScreen x:Name="Splash"
44-
Platforms="Android,iOS" />
45-
```
46-
4725
### Setup the splash screen
4826

4927
The following code snippet demonstrates a suggested pattern for using the `ExtendedSplashScreen`. The first step is to define a custom `UserControl` that will be used as the main shell for the application content. This control will be used to host the `ExtendedSplashScreen` and the main application content.
@@ -96,7 +74,7 @@ Next, the `Shell` control should be used as the root visual for the `Window` in
9674
```csharp
9775
protected override async void OnLaunched(LaunchActivatedEventArgs args)
9876
{
99-
// Code ommited for brevity
77+
// Boilerplate code omitted for brevity
10078
10179
if (MainWindow.Content is not Shell shell)
10280
{
@@ -119,17 +97,3 @@ protected override async void OnLaunched(LaunchActivatedEventArgs args)
11997
With these changes, the splash screen will be displayed when the application first launches and the main application content will be displayed once the loading state is complete.
12098

12199
In order to prolong the splash screen display, you can set the `Source` property of the `ExtendedSplashScreen` control to any custom implementation of the `ILoadable` interface. More information on how to use the `ILoadable` interface can be found in the [`LoadingView`](xref:Toolkit.Controls.LoadingView#iloadable) documentation.
122-
123-
## Setup on Android
124-
125-
To use the `ExtendedSplashScreen` on Android, you need to add the following to your `MainActivity`:
126-
127-
```csharp
128-
protected override void OnCreate(Bundle bundle)
129-
{
130-
// Handle the splash screen transition.
131-
Uno.Toolkit.UI.ExtendedSplashScreen.Init(this);
132-
133-
base.OnCreate(bundle);
134-
}
135-
```

src/Uno.Toolkit.RuntimeTests/Tests/ExtendedSplashScreenTests.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,22 @@ namespace Uno.Toolkit.RuntimeTests.Tests;
1919
public class ExtendedSplashScreenTests
2020
{
2121
[TestMethod]
22-
#if __ANDROID__ || __IOS__
23-
[Ignore]
24-
#endif
2522
public async Task Smoke_Test()
2623
{
27-
var host = await ExtendedSplashScreen.GetNativeSplashScreen().ConfigureAwait(false) ?? throw new Exception("Failed to load native splash screen");
24+
var host = await ExtendedSplashScreen.GetSplashScreen().ConfigureAwait(false) ?? throw new Exception("Failed to load native splash screen");
2825

29-
#if !__MOBILE__ // ignore native platforms impl: ios,droid,macos
3026
var sut = host.GetFirstDescendant<Image>() ?? throw new Exception("Failed to find splash image control");
3127
var tcs = new TaskCompletionSource<(bool Success, string? Message)>();
3228

3329
sut.ImageOpened += (s, e) => tcs.SetResult((Success: true, null));
3430
sut.ImageFailed += (s, e) => tcs.SetResult((Success: false, e.ErrorMessage));
35-
#endif
3631

3732
await UnitTestUIContentHelperEx.SetContentAndWait(host);
3833

39-
#if !__MOBILE__
4034
if (await Task.WhenAny(tcs.Task, Task.Delay(2000)) != tcs.Task)
4135
throw new TimeoutException("Timed out waiting on image to load");
4236

4337
if ((await tcs.Task) is { Success: false, Message: var message })
4438
throw new Exception($"Failed to load image: {message}");
45-
#endif
4639
}
4740
}

0 commit comments

Comments
 (0)