Skip to content

Commit de4002d

Browse files
authored
Restore ContentDialogClosed event (#228)
* restore OnContentDialogClosed since we need the return value from the show operation * Change files * update package.json * Update package/Codegen/Program.cs
1 parent c90b315 commit de4002d

File tree

9 files changed

+57
-9
lines changed

9 files changed

+57
-9
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": "Sun, 25 Sep 2022 05:36:46 GMT",
6+
"tag": "react-native-xaml_v0.0.70",
7+
"version": "0.0.70",
8+
"comments": {
9+
"patch": [
10+
{
11+
"author": "[email protected]",
12+
"package": "react-native-xaml",
13+
"comment": "restore OnContentDialogClosed since we need the return value from the show operation",
14+
"commit": "f1462114e7a7edc5202503d29e52064331890b6e"
15+
}
16+
]
17+
}
18+
},
419
{
520
"date": "Tue, 13 Sep 2022 21:38:24 GMT",
621
"tag": "react-native-xaml_v0.0.69",

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 Tue, 13 Sep 2022 21:38:24 GMT and should not be manually modified.
3+
This log was last generated on Sun, 25 Sep 2022 05:36:46 GMT and should not be manually modified.
44

55
<!-- Start content -->
66

7+
## 0.0.70
8+
9+
Sun, 25 Sep 2022 05:36:46 GMT
10+
11+
### Patches
12+
13+
- restore OnContentDialogClosed since we need the return value from the show operation ([email protected])
14+
715
## 0.0.69
816

917
Tue, 13 Sep 2022 21:38:24 GMT

package/Codegen/Program.cs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,24 @@ private void DumpTypes(Version version)
225225
var typeName = val.Substring(0, val.LastIndexOf('.'));
226226
var eventName = val.Substring(val.LastIndexOf('.') + 1);
227227

228-
syntheticEvents.Add(new SyntheticProperty()
228+
if (context.TryFindMrType(GetTypeNameFromJson(entry.Value), out var ptype))
229229
{
230-
Name = eventName,
231-
DeclaringType = context.GetType(typeName),
232-
FakePropertyType = entry.Value.GetString(),
233-
});
230+
syntheticEvents.Add(new SyntheticProperty()
231+
{
232+
Name = eventName,
233+
DeclaringType = context.GetType(typeName),
234+
PropertyType = ptype,
235+
});
236+
}
237+
else
238+
{
239+
syntheticEvents.Add(new SyntheticProperty()
240+
{
241+
Name = eventName,
242+
DeclaringType = context.GetType(typeName),
243+
FakePropertyType = entry.Value.ToString()
244+
});
245+
}
234246
}
235247

236248

package/Codegen/Windows.UI.Xaml.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
}
104104
],
105105
"syntheticEvents": {
106+
"$xaml.Controls.ContentDialog.ContentDialogClosed": "$xaml.Controls.ContentDialogResult"
106107
},
107108
"propNameMapping": {
108109
"$xaml.Input.KeyboardAccelerator.Key": "virtualKey",

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.69",
4+
"version": "0.0.70",
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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2710,6 +2710,7 @@ export interface NativeContentDialogProps extends NativeContentControlProps {
27102710
onPrimaryButtonClick?: (event: NativeSyntheticEvent<TypedEvent<NativeContentDialogButtonClickEventArgs>>) => void;
27112711
onSecondaryButtonClick?: (event: NativeSyntheticEvent<TypedEvent<NativeContentDialogButtonClickEventArgs>>) => void;
27122712
onCloseButtonClick?: (event: NativeSyntheticEvent<TypedEvent<NativeContentDialogButtonClickEventArgs>>) => void;
2713+
onContentDialogClosed?: (event: NativeSyntheticEvent<Enums.ContentDialogResult>) => void;
27132714
}
27142715
export interface NativeContentPresenterProps extends NativeFrameworkElementProps {
27152716
type: 'Windows.UI.Xaml.Controls.ContentPresenter' |

package/windows/ReactNativeXaml/Codegen/TypeEvents.g.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4345,9 +4345,10 @@ __declspec(noinline) void DispatchTheEvent(const EventAttachInfo& eai, const win
43454345
}
43464346
return winrt::event_token{0};
43474347
} },
4348+
{"ContentDialogClosed", nullptr /* synthetic event */},
43484349
};
43494350

4350-
static_assert(ARRAYSIZE(EventInfo::xamlEventMap) == 330);
4351+
static_assert(ARRAYSIZE(EventInfo::xamlEventMap) == 331);
43514352

43524353
void JsEvent(winrt::Microsoft::ReactNative::IJSValueWriter const& constantWriter, std::wstring topName, std::wstring onName) {
43534354
constantWriter.WritePropertyName(topName);

package/windows/ReactNativeXaml/Codegen/Version.g.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ THIS FILE WAS AUTOMATICALLY GENERATED, DO NOT MODIFY MANUALLY
77
#define VERSION_MAJOR 0
88
#define VERSION_MINOR 0
99
#define VERSION_REVISION 0
10-
#define VERSION_BUILD 69
10+
#define VERSION_BUILD 70

package/windows/ReactNativeXaml/XamlMetadata.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,16 @@ void SetShowState_ContentDialog(const xaml::DependencyObject& dobj, const xaml::
236236
case 3: // Hidden
237237
return cd.Hide();
238238
}
239+
op.Completed([cd, context](const IAsyncOperation<ContentDialogResult>& operation, const AsyncStatus& asyncStatus) {
240+
if (asyncStatus == AsyncStatus::Completed) {
241+
auto result = static_cast<int32_t>(operation.GetResults());
242+
243+
XamlUIService::FromContext(context).DispatchEvent(cd, L"topContentDialogClosed",
244+
[result](const winrt::Microsoft::ReactNative::IJSValueWriter& evtDataWriter) {
245+
evtDataWriter.WriteInt64(result);
246+
});
247+
}
248+
});
239249
}
240250
}
241251

0 commit comments

Comments
 (0)