forked from dotnet/maui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the LabelHandler for WinUI (dotnet#655)
* Add the LabelHandler for WinUI * Windows is beautiful * ws * my bad. it does work. * Revert "my bad. it does work." This reverts commit 3c985b5. * Revert "Revert "my bad. it does work."" This reverts commit 4b4e0b3. * not this now * Don't remove all the xaml on non-Windows Android and iOS are non-Windows and thus they lose all XAML files. THis only came in with WinUI and is only noticeable since we started using the App.xaml as the main entry point. * - add build step to winui cake * Moving toys Co-authored-by: Shane Neuville <[email protected]>
- Loading branch information
1 parent
5a2aa3a
commit 6a71d58
Showing
7 changed files
with
104 additions
and
18 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,48 @@ | ||
using System; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.UI.Xaml; | ||
using Microsoft.UI.Xaml.Controls; | ||
|
||
namespace Microsoft.Maui.Handlers | ||
{ | ||
public partial class LabelHandler : AbstractViewHandler<ILabel, TextBlock> | ||
public partial class LabelHandler : AbstractViewHandler<ILabel, FrameworkElement> | ||
{ | ||
protected override TextBlock CreateNativeView() => new TextBlock(); | ||
protected TextBlock? TextBlock { get; set; } | ||
|
||
public static void MapText(IViewHandler handler, ILabel label) => | ||
(handler as LabelHandler)?.TypedNativeView?.UpdateText(label); | ||
protected override FrameworkElement CreateNativeView() | ||
{ | ||
TextBlock = new TextBlock(); | ||
return new Border { Child = TextBlock }; | ||
} | ||
|
||
public static void MapText(LabelHandler handler, ILabel label) => | ||
handler.TextBlock?.UpdateText(label); | ||
|
||
public static void MapTextColor(LabelHandler handler, ILabel label) => | ||
handler.TextBlock?.UpdateTextColor(label); | ||
|
||
public static void MapCharacterSpacing(LabelHandler handler, ILabel label) { } | ||
|
||
public static void MapFont(LabelHandler handler, ILabel label) | ||
{ | ||
_ = handler.Services ?? throw new InvalidOperationException($"{nameof(Services)} should have been set by base class."); | ||
|
||
var fontManager = handler.Services.GetRequiredService<IFontManager>(); | ||
|
||
handler.TextBlock?.UpdateFont(label, fontManager); | ||
} | ||
|
||
public static void MapTextColor(IViewHandler handler, ILabel label) { } | ||
public static void MapCharacterSpacing(IViewHandler handler, ILabel label) { } | ||
public static void MapFont(LabelHandler handler, ILabel label) { } | ||
public static void MapHorizontalTextAlignment(LabelHandler handler, ILabel label) { } | ||
|
||
public static void MapLineBreakMode(LabelHandler handler, ILabel label) { } | ||
|
||
public static void MapTextDecorations(LabelHandler handler, ILabel label) { } | ||
public static void MapMaxLines(IViewHandler handler, ILabel label) { } | ||
public static void MapPadding(LabelHandler handler, ILabel label) { } | ||
|
||
public static void MapMaxLines(LabelHandler handler, ILabel label) { } | ||
|
||
public static void MapPadding(LabelHandler handler, ILabel label) => | ||
handler.TextBlock?.UpdatePadding(label); | ||
|
||
public static void MapLineHeight(LabelHandler handler, ILabel label) { } | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using WPoint = Windows.Foundation.Point; | ||
using WThickness = Microsoft.UI.Xaml.Thickness; | ||
|
||
namespace Microsoft.Maui | ||
{ | ||
public static class PrimitiveExtensions | ||
{ | ||
public static WPoint ToNative(this Point point) => | ||
new WPoint(point.X, point.Y); | ||
|
||
public static WThickness ToNative(this Thickness thickness) => | ||
new WThickness( | ||
thickness.Left, | ||
thickness.Top, | ||
thickness.Right, | ||
thickness.Bottom); | ||
} | ||
} |
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