UIAction initializer with all parameters
- Dominant language
- C#
- Stars
- 2.9k
- Forks
- 576
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 123
Description
I wish to create a UIAction with all desired attributes (e.g. `UIMenuElementAttribute.Destructive` or `UIMenuElementState.On`) in one method call so that I can quickly create UIMenus without having to assign actions to a local variable first and setting a property.
### Expected Behavior
Create UIAction with attributes in constructor [like this](https://developer.apple.com/documentation/uikit/uiaction/3358590-init)
```
return UIMenu.Create(menuTitle, new[]
{
UIAction.Create("Delete", UIImage.GetSystemImage("trash"), attributes: UIMenuElementAttributes.Destructive, handler: a => DeleteStuff());
};
```
or
```
return UIMenu.Create(menuTitle, new[]
{
new UIAction("Delete", UIImage.GetSystemImage("trash"), a => DeleteStuff()) { Attributes = UIMenuElementAttributes.Destructive };
};
```
### Actual Behavior
```
var action = UIAction.Create("Delete", UIImage.GetSystemImage("trash"), null, a => DeleteStuff());
action.Attributes = UIMenuElementAttributes.Destructive;
return UIMenu.Create(menuTitle, new[]
{
action
};
```
### Environment
```
=== Visual Studio Community 2019 for Mac ===
Version 8.9.3 (build 13)
Installation UUID: 6131427e-67b0-4076-bcff-3753bb74975a
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638)
Package version: 612000125
=== Mono Framework MDK ===
Runtime:
Mono 6.12.0.125 (2020-02/8c552e98bd6) (64-bit)
Package version: 612000125
=== Roslyn (Language Service) ===
3.9.0-6.21152.10+c10f884b30737542ddd84ca889a4aad9281ce210
=== NuGet ===
Version: 5.8.0.6860
=== .NET Core SDK ===
SDK: /usr/local/share/dotnet/sdk/5.0.201/Sdks
SDK Versions:
5.0.201
3.1.407
MSBuild SDKs: /Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/bin/MSBuild/Current/bin/Sdks
=== .NET Core Runtime ===
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
5.0.4
3.1.13
=== .NET Core 3.1 SDK ===
SDK: 3.1.407
=== Xamarin.Profiler ===
Version: 1.6.15.68
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler
=== Updater ===
Version: 11
=== Xamarin Designer ===
Version: 16.9.0.316
Hash: 2241b204a
Branch: tags/vsm-rel/d16.9-4540908
Build date: 2021-03-10 21:18:10 UTC
=== Apple Developer Tools ===
Xcode 12.4 (17801)
Build 12D4e
=== Xamarin.Mac ===
Version: 7.8.2.5 (Visual Studio Community)
Hash: 3836759d4
Branch: d16-9
Build date: 2021-02-10 17:56:43-0500
=== Xamarin.iOS ===
Version: 14.14.2.5 (Visual Studio Community)
Hash: 3836759d4
Branch: d16-9
Build date: 2021-02-10 17:56:44-0500
=== Xamarin.Android ===
Not Installed
=== Microsoft OpenJDK for Mobile ===
Java SDK: Not Found
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL
=== Android SDK Manager ===
Version: 16.9.0.22
Hash: a391de2
Branch: remotes/origin/d16-9
Build date: 2021-03-05 18:52:30 UTC
=== Android Device Manager ===
Version: 16.9.0.17
Hash: fc2b3db
Branch: remotes/origin/d16-9
Build date: 2021-03-05 18:52:54 UTC
=== Build Information ===
Release ID: 809030013
Git revision: 9f03968ddc9d55da84019ce7a972b9fe225009fe
Build date: 2021-03-18 10:15:43-04
Build branch: release-8.9
Xamarin extensions: 9f03968ddc9d55da84019ce7a972b9fe225009fe
=== Operating System ===
Mac OS X 10.16.0
Darwin 20.3.0 Darwin Kernel Version 20.3.0
Thu Jan 21 00:06:51 PST 2021
root:xnu-7195.81.3~1/RELEASE_ARM64_T8101 x86_64
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at the UIAction.Create entry point and compare its available parameters with Apple's UIKit UIAction initializer documentation linked in the issue. Done means callers can provide the desired attributes during UIAction creation, as shown in the requested examples, without assigning the action to a local variable first.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, ios
- Domain
- mobile
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100