Skip to content

Commit 14f1859

Browse files
committed
first commit
1 parent c85a724 commit 14f1859

File tree

29 files changed

+332
-1114
lines changed

29 files changed

+332
-1114
lines changed

.all-contributorsrc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"files": [
3+
"README.md"
4+
],
5+
"imageSize": 100,
6+
"commit": false,
7+
"contributors": [
8+
{
9+
"login": "Marcoo09",
10+
"name": "Marco Fiorito",
11+
"avatar_url": "https://avatars.githubusercontent.com/Marcoo09",
12+
"profile": "https://github.com/Marcoo09",
13+
"contributions": [
14+
"code",
15+
]
16+
},
17+
],
18+
"contributorsPerLine": 7,
19+
"projectName": "react-native-vimeo-player",
20+
"projectOwner": "Marcoo09",
21+
"repoType": "github",
22+
"repoHost": "https://github.com",
23+
"skipCi": true
24+
}

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2021 Alex Demchenko
3+
Copyright (c) 2021 Marco Fiorito
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 37 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -1,138 +1,55 @@
1-
# React Native Module Template
1+
# React Native Vimeo Player
22

3-
A starter for the React Native library written in TypeScript, with linked example project and optional native code written in Swift and Kotlin. This project aims to support the latest React Native versions and keep best practices in mind.
3+
React Native Vimeo Player is a library to render Vimeo videos in a React Native app.
4+
This component allows you to embed a Vimeo video in your app and have full access to
5+
the Vimeo player JS API (more information https://developer.vimeo.com/player/js-api).
46

5-
## Alternatives
7+
## Installation
68

7-
[create-react-native-module](https://github.com/brodybits/create-react-native-module)
9+
1. Go through the instructions for installing the
10+
`React Native Webview` library: https://github.com/react-native-webview/react-native-webview.
811

9-
### Why this template?
12+
1. Run `npm install react-native-vimeo-player` or `yarn add react-native-vimeo-player` within your project.
1013

11-
First of all, it has TypeScript set up and ready. Also, if you will use a native code, this template uses Swift and Kotlin, which is much better than Objective-C and Java.
12-
13-
The example project is linked in a way so that you can work on your library and see the results of your work immediately. If you use native code you can see linked libraries in the example project opened in Xcode or Android Studio and can modify the code directly from there, just remember to rebuild the example to see the changes. When you change TypeScript code you need to compile it first (using `yarn` command, it has `prepare` hook set up) since with npm you are supplying `lib` folder with JavaScript and type definitions, but there is an [option](#how-to-see-my-changes-immediately-in-the-example) to point example to the `src` folder instead, so that when you modify your library you see changes immediately in the example thanks to [Fast Refresh](https://facebook.github.io/react-native/docs/fast-refresh).
14+
1. Compile and build to make sure everything is set up properly.
1415

1516
## Usage
1617

17-
Clone this repo, rename the `react-native-module-template` folder to your library name, navigate to that folder and run
18-
19-
```
20-
node rename.js
21-
```
22-
23-
or if you want to **remove native code**
24-
25-
```
26-
node rename.js js-only
27-
```
28-
29-
This will invoke rename script, which removes all references to the template and makes some cleanup.
30-
31-
⚠️⚠️⚠️ This script is not made to be bulletproof, some assumptions are made:
32-
33-
- The script will ask for different information (such as library name, author name, author email etc.) and there might be instructions in the parenthesis, please follow them or something will likely **fail**.
34-
- Use `kebab-case` for the library name, _preferably_ with `react-native` prefix (e.g. `react-native-blue-button`, blue-button, button).
35-
- Use `PascalCase` for the library short name (in case you will have native code, with `js-only` argument script will not ask for this), it is used in native projects (RNModuleTemplate.xcodeproj, RNModuleTemplatePackage.kt etc.). If you prefixed your library name with `react-native` use prefix `RN` for the short name (e.g. `RNBlueButton`, BlueButton, Button).
36-
- Library homepage is used only in `package.json`, if you are not sure, you can press enter to skip this step and modify this field later. Library git url is used only in `.podspec` file, same as above (note that this file will be removed if you pass `js-only` argument).
37-
- Please don't use any special characters in author name since it is a part of Android package name, (e.g. `com.alexdemchenko.reactnativemoduletemplate`) and used in Kotlin and other files. Android package name is generated from author name (with removed spaces and lowercased) and library name (with removed dashes).
38-
39-
Don't forget to remove the rename script, do `yarn` to install dependencies in root and example folders, and, if you kept native code, do `pod install` in `example/ios`.
40-
41-
If you didn't use `js-only` you are good to go. If you did, you need to unlink native code from the example
42-
43-
### iOS
44-
45-
Open Xcode, in the project navigator find `Libraries` folder, reveal contents using the small arrow and hit `DELETE` on `RNModuleTemplate.xcodeproj`. Alternatively, open `example/ios/example.xcodeproj/project.pbxproj`, search for the `Template` (there should be a number of `libRNModuleTemplate.a` and `RNModuleTemplate.xcodeproj` files) and remove all references to them. Please remove whole lines if it among files with other names or whole sections if it is the only item. Groups, like `Library` or `Products`, must stay, just remove the template from appropriate children field.
46-
47-
### Android
48-
49-
In `example/android/settings.gradle` remove
50-
51-
```gradle
52-
include ':react-native-module-template'
53-
project(':react-native-module-template').projectDir = new File(rootProject.projectDir, '../../android')
54-
```
55-
56-
In `example/android/app/build.gradle` remove
57-
58-
```gradle
59-
implementation project(':react-native-module-template')
60-
```
61-
62-
In `example/android/app/src/main/java/com/example/MainApplication.kt` remove
63-
64-
```kotlin
65-
import com.alexdemchenko.reactnativemoduletemplate.RNModuleTemplatePackage
66-
67-
packages.add(RNModuleTemplatePackage())
68-
```
69-
70-
## How example project is linked
71-
72-
The native part is manually linked (you can see changes for Android right above), for iOS check [official docs](https://facebook.github.io/react-native/docs/linking-libraries-ios#manual-linking), but **Header Search Paths** are pointing to the `ios` folder, `$(SRCROOT)/../../ios`, not node_modules.
73-
74-
JavaScript part is using Metro Bundler configuration, see [this article](https://callstack.com/blog/adding-an-example-app-to-your-react-native-library/) for more details and final configuration [here](example/metro.config.js).
75-
76-
In the example's [tsconfig.json](example/tsconfig.json) custom path is specified, so you can import your code the same way end user will do.
77-
78-
```json
79-
"paths": {
80-
"react-native-module-template": ["../src"]
81-
},
82-
```
83-
84-
### How to see my changes immediately in the example
85-
86-
In the library's `package.json` change
87-
88-
```json
89-
"main": "lib/index.js",
90-
```
91-
92-
to
93-
94-
```json
95-
"main": "src/index.tsx", // or `index.ts` if you don't have JSX there
96-
```
97-
98-
restart the bundler if you have it running
99-
10018
```
101-
yarn start
19+
<Vimeo
20+
videoId={'513199601'}
21+
onReady={() => console.log('Video is ready')}
22+
onPlay={() => console.log('Video is playing')}
23+
onPlayProgress={(data) => console.log('Video progress data:', data)}
24+
onFinish={() => console.log('Video is finished')}
25+
loop={false}
26+
autoPlay={false}
27+
controls={true}
28+
speed={false}
29+
/>
10230
```
10331

104-
⚠️⚠️⚠️ Don't forget to change this back before making a release, since with npm you supply `lib` folder, not `src`. Let me know if there is a way to do this automatically.
32+
## How it works
10533

106-
## Release
34+
Internally, a webview loads a HTML page. This HTML page loads your
35+
Vimeo video in an iFrame, then uses the Froogaloop JS library provided by Vimeo to pass event
36+
information to your application.
10737

108-
Create an npm account [here](https://www.npmjs.com/signup) if you don't have one. Then do
38+
## Example
10939

110-
```
111-
npm login
112-
```
40+
If you want to see `MetaLabs-inc/react-native-vimeo-player` in action, just move into the [example](/example) folder and run `yarn && cd ios && pod install && cd .. && yarn ios` or `yarn && yarn android`. By seeing its source code, you will have a better understanding of the library usage.
11341

114-
and
115-
116-
```
117-
npm publish
118-
```
42+
## Contributors
11943

120-
ℹ️ If you want to see what files will be included in your package before release run `npm pack`
121-
122-
ℹ️ If you have native code in your library most of the time you will need `.kt`, `.h`/`.m`, `.swift` files, `project.pbxproj`, `AndroidManifest.xml` and `build.gradle` aside from TypeScript code and default stuff, so keep an eye on what you are publishing, some configuration/build folders or files might sneak in. Most of them (if not all) are ignored in [package.json](package.json).
123-
124-
## FAQ
125-
126-
### VSCode ESLint plugin does not lint example project
127-
128-
By default, ESLint is configured separately for the library's source code and the example. It uses two `.eslintignore` files, the first one for the library, among others it ignores `/example` folder, and the second one for the example project. Since `/example` folder is ignored in one of these files, the plugin does not lint anything in it, see this [issue](https://github.com/microsoft/vscode-eslint/issues/111). To fix that, go to the VSCode settings and set
129-
130-
```json
131-
"eslint.workingDirectories": [
132-
"./example"
133-
]
134-
```
44+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
45+
<!-- prettier-ignore-start -->
46+
<!-- markdownlint-disable -->
47+
<table>
48+
<tr>
49+
<td align="center"><a href="https://github.com/Marcoo09"><img src="https://avatars.githubusercontent.com/Marcoo09" width="100px;" alt=""/><br /><sub><b>Marco Fiorito</b></sub></a><br />💻</td>
50+
</tr>
51+
</table>
13552

136-
## License
53+
## Acknowledgements
13754

138-
[MIT](LICENSE)
55+
- [@Myagi](https://github.com/Myagi) for `react-native-vimeo`, I based on that library to make that library with the latest versions of react-native.

android/build.gradle

Lines changed: 0 additions & 44 deletions
This file was deleted.

android/src/main/AndroidManifest.xml

Lines changed: 0 additions & 2 deletions
This file was deleted.

android/src/main/java/com/alexdemchenko/reactnativemoduletemplate/RNModuleTemplateModule.kt

Lines changed: 0 additions & 13 deletions
This file was deleted.

android/src/main/java/com/alexdemchenko/reactnativemoduletemplate/RNModuleTemplatePackage.kt

Lines changed: 0 additions & 19 deletions
This file was deleted.

example/android/app/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ android {
182182
}
183183

184184
dependencies {
185-
implementation project(':react-native-module-template')
186185
implementation fileTree(dir: 'libs', include: ['*.jar'])
187186
//noinspection GradleDynamicVersion
188187
implementation 'com.facebook.react:react-native:+' // From node_modules

example/android/app/src/main/java/com/example/MainApplication.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.example
22

33
import android.app.Application
44
import android.content.Context
5-
import com.alexdemchenko.reactnativemoduletemplate.RNModuleTemplatePackage
65
import com.facebook.react.*
76
import com.facebook.soloader.SoLoader
87
import java.lang.reflect.InvocationTargetException
@@ -16,7 +15,6 @@ class MainApplication : Application(), ReactApplication {
1615

1716
override fun getPackages(): List<ReactPackage> {
1817
val packages = PackageList(this).packages
19-
packages.add(RNModuleTemplatePackage())
2018
return packages
2119
}
2220

example/android/settings.gradle

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
rootProject.name = 'example'
2-
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
3-
41
include ':react-native-module-template'
52
project(':react-native-module-template').projectDir = new File(rootProject.projectDir, '../../android')
63

0 commit comments

Comments
 (0)