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 kotlin sample code in "Integration with an Android Fragment" documentation #2977

Merged
merged 20 commits into from
Mar 24, 2022

Conversation

mdvacca
Copy link
Contributor

@mdvacca mdvacca commented Feb 25, 2022

This PR updates the "[https://reactnative.dev/docs/integration-with-android-fragment](Integration with an Android Fragment)" documentation to display Kotlin and java code samples

This is the first step on the effort to display Kotlin code in RN OSS documentation

integration-with-android-fragment-kotlin

@netlify
Copy link

netlify bot commented Feb 25, 2022

Deploy Preview for react-native ready!

Name Link
🔨 Latest commit 9feedb8
🔍 Latest deploy log https://app.netlify.com/sites/react-native/deploys/623c5cd6b538390008979a9e
😎 Deploy Preview https://deploy-preview-2977--react-native.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

mdvacca and others added 3 commits February 25, 2022 13:59
…ragment.md

Co-authored-by: Andrei Shikov <andreiishikov@gmail.com>
…ragment.md

Co-authored-by: Andrei Shikov <andreiishikov@gmail.com>
making java default
@mdvacca mdvacca marked this pull request as ready for review February 28, 2022 19:42
Copy link
Collaborator

@Simek Simek left a comment

Choose a reason for hiding this comment

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

Hello @mdvacca, thank you for the updates! 👍 That's great idea to adopt more Kotlin code alternative examples on the website.

I have only two small request:

  • for some reason, it looks like for tabs text the value is used, not the label, which leads to the lowercased tab captions
    Screenshot 2022-03-03 172619
  • the edits have been performed only on the versioned docs, this means that the changes will apply only for the 0.67 docs and won't be populated for the future versions, the source for versioned docs generation is /docs folder, and it content is also available under the Next tag on the website. In this situation I would recommend to apply the same changes to the /docs files and leave the 0.67 docs file as is, because 0.67 it is currently the default version, so it will make the changes more accessible (there will be no need to change to Next to see the Kotlin examples). 🙂

Copy link
Contributor

@cortinico cortinico left a comment

Choose a reason for hiding this comment

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

Great stuff 🚀 It's awesome to see more Koltin code in the React Native docs!

Left several comments on how to improve the code

@Simek
Copy link
Collaborator

Simek commented Mar 8, 2022

for some reason, it looks like for tabs text the value is used, not the label, which leads to the lowercased tab captions

It looks like, the missing exports for newly added androidLanaguages are the cause here. We probably should rewrite the file, so we use inline exports (export const = ...) instead just to avoid issues like this. 😅

Also I'm not sure why Docusaurus did not warn about this problem, but maybe it is due to the way in which imports are used in MD files.

mdvacca and others added 7 commits March 17, 2022 11:51
…ragment.md

Co-authored-by: Nicola Corti <corti.nico@gmail.com>
…ragment.md

Co-authored-by: Nicola Corti <corti.nico@gmail.com>
…ragment.md

Co-authored-by: Nicola Corti <corti.nico@gmail.com>
…ragment.md

Co-authored-by: Nicola Corti <corti.nico@gmail.com>
…ragment.md

Co-authored-by: Nicola Corti <corti.nico@gmail.com>
@Simek Simek requested review from Simek and cortinico March 18, 2022 14:37
@Simek
Copy link
Collaborator

Simek commented Mar 18, 2022

@cortinico David asked me if I can help and finish this PR, so I have ported the changes to the current docs file (located in docs) and I have fixed tabs issue:

Screenshot 2022-03-18 at 15 40 54

Since now I'm co-author, I have requested your re-review. Feel free to merge this in, if everything looks fine. 🙂

@Simek Simek removed their request for review March 18, 2022 14:45
Copy link
Contributor

@ShikaSD ShikaSD left a comment

Choose a reason for hiding this comment

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

One small nit, looks good to me otherwise

override fun getUseDeveloperSupport() = BuildConfig.DEBUG

