Skip to content

Commit

Permalink
Merge branch 'main' into fix-4734-ios
Browse files Browse the repository at this point in the history
  • Loading branch information
jsuarezruiz committed Jul 5, 2023
2 parents b1543a3 + 700944b commit b717d17
Show file tree
Hide file tree
Showing 49 changed files with 785 additions and 279 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Expand Up @@ -15,7 +15,7 @@
]
},
"microsoft.dotnet.xharness.cli": {
"version": "8.0.0-prerelease.23321.2",
"version": "8.0.0-prerelease.23326.1",
"commands": [
"xharness"
]
Expand Down
42 changes: 24 additions & 18 deletions .github/DEVELOPMENT.md
Expand Up @@ -2,45 +2,51 @@

This page contains steps to build and run the .NET MAUI repository from source. If you are looking to build apps with .NET MAUI please head over to the links in the [README](https://github.com/dotnet/maui/blob/main/README.md) to get started.

## Requirements

### Visual Studio
## Visual Studio
Follow the instructions here to install .NET MAUI with Visual Studio Stable:
- [Windows](https://learn.microsoft.com/dotnet/maui/get-started/installation?tabs=vswin)
- Select the 20348 SDK option inside Individual Components or [install 20348 manually](https://go.microsoft.com/fwlink/?linkid=2164145)
- If you know you have 20348 installed but are still getting an error around this SDK missing, trying uninstalling and reinstalling the SDK.
- [macOS](https://learn.microsoft.com/dotnet/maui/get-started/installation?tabs=vsmac)

### iOS / MacCatalyst
## iOS / MacCatalyst

iOS and MacCatalyst will require current stable Xcode. You can get this [here](https://developer.apple.com/download/more/?name=Xcode).

### Android
## Android

If you're missing any of the Android SDKs, Visual Studio should prompt you to install them. If it doesn't prompt you then use the [Android SDK Manager](https://learn.microsoft.com/xamarin/android/get-started/installation/android-sdk) to install the necessary SDKs.

### Opening the Repository
## Building the Build Tasks
Before opening the solution in Visual Studio you **MUST** build the build tasks. You have two options:

```dotnetcli
dotnet tool restore
dotnet cake --target=VS --workloads=global
```
- Do this to build the build tasks and launch Visual Studio, automatically opening the default solution:

*NOTE*: Intellisense takes a decent amount of time to fully process your solution. It will eventually work through all the necessary tasks. If you are having intellisense issues, usually unloading/reloading the `maui.core` and `maui.controls` projects will resolve.
```dotnetcli
dotnet tool restore
dotnet cake --target=VS --workloads=global
```

#### MacOS
*NOTE*: `--workloads=global` means use the normal (globally installed) .NET workloads.

All of the above cake commands should work fine on `MacOS`.
- OR do this to just build the build tasks. You can then launch Visual Studio manually and open the solution of your choosing:

#### Solutions
```dotnetcli
dotnet tool restore
dotnet build ./Microsoft.Maui.BuildTasks.slnf
```

## Available Solutions
- Microsoft.Maui.sln
- Kitchen sink solution. This includes all of the `Compatibility` projects and all of the platforms that we compile for. It is very unlikely you will need to use this solution for development.
- Microsoft.Maui-dev.sln
- `Microsoft.Maui.sln` but without the `Compatibility` projects. Because we can't detect solution filters inside `MSBuild` we had to create a separate `sln` without the `Compatibility` projects.
- Microsoft.Maui-mac.slnf
- `Microsoft.Maui-dev.sln` with all of the `Windows` targets filtered out
- Microsoft.Maui-windows.slnf
- `Microsoft.Maui-dev.sln` with all of the targets you can't build on `Windows` removed (GTK/Catalyst).
- `Microsoft.Maui-dev.sln` with all of the targets you can't build on `Windows` removed (GTK/Catalyst). Default solution on Windows.
- Microsoft.Maui-mac.slnf
- `Microsoft.Maui-dev.sln` with all of the `Windows` targets filtered out. Default solution on Mac.

*NOTE*: IntelliSense takes a decent amount of time to fully process your solution. It will eventually work through all the necessary tasks. If you are having IntelliSense issues, usually unloading/reloading the `maui.core` and `maui.controls` projects will resolve.

## What branch should I use?
- main
Expand Down Expand Up @@ -174,7 +180,7 @@ public static int foo = 2130771968;

### Compile using a local `bin\dotnet`

This method ensures that the workloads installed by Visual Studio won't get changed. This is usually the best method to use if you want to preserve the global state of your machine. This method will also use the versions that are specific to the branch you are on which is a good way to ensure compatibility.
This method will use the .NET and workload versions that are specific to the branch you are on, which is a good way to ensure compatibility.

#### Cake

Expand Down
12 changes: 6 additions & 6 deletions eng/Version.Details.xml
Expand Up @@ -51,17 +51,17 @@
<Uri>https://github.com/dotnet/templating</Uri>
<Sha>3f4da9ced34942d83054e647f3b1d9d7dde281e8</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.XHarness.TestRunners.Common" Version="8.0.0-prerelease.23321.2">
<Dependency Name="Microsoft.DotNet.XHarness.TestRunners.Common" Version="8.0.0-prerelease.23326.1">
<Uri>https://github.com/dotnet/xharness</Uri>
<Sha>d59c983920609fddd0d378921e36388c3bae8d00</Sha>
<Sha>747cfb23923a644ee43b012c5bcd7b738a485b8e</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.XHarness.TestRunners.Xunit" Version="8.0.0-prerelease.23321.2">
<Dependency Name="Microsoft.DotNet.XHarness.TestRunners.Xunit" Version="8.0.0-prerelease.23326.1">
<Uri>https://github.com/dotnet/xharness</Uri>
<Sha>d59c983920609fddd0d378921e36388c3bae8d00</Sha>
<Sha>747cfb23923a644ee43b012c5bcd7b738a485b8e</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.XHarness.CLI" Version="8.0.0-prerelease.23321.2">
<Dependency Name="Microsoft.DotNet.XHarness.CLI" Version="8.0.0-prerelease.23326.1">
<Uri>https://github.com/dotnet/xharness</Uri>
<Sha>d59c983920609fddd0d378921e36388c3bae8d00</Sha>
<Sha>747cfb23923a644ee43b012c5bcd7b738a485b8e</Sha>
</Dependency>
</ProductDependencies>
</Dependencies>
6 changes: 3 additions & 3 deletions eng/Versions.props
Expand Up @@ -69,9 +69,9 @@
<_HarfBuzzSharpVersion>2.8.2.2</_HarfBuzzSharpVersion>
<_SkiaSharpNativeAssetsVersion>0.0.0-commit.193b587552cb0ed39372a049d7e6c692db98c267.483</_SkiaSharpNativeAssetsVersion>
<MicrosoftTemplateEngineTasksVersion>7.0.100-preview.5.22226.1</MicrosoftTemplateEngineTasksVersion>
<MicrosoftDotNetXHarnessTestRunnersCommonVersion>8.0.0-prerelease.23321.2</MicrosoftDotNetXHarnessTestRunnersCommonVersion>
<MicrosoftDotNetXHarnessTestRunnersXunitVersion>8.0.0-prerelease.23321.2</MicrosoftDotNetXHarnessTestRunnersXunitVersion>
<MicrosoftDotNetXHarnessCLIVersion>8.0.0-prerelease.23321.2</MicrosoftDotNetXHarnessCLIVersion>
<MicrosoftDotNetXHarnessTestRunnersCommonVersion>8.0.0-prerelease.23326.1</MicrosoftDotNetXHarnessTestRunnersCommonVersion>
<MicrosoftDotNetXHarnessTestRunnersXunitVersion>8.0.0-prerelease.23326.1</MicrosoftDotNetXHarnessTestRunnersXunitVersion>
<MicrosoftDotNetXHarnessCLIVersion>8.0.0-prerelease.23326.1</MicrosoftDotNetXHarnessCLIVersion>
<TizenUIExtensionsVersion>0.9.0</TizenUIExtensionsVersion>
<SvgSkiaPackageVersion>0.5.13</SvgSkiaPackageVersion>
<FizzlerPackageVersion>1.2.0</FizzlerPackageVersion>
Expand Down
25 changes: 0 additions & 25 deletions src/Controls/docs/Microsoft.Maui.Controls/Accelerator.xml
Expand Up @@ -120,31 +120,6 @@
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="Modifiers">
<MemberSignature Language="C#" Value="public System.Collections.Generic.IEnumerable&lt;string&gt; Modifiers { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Collections.Generic.IEnumerable`1&lt;string&gt; Modifiers" />
<MemberSignature Language="DocId" Value="P:Microsoft.Maui.Controls.Accelerator.Modifiers" />
<MemberSignature Language="F#" Value="member this.Modifiers : seq&lt;string&gt; with get, set" Usage="Microsoft.Maui.Controls.Accelerator.Modifiers" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyName>Microsoft.Maui.Controls.Core</AssemblyName>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName>System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Collections.Generic.IEnumerable&lt;System.String&gt;</ReturnType>
</ReturnValue>
<Docs>
<summary>For internal use only.</summary>
<value>To be added.</value>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="op_Implicit">
<MemberSignature Language="C#" Value="public static implicit operator Microsoft.Maui.Controls.Accelerator (string accelerator);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig specialname class Microsoft.Maui.Controls.Accelerator op_Implicit(string accelerator) cil managed" />
Expand Down
Expand Up @@ -10,10 +10,10 @@
<Button Text="Increment by 1 (or right-click me)" Clicked="OnIncrementByOneClicked" FontSize="30" BackgroundColor="DarkGray">
<FlyoutBase.ContextFlyout>
<MenuFlyout>
<MenuFlyoutItem Text="Increment by 10" Clicked="OnIncrementMenuItemClicked" CommandParameter="10"></MenuFlyoutItem>
<MenuFlyoutItem Text="Increment by 20" Clicked="OnIncrementMenuItemClicked" CommandParameter="20"></MenuFlyoutItem>
<MenuFlyoutItem Text="Increment by 30 (disabled)" Clicked="OnIncrementMenuItemClicked" CommandParameter="30" x:Name="bbb"></MenuFlyoutItem>
<MenuFlyoutItem Text="Increment by 40 (dynamic enabled/disabled)" Command="{Binding DynamicEnabledCommand}" CommandParameter="40"></MenuFlyoutItem>
<MenuFlyoutItem x:Name="Increment10MenuFlyoutItem" Text="Increment by 10" Clicked="OnIncrementMenuItemClicked" CommandParameter="10" />
<MenuFlyoutItem x:Name="Increment20MenuFlyoutItem" Text="Increment by 20" Clicked="OnIncrementMenuItemClicked" CommandParameter="20" />
<MenuFlyoutItem Text="Increment by 30 (disabled)" Clicked="OnIncrementMenuItemClicked" CommandParameter="30" x:Name="bbb" />
<MenuFlyoutItem Text="Increment by 40 (dynamic enabled/disabled)" Command="{Binding DynamicEnabledCommand}" CommandParameter="40" />
<MenuFlyoutSubItem Text="More options">
<MenuFlyoutItem Text="Increment by 1,000!" Clicked="OnIncrementMenuItemClicked" CommandParameter="1000"></MenuFlyoutItem>
<MenuFlyoutItem Text="Increment by 1,000,000!" Clicked="OnIncrementMenuItemClicked" CommandParameter="1000000"></MenuFlyoutItem>
Expand Down
Expand Up @@ -42,6 +42,10 @@ public ContextFlyoutPage()
bbb.IsEnabled = false;

ContextMenuWebView.HandlerChanged += OnWebViewHandlerChanged;

MenuItem.SetAccelerator(Increment10MenuFlyoutItem, Accelerator.FromString("alt+ctrl+a"));
MenuItem.SetAccelerator(Increment20MenuFlyoutItem, Accelerator.FromString("ctrl+b"));
MenuItem.SetAccelerator(bbb, Accelerator.FromString("c"));
}


Expand Down
@@ -1,10 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Graphics;

namespace Maui.Controls.Sample.Pages
{
Expand All @@ -13,6 +10,8 @@ public partial class MenuBarPage
public MenuBarPage()
{
InitializeComponent();

MenuItem.SetAccelerator(CustomFileMenuFlyoutItem, Accelerator.FromString("ctrl+shift+f"));
}

void ItemClicked(object sender, EventArgs e)
Expand Down
14 changes: 7 additions & 7 deletions src/Controls/samples/Controls.Sample/Pages/Core/MenuBarPage.xaml
Expand Up @@ -6,13 +6,13 @@
xmlns:views="clr-namespace:Maui.Controls.Sample.Pages.Base">
<views:BasePage.MenuBarItems>
<MenuBarItem Text="Before File">
<MenuFlyoutItem Clicked="ItemClicked" Text="Before File Action"></MenuFlyoutItem>
<MenuFlyoutItem Clicked="ItemClicked" Text="Before File Action" Accelerator="b" />
<MenuFlyoutItem Text="Cool item 1"></MenuFlyoutItem>
<MenuFlyoutSeparator />
<MenuFlyoutItem Text="Cool item 2"></MenuFlyoutItem>
</MenuBarItem>
<MenuBarItem Text="File">
<MenuFlyoutItem Clicked="ItemClicked" Text="Custom File">
<MenuFlyoutItem x:Name="CustomFileMenuFlyoutItem" Clicked="ItemClicked" Text="Custom File" >
<MenuFlyoutItem.IconImageSource>
<FontImageSource
FontAutoScalingEnabled="False"
Expand All @@ -23,17 +23,17 @@
</MenuFlyoutItem>
</MenuBarItem>
<MenuBarItem Text="Custom Menu">
<MenuFlyoutItem Clicked="ItemClicked" Text="Item 1"></MenuFlyoutItem>
<MenuFlyoutItem Clicked="ItemClicked" Text="Item 1" Accelerator="ctrl+5" />
<MenuFlyoutSubItem Clicked="ItemClicked" Text="Sub Menu 1">
<MenuFlyoutItem IconImageSource="mic.png" Clicked="ItemClicked" Text="Flyout item 1"></MenuFlyoutItem>
<MenuFlyoutItem IconImageSource="coffee.png" Clicked="ItemClicked" Text="Flyout item 2"></MenuFlyoutItem>
<MenuFlyoutItem IconImageSource="mic.png" Clicked="ItemClicked" Text="Flyout item 1" Accelerator="Shift+M" />
<MenuFlyoutItem IconImageSource="coffee.png" Clicked="ItemClicked" Text="Flyout item 2" Accelerator="ALT+C" />
</MenuFlyoutSubItem>
</MenuBarItem>
</views:BasePage.MenuBarItems>
<views:BasePage.Content>
<VerticalStackLayout Margin="12">
<Label x:Name="menuLabel" Text="You clicked on Menu Item:"></Label>
<Button Text="Toggle Menu Bar Item" Clicked="ToggleMenuBarItem"></Button>
<Label x:Name="menuLabel" Text="You clicked on Menu Item:" />
<Button Text="Toggle Menu Bar Item" Clicked="ToggleMenuBarItem" />
</VerticalStackLayout>
</views:BasePage.Content>
</views:BasePage>
68 changes: 44 additions & 24 deletions src/Controls/src/Core/Accelerator.cs
@@ -1,4 +1,4 @@
#nullable disable
#nullable disable
using System;
using System.Collections.Generic;
using System.ComponentModel;
Expand All @@ -7,36 +7,56 @@ namespace Microsoft.Maui.Controls
{
/// <include file="../../docs/Microsoft.Maui.Controls/Accelerator.xml" path="Type[@FullName='Microsoft.Maui.Controls.Accelerator']/Docs/*" />
[System.ComponentModel.TypeConverter(typeof(AcceleratorTypeConverter))]
public class Accelerator
public class Accelerator : IAccelerator
{
const char Separator = '+';
string _text;
const string Separator = "+";
readonly string _text;
readonly List<string> _modifiers;

internal Accelerator(string text)
internal Accelerator(string text, IEnumerable<string> modifiers, string key)
{
if (string.IsNullOrEmpty(text))
throw new ArgumentNullException(nameof(text));

_text = text;
Key = key;
_modifiers = new List<string>(modifiers);
}

/// <include file="../../docs/Microsoft.Maui.Controls/Accelerator.xml" path="//Member[@MemberName='Modifiers']/Docs/*" />
[EditorBrowsable(EditorBrowsableState.Never)]
public IEnumerable<string> Modifiers { get; set; }
/// <summary>
/// Gets the modifiers for the accelerator.
/// </summary>
public IEnumerable<string> Modifiers => _modifiers;

IReadOnlyList<string> IAccelerator.Modifiers => _modifiers;

/// <include file="../../docs/Microsoft.Maui.Controls/Accelerator.xml" path="//Member[@MemberName='Keys']/Docs/*" />
[EditorBrowsable(EditorBrowsableState.Never)]
public IEnumerable<string> Keys { get; set; }
[Obsolete("Use Key instead.")]
public IEnumerable<string> Keys
{
get => Key is null ? null : new[] { Key };
}

/// <summary>
/// Gets the key for the accelerator.
/// </summary>
public string Key { get; }

/// <include file="../../docs/Microsoft.Maui.Controls/Accelerator.xml" path="//Member[@MemberName='FromString']/Docs/*" />
public static Accelerator FromString(string text)
{
var accelarat = new Accelerator(text);
if (string.IsNullOrEmpty(text))
throw new ArgumentNullException(nameof(text));

var str = text;
var modifiers = new List<string>();
var key = string.Empty;

var acceleratorParts = text.Split(Separator);
var acceleratorParts = text.Split(new[] { Separator }, StringSplitOptions.None);

if (acceleratorParts.Length > 1)
{
var modifiers = new List<string>();
for (int i = 0; i < acceleratorParts.Length; i++)
{
var modifierMask = acceleratorParts[i];
Expand All @@ -51,27 +71,27 @@ public static Accelerator FromString(string text)
case "win":
modifiers.Add(modiferMaskLower);
#if NETSTANDARD2_0
text = text.Replace(modifierMask, "");
text = text.Replace(modifierMask, string.Empty);
#else
text = text.Replace(modifierMask, "", StringComparison.Ordinal);
text = text.Replace(modifierMask, string.Empty, StringComparison.Ordinal);
#endif
break;
}
}
accelarat.Modifiers = modifiers;

}

if (text != Separator.ToString())
{
var keys = text.Split(new char[] { Separator }, StringSplitOptions.RemoveEmptyEntries);
accelarat.Keys = keys;
}
else
if (!string.Equals(text, Separator, StringComparison.Ordinal))
{
accelarat.Keys = new[] { text };
#if NETSTANDARD2_0
text = text.Replace(Separator, string.Empty);
#else
text = text.Replace(Separator, string.Empty, StringComparison.Ordinal);
#endif
}
return accelarat;

key = text;

return new Accelerator(str, modifiers, key);
}

/// <include file="../../docs/Microsoft.Maui.Controls/Accelerator.xml" path="//Member[@MemberName='ToString']/Docs/*" />
Expand Down

0 comments on commit b717d17

Please sign in to comment.