Skip to content

Commit 327b300

Browse files
authored
Merge pull request #184 from microsoft/nullableProps
Nullable props
2 parents d85fa6f + ac0de45 commit 327b300

File tree

8 files changed

+129
-58
lines changed

8 files changed

+129
-58
lines changed

package/CHANGELOG.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
{
22
"name": "react-native-xaml",
33
"entries": [
4+
{
5+
"date": "Mon, 14 Feb 2022 08:09:35 GMT",
6+
"tag": "react-native-xaml_v0.0.61",
7+
"version": "0.0.61",
8+
"comments": {
9+
"patch": [
10+
{
11+
"author": "[email protected]",
12+
"package": "react-native-xaml",
13+
"comment": "Fix some prop types not being codegen'd because they are treated as nullable, like Color",
14+
"commit": "1e6cfdc6ca137ba4c674c977d373c5b11f6d67ee"
15+
}
16+
]
17+
}
18+
},
419
{
520
"date": "Thu, 10 Feb 2022 17:17:17 GMT",
621
"tag": "react-native-xaml_v0.0.60",

package/CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
# Change Log - react-native-xaml
22

3-
This log was last generated on Thu, 10 Feb 2022 17:17:17 GMT and should not be manually modified.
3+
This log was last generated on Mon, 14 Feb 2022 08:09:35 GMT and should not be manually modified.
44

55
<!-- Start content -->
66

7+
## 0.0.61
8+
9+
Mon, 14 Feb 2022 08:09:35 GMT
10+
11+
### Patches
12+
13+
- Fix some prop types not being codegen'd because they are treated as nullable, like Color ([email protected])
14+
715
## 0.0.60
816

917
Thu, 10 Feb 2022 17:17:17 GMT

package/Codegen/Util.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,18 @@ public static string GetCppWinRTType(MrType t)
148148
{
149149
// MapStyle has a bug where it doesn't support coercion from int
150150
}
151-
else if (t.IsEnum) return "int32_t";
152-
151+
else if (t.IsEnum) { return "int32_t"; }
152+
else if (t.GetFullName() == "System.Nullable`1")
153+
{
154+
return GetCppWinRTType(t.GetGenericTypeParameters().First());
155+
}
153156
if (primitiveTypes.ContainsKey(t.GetFullName()))
154157
{
155158
return primitiveTypes[t.GetFullName()];
156159
}
160+
161+
162+
157163
return $"winrt::{t.GetFullName().Replace(".", "::")}";
158164
}
159165

@@ -229,6 +235,10 @@ private static ViewManagerPropertyType GetVMPropertyType(MrType propType)
229235
return ViewManagerPropertyType.Number;
230236
case "System.Object":
231237
return ViewManagerPropertyType.Map;
238+
case "System.Nullable`1":
239+
return GetVMPropertyType(propType.GetGenericTypeParameters().First());
240+
case "Windows.UI.Color":
241+
return ViewManagerPropertyType.Map;
232242
}
233243

234244
if (TypeMapping.TryGetValue(propType.GetFullName(), out var mapping)) {
@@ -342,7 +352,7 @@ private static string GetTypeScriptType(MrType propType)
342352
case "Windows.Foundation.Point":
343353
return "Point";
344354
case "Windows.UI.Color":
345-
return "Color";
355+
return "Color | number";
346356
}
347357

348358
if (TypeMapping.TryGetValue(propType.GetFullName(), out var mapping))

package/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-native-xaml",
33
"title": "React Native Xaml",
4-
"version": "0.0.60",
4+
"version": "0.0.61",
55
"description": "Allows using XAML directly, inside of a React Native Windows app",
66
"main": "lib/index.js",
77
"typings": "lib/index.d.ts",

package/src/Props.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ export type BreadcrumbBarItemClickedEventArgs = {
2929
}
3030
export namespace WinUI {
3131
export type ColorChangedEventArgs = {
32-
readonly newColor: Color;
33-
readonly oldColor: Color;
32+
readonly newColor: Color | number;
33+
readonly oldColor: Color | number;
3434
}
3535
}
3636
export namespace WinUI {
@@ -351,8 +351,8 @@ export type CalendarDatePickerDateChangedEventArgs = {
351351
export type CalendarViewSelectedDatesChangedEventArgs = {
352352
}
353353
export type ColorChangedEventArgs = {
354-
readonly newColor: Color;
355-
readonly oldColor: Color;
354+
readonly newColor: Color | number;
355+
readonly oldColor: Color | number;
356356
}
357357
export type ComboBoxTextSubmittedEventArgs = {
358358
readonly handled: boolean;
@@ -727,6 +727,7 @@ export interface NativeBreadcrumbBarItemProps extends NativeContentControlProps
727727
export namespace NativeWinUI {
728728
export interface NativeColorPickerProps extends NativeControlProps {
729729
type: 'Microsoft.UI.Xaml.Controls.ColorPicker';
730+
previousColor?: any;
730731
minValue?: number;
731732
minSaturation?: number;
732733
minHue?: number;
@@ -744,6 +745,7 @@ export interface NativeColorPickerProps extends NativeControlProps {
744745
isAlphaEnabled?: boolean;
745746
colorSpectrumShape?: Enums.WinUIEnums.ColorSpectrumShape;
746747
colorSpectrumComponents?: Enums.WinUIEnums.ColorSpectrumComponents;
748+
color?: Color | number;
747749
onColorChanged?: (event: NativeSyntheticEvent<TypedEvent<WinUI.ColorChangedEventArgs>>) => void;
748750
}
749751
}
@@ -974,6 +976,7 @@ export interface NativeColorSpectrumProps extends NativeControlProps {
974976
maxSaturation?: number;
975977
maxHue?: number;
976978
components?: Enums.WinUIEnums.ColorSpectrumComponents;
979+
color?: Color | number;
977980
onColorChanged?: (event: NativeSyntheticEvent<TypedEvent<WinUI.ColorChangedEventArgs>>) => void;
978981
}
979982
}
@@ -992,6 +995,7 @@ export interface NativeInfoBarPanelProps extends NativePanelProps {
992995
export namespace NativeWinUI {
993996
export interface NativeMonochromaticOverlayPresenterProps extends NativeGridProps {
994997
type: 'Microsoft.UI.Xaml.Controls.Primitives.MonochromaticOverlayPresenter';
998+
replacementColor?: Color | number;
995999
}
9961000
}
9971001
export namespace NativeWinUI {
@@ -2371,6 +2375,7 @@ export interface NativeToggleButtonProps extends NativeButtonBaseProps {
23712375
'Windows.UI.Xaml.Controls.InkToolbarRulerButton' |
23722376
'Windows.UI.Xaml.Controls.InkToolbarStencilButton';
23732377
isThreeState?: boolean;
2378+
isChecked?: any;
23742379
onChecked?: (event: NativeSyntheticEvent<undefined>) => void;
23752380
onIndeterminate?: (event: NativeSyntheticEvent<undefined>) => void;
23762381
onUnchecked?: (event: NativeSyntheticEvent<undefined>) => void;
@@ -2559,6 +2564,7 @@ export interface NativeCheckBoxProps extends NativeToggleButtonProps {
25592564
}
25602565
export interface NativeColorPickerProps extends NativeControlProps {
25612566
type: 'Windows.UI.Xaml.Controls.ColorPicker';
2567+
previousColor?: any;
25622568
minValue?: number;
25632569
minSaturation?: number;
25642570
minHue?: number;
@@ -2576,6 +2582,7 @@ export interface NativeColorPickerProps extends NativeControlProps {
25762582
isAlphaEnabled?: boolean;
25772583
colorSpectrumShape?: Enums.ColorSpectrumShape;
25782584
colorSpectrumComponents?: Enums.ColorSpectrumComponents;
2585+
color?: Color | number;
25792586
onColorChanged?: (event: NativeSyntheticEvent<TypedEvent<ColorChangedEventArgs>>) => void;
25802587
}
25812588
export interface NativeSelectorProps extends NativeItemsControlProps {
@@ -2594,6 +2601,7 @@ export interface NativeSelectorProps extends NativeItemsControlProps {
25942601
selectedValue?: object;
25952602
selectedItem?: object;
25962603
selectedIndex?: number;
2604+
isSynchronizedWithCurrentItem?: any;
25972605
onSelectionChanged?: (event: NativeSyntheticEvent<undefined>) => void;
25982606
}
25992607
export interface NativeComboBoxProps extends NativeSelectorProps {
@@ -3123,6 +3131,7 @@ export interface NativeMediaElementProps extends NativeFrameworkElementProps {
31233131
posterSource?: string;
31243132
playbackRate?: number;
31253133
autoPlay?: boolean;
3134+
audioStreamIndex?: any;
31263135
isMuted?: boolean;
31273136
audioDeviceType?: Enums.AudioDeviceType;
31283137
audioCategory?: Enums.AudioCategory;
@@ -3419,6 +3428,7 @@ export interface NativeColorSpectrumProps extends NativeControlProps {
34193428
maxSaturation?: number;
34203429
maxHue?: number;
34213430
components?: Enums.ColorSpectrumComponents;
3431+
color?: Color | number;
34223432
onColorChanged?: (event: NativeSyntheticEvent<TypedEvent<ColorChangedEventArgs>>) => void;
34233433
}
34243434
export interface NativeCommandBarFlyoutCommandBarProps extends NativeCommandBarProps {
@@ -4042,6 +4052,7 @@ export interface NativeVirtualizingStackPanelProps extends NativeOrientedVirtual
40424052
export interface NativeWebViewProps extends NativeFrameworkElementProps {
40434053
type: 'Windows.UI.Xaml.Controls.WebView';
40444054
source?: string;
4055+
defaultBackgroundColor?: Color | number;
40454056
onLoadCompleted?: (event: NativeSyntheticEvent<undefined>) => void;
40464057
onNavigationFailed?: (event: NativeSyntheticEvent<undefined>) => void;
40474058
onScriptNotify?: (event: NativeSyntheticEvent<undefined>) => void;

0 commit comments

Comments
 (0)