Skip to content

Commit 1f38e6a

Browse files
committed
Bump to latest
- Modal Navigation Manager (dotnet#1563) - Implement the basic WindowHandler (dotnet#1468) - Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485) - Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328) - And so on.
1 parent 4340f1d commit 1f38e6a

22 files changed

+197
-66
lines changed

src/Compatibility/Core/src/AppHostBuilderExtensions.cs

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -152,18 +152,19 @@ static IAppHostBuilder SetupDefaults(this IAppHostBuilder builder)
152152
events.AddTizen(tizen => tizen
153153
.OnPreCreate((a) =>
154154
{
155-
// This just gets Forms Compat bits setup with what it needs
156-
// to initialize the first view. MauiContext hasn't been initialized at this point
157-
// so we setup one that will look exactly the same just
158-
// to make legacy Forms bits happy
155+
// This is the initial Init to set up any system services registered by
156+
// Forms.Init(). This happens before any UI has appeared.
157+
// This creates a dummy MauiContext.
158+
159159
var services = MauiApplication.Current.Services;
160-
MauiContext mauiContext = new MauiContext(services, CoreUIAppContext.GetInstance(MauiApplication.Current));
161-
ActivationState state = new ActivationState(mauiContext);
160+
var mauiContext = new MauiContext(services, CoreUIAppContext.GetInstance(MauiApplication.Current));
161+
var state = new ActivationState(mauiContext);
162162
var options = services.GetService<InitializationOptions>();
163163

164164
if (options != null)
165165
{
166166
options.Context = options.Context ?? MauiApplication.Current;
167+
options.Flags = InitializationFlags.SkipRenderers;
167168
Forms.Init(state, options);
168169

169170
var unit = options.DisplayResolutionUnit;
@@ -196,24 +197,13 @@ static IAppHostBuilder SetupDefaults(this IAppHostBuilder builder)
196197
{
197198
Forms.Init(state, new InitializationOptions(MauiApplication.Current) { Flags = InitializationFlags.SkipRenderers });
198199
}
199-
200-
GraphicsPlatform.RegisterGlobalService(SkiaGraphicsService.Instance);
201200
})
202-
.OnCreate((a) =>
201+
.OnMauiContextCreated((mauiContext) =>
203202
{
204-
// This calls Init again so that the MauiContext that's part of
205-
// Forms.Init matches the rest of the maui application
206-
var mauiApp = MauiApplication.Current.Application;
207-
if (mauiApp.Windows.Count > 0)
208-
{
209-
var window = mauiApp.Windows[0];
210-
var mauiContext = window.Handler?.MauiContext ?? window.View.Handler?.MauiContext;
203+
// This is the final Init that sets up the real context from the application.
211204

212-
if (mauiContext != null)
213-
{
214-
Forms.Init(new ActivationState(mauiContext));
215-
}
216-
}
205+
var state = new ActivationState(mauiContext!);
206+
Forms.Init(state);
217207
}));
218208
#endif
219209
});

src/Compatibility/Core/src/Tizen/Forms.cs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,9 @@ static void SetupInit(IMauiContext context, InitializationOptions options = null
484484
Device.Info = new Forms.TizenDeviceInfo();
485485
Device.SetFlags(s_flags);
486486

487+
if (options?.Flags.HasFlag(InitializationFlags.SkipRenderers) != true)
488+
RegisterCompatRenderers(options);
489+
487490
string profile = ((TizenDeviceInfo)Device.Info).Profile;
488491
if (profile == "mobile")
489492
{
@@ -523,6 +526,50 @@ static void SetupInit(IMauiContext context, InitializationOptions options = null
523526
IsInitialized = true;
524527
}
525528

529+
internal static void RegisterCompatRenderers(InitializationOptions maybeOptions = null)
530+
{
531+
if (!IsInitializedRenderers)
532+
{
533+
IsInitializedRenderers = true;
534+
if (maybeOptions != null)
535+
{
536+
var options = maybeOptions;
537+
var handlers = options.Handlers;
538+
var flags = options.Flags;
539+
var effectScopes = options.EffectScopes;
540+
541+
//TODO: ExportCell?
542+
//TODO: ExportFont
543+
544+
// renderers
545+
Registrar.RegisterRenderers(handlers);
546+
547+
// effects
548+
if (effectScopes != null)
549+
{
550+
for (var i = 0; i < effectScopes.Length; i++)
551+
{
552+
var effectScope = effectScopes[0];
553+
Registrar.RegisterEffects(effectScope.Name, effectScope.Effects);
554+
}
555+
}
556+
557+
// css
558+
Registrar.RegisterStylesheets(flags);
559+
}
560+
else
561+
{
562+
// Only need to do this once
563+
Registrar.RegisterAll(new[] {
564+
typeof(ExportRendererAttribute),
565+
typeof(ExportCellAttribute),
566+
typeof(ExportImageSourceHandlerAttribute),
567+
typeof(ExportFontAttribute)
568+
});
569+
}
570+
}
571+
}
572+
526573
static void RegisterSkiaSharpRenderers()
527574
{
528575
// Register all skiasharp-based rednerers here.

src/Compatibility/Core/src/Tizen/HandlerToRendererShim.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,14 @@ public MockParentHandler(VisualElement parent)
123123

124124
public IMauiContext MauiContext => null;
125125

126-
object IViewHandler.NativeView => NativeView;
126+
object IElementHandler.NativeView => NativeView;
127127

128128
object IViewHandler.ContainerView => NativeView;
129129

130-
bool HasContainer { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
131130
bool IViewHandler.HasContainer { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
132131

132+
Maui.IElement IElementHandler.VirtualView => throw new NotImplementedException();
133+
133134
public void DisconnectHandler() { }
134135

135136
public void Dispose()
@@ -170,6 +171,11 @@ public void UpdateValue(string property)
170171
{
171172
throw new NotImplementedException();
172173
}
174+
175+
public void SetVirtualView(Maui.IElement view)
176+
{
177+
throw new NotImplementedException();
178+
}
173179
}
174180

175181
}

src/Compatibility/Core/src/Tizen/Platform.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ internal static IVisualElementRenderer CreateRenderer(VisualElement element)
5353
//TODO: Handle this with AppBuilderHost
5454
try
5555
{
56-
handler = Forms.MauiContext.Handlers.GetHandler(element.GetType());
56+
handler = Forms.MauiContext.Handlers.GetHandler(element.GetType()) as IViewHandler;
5757
handler.SetMauiContext(Forms.MauiContext);
5858
}
5959
catch
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#nullable enable
2+
using System;
3+
using EWindow = ElmSharp.Window;
4+
5+
namespace Microsoft.Maui.Controls
6+
{
7+
public partial class Window
8+
{
9+
internal EWindow NativeWindow =>
10+
(Handler?.NativeView as EWindow) ?? throw new InvalidOperationException("Window should have a ElmSharp.Window set.");
11+
}
12+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
3+
namespace Microsoft.Maui.Controls.Platform
4+
{
5+
internal partial class AlertManager
6+
{
7+
internal static void Subscribe(Window window)
8+
{
9+
//TODO: Need to implementation
10+
//throw new NotImplementedException();
11+
}
12+
13+
internal static void Unsubscribe(Window window)
14+
{
15+
//TODO: Need to implementation
16+
//throw new NotImplementedException();
17+
}
18+
}
19+
}

src/Controls/src/Core/Platform/ModalNavigationService/ModalNavigationService.Tizen.cs renamed to src/Controls/src/Core/Platform/ModalNavigationManager/ModalNavigationManager.Tizen.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Microsoft.Maui.Controls.Platform
66
{
7-
internal partial class ModalNavigationService
7+
internal partial class ModalNavigationManager
88
{
99
ModalStack _modalStack => MauiContext.Context!.ModalStack;
1010
IPageController CurrentPageController => _navModel.CurrentPage;

src/Core/src/Handlers/Label/LabelHandler.Tizen.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ public static void MapHorizontalTextAlignment(LabelHandler handler, ILabel label
2424
handler.NativeView?.UpdateHorizontalTextAlignment(label);
2525
}
2626

27+
public static void MapVerticalTextAlignment(LabelHandler handler, ILabel label)
28+
{
29+
handler.NativeView?.UpdateVerticalTextAlignment(label);
30+
}
31+
2732
public static void MapLineBreakMode(LabelHandler handler, ILabel label)
2833
{
2934
handler.NativeView?.UpdateLineBreakMode(label);

src/Core/src/Handlers/ProgressBar/ProgressBarHandler.Tizen.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ protected override EProgressBar CreateNativeView()
1515
return progressBar;
1616
}
1717

18-
protected override void SetupDefaults(EProgressBar nativeView)
18+
void SetupDefaults(EProgressBar nativeView)
1919
{
2020
nativeView.Color = ThemeConstants.ProgressBar.ColorClass.Default;
2121
}

src/Core/src/Handlers/Slider/SliderHandler.Tizen.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ protected override void DisconnectHandler(ESlider nativeView)
2727
nativeView!.DragStopped -= OnDragStopped;
2828
}
2929

30-
protected override void SetupDefaults(ESlider nativeView)
30+
void SetupDefaults(ESlider nativeView)
3131
{
3232
DefaultMinTrackColor = nativeView.GetBarColor();
3333
DefaultMaxTrackColor = nativeView.GetBackgroundColor();

0 commit comments

Comments
 (0)