Merge pull request #87 from asklar/typingsContentMapStyle

Better typings
This commit is contained in:
Alexander Sklar 2021-07-04 15:14:57 -07:00 коммит произвёл GitHub
Родитель 17567a0d9f 74db02f4be
Коммит 64e2417a44
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
14 изменённых файлов: 173 добавлений и 86 удалений

Просмотреть файл

@ -27,7 +27,7 @@ If you have questions about a scenario you don't see below, please [file an issu
```jsx
<StackPanel orientation="horizontal">
<HyperlinkButton content={{ string: "Click me!" }} onClick={(args) => {
<HyperlinkButton content="Click me!" onClick={(args) => {
alert(`clicked! Native event args: ${JSON.stringify(args.nativeEvent)}`);
}} />
@ -36,7 +36,7 @@ If you have questions about a scenario you don't see below, please [file an issu
</Border>
<TextBlock text="this is another textblock" foreground='green' textAlignment="center" />
<Button content={{ string: "this is a button" }} onClick={() => { alert("you clicked the button!"); }} />
<Button content="this is a button" onClick={() => { alert("you clicked the button!"); }} />
</StackPanel>
```
@ -69,7 +69,7 @@ If you have questions about a scenario you don't see below, please [file an issu
</MenuFlyout>
</TextBox>
<Button content={{ string: `Last selected option = ${option} ${count}` }}
<Button content={`Last selected option = ${option} ${count}`}
onClick={(a) => {
setIsOpen(true); }} />
```
@ -77,12 +77,12 @@ If you have questions about a scenario you don't see below, please [file an issu
## ComboBox
```jsx
<ComboBox text="this is a combobox" description={{ string: "best bois" }}
<ComboBox text="this is a combobox" description="best bois"
onSelectionChanged={(args) =>
{ alert(`sel changed! Native event args: ${JSON.stringify(args.nativeEvent)}`); }
} >
<ComboBoxItem content={{ string: "garfield" }} foreground="black" />
<ComboBoxItem content={{ string: "snoopy" }} foreground="black" />
<ComboBoxItem content="garfield" foreground="black" />
<ComboBoxItem content="snoopy" foreground="black" />
</ComboBox>
```
@ -110,10 +110,10 @@ Note that only react-native-xaml components will respect the `gridRow`/`gridColu
```jsx
<NavigationView style={{ height: 200, width: 120 }}>
<NavigationViewItem content={{ string: "item 1" }}>
<NavigationViewItem content="item 1">
<FontIcon glyph="&#xE790;" />
</NavigationViewItem>
<NavigationViewItem content={{ string: "item 2" }} />
<NavigationViewItem content="item 2" />
</NavigationView>
```
@ -161,7 +161,7 @@ Note that only react-native-xaml components will respect the `gridRow`/`gridColu
react-native-xaml supports raising events and sending event args to the registered JavaScript event handlers. The native XAML event args object is projected to JavaScript through the `nativeEvent` method:
```jsx
<HyperlinkButton content={{ string: "Click me!" }}
<HyperlinkButton content="Click me!"
onClick={(args) => {
alert(JSON.stringify(args.nativeEvent));
}} />

Просмотреть файл

@ -0,0 +1,11 @@
using System.Collections.Generic;
namespace Codegen
{
public struct FakeEnum
{
public string Name { get; set; }
public Dictionary<string, int> Values { get; set; }
}
}

Просмотреть файл

@ -289,8 +289,8 @@ namespace Codegen
var typeCreatorGen = new TypeCreator(creatableTypes).TransformText();
var propertiesGen = new TypeProperties(properties, fakeProps, syntheticProps).TransformText();
Util.fakeEnums.Add(new Util.FakeEnum() { Name = "AppBarButtonPriority", Values = new Dictionary<string, int>() { { "Primary", 0 }, { "Secondary", 1 } } });
Util.fakeEnums.Add(new Util.FakeEnum() { Name = "NavigationViewItemPriority", Values = new Dictionary<string, int>() { { "MenuItem", 0 }, { "FooterMenuItem", 1 } } });
Util.fakeEnums.Add(new FakeEnum() { Name = "AppBarButtonPriority", Values = new Dictionary<string, int>() { { "Primary", 0 }, { "Secondary", 1 } } });
Util.fakeEnums.Add(new FakeEnum() { Name = "NavigationViewItemPriority", Values = new Dictionary<string, int>() { { "MenuItem", 0 }, { "FooterMenuItem", 1 } } });
var tsEnumsGen = new TSEnums().TransformText();
var eventsGen = new TypeEvents(events).TransformText();
@ -348,13 +348,13 @@ namespace Codegen
}
}
private static void UpdateFile(string path, string content)
private static void UpdateFile(string path, string newContent)
{
var existing = File.Exists(path) ? File.ReadAllText(path) : "";
if (existing != content)
if (existing != newContent)
{
Console.WriteLine($" Writing {path}");
File.WriteAllText(path, content);
File.WriteAllText(path, newContent);
}
}

Просмотреть файл

@ -0,0 +1,14 @@
using MiddleweightReflection;
namespace Codegen
{
public class SyntheticProperty
{
public string Name { get; set; }
public MrType DeclaringType { get; set; }
public MrType PropertyType { get; set; }
public string FakePropertyType { get; set; }
public string Comment { get; set; }
}
}

Просмотреть файл

@ -83,14 +83,14 @@ foreach (var prop in type.GetProperties().Where(p => Util.ShouldEmitPropertyMeta
this.Write(" ");
#line 22 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSProps.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(Util.ToJsName(prop.GetName())));
this.Write(this.ToStringHelper.ToStringWithCulture(Util.ToJsName(prop)));
#line default
#line hidden
this.Write("?: ");
#line 22 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSProps.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(Util.GetTypeScriptType(prop.GetPropertyType())));
this.Write(this.ToStringHelper.ToStringWithCulture(Util.GetTypeScriptType(prop)));
#line default
#line hidden
@ -105,14 +105,14 @@ foreach (var prop in FakeProps.Where(p => type == p.DeclaringType)) {
this.Write(" ");
#line 25 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSProps.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(Util.ToJsName(prop.GetName())));
this.Write(this.ToStringHelper.ToStringWithCulture(Util.ToJsName(prop)));
#line default
#line hidden
this.Write("?: ");
#line 25 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSProps.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(Util.GetTypeScriptType(prop.GetPropertyType())));
this.Write(this.ToStringHelper.ToStringWithCulture(Util.GetTypeScriptType(prop)));
#line default
#line hidden
@ -141,7 +141,7 @@ foreach (var prop in SyntheticProps.Where(p => type == p.DeclaringType)) {
this.Write("?: ");
#line 31 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSProps.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(prop.PropertyType != null ? Util.GetTypeScriptType(prop.PropertyType) : Util.GetTypeScriptType(prop.FakePropertyType)));
this.Write(this.ToStringHelper.ToStringWithCulture(Util.GetTypeScriptType(prop)));
#line default
#line hidden

Просмотреть файл

@ -19,16 +19,16 @@ if (typeProp != "") { #>
type: <#= typeProp #>;
<# }
foreach (var prop in type.GetProperties().Where(p => Util.ShouldEmitPropertyMetadata(p))) { #>
<#= Util.ToJsName(prop.GetName()) #>?: <#= Util.GetTypeScriptType(prop.GetPropertyType()) #>;
<#= Util.ToJsName(prop) #>?: <#= Util.GetTypeScriptType(prop) #>;
<# }
foreach (var prop in FakeProps.Where(p => type == p.DeclaringType)) { #>
<#= Util.ToJsName(prop.GetName()) #>?: <#= Util.GetTypeScriptType(prop.GetPropertyType()) #>; // synthetic property
<#= Util.ToJsName(prop) #>?: <#= Util.GetTypeScriptType(prop) #>; // synthetic property
<# }
foreach (var prop in SyntheticProps.Where(p => type == p.DeclaringType)) { #>
/**
* <#= prop.Comment #>
*/
<#= Util.ToJsName(prop.Name) #>?: <#= prop.PropertyType != null ? Util.GetTypeScriptType(prop.PropertyType) : Util.GetTypeScriptType(prop.FakePropertyType) #>; // synthetic property
<#= Util.ToJsName(prop.Name) #>?: <#= Util.GetTypeScriptType(prop) #>; // synthetic property
<# }
foreach (var evt in type.GetEvents()) { #>
on<#= evt.GetName() #>?: (event: NativeSyntheticEvent<undefined>) => void;

Просмотреть файл

@ -80,7 +80,7 @@ winrt::Windows::Foundation::IInspectable AsUnwrappedType(const winrt::Windows::F
this.Write(" { MAKE_KEY(\"");
#line 31 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TypeProperties.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(Util.ToJsName(p.GetName())));
this.Write(this.ToStringHelper.ToStringWithCulture(Util.ToJsName(p)));
#line default
#line hidden
@ -122,7 +122,7 @@ winrt::Windows::Foundation::IInspectable AsUnwrappedType(const winrt::Windows::F
this.Write(">, ViewManagerPropertyType::");
#line 31 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TypeProperties.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(Util.GetVMPropertyType(p.GetPropertyType())));
this.Write(this.ToStringHelper.ToStringWithCulture(Util.GetVMPropertyType(p)));
#line default
#line hidden
@ -201,7 +201,7 @@ winrt::Windows::Foundation::IInspectable AsUnwrappedType(const winrt::Windows::F
this.Write(" { MAKE_KEY(\"");
#line 45 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TypeProperties.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(Util.ToJsName(p.GetName())));
this.Write(this.ToStringHelper.ToStringWithCulture(Util.ToJsName(p)));
#line default
#line hidden
@ -229,7 +229,7 @@ winrt::Windows::Foundation::IInspectable AsUnwrappedType(const winrt::Windows::F
this.Write(", ViewManagerPropertyType::");
#line 45 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TypeProperties.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(Util.GetVMPropertyType(p.GetPropertyType())));
this.Write(this.ToStringHelper.ToStringWithCulture(Util.GetVMPropertyType(p)));
#line default
#line hidden
@ -277,7 +277,7 @@ winrt::Windows::Foundation::IInspectable AsUnwrappedType(const winrt::Windows::F
this.Write(", ViewManagerPropertyType::");
#line 48 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TypeProperties.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(p.PropertyType != null ? Util.GetVMPropertyType(p.PropertyType) : Util.GetVMPropertyType(p.FakePropertyType)));
this.Write(this.ToStringHelper.ToStringWithCulture(Util.GetVMPropertyType(p)));
#line default
#line hidden
@ -300,14 +300,14 @@ winrt::Windows::Foundation::IInspectable AsUnwrappedType(const winrt::Windows::F
this.Write(" nativeProps.Insert(winrt::to_hstring(\"");
#line 56 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TypeProperties.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(Util.ToJsName(p.GetName())));
this.Write(this.ToStringHelper.ToStringWithCulture(Util.ToJsName(p)));
#line default
#line hidden
this.Write("\"), ViewManagerPropertyType::");
#line 56 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TypeProperties.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(Util.GetVMPropertyType(p.GetPropertyType())));
this.Write(this.ToStringHelper.ToStringWithCulture(Util.GetVMPropertyType(p)));
#line default
#line hidden

Просмотреть файл

@ -28,7 +28,7 @@ winrt::Windows::Foundation::IInspectable AsUnwrappedType(const winrt::Windows::F
/*static*/ const PropInfo xamlPropertyMap[] = {
<# foreach (var p in Properties) { #>
{ MAKE_KEY("<#= Util.ToJsName(p.GetName()) #>"), <#= Util.DerivesFrom(p.DeclaringType, $"{XamlNames.XamlNamespace}.FrameworkElement") ? "AsType" : "AsUnwrappedType" #><<#= Util.GetCppWinRTType(p.DeclaringType) #>>, []() { return <#= Util.GetCppWinRTType(p.DeclaringType) #>::<#= p.GetName() #>Property(); }, SetPropValue<<#= Util.GetCppWinRTType(p.GetPropertyType()) #>>, ViewManagerPropertyType::<#= Util.GetVMPropertyType(p.GetPropertyType()) #> },
{ MAKE_KEY("<#= Util.ToJsName(p) #>"), <#= Util.DerivesFrom(p.DeclaringType, $"{XamlNames.XamlNamespace}.FrameworkElement") ? "AsType" : "AsUnwrappedType" #><<#= Util.GetCppWinRTType(p.DeclaringType) #>>, []() { return <#= Util.GetCppWinRTType(p.DeclaringType) #>::<#= p.GetName() #>Property(); }, SetPropValue<<#= Util.GetCppWinRTType(p.GetPropertyType()) #>>, ViewManagerPropertyType::<#= Util.GetVMPropertyType(p) #> },
<# } #>
};
@ -42,10 +42,10 @@ void Set<#= p.Name #>_<#= p.DeclaringType.GetName() #>(const xaml::DependencyObj
/*static*/ const PropInfo fakeProps[] = {
<# foreach (var p in FakeProps) { #>
{ MAKE_KEY("<#= Util.ToJsName(p.GetName()) #>"), AsUnwrappedType<<#= Util.GetCppWinRTType(p.DeclaringType) #>>, nullptr, Set<#= p.GetName() #>_<#= p.DeclaringType.GetName() #>, ViewManagerPropertyType::<#= Util.GetVMPropertyType(p.GetPropertyType()) #> },
{ MAKE_KEY("<#= Util.ToJsName(p) #>"), AsUnwrappedType<<#= Util.GetCppWinRTType(p.DeclaringType) #>>, nullptr, Set<#= p.GetName() #>_<#= p.DeclaringType.GetName() #>, ViewManagerPropertyType::<#= Util.GetVMPropertyType(p) #> },
<# } #>
<# foreach (var p in SyntheticProps) { #>
{ MAKE_KEY("<#= Util.ToJsName(p.Name) #>"), AsType<<#= Util.GetCppWinRTType(p.DeclaringType) #>>, nullptr, Set<#= p.Name #>_<#= p.DeclaringType.GetName() #>, ViewManagerPropertyType::<#= p.PropertyType != null ? Util.GetVMPropertyType(p.PropertyType) : Util.GetVMPropertyType(p.FakePropertyType) #> },
{ MAKE_KEY("<#= Util.ToJsName(p.Name) #>"), AsType<<#= Util.GetCppWinRTType(p.DeclaringType) #>>, nullptr, Set<#= p.Name #>_<#= p.DeclaringType.GetName() #>, ViewManagerPropertyType::<#= Util.GetVMPropertyType(p) #> },
<# } #>
};
@ -53,7 +53,7 @@ void Set<#= p.Name #>_<#= p.DeclaringType.GetName() #>(const xaml::DependencyObj
#ifdef USE_CRC32
void XamlMetadata::PopulateNativeProps(winrt::Windows::Foundation::Collections::IMap<winrt::hstring, ViewManagerPropertyType>& nativeProps) const {
<# foreach (MiddleweightReflection.MrProperty p in Properties.Distinct(new Codegen.NameEqualityComparer())) { #>
nativeProps.Insert(winrt::to_hstring("<#= Util.ToJsName(p.GetName()) #>"), ViewManagerPropertyType::<#= Util.GetVMPropertyType(p.GetPropertyType()) #>);
nativeProps.Insert(winrt::to_hstring("<#= Util.ToJsName(p) #>"), ViewManagerPropertyType::<#= Util.GetVMPropertyType(p) #>);
<# } #>
}
#else

Просмотреть файл

@ -6,21 +6,20 @@ using System.Linq;
namespace Codegen
{
public class SyntheticProperty
{
public string Name { get; set; }
public MrType DeclaringType { get; set; }
public MrType PropertyType { get; set; }
public string FakePropertyType { get; set; }
public string Comment { get; set; }
}
public static class Util
{
static Dictionary<string, string> propNameMap = new Dictionary<string, string> {
{ "Key", "virtualKey" },
{ $"{XamlNames.XamlNamespace}.Input.KeyboardAccelerator.Key", "virtualKey" },
{ $"{XamlNames.XamlNamespace}.Controls.Maps.MapControl.Style", "mapStyle" },
};
public static string ToJsName(MrProperty prop)
{
var fullName = $"{prop.DeclaringType.GetFullName()}.{prop.GetName()}";
if (propNameMap.ContainsKey(fullName)) { return propNameMap[fullName]; }
return ToJsName(prop.GetName());
}
public static string ToJsName(string name)
{
var specialPrefixes = new string[] { "UI", "XY" };
@ -31,8 +30,8 @@ namespace Codegen
return p.ToLower() + name.Substring(p.Length);
}
}
if (propNameMap.ContainsKey(name)) { return propNameMap[name]; }
return name[0].ToString().ToLower() + name.Substring(1);
}
@ -66,16 +65,19 @@ namespace Codegen
if (name == "ActivatableAttribute")
{
factoryInfo.Activatable = true;
} else if (name == "StaticAttribute")
}
else if (name == "StaticAttribute")
{
factoryInfo.Statics = true;
factoryInfo.Type = (MrType)_fixed[0].Value;
} else if (name == "ComposableAttribute")
}
else if (name == "ComposableAttribute")
{
factoryInfo.Composable = true;
factoryInfo.Type = (MrType)_fixed[0].Value;
} else
}
else
{
continue;
}
@ -85,10 +87,6 @@ namespace Codegen
}
public static string GetCppWinRTType(MrType t)
{
if (t.GetName() == "NavigationViewItem")
{
var f = GetFactories(t);
}
var primitiveTypes = new Dictionary<string, string>()
{
{ "System.String", "winrt::hstring" },
@ -100,7 +98,13 @@ namespace Codegen
{ "System.Uri", "winrt::Windows::Foundation::Uri" },
{ "System.Object", "winrt::Windows::Foundation::IInspectable" },
};
if (t.IsEnum) return "int32_t";
if (t.GetFullName() == $"{XamlNames.XamlNamespace}.Controls.Maps.MapStyle")
{
// MapStyle has a bug where it doesn't support coercion from int
}
else if (t.IsEnum) return "int32_t";
if (primitiveTypes.ContainsKey(t.GetFullName()))
{
return primitiveTypes[t.GetFullName()];
@ -109,28 +113,30 @@ namespace Codegen
}
public struct FakeEnum
{
public string Name { get; set; }
public Dictionary<string, int> Values { get; set; }
}
public static HashSet<FakeEnum> fakeEnums = new HashSet<FakeEnum>();
public static HashSet<MrType> enumsToGenerateConvertersFor = new HashSet<MrType>();
public static MrLoadContext LoadContext { get; internal set; }
public static ViewManagerPropertyType GetVMPropertyType(string propType)
public static ViewManagerPropertyType GetVMPropertyType(SyntheticProperty prop)
{
if (prop.PropertyType != null) return GetVMPropertyType(prop.PropertyType);
var propType = prop.Name;
switch (propType)
{
case "GridLayout":
return ViewManagerPropertyType.Map;
}
throw new ArgumentException($"Invalid propery type ${propType}");
throw new ArgumentException($"Invalid property type ${propType}");
}
public static ViewManagerPropertyType GetVMPropertyType(MrType propType)
public static ViewManagerPropertyType GetVMPropertyType(MrProperty prop)
{
if (IsPropertyContentProperty(prop)) return ViewManagerPropertyType.String;
return GetVMPropertyType(prop.GetPropertyType());
}
private static ViewManagerPropertyType GetVMPropertyType(MrType propType)
{
if (propType.IsEnum)
{
@ -147,7 +153,7 @@ namespace Codegen
case "System.String":
case "System.Uri":
return ViewManagerPropertyType.String;
case "System.Boolean":
case "System.Boolean":
return ViewManagerPropertyType.Boolean;
case "System.Int32":
case "System.Int64":
@ -168,8 +174,10 @@ namespace Codegen
return ViewManagerPropertyType.Unknown;
}
public static string GetTypeScriptType(string typeName)
public static string GetTypeScriptType(SyntheticProperty prop)
{
if (prop.PropertyType != null) return GetTypeScriptType(prop.PropertyType);
var typeName = prop.FakePropertyType;
switch (typeName)
{
case "GridLayout":
@ -178,7 +186,32 @@ namespace Codegen
throw new ArgumentException($"Unknown type ${typeName}");
}
public static string GetTypeScriptType(MrType propType)
public static string GetTypeScriptType(MrProperty prop)
{
var tsTypeFromPropType = GetTypeScriptType(prop.GetPropertyType());
if (tsTypeFromPropType == "object" && IsPropertyContentProperty(prop))
{
return "string";
}
return tsTypeFromPropType;
}
static bool IsPropertyContentProperty(MrProperty prop)
{
return prop.DeclaringType.GetCustomAttributes().Any(x =>
{
x.GetNameAndNamespace(out var name, out var ns);
if (name == "ContentPropertyAttribute")
{
x.GetArguments(out var fixedArgs, out var namedArgs);
var na = namedArgs.Where(n => n.Name == "Name").First();
return (string)na.Value == prop.GetName();
}
return false;
});
}
private static string GetTypeScriptType(MrType propType)
{
if (propType.IsEnum)
{
@ -243,21 +276,25 @@ namespace Codegen
}
public static bool IsReservedName(string name)
public static bool IsReservedName(MrProperty prop)
{
switch (name)
var fullName = $"{prop.DeclaringType.GetFullName()}.{prop.GetName()}";
switch (fullName)
{
case "Style":
case "Type":
case $"{XamlNames.XamlNamespace}.FrameworkElement.Style":
return true;
default:
return false;
}
if (prop.GetName() == "Type")
{
return true;
}
return false;
}
public static bool ShouldEmitPropertyMetadata(MrProperty p)
{
if (IsReservedName(p.GetName())) return false;
if (IsReservedName(p)) return false;
if (p.Setter == null) return false;
bool isStatic = p.Getter.MethodDefinition.Attributes.HasFlag(System.Reflection.MethodAttributes.Static);
if (!isStatic)

Просмотреть файл

@ -341,6 +341,17 @@ export enum MapWatermarkMode {
On = 1,
}
export enum MapStyle {
None = 0,
Road = 1,
Aerial = 2,
AerialWithRoads = 3,
Terrain = 4,
Aerial3D = 5,
Aerial3DWithRoads = 6,
Custom = 7,
}
export enum MapColorScheme {
Light = 0,
Dark = 1,

Просмотреть файл

@ -169,7 +169,7 @@ export interface NativeControlProps extends NativeFrameworkElementProps {
export interface NativeContentControlProps extends NativeControlProps {
type: 'Windows.UI.Xaml.Controls.ContentControl'|'Windows.UI.Xaml.Controls.AppBar'|'Windows.UI.Xaml.Controls.Button'|'Windows.UI.Xaml.Controls.AppBarButton'|'Windows.UI.Xaml.Controls.AppBarElementContainer'|'Windows.UI.Xaml.Controls.Primitives.ToggleButton'|'Windows.UI.Xaml.Controls.AppBarToggleButton'|'Windows.UI.Xaml.Controls.CheckBox'|'Windows.UI.Xaml.Controls.ComboBoxItem'|'Windows.UI.Xaml.Controls.CommandBar'|'Windows.UI.Xaml.Controls.ContentDialog'|'Windows.UI.Xaml.Controls.DropDownButton'|'Windows.UI.Xaml.Controls.FlipViewItem'|'Windows.UI.Xaml.Controls.FlyoutPresenter'|'Windows.UI.Xaml.Controls.Frame'|'Windows.UI.Xaml.Controls.GridViewHeaderItem'|'Windows.UI.Xaml.Controls.GridViewItem'|'Windows.UI.Xaml.Controls.GroupItem'|'Windows.UI.Xaml.Controls.HyperlinkButton'|'Windows.UI.Xaml.Controls.RadioButton'|'Windows.UI.Xaml.Controls.InkToolbarBallpointPenButton'|'Windows.UI.Xaml.Controls.InkToolbarCustomPenButton'|'Windows.UI.Xaml.Controls.InkToolbarCustomToggleButton'|'Windows.UI.Xaml.Controls.InkToolbarCustomToolButton'|'Windows.UI.Xaml.Controls.InkToolbarEraserButton'|'Windows.UI.Xaml.Controls.InkToolbarFlyoutItem'|'Windows.UI.Xaml.Controls.InkToolbarHighlighterButton'|'Windows.UI.Xaml.Controls.InkToolbarPencilButton'|'Windows.UI.Xaml.Controls.InkToolbarRulerButton'|'Windows.UI.Xaml.Controls.InkToolbarStencilButton'|'Windows.UI.Xaml.Controls.ListBoxItem'|'Windows.UI.Xaml.Controls.ListViewHeaderItem'|'Windows.UI.Xaml.Controls.ListViewItem'|'Windows.UI.Xaml.Controls.NavigationView'|'Windows.UI.Xaml.Controls.NavigationViewItem'|'Windows.UI.Xaml.Controls.NavigationViewItemHeader'|'Windows.UI.Xaml.Controls.NavigationViewItemSeparator'|'Windows.UI.Xaml.Controls.PivotItem'|'Windows.UI.Xaml.Controls.Primitives.CommandBarFlyoutCommandBar'|'Windows.UI.Xaml.Controls.Primitives.NavigationViewItemPresenter'|'Windows.UI.Xaml.Controls.Primitives.PivotHeaderItem'|'Windows.UI.Xaml.Controls.Primitives.RepeatButton'|'Windows.UI.Xaml.Controls.RefreshContainer'|'Windows.UI.Xaml.Controls.ScrollViewer'|'Windows.UI.Xaml.Controls.SettingsFlyout'|'Windows.UI.Xaml.Controls.SplitButton'|'Windows.UI.Xaml.Controls.SwipeControl'|'Windows.UI.Xaml.Controls.ToggleSplitButton'|'Windows.UI.Xaml.Controls.ToolTip'|'Windows.UI.Xaml.Controls.TreeViewItem';
content?: object;
content?: string;
}
@ -517,7 +517,7 @@ export interface NativeContentPresenterProps extends NativeFrameworkElementProps
fontStretch?: Enums.FontStretch;
fontSize?: number;
fontFamily?: string;
content?: object;
content?: string;
characterSpacing?: number;
textLineBounds?: Enums.TextLineBounds;
opticalMarginAlignment?: Enums.OpticalMarginAlignment;
@ -543,7 +543,7 @@ export interface NativeDatePickerProps extends NativeControlProps {
orientation?: Enums.Orientation;
monthVisible?: boolean;
monthFormat?: string;
header?: object;
header?: string;
dayVisible?: boolean;
dayFormat?: string;
calendarIdentifier?: string;
@ -937,6 +937,7 @@ export interface NativeMapControlProps extends NativeControlProps {
zoomLevel?: number;
watermarkMode?: Enums.MapWatermarkMode;
trafficFlowVisible?: boolean;
mapStyle?: Enums.MapStyle;
pedestrianFeaturesVisible?: boolean;
mapServiceToken?: string;
heading?: number;
@ -1837,7 +1838,7 @@ export interface NativeTextCommandBarFlyoutProps extends NativeCommandBarFlyoutP
export interface NativeTimePickerProps extends NativeControlProps {
type: 'Windows.UI.Xaml.Controls.TimePicker';
minuteIncrement?: number;
header?: object;
header?: string;
clockIdentifier?: string;
lightDismissOverlayMode?: Enums.LightDismissOverlayMode;
onTimeChanged?: (event: NativeSyntheticEvent<undefined>) => void;
@ -1875,7 +1876,7 @@ export interface NativeToggleSwitchProps extends NativeControlProps {
onContent?: object;
offContent?: object;
isOn?: boolean;
header?: object;
header?: string;
onToggled?: (event: NativeSyntheticEvent<undefined>) => void;
}

Просмотреть файл

@ -189,8 +189,8 @@ const EventArgsProperty eventArgsProperties[] = {
{ "items", IsType<winrt::Windows::UI::Xaml::Controls::DragItemsStartingEventArgs>, [](const winrt::Windows::Foundation::IInspectable& obj) { auto ea = obj.as<winrt::Windows::UI::Xaml::Controls::DragItemsStartingEventArgs>(); return winrt::box_value(ea.Items()); } },
{ "items", IsType<winrt::Windows::UI::Xaml::Controls::TreeViewDragItemsCompletedEventArgs>, [](const winrt::Windows::Foundation::IInspectable& obj) { auto ea = obj.as<winrt::Windows::UI::Xaml::Controls::TreeViewDragItemsCompletedEventArgs>(); return winrt::box_value(ea.Items()); } },
{ "items", IsType<winrt::Windows::UI::Xaml::Controls::TreeViewDragItemsStartingEventArgs>, [](const winrt::Windows::Foundation::IInspectable& obj) { auto ea = obj.as<winrt::Windows::UI::Xaml::Controls::TreeViewDragItemsStartingEventArgs>(); return winrt::box_value(ea.Items()); } },
{ "virtualKey", IsType<winrt::Windows::UI::Xaml::Input::KeyRoutedEventArgs>, [](const winrt::Windows::Foundation::IInspectable& obj) { auto ea = obj.as<winrt::Windows::UI::Xaml::Input::KeyRoutedEventArgs>(); return winrt::box_value(static_cast<uint32_t>(ea.Key())); } },
{ "virtualKey", IsType<winrt::Windows::UI::Xaml::Input::ProcessKeyboardAcceleratorEventArgs>, [](const winrt::Windows::Foundation::IInspectable& obj) { auto ea = obj.as<winrt::Windows::UI::Xaml::Input::ProcessKeyboardAcceleratorEventArgs>(); return winrt::box_value(static_cast<uint32_t>(ea.Key())); } },
{ "key", IsType<winrt::Windows::UI::Xaml::Input::KeyRoutedEventArgs>, [](const winrt::Windows::Foundation::IInspectable& obj) { auto ea = obj.as<winrt::Windows::UI::Xaml::Input::KeyRoutedEventArgs>(); return winrt::box_value(static_cast<uint32_t>(ea.Key())); } },
{ "key", IsType<winrt::Windows::UI::Xaml::Input::ProcessKeyboardAcceleratorEventArgs>, [](const winrt::Windows::Foundation::IInspectable& obj) { auto ea = obj.as<winrt::Windows::UI::Xaml::Input::ProcessKeyboardAcceleratorEventArgs>(); return winrt::box_value(static_cast<uint32_t>(ea.Key())); } },
{ "keyboardAccelerator", IsType<winrt::Windows::UI::Xaml::Input::KeyboardAcceleratorInvokedEventArgs>, [](const winrt::Windows::Foundation::IInspectable& obj) { auto ea = obj.as<winrt::Windows::UI::Xaml::Input::KeyboardAcceleratorInvokedEventArgs>(); return winrt::box_value(ea.KeyboardAccelerator()); } },
{ "keyModifiers", IsType<winrt::Windows::UI::Xaml::Input::PointerRoutedEventArgs>, [](const winrt::Windows::Foundation::IInspectable& obj) { auto ea = obj.as<winrt::Windows::UI::Xaml::Input::PointerRoutedEventArgs>(); return winrt::box_value(static_cast<uint32_t>(ea.KeyModifiers())); } },
{ "keyModifiers", IsType<winrt::Windows::UI::Xaml::Controls::SearchBoxQuerySubmittedEventArgs>, [](const winrt::Windows::Foundation::IInspectable& obj) { auto ea = obj.as<winrt::Windows::UI::Xaml::Controls::SearchBoxQuerySubmittedEventArgs>(); return winrt::box_value(static_cast<uint32_t>(ea.KeyModifiers())); } },

Просмотреть файл

@ -142,8 +142,8 @@ winrt::Windows::Foundation::IInspectable AsUnwrappedType(const winrt::Windows::F
{ MAKE_KEY("components"), AsType<winrt::Windows::UI::Xaml::Controls::Primitives::ColorSpectrum>, []() { return winrt::Windows::UI::Xaml::Controls::Primitives::ColorSpectrum::ComponentsProperty(); }, SetPropValue<int32_t>, ViewManagerPropertyType::Number },
{ MAKE_KEY("compositeMode"), AsUnwrappedType<winrt::Windows::UI::Xaml::UIElement>, []() { return winrt::Windows::UI::Xaml::UIElement::CompositeModeProperty(); }, SetPropValue<int32_t>, ViewManagerPropertyType::Number },
{ MAKE_KEY("confirmationButtonsVisible"), AsUnwrappedType<winrt::Windows::UI::Xaml::Controls::PickerFlyout>, []() { return winrt::Windows::UI::Xaml::Controls::PickerFlyout::ConfirmationButtonsVisibleProperty(); }, SetPropValue<bool>, ViewManagerPropertyType::Boolean },
{ MAKE_KEY("content"), AsType<winrt::Windows::UI::Xaml::Controls::ContentControl>, []() { return winrt::Windows::UI::Xaml::Controls::ContentControl::ContentProperty(); }, SetPropValue<winrt::Windows::Foundation::IInspectable>, ViewManagerPropertyType::Map },
{ MAKE_KEY("content"), AsType<winrt::Windows::UI::Xaml::Controls::ContentPresenter>, []() { return winrt::Windows::UI::Xaml::Controls::ContentPresenter::ContentProperty(); }, SetPropValue<winrt::Windows::Foundation::IInspectable>, ViewManagerPropertyType::Map },
{ MAKE_KEY("content"), AsType<winrt::Windows::UI::Xaml::Controls::ContentControl>, []() { return winrt::Windows::UI::Xaml::Controls::ContentControl::ContentProperty(); }, SetPropValue<winrt::Windows::Foundation::IInspectable>, ViewManagerPropertyType::String },
{ MAKE_KEY("content"), AsType<winrt::Windows::UI::Xaml::Controls::ContentPresenter>, []() { return winrt::Windows::UI::Xaml::Controls::ContentPresenter::ContentProperty(); }, SetPropValue<winrt::Windows::Foundation::IInspectable>, ViewManagerPropertyType::String },
{ MAKE_KEY("contentLinkBackgroundColor"), AsType<winrt::Windows::UI::Xaml::Controls::RichEditBox>, []() { return winrt::Windows::UI::Xaml::Controls::RichEditBox::ContentLinkBackgroundColorProperty(); }, SetPropValue<winrt::Windows::UI::Xaml::Media::SolidColorBrush>, ViewManagerPropertyType::Color },
{ MAKE_KEY("contentLinkForegroundColor"), AsType<winrt::Windows::UI::Xaml::Controls::RichEditBox>, []() { return winrt::Windows::UI::Xaml::Controls::RichEditBox::ContentLinkForegroundColorProperty(); }, SetPropValue<winrt::Windows::UI::Xaml::Media::SolidColorBrush>, ViewManagerPropertyType::Color },
{ MAKE_KEY("contentMargin"), AsType<winrt::Windows::UI::Xaml::Controls::Primitives::GridViewItemPresenter>, []() { return winrt::Windows::UI::Xaml::Controls::Primitives::GridViewItemPresenter::ContentMarginProperty(); }, SetPropValue<winrt::Windows::UI::Xaml::Thickness>, ViewManagerPropertyType::Map },
@ -280,7 +280,7 @@ winrt::Windows::Foundation::IInspectable AsUnwrappedType(const winrt::Windows::F
{ MAKE_KEY("header"), AsType<winrt::Windows::UI::Xaml::Controls::AutoSuggestBox>, []() { return winrt::Windows::UI::Xaml::Controls::AutoSuggestBox::HeaderProperty(); }, SetPropValue<winrt::Windows::Foundation::IInspectable>, ViewManagerPropertyType::Map },
{ MAKE_KEY("header"), AsType<winrt::Windows::UI::Xaml::Controls::CalendarDatePicker>, []() { return winrt::Windows::UI::Xaml::Controls::CalendarDatePicker::HeaderProperty(); }, SetPropValue<winrt::Windows::Foundation::IInspectable>, ViewManagerPropertyType::Map },
{ MAKE_KEY("header"), AsType<winrt::Windows::UI::Xaml::Controls::ComboBox>, []() { return winrt::Windows::UI::Xaml::Controls::ComboBox::HeaderProperty(); }, SetPropValue<winrt::Windows::Foundation::IInspectable>, ViewManagerPropertyType::Map },
{ MAKE_KEY("header"), AsType<winrt::Windows::UI::Xaml::Controls::DatePicker>, []() { return winrt::Windows::UI::Xaml::Controls::DatePicker::HeaderProperty(); }, SetPropValue<winrt::Windows::Foundation::IInspectable>, ViewManagerPropertyType::Map },
{ MAKE_KEY("header"), AsType<winrt::Windows::UI::Xaml::Controls::DatePicker>, []() { return winrt::Windows::UI::Xaml::Controls::DatePicker::HeaderProperty(); }, SetPropValue<winrt::Windows::Foundation::IInspectable>, ViewManagerPropertyType::String },
{ MAKE_KEY("header"), AsType<winrt::Windows::UI::Xaml::Controls::Hub>, []() { return winrt::Windows::UI::Xaml::Controls::Hub::HeaderProperty(); }, SetPropValue<winrt::Windows::Foundation::IInspectable>, ViewManagerPropertyType::Map },
{ MAKE_KEY("header"), AsType<winrt::Windows::UI::Xaml::Controls::HubSection>, []() { return winrt::Windows::UI::Xaml::Controls::HubSection::HeaderProperty(); }, SetPropValue<winrt::Windows::Foundation::IInspectable>, ViewManagerPropertyType::Map },
{ MAKE_KEY("header"), AsType<winrt::Windows::UI::Xaml::Controls::ItemsPresenter>, []() { return winrt::Windows::UI::Xaml::Controls::ItemsPresenter::HeaderProperty(); }, SetPropValue<winrt::Windows::Foundation::IInspectable>, ViewManagerPropertyType::Map },
@ -291,8 +291,8 @@ winrt::Windows::Foundation::IInspectable AsUnwrappedType(const winrt::Windows::F
{ MAKE_KEY("header"), AsType<winrt::Windows::UI::Xaml::Controls::RichEditBox>, []() { return winrt::Windows::UI::Xaml::Controls::RichEditBox::HeaderProperty(); }, SetPropValue<winrt::Windows::Foundation::IInspectable>, ViewManagerPropertyType::Map },
{ MAKE_KEY("header"), AsType<winrt::Windows::UI::Xaml::Controls::Slider>, []() { return winrt::Windows::UI::Xaml::Controls::Slider::HeaderProperty(); }, SetPropValue<winrt::Windows::Foundation::IInspectable>, ViewManagerPropertyType::Map },
{ MAKE_KEY("header"), AsType<winrt::Windows::UI::Xaml::Controls::TextBox>, []() { return winrt::Windows::UI::Xaml::Controls::TextBox::HeaderProperty(); }, SetPropValue<winrt::Windows::Foundation::IInspectable>, ViewManagerPropertyType::Map },
{ MAKE_KEY("header"), AsType<winrt::Windows::UI::Xaml::Controls::TimePicker>, []() { return winrt::Windows::UI::Xaml::Controls::TimePicker::HeaderProperty(); }, SetPropValue<winrt::Windows::Foundation::IInspectable>, ViewManagerPropertyType::Map },
{ MAKE_KEY("header"), AsType<winrt::Windows::UI::Xaml::Controls::ToggleSwitch>, []() { return winrt::Windows::UI::Xaml::Controls::ToggleSwitch::HeaderProperty(); }, SetPropValue<winrt::Windows::Foundation::IInspectable>, ViewManagerPropertyType::Map },
{ MAKE_KEY("header"), AsType<winrt::Windows::UI::Xaml::Controls::TimePicker>, []() { return winrt::Windows::UI::Xaml::Controls::TimePicker::HeaderProperty(); }, SetPropValue<winrt::Windows::Foundation::IInspectable>, ViewManagerPropertyType::String },
{ MAKE_KEY("header"), AsType<winrt::Windows::UI::Xaml::Controls::ToggleSwitch>, []() { return winrt::Windows::UI::Xaml::Controls::ToggleSwitch::HeaderProperty(); }, SetPropValue<winrt::Windows::Foundation::IInspectable>, ViewManagerPropertyType::String },
{ MAKE_KEY("headerBackground"), AsType<winrt::Windows::UI::Xaml::Controls::SettingsFlyout>, []() { return winrt::Windows::UI::Xaml::Controls::SettingsFlyout::HeaderBackgroundProperty(); }, SetPropValue<winrt::Windows::UI::Xaml::Media::Brush>, ViewManagerPropertyType::Color },
{ MAKE_KEY("headerFocusVisualPlacement"), AsType<winrt::Windows::UI::Xaml::Controls::Pivot>, []() { return winrt::Windows::UI::Xaml::Controls::Pivot::HeaderFocusVisualPlacementProperty(); }, SetPropValue<int32_t>, ViewManagerPropertyType::Number },
{ MAKE_KEY("headerForeground"), AsType<winrt::Windows::UI::Xaml::Controls::SettingsFlyout>, []() { return winrt::Windows::UI::Xaml::Controls::SettingsFlyout::HeaderForegroundProperty(); }, SetPropValue<winrt::Windows::UI::Xaml::Media::Brush>, ViewManagerPropertyType::Color },
@ -787,6 +787,7 @@ winrt::Windows::Foundation::IInspectable AsUnwrappedType(const winrt::Windows::F
{ MAKE_KEY("strokeMiterLimit"), AsType<winrt::Windows::UI::Xaml::Shapes::Shape>, []() { return winrt::Windows::UI::Xaml::Shapes::Shape::StrokeMiterLimitProperty(); }, SetPropValue<double>, ViewManagerPropertyType::Number },
{ MAKE_KEY("strokeStartLineCap"), AsType<winrt::Windows::UI::Xaml::Shapes::Shape>, []() { return winrt::Windows::UI::Xaml::Shapes::Shape::StrokeStartLineCapProperty(); }, SetPropValue<int32_t>, ViewManagerPropertyType::Number },
{ MAKE_KEY("strokeThickness"), AsType<winrt::Windows::UI::Xaml::Shapes::Shape>, []() { return winrt::Windows::UI::Xaml::Shapes::Shape::StrokeThicknessProperty(); }, SetPropValue<double>, ViewManagerPropertyType::Number },
{ MAKE_KEY("mapStyle"), AsType<winrt::Windows::UI::Xaml::Controls::Maps::MapControl>, []() { return winrt::Windows::UI::Xaml::Controls::Maps::MapControl::StyleProperty(); }, SetPropValue<winrt::Windows::UI::Xaml::Controls::Maps::MapStyle>, ViewManagerPropertyType::Number },
{ MAKE_KEY("styleSimulations"), AsType<winrt::Windows::UI::Xaml::Documents::Glyphs>, []() { return winrt::Windows::UI::Xaml::Documents::Glyphs::StyleSimulationsProperty(); }, SetPropValue<int32_t>, ViewManagerPropertyType::Number },
{ MAKE_KEY("symbol"), AsType<winrt::Windows::UI::Xaml::Controls::SymbolIcon>, []() { return winrt::Windows::UI::Xaml::Controls::SymbolIcon::SymbolProperty(); }, SetPropValue<int32_t>, ViewManagerPropertyType::Number },
{ MAKE_KEY("tabFocusNavigation"), AsUnwrappedType<winrt::Windows::UI::Xaml::UIElement>, []() { return winrt::Windows::UI::Xaml::UIElement::TabFocusNavigationProperty(); }, SetPropValue<int32_t>, ViewManagerPropertyType::Number },
@ -991,7 +992,7 @@ void XamlMetadata::PopulateNativeProps(winrt::Windows::Foundation::Collections::
nativeProps.Insert(winrt::to_hstring("components"), ViewManagerPropertyType::Number);
nativeProps.Insert(winrt::to_hstring("compositeMode"), ViewManagerPropertyType::Number);
nativeProps.Insert(winrt::to_hstring("confirmationButtonsVisible"), ViewManagerPropertyType::Boolean);
nativeProps.Insert(winrt::to_hstring("content"), ViewManagerPropertyType::Map);
nativeProps.Insert(winrt::to_hstring("content"), ViewManagerPropertyType::String);
nativeProps.Insert(winrt::to_hstring("contentLinkBackgroundColor"), ViewManagerPropertyType::Color);
nativeProps.Insert(winrt::to_hstring("contentLinkForegroundColor"), ViewManagerPropertyType::Color);
nativeProps.Insert(winrt::to_hstring("contentMargin"), ViewManagerPropertyType::Map);
@ -1397,6 +1398,7 @@ void XamlMetadata::PopulateNativeProps(winrt::Windows::Foundation::Collections::
nativeProps.Insert(winrt::to_hstring("strokeMiterLimit"), ViewManagerPropertyType::Number);
nativeProps.Insert(winrt::to_hstring("strokeStartLineCap"), ViewManagerPropertyType::Number);
nativeProps.Insert(winrt::to_hstring("strokeThickness"), ViewManagerPropertyType::Number);
nativeProps.Insert(winrt::to_hstring("mapStyle"), ViewManagerPropertyType::Number);
nativeProps.Insert(winrt::to_hstring("styleSimulations"), ViewManagerPropertyType::Number);
nativeProps.Insert(winrt::to_hstring("symbol"), ViewManagerPropertyType::Number);
nativeProps.Insert(winrt::to_hstring("tabFocusNavigation"), ViewManagerPropertyType::Number);

Просмотреть файл

@ -7,6 +7,8 @@
#include <JSValueXaml.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.UI.Xaml.Controls.Maps.h>
#include <UI.Xaml.Media.h>
#include "Crc32Str.h"
#include <JSI/JsiApiContext.h>
@ -77,6 +79,15 @@ void SetPropValue(const xaml::DependencyObject& o, const xaml::DependencyPropert
o.SetValue(prop, winrt::box_value(b));
}
// MapStyle has a bug where it expects the property to be set as an IReference<MapStyle> always, and does not support IReference<uint32_t>
template<typename T, std::enable_if_t<
std::is_same<winrt::Windows::UI::Xaml::Controls::Maps::MapStyle, T>::value, int> = 0>
void SetPropValue(const xaml::DependencyObject& o, const xaml::DependencyProperty& prop, const winrt::Microsoft::ReactNative::JSValue& v) {
auto boxed = v.To<winrt::Windows::UI::Xaml::Controls::Maps::MapStyle>();
o.SetValue(prop, winrt::box_value(boxed));
}
template<typename T, std::enable_if_t<std::is_same<T, winrt::hstring>::value, int> = 0>
void SetPropValue(const xaml::DependencyObject& o, const xaml::DependencyProperty& prop, const winrt::Microsoft::ReactNative::JSValue& v) {
auto b = v.AsString();