Skip to content

Commit

Permalink
Bring back XAML2006/2009 XmlnsDefinition attributes (#878)
Browse files Browse the repository at this point in the history
* Fix yaml triggers

* Run pr's for release branches

* Automated dotnet-format update (#839)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* [Housekeeping] Add provisionating xcode to net6 (#836)

* Add provisionating xcode to net6

* Fix essentials device tests

* try again

* Update dependencies from https://github.com/xamarin/xamarin-android build main-a2156d41275b92de3cf23f7c79801327c74b7fe0-1 (#846)

Microsoft.Android.Sdk.Windows
 From Version 11.0.200-ci.main.226 -> To Version 11.0.200-ci.main.234

Dependency coherency updates

Microsoft.Dotnet.Sdk.Internal
 From Version 6.0.100-preview.4.21215.1 -> To Version 6.0.100-preview.4.21221.10 (parent: Microsoft.Android.Sdk.Windows

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>

* WinUI Navigation Handler (#801)

* WinUI Navigation Handler

* - PR comments

* - consolidate a few more APIs

* - fix namespaces

* - fix namespaces

* Update src/Compatibility/Core/src/WinUI/FlyoutPageRenderer.cs

Co-authored-by: Matthew Leibowitz <mattleibow@live.com>

Co-authored-by: Matthew Leibowitz <mattleibow@live.com>

* Improve Hot Reload Integration (#851)

* Fixes HotReload (#853)

Reverts changed from: 7d4d1ce#diff-2b4bb95e12307423f7126d91b43a1511b68d00535e9f2b5f535af85d7a388333R36

* Android Push/Pop Navigation (#837)

* Android Navigation

* - fix layout

* - changes

* - yay pushing

* - wire up nav to use bundle ids

* - cleanup

* - setup pop

* - build up nav stack

* - remove nav push

* - remove graph xml

* Update global.json

* - add android to non net6 controls project

* - fix namespace

* Update Microsoft.Maui-net6.sln

* iOS NavigationPageHandler (#852)

* iOS Navigation

* - wire up iOS Navigation

* - remove VET

* - rework with HR

* - fix namespace

* - fix HR

* - fix hr

* - fix SO exception

* - maybe?

* - nullabel fix

* Update dependencies from https://github.com/xamarin/xamarin-macios build 20210426.5 (#847)

Microsoft.MacCatalyst.Sdk , Microsoft.iOS.Sdk
 From Version 14.5.100-ci.main.620 -> To Version 14.5.100-ci.main.658

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Rui Marinho <me@ruimarinho.net>

* Automated dotnet-format update (#854)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Implement PickerHandler in WinUI (#779)

* Implement PickerHandler in WinUI

* Enab le nullable in some classes

* Fix build error

* Register MauiComboBox ResourceDictionary

* Updated PickerExtensions

* Updated MauiComboBox

Co-authored-by: Rachel Kang <rachelkang@microsoft.com>

* [Build] Update maestro with macOS and tvOS (#862)

* [Build] Update maestro with macOS and tvOS

* [Build] Add tvOS and macOS to workload/dogfood

* Add Microsoft.iOS.Windows.Sdk

Co-authored-by: Jonathan Peppers <jonathan.peppers@microsoft.com>

* Update README.md (#865)

* ContainerViewControllers should use the correct background color. (#868)

Also set the title of the VC from a page

* Automated dotnet-format update (#872)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Bring back XAML2006/2009 XmlnsDefinition attributes

These are required so that things like x:Static can be resolved to Microsoft.Maui.Controls.Xaml.StaticExtension.

Co-authored-by: Rui Marinho <me@ruimarinho.net>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Shane Neuville <shneuvil@microsoft.com>
Co-authored-by: Matthew Leibowitz <mattleibow@live.com>
Co-authored-by: James Clancey <james.clancey@gmail.com>
Co-authored-by: Javier Suárez <javiersuarezruiz@hotmail.com>
Co-authored-by: Rachel Kang <rachelkang@microsoft.com>
Co-authored-by: Jonathan Peppers <jonathan.peppers@microsoft.com>
Co-authored-by: 1d0n7kn0w <3910210+1d0n7kn0w@users.noreply.github.com>
Co-authored-by: Jonathan Dick <jodick@microsoft.com>
  • Loading branch information
13 people authored Apr 28, 2021
1 parent 10e2ec5 commit 4f8ee0f
Show file tree
Hide file tree
Showing 16 changed files with 484 additions and 33 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
## Maui.sln

### SDKS required
- Install the SDKs listed here https://github.com/xamarin/net6-samples
- Install the SDKs listed here https://github.com/dotnet/net6-mobile-samples

- And/or run the following

Expand Down
45 changes: 38 additions & 7 deletions eng/pipelines/handlers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,6 @@ stages:
demands:
- sh
- Xamarin.iOS
variables:
provisionator.xcode : '$(System.DefaultWorkingDirectory)/eng/provisioning/xcode.csx'
provisionator.path : '$(System.DefaultWorkingDirectory)/eng/provisioning/provisioning.csx'
provisionator.extraArguments : '--v'
steps:
- template: common/controlgallery-ios.yml

Expand All @@ -168,9 +164,6 @@ stages:
variables:
renderers: 'FAST'
outputfolder: 'newRenderers'
provisionator.xcode : '$(System.DefaultWorkingDirectory)/eng/provisioning/xcode.csx'
provisionator.path : '$(System.DefaultWorkingDirectory)/eng/provisioning/provisioning.csx'
provisionator.extraArguments : '--v'
steps:
- template: common/controlgallery-android.yml

Expand All @@ -189,6 +182,25 @@ stages:
vmImage: ${{ BuildPlatform.vmImage }}
steps:
- ${{ if eq(BuildPlatform.name, 'macos') }}:
- task: xamops.azdevex.provisionator-task.provisionator@1
displayName: 'Provision Xcode'
condition: ne(variables['REQUIRED_XCODE'], '')
inputs:
provisioning_script: $(provisionator.xcode)

- task: xamops.azdevex.provisionator-task.provisionator@1
displayName: 'Provisionator'
condition: eq(variables['provisioning'], 'true')
inputs:
provisioning_script: $(provisionator.xcode)
provisioning_extra_args: $(provisionator.extraArguments)

- script: |
echo "##vso[task.prependpath]/Library/Frameworks/Mono.framework/Versions/Current/Commands/"
echo "##vso[task.prependpath]~/Library/Developer/Xamarin/android-sdk-macosx"
displayName: 'Setup SDK Paths'
condition: ne(variables['osx2019VmPool'], 'Azure Pipelines')
- bash: |
set -x
mkdir -p ~/Library/Preferences/Xamarin
Expand Down Expand Up @@ -240,6 +252,25 @@ stages:
vmImage: ${{ BuildPlatform.vmImage }}
steps:
- ${{ if eq(BuildPlatform.name, 'macos') }}:
- task: xamops.azdevex.provisionator-task.provisionator@1
displayName: 'Provision Xcode'
condition: ne(variables['REQUIRED_XCODE'], '')
inputs:
provisioning_script: $(provisionator.xcode)

- task: xamops.azdevex.provisionator-task.provisionator@1
displayName: 'Provisionator'
condition: eq(variables['provisioning'], 'true')
inputs:
provisioning_script: $(provisionator.xcode)
provisioning_extra_args: $(provisionator.extraArguments)

- script: |
echo "##vso[task.prependpath]/Library/Frameworks/Mono.framework/Versions/Current/Commands/"
echo "##vso[task.prependpath]~/Library/Developer/Xamarin/android-sdk-macosx"
displayName: 'Setup SDK Paths'
condition: ne(variables['osx2019VmPool'], 'Azure Pipelines')
- bash: |
set -x
mkdir -p ~/Library/Preferences/Xamarin
Expand Down
6 changes: 6 additions & 0 deletions src/Compatibility/Core/src/WinUI/PickerRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ void ControlOnOpenAnimationCompleted(object sender, EventArgs eventArgs)
}
}

[PortHandler]
void OnControlSelectionChanged(object sender, WSelectionChangedEventArgs e)
{
if (Element != null)
Expand Down Expand Up @@ -173,11 +174,13 @@ void StartAnimationRefresh()
});
}

[PortHandler]
void UpdateCharacterSpacing()
{
Control.CharacterSpacing = Element.CharacterSpacing.ToEm();
}

[PortHandler]
void UpdateFont()
{
if (Control == null)
Expand Down Expand Up @@ -211,17 +214,20 @@ void UpdateFont()
_fontApplied = true;
}

[PortHandler]
void UpdateSelectedIndex()
{
Control.SelectedIndex = Element.SelectedIndex;
}

[PortHandler]
void UpdateTextColor()
{
Color color = Element.TextColor;
Control.Foreground = color.IsDefault() ? (_defaultBrush ?? Maui.ColorExtensions.ToNative(color)) : Maui.ColorExtensions.ToNative(color);
}

[PortHandler]
void UpdateTitle()
{
Control.Header = null;
Expand Down
2 changes: 1 addition & 1 deletion src/Controls/samples/Controls.Sample/Pages/MainPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,4 +337,4 @@ void AddTextResizeDemo(Microsoft.Maui.ILayout layout)
layout.Add(explicitWidthTestLabel);
}
}
}
}
2 changes: 1 addition & 1 deletion src/Controls/src/Core/AppHostBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ private static void ConfigureNativeServices(HostBuilderContext arg1, IServiceCol
#endif
}
}
}
}
6 changes: 6 additions & 0 deletions src/Controls/src/Xaml/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@

[assembly: XmlnsDefinition("http://schemas.microsoft.com/dotnet/2021/maui", "Microsoft.Maui.Controls.Xaml")]
[assembly: XmlnsDefinition("http://schemas.microsoft.com/dotnet/2021/maui/design", "Microsoft.Maui.Controls.Xaml")]
[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml", "Microsoft.Maui.Controls.Xaml")]
[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml", "System", AssemblyName = "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml", "System", AssemblyName = "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2009/xaml", "Microsoft.Maui.Controls.Xaml")]
[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2009/xaml", "System", AssemblyName = "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2009/xaml", "System", AssemblyName = "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]

#pragma warning disable CS0612 // Type or member is obsolete
[assembly: TypeForwardedTo(typeof(Microsoft.Maui.Controls.Xaml.Internals.INameScopeProvider))]
Expand Down
74 changes: 60 additions & 14 deletions src/Core/src/Handlers/Picker/PickerHandler.Windows.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,74 @@
using System;
using Microsoft.UI.Xaml.Controls;
#nullable enable
using WBrush = Microsoft.UI.Xaml.Media.Brush;
using WSelectionChangedEventArgs = Microsoft.UI.Xaml.Controls.SelectionChangedEventArgs;

namespace Microsoft.Maui.Handlers
{
public partial class PickerHandler : ViewHandler<IPicker, ComboBox>
public partial class PickerHandler : ViewHandler<IPicker, MauiComboBox>
{
protected override ComboBox CreateNativeView() => new ComboBox();
WBrush? _defaultForeground;

[MissingMapper]
public static void MapTitle(PickerHandler handler, IPicker view) { }
protected override MauiComboBox CreateNativeView()
{
var nativePicker = new MauiComboBox();

if (VirtualView != null)
nativePicker.ItemsSource = ((LockableObservableListWrapper)VirtualView.Items)._list;

return nativePicker;
}

[MissingMapper]
public static void MapSelectedIndex(PickerHandler handler, IPicker view) { }
protected override void ConnectHandler(MauiComboBox nativeView)
{
nativeView.SelectionChanged += OnControlSelectionChanged;
}

[MissingMapper]
public static void MapCharacterSpacing(PickerHandler handler, IPicker view) { }
protected override void DisconnectHandler(MauiComboBox nativeView)
{
nativeView.SelectionChanged -= OnControlSelectionChanged;
}

[MissingMapper]
public static void MapFont(PickerHandler handler, IPicker view) { }
protected override void SetupDefaults(MauiComboBox nativeView)
{
_defaultForeground = nativeView.Foreground;

[MissingMapper]
public static void MapTextColor(PickerHandler handler, IPicker view) { }
base.SetupDefaults(nativeView);
}

public static void MapTitle(PickerHandler handler, IPicker picker)
{
handler.NativeView?.UpdateTitle(picker);
}

public static void MapSelectedIndex(PickerHandler handler, IPicker picker)
{
handler.NativeView?.UpdateSelectedIndex(picker);
}

public static void MapCharacterSpacing(PickerHandler handler, IPicker picker)
{
handler.NativeView?.UpdateCharacterSpacing(picker);
}

public static void MapFont(PickerHandler handler, IPicker picker)
{
var fontManager = handler.GetRequiredService<IFontManager>();

handler.NativeView?.UpdateFont(picker, fontManager);
}

public static void MapTextColor(PickerHandler handler, IPicker picker)
{
handler.NativeView?.UpdateTextColor(picker, handler._defaultForeground);
}

[MissingMapper]
public static void MapHorizontalTextAlignment(PickerHandler handler, IPicker view) { }

void OnControlSelectionChanged(object? sender, WSelectionChangedEventArgs e)
{
if (VirtualView != null && NativeView != null)
VirtualView.SelectedIndex = NativeView.SelectedIndex;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ public static int ToEm(this double pt)
return Convert.ToInt32(pt * 0.0624f * 1000); // Coefficient for converting Pt to Em. The value is uniform spacing between characters, in units of 1/1000 of an em.
}
}
}
}
27 changes: 27 additions & 0 deletions src/Core/src/Platform/Windows/ColorConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using Microsoft.UI;
using WBrush = Microsoft.UI.Xaml.Media.Brush;
using WSolidColorBrush = Microsoft.UI.Xaml.Media.SolidColorBrush;

namespace Microsoft.Maui
{
public sealed class ColorConverter : UI.Xaml.Data.IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
var color = (Graphics.Color)value;
var defaultColorKey = (string)parameter;

WBrush defaultBrush = defaultColorKey != null ?
(WBrush)UI.Xaml.Application.Current.Resources[defaultColorKey] :
new WSolidColorBrush(Colors.Transparent);

return color.IsDefault() ? defaultBrush : color.ToNative();
}

public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
}
26 changes: 26 additions & 0 deletions src/Core/src/Platform/Windows/MauiCombobox.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#nullable enable
using Microsoft.UI.Xaml.Controls;

namespace Microsoft.Maui
{
public class MauiComboBox : ComboBox
{
public MauiComboBox()
{
DefaultStyleKey = typeof(MauiComboBox);

DropDownOpened += OnMauiComboBoxDropDownOpened;
SelectionChanged += OnMauiComboBoxSelectionChanged;
}

void OnMauiComboBoxDropDownOpened(object? sender, object e)
{
MinWidth = ActualWidth;
}

void OnMauiComboBoxSelectionChanged(object? sender, SelectionChangedEventArgs e)
{
MinWidth = 0;
}
}
}
43 changes: 43 additions & 0 deletions src/Core/src/Platform/Windows/PickerExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#nullable enable
using Microsoft.Maui.Graphics;
using Microsoft.UI.Xaml.Controls;
using WBrush = Microsoft.UI.Xaml.Media.Brush;

namespace Microsoft.Maui
{
public static class PickerExtensions
{
public static void UpdateTitle(this MauiComboBox nativeComboBox, IPicker picker)
{
nativeComboBox.Header = null;

nativeComboBox.HeaderTemplate = string.IsNullOrEmpty(picker.Title) ? null :
(UI.Xaml.DataTemplate)UI.Xaml.Application.Current.Resources["ComboBoxHeader"];

nativeComboBox.DataContext = picker;
}
public static void UpdateTextColor(this MauiComboBox nativeComboBox, IPicker picker)
{
nativeComboBox.UpdateTextColor(picker, null);
}

public static void UpdateTextColor(this MauiComboBox nativeComboBox, IPicker picker, WBrush? defaultForeground)
{
Color color = picker.TextColor;
nativeComboBox.Foreground = color.IsDefault() ? (defaultForeground ?? color.ToNative()) : color.ToNative();
}

public static void UpdateSelectedIndex(this MauiComboBox nativeComboBox, IPicker picker)
{
nativeComboBox.SelectedIndex = picker.SelectedIndex;
}

public static void UpdateCharacterSpacing(this MauiComboBox nativeComboBox, IPicker picker)
{
nativeComboBox.CharacterSpacing = picker.CharacterSpacing.ToEm();
}

public static void UpdateFont(this MauiComboBox nativeComboBox, IPicker picker, IFontManager fontManager) =>
nativeComboBox.UpdateFont(picker.Font, fontManager);
}
}
Loading

0 comments on commit 4f8ee0f

Please sign in to comment.