-
Notifications
You must be signed in to change notification settings - Fork 44
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
base: main
Are you sure you want to change the base?
Conversation
{ | ||
key: 'WinRT', | ||
component: WinRTExamplePage, | ||
icon: '\uEF15', | ||
type: 'Layout', | ||
}, |
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type: 'Layout', | |
type: 'System', |
const ToastNotification = Notifications.ToastNotification; | ||
|
||
export function showNotification(notification) { | ||
var type = ToastTemplateType.toastText01; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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]); | ||
} |
There was a problem hiding this comment.
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?
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)
There was a problem hiding this comment.
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.
for (var arrValue of arr) { | ||
var node = xmlElements[i++]; |
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
url: 'https://github.com/asklar/react-native-winrt', | |
url: 'https://github.com/microsoft/react-native-winrt', |
flexWrap: 'wrap', | ||
alignItems: 'center', | ||
}}> | ||
<Pressable |
There was a problem hiding this comment.
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.
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