override fun getPackages(): List<ReactPackage> {
val packages = PackageList(this).getPackages()
Copy link
Contributor

@ShikaSD ShikaSD Mar 21, 2022

Choose a reason for hiding this comment

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

does .getPackages() return List or MutableList? Assuming the intention was to allow manual additions here, it won't work in Kotlin because List doesn't have .add methods

Copy link
Contributor Author

@mdvacca mdvacca left a comment

Choose a reason for hiding this comment

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

updated getPackages() method

@cortinico
Copy link
Contributor

cortinico commented Mar 22, 2022

Code looks good to me, but it needs to be reformatted with:
https://facebookincubator.github.io/ktfmt/

I tried to leave code suggestions to this PR, but I think I broke Github ¯_(ツ)_/¯ Whenever I try to post a comment with a code suggestion I receive a 500 from GH, not sure why.

Edit: I managed to leave those comments

We can merge it as it is and reformat the code afterwards, or maybe @mdvacca you can take a stab and reformat those snippets using the Web UI of Ktfmt

mdvacca and others added 4 commits March 22, 2022 15:10
Co-authored-by: Nicola Corti <corti.nico@gmail.com>
Co-authored-by: Nicola Corti <corti.nico@gmail.com>
…ragment.md

Co-authored-by: Nicola Corti <corti.nico@gmail.com>
…ragment.md

Co-authored-by: Nicola Corti <corti.nico@gmail.com>
@mdvacca
Copy link
Contributor Author

mdvacca commented Mar 22, 2022

Thanks @cortinico, I just accepted/committed all your code suggestions

@cortinico cortinico merged commit e2d5b22 into facebook:main Mar 24, 2022
sunnylqm added a commit to reactnativecn/react-native-website that referenced this pull request Mar 26, 2022
* Generate 0.67 version of the docs (facebook#2926)

* version 0.67

* Revert "version 0.67"

This reverts commit f4896ac.

* updated v0.67 docs cut

* blogpost for 0.67 (facebook#2933)

* add Lorenzo

* Facebook -> Meta

* 067 blogpost

* add highlights and truncate

* tweak

* Update website/blog/2022-01-19-version-067.md

* Update website/blog/2022-01-19-version-067.md

Co-authored-by: Eli White <github@eli-white.com>

* Move Hermes 0.10 issue callout to acknowledgements

* Link the wiki

Co-authored-by: Luna <lunaleaps@gmail.com>
Co-authored-by: Eli White <github@eli-white.com>

* blogpost: React Native - H2 2021 Recap (facebook#2937)

Co-authored-by: Luna <luwe@fb.com>

* Fix typo in H2 blog post: next year / half -> numbers (facebook#2938)

* Use numbers for the time

* Bump nanoid from 3.1.30 to 3.2.0 (facebook#2939)

Bumps [nanoid](https://github.com/ai/nanoid) from 3.1.30 to 3.2.0.
- [Release notes](https://github.com/ai/nanoid/releases)
- [Changelog](https://github.com/ai/nanoid/blob/main/CHANGELOG.md)
- [Commits](ai/nanoid@3.1.30...3.2.0)

---
updated-dependencies:
- dependency-name: nanoid
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* remove text in running on device (facebook#2943)

* remove text on docs running-on-device (facebook#2944)

* Fix small grammatical error (facebook#2942)

* update copyright on website (facebook#2940)

Co-authored-by: luism3861 <Eduardo_Medina@fragua.com.mx>

* Fix flexShrink default value in Layout Props docs (facebook#2945)

* update website font, misc UI tweaks (facebook#2947)

* Fix the guide to the deprecated OpenJDK installation command. (facebook#2817)

* Add function based components example for Flat list optimisation (facebook#2955)

* Update typo in render-pipeline.md (facebook#2951)

* Update typo in tutorial.md (facebook#2946)

* Add an extra command to the troubleshooting guide for typescript template (facebook#2954)

Co-authored-by: Nicola Corti <corti.nico@gmail.com>

* (Image) Fix documentation for onLoad event. (facebook#2964)

* - (Image) Fix documentation for onLoad event.

* - (Image) Prettier.

* Update image.md (facebook#2965)

* Bump follow-redirects from 1.14.7 to 1.14.8 (facebook#2966)

Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.14.7 to 1.14.8.
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](follow-redirects/follow-redirects@v1.14.7...v1.14.8)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Fixed a typo in Linking page. (facebook#2968)

AndroidManifext.xml should be AndroidManifest.xml

* 📚 Guide: Getting Started with The New Architecture (a.k.a. the Playbook) (facebook#2879)

* Initial Draft of the New Architecture Playbook

* Fix c++ codeblocks not rendering correctly

* Fix Android.mk containing wrong wildcards

* Remove Markdown exports artifacts

* Fix missing parenthesis in section header

* Renamed section header as it was incomplete

* Removed canCreateTurboModule as it was not used

* Fix indententation and add imports to MyComponentsRegistry.java

* Add missing import for MyComponentsRegistry.h

* Fix the broken table

* s/two/three arguments

* Fix comments inside podfile

* split The New Architecture guide into few pages (facebook#2882)

* Fix wrong import for ./RNTMyNativeViewNativeComponent

* Fix import for codegenNativeCommands

* Add a banner for TypeScript support

* Do not sound prescriptive with 'you will be using flow'

* React concurrent mode -> React 18

* Add a banner on homepage about the number of manual steps

* Fix typo on Enabling TurboModule section title

Co-authored-by: Johny Urgiles <jurgiles@users.noreply.github.com>

* code formatting, admonitions and small tweaks (facebook#2922)

Co-authored-by: Nicola Corti <corti.nico@gmail.com>

* Use descriptive component names and fix use of ref (facebook#2935)

* Use descriptive component names and fix use of ref

* Remove ambiguity from migrating .measure* example

* Playbook => Guide

* Use implicit dependency substitution for the Gradle Plugin

* Specify reactRoot and codegenDir in the App setup

* Add a patch for configureNdkBuild not depending on preBuild

* Add the getTurboModule method

* Copy the warning banner on all the pages

* Update pod install to specify RCT_NEW_ARCH_ENABLED

* HermesExecutorFactory header lives inside reacthermes/ and not React/

* Fix broken jsExecutorFactoryForBridge iOS

* Bump used nightly version to 0.0.0-20220201-2008-79975d146

* Clarify the react-native-codegen version to use

* Suggest to use :app:externalNativeBuildDebug instead of Release

* Put LOCAL_SHARED_LIBRARIES on Android.mk on separate lines

* Update docs/new-architecture-app-renderer-ios.md

Co-authored-by: Bartosz Kaszubowski <gosimek@gmail.com>

* Remove unnecessary duplicated `pod install`

Co-authored-by: Bartosz Kaszubowski <gosimek@gmail.com>

* Setup a New Architecture Troubleshooting page

* Fix lint failures on troubleshooting section

Co-authored-by: Bartosz Kaszubowski <gosimek@gmail.com>
Co-authored-by: Johny Urgiles <jurgiles@users.noreply.github.com>
Co-authored-by: Samuel Susla <samuel.susla@gmail.com>

* fix(ios): update Fabric in Podfile instructions (facebook#2973)

* fix(ios): update Fabric in Podfile instructions

* move fabric_enabled comment closer to the property

* 📚 Add instruction for M1 users to work with Cocoapods (facebook#2974)

* Update Android SDK version to 30 (facebook#2975)

* Adding Explain Like I'm 5 video to the home page (facebook#2971)

* Adding ELI5 video to the home page

* Remove unused VideoContainer function

* Combining Video and Talk sections

Co-authored-by: Dmitry Vinnik <dvinnik@fb.com>

* Updated expired link in docs/security (facebook#2972)

* Updated link colors to meet WCAG color contrast guidelines. (facebook#2976)

* Bump prismjs from 1.25.0 to 1.27.0 (facebook#2978)

Bumps [prismjs](https://github.com/PrismJS/prism) from 1.25.0 to 1.27.0.
- [Release notes](https://github.com/PrismJS/prism/releases)
- [Changelog](https://github.com/PrismJS/prism/blob/master/CHANGELOG.md)
- [Commits](PrismJS/prism@v1.25.0...v1.27.0)

---
updated-dependencies:
- dependency-name: prismjs
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* fix: spelling error mudule -> module (facebook#2979)

* Update migration guide feedback link to the working group (facebook#2983)

* Add TOC sections for the 'Render, Commit, and Mount' page (facebook#2985)

* Adding Social Banner in Support of Ukraine  (facebook#2986)

* fix layout resizing when page includes wide code block (facebook#2980)

* docs: Moving to use Announcement Banner for the Support Ukraine Initiative (facebook#2988)

* Fix deeplink to react-host-components-or-host-components in Glossary (facebook#2992)

* Clarify intended audience for architecture overview (facebook#2995)

* changed android_hyphenation for 0.67+ (facebook#2982)

* Add missing `normal` enum for Hyphenation (facebook#3002)

* add ToC headers for phases on Render Pipeline page (facebook#2997)

* Moving Release Wiki to react-native-website (facebook#2961)

Co-authored-by: Simek <gosimek@gmail.com>

* Update discrete update threading model diagram (facebook#2999)

* move Fabric warning to partial, use admonition (facebook#2998)

* Clarify the Configure Codegen in your Gradle File section (facebook#2993)

Co-authored-by: Bartosz Kaszubowski <gosimek@gmail.com>

* Unversion Architecture docs (facebook#3000)

Co-authored-by: Bartosz Kaszubowski <gosimek@gmail.com>

* refactor(getting-started): path to sdk binaries (facebook#2991)

* bump lint stack, include `website` files in check (facebook#3004)

* Add table of contents and encourage people to leave feedback in working group in Architecture Overview intro (facebook#2996)

* Clarify intended audience for architecture overview
* Fix broken links

* Blogpost: An update on the New Architecture Rollout (facebook#3009)

Co-authored-by: Bartosz Kaszubowski <gosimek@gmail.com>
Co-authored-by: Lorenzo Sciandra <notkelset@kelset.dev>

* Use bundler to pod install (facebook#3011)

* Use placeholders instead of hardcoded strings (facebook#3015)

* Use @flow annotation and fix syntax (facebook#3016)

* Improve documentation about JS Specs (facebook#3017)

* Use more specific dependency React-Core (facebook#3020)

* distinguish windows from mac keytool instructions (facebook#3019)

Co-authored-by: Bartosz Kaszubowski <gosimek@gmail.com>

* spelling fix (facebook#3021)

* Rename _bridge into bridge (facebook#3013)

* Use empty dicts instead of nil (facebook#3014)

* 📚 Rename JSCExecutorFactory into HermesExecutorFactory (facebook#3012)

* fix codegenNativeCommands section example (facebook#3024)

Co-authored-by: Piotr Trocki <piotr@trocki.com>

* [sync-api] Replace deprecated String.prototype.substr() (facebook#3025)

* Add kotlin sample code in "Integration with an Android Fragment" documentation (facebook#2977)

Co-authored-by: Andrei Shikov <andreiishikov@gmail.com>
Co-authored-by: Nicola Corti <corti.nico@gmail.com>
Co-authored-by: Simek <gosimek@gmail.com>

* small custom CSS fixes and tweaks (facebook#3026)

* Update references from Java to Java/Kotlin in the body of the article (facebook#3028)

Co-authored-by: Bartosz Kaszubowski <gosimek@gmail.com>

* update project structure in Readme (facebook#3031)

Co-authored-by: Lorenzo Sciandra <notkelset@kelset.dev>
Co-authored-by: Luna <lunaleaps@gmail.com>
Co-authored-by: Eli White <github@eli-white.com>
Co-authored-by: Nicola Corti <ncor@fb.com>
Co-authored-by: Luna <luwe@fb.com>
Co-authored-by: Sota <5866096+sota000@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Luis Medina Huerta <luism3861@gmail.com>
Co-authored-by: Palash Shrivastava <35087196+BattleOfPlassey@users.noreply.github.com>
Co-authored-by: Michael Evans <michaelrevans@live.co.uk>
Co-authored-by: luism3861 <Eduardo_Medina@fragua.com.mx>
Co-authored-by: jzxchiang1 <15524484+jzxchiang1@users.noreply.github.com>
Co-authored-by: Bartosz Kaszubowski <gosimek@gmail.com>
Co-authored-by: 1natsu <1natsu172@users.noreply.github.com>
Co-authored-by: DIBYAJYOTI MISHRA <dibyajyotimishra14@gmail.com>
Co-authored-by: Jiovanna Manriquez <jiovannamanriquez@gmail.com>
Co-authored-by: markbell2410 <24226636+markbell2410@users.noreply.github.com>
Co-authored-by: Nicola Corti <corti.nico@gmail.com>
Co-authored-by: Erick Maeda Lopes <erick.maeda26@gmail.com>
Co-authored-by: Kavanaugh Latiolais <kav@pelo.tech>
Co-authored-by: hj <jiehecd@gmail.com>
Co-authored-by: Johny Urgiles <jurgiles@users.noreply.github.com>
Co-authored-by: Samuel Susla <samuel.susla@gmail.com>
Co-authored-by: Tommy Nguyen <4123478+tido64@users.noreply.github.com>
Co-authored-by: Riccardo <riccardo.cipolleschi@gmail.com>
Co-authored-by: Kid <44045911+kidonng@users.noreply.github.com>
Co-authored-by: Dmitry Vinnik <dmitryvinn@users.noreply.github.com>
Co-authored-by: Dmitry Vinnik <dvinnik@fb.com>
Co-authored-by: Vishwa Gaurav <81325730+VishwaGauravIn@users.noreply.github.com>
Co-authored-by: blavalla <blavalla@gmail.com>
Co-authored-by: RayKay91 <61206305+RayKay91@users.noreply.github.com>
Co-authored-by: zegermouw <zegermouw@gmail.com>
Co-authored-by: Nicolas <nicolashortaadam@gmail.com>
Co-authored-by: Sébastien Lorber <slorber@users.noreply.github.com>
Co-authored-by: Henry Hobhouse <henryhobhouse@gmail.com>
Co-authored-by: Samuel Susla <samuelsusla@fb.com>
Co-authored-by: Danilo Bürger <info@danilobuerger.de>
Co-authored-by: Riccardo <cipolleschi@fb.com>
Co-authored-by: Fernando Cervera <86963649+fernandocervera-abi@users.noreply.github.com>
Co-authored-by: Rajesh Sharma <broncha@rajesharma.com>
Co-authored-by: troZee <12766071+troZee@users.noreply.github.com>
Co-authored-by: Piotr Trocki <piotr@trocki.com>
Co-authored-by: CommanderRoot <CommanderRoot@users.noreply.github.com>
Co-authored-by: David Vacca <515103+mdvacca@users.noreply.github.com>
Co-authored-by: Andrei Shikov <andreiishikov@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants