Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WinRT example page #415

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Yajur-Grover
Copy link
Contributor

@Yajur-Grover Yajur-Grover commented Apr 19, 2024

Description

Add an example page using react-native-winrt, one of the community modules that we support.

Note: currently WIP, adding more API examples.

Why

Showcase community modules available in React Native Windows.

What

Add example page showcasing various APIs used in the react-native-winrt example application.

Screenshots

image

Comment on lines +270 to +275
{
key: 'WinRT',
component: WinRTExamplePage,
icon: '\uEF15',
type: 'Layout',
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI when you have to merge this later, look for:
icon -> textIcon

key: 'WinRT',
component: WinRTExamplePage,
icon: '\uEF15',
type: 'Layout',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type: 'Layout',
type: 'System',

const ToastNotification = Notifications.ToastNotification;

export function showNotification(notification) {
var type = ToastTemplateType.toastText01;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var type = ToastTemplateType.toastText01;
let type = ToastTemplateType.toastText01;

I'm surprised we don't have lint rules setup about var. As a default in our JS, we should always prefer let. It's scoped in a way that is much more sensible.

Comment on lines +24 to +30
if (typeof value === 'string') {
fillXmlElements(xml, xmlElements, [value]);
} else if (Array.isArray(value)) {
fillXmlElements(xml, xmlElements, value);
} else if (typeof value === 'object') {
fillXmlElements(xml, xmlElements, [value]);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like case 1 and 3 are the same. Is this still correct?

Suggested change
if (typeof value === 'string') {
fillXmlElements(xml, xmlElements, [value]);
} else if (Array.isArray(value)) {
fillXmlElements(xml, xmlElements, value);
} else if (typeof value === 'object') {
fillXmlElements(xml, xmlElements, [value]);
}
if (Array.isArray(value)) {
fillXmlElements(xml, xmlElements, value);
} else {
fillXmlElements(xml, xmlElements, [value]);
}

Or do you get types other than string/object in there? (like numeric literals or something)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If your goal is "if it's an array, leave it; otherwise, place in an array" there might be other options. Like:

[...value]

Does that do the right thing? It definitely spreads a source array into a new array. But for a single item... I think still the same thing? Hmmm... except strings are iterable so that'll break apart the string. Anyway, might be some syntactic magic here.

Comment on lines +39 to +40
for (var arrValue of arr) {
var node = xmlElements[i++];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's happening here? Are arr and xmlElements ensured to be the same length? Why are we enumerating over arr but indexing into xmlElements?

documentation={[
{
label: 'WinRT Source Code',
url: 'https://github.com/asklar/react-native-winrt',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
url: 'https://github.com/asklar/react-native-winrt',
url: 'https://github.com/microsoft/react-native-winrt',

flexWrap: 'wrap',
alignItems: 'center',
}}>
<Pressable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason this doesn't just use a Button instead of a custom Pressable? It looks... button-y. And the point of the sample isn't any exact visual style, so it should be simple first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants