Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Commit

Permalink
Switch project to TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
zoontek committed Jun 27, 2022
1 parent aede1c9 commit 70bb8f1
Show file tree
Hide file tree
Showing 16 changed files with 1,243 additions and 240 deletions.
66 changes: 0 additions & 66 deletions .flowconfig

This file was deleted.

173 changes: 173 additions & 0 deletions .github/funding-octocat.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ DerivedData
*.hmap
*.ipa
*.xcuserstate
ios/.xcode.env.local
.xcode.env.local

# Android/IntelliJ
#
Expand Down Expand Up @@ -58,6 +58,9 @@ buck-out/
# Bundle artifact
*.jsbundle

# Bob
dist/

# Ruby / CocoaPods
example/ios/Pods/
example/vendor/bundle/
2 changes: 0 additions & 2 deletions .npmignore

This file was deleted.

1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist/
node_modules/
Pods/

Expand Down
114 changes: 57 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,32 @@
# 📳 react-native-dev-menu

[![npm version](https://badge.fury.io/js/react-native-dev-menu.svg)](https://badge.fury.io/js/react-native-dev-menu)
[![npm version](https://badge.fury.io/js/react-native-dev-menu.svg)](https://www.npmjs.org/package/react-native-dev-menu)
[![npm](https://img.shields.io/npm/dt/react-native-dev-menu.svg)](https://www.npmjs.org/package/react-native-dev-menu)
![Platform - Android and iOS](https://img.shields.io/badge/platform-Android%20%7C%20iOS-yellow.svg)
![MIT](https://img.shields.io/dub/l/vibe-d.svg)
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)

Add custom items to the React Native dev menu.
[![MIT](https://img.shields.io/dub/l/vibe-d.svg)](https://opensource.org/licenses/MIT)
<br />
[![Platform - Android](https://img.shields.io/badge/platform-Android-3ddc84.svg?style=flat&logo=android)](https://www.android.com)
[![Platform - iOS](https://img.shields.io/badge/platform-iOS-000.svg?style=flat&logo=apple)](https://developer.apple.com/ios)

Add custom items to the React Native dev menu.<br />
The native part of this module is a variation of [react-native-async-storage-dev-menu-item](https://github.com/jsoendermann/react-native-async-storage-dev-menu-item/).

![](https://github.com/zoontek/react-native-dev-menu/blob/master/docs/screenshots.png?raw=true)

## Support

| Version | React Native Support |
| ------- | -------------------- |
| 4.0.0+ | 0.61.0+ |
| 3.0.0+ | 0.60.0 - 0.60.6 |
| 2.0.0+ | 0.56.0 - 0.59.10 |

## Usage
## Funding

```js
if (__DEV__) {
const DevMenu = require("react-native-dev-menu");
DevMenu.addItem("Say Hello", () => alert("Hello!"));
}
```
<a href="https://github.com/sponsors/zoontek">
<img align="right" width="150" alt="This library helped you? Consider sponsoring!" src=".github/funding-octocat.svg">
</a>

## Screenshots
This module is provided **as is**, I work on it in my free time.

![](https://github.com/zoontek/react-native-dev-menu/blob/master/docs/screenshots.png?raw=true)
If your company uses it in a production app, consider sponsoring this project 💰. You also can contact me for **premium** enterprise support, help with issues, prioritize bugfixes, feature requests, etc.

## Setup

Expand All @@ -39,71 +36,74 @@ $ npm install --save react-native-dev-menu
$ yarn add react-native-dev-menu
```

## Manual linking
_Don't forget to run `pod install` after that !_

If you use this package with React Native 0.60.0 or superior, you will probably don't need to link it. Otherwise if it still cannot be found, follow this steps to link it manually :
## 🆘  Manual linking

```bash
$ react-native link react-native-dev-menu
```
Because this package targets React Native 0.61.0+, you will probably don't need to link it manually. Otherwise if it's not the case, follow this additional instructions:

_NB: If you use a Cocoapods and have a `Podfile`, `react-native link` will only add this library as a dependency, and you'll need to run `pod install`._
<details>
<summary><b>👀 See manual linking instructions</b></summary>

### iOS specific setup
### iOS

#### CocoaPods linking

After installing the npm package, add the following line to your Podfile :

```ruby
pod 'RNDevMenu', :path => '../node_modules/react-native-dev-menu'
```
Add this line to your `ios/Podfile` file, then run `pod install`.

```bash
$ pod install
target 'YourAwesomeProject' do
#
pod 'RNDevMenu', :path => '../node_modules/react-native-dev-menu'
end
```

#### Manual linking
### Android

1. In the XCode's "Project navigator", right click on your project's Libraries folder ➜ `Add Files to <...>`
2. Go to `node_modules``react-native-dev-menu` ➜ select `RNDevMenu.xcodeproj`
3. Add `libRNDevMenu.a` to `Build Phases` -> `Link Binary With Libraries`

### Android specific setup

#### Manual linking

After installing the package, add the following line to the `./android/settings.gradle` file :
1. Add the following lines to `android/settings.gradle`:

```gradle
include ':app', ':react-native-dev-menu'
include ':react-native-dev-menu'
project(':react-native-dev-menu').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-dev-menu/android')
```

Include it as dependency in the `./android/app/build.gradle` file :
2. Add the implementation line to the dependencies in `android/app/build.gradle`:

```gradle
dependencies {
implementation project(':react-native-dev-menu')
// ...
// ...
implementation project(':react-native-dev-menu')
}
```

Finally, you need to link the package to the `./android/app/src/main/java/…/MainApplication.java` file :
3. Add the import and link the package in `MainApplication.java`:

```java
import com.zoontek.rndevmenu.RNDevMenuPackage;
import com.zoontek.rndevmenu.RNDevMenuPackage; // <- add the RNDevMenuPackage import

public class MainApplication extends Application implements ReactApplication {

// ...
//

@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
// ...
new RNDevMenuPackage(), // <-- Add it to the packages list
);
@Override
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
//
packages.add(new RNDevMenuPackage());
return packages;
}

//
}
```

</details>

// ...
## Usage

```ts
import DevMenu from "react-native-dev-menu";

if (__DEV__) {
DevMenu.addItem("Say Hello", () => alert("Hello!"));
}
```
11 changes: 11 additions & 0 deletions android/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.gradle/
.idea/
build/
gradle/

.DS_Store
.npmignore
gradlew
gradlew.bat
*.iml
local.properties
24 changes: 9 additions & 15 deletions example/App.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
// @flow

import React, { Component } from "react";
import * as React from "react";
import { StyleSheet, Text, View } from "react-native";
import DevMenu from "react-native-dev-menu";

if (__DEV__) {
const DevMenu = require("react-native-dev-menu");
DevMenu.addItem("Say Hello", () => alert("Hello!"));
}

export default class App extends Component<{}> {
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>Welcome to React Native!</Text>
<Text style={styles.instructions}>Please open the developer menu</Text>
</View>
);
}
}

const styles = StyleSheet.create({
container: {
flex: 1,
Expand All @@ -37,3 +24,10 @@ const styles = StyleSheet.create({
marginBottom: 5,
},
});

export const App = () => (
<View style={styles.container}>
<Text style={styles.welcome}>Welcome to React Native!</Text>
<Text style={styles.instructions}>Please open the developer menu</Text>
</View>
);
2 changes: 1 addition & 1 deletion example/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AppRegistry } from "react-native";
import App from "./App";
import { App } from "./App";
import { name as appName } from "./app.json";

AppRegistry.registerComponent(appName, () => App);
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ PODS:
- React-jsi (= 0.69.0)
- React-logger (= 0.69.0)
- React-perflogger (= 0.69.0)
- RNDevMenu (4.0.3):
- RNDevMenu (4.1.0):
- React-Core
- React-Core/DevSupport
- React-RCTNetwork
Expand Down Expand Up @@ -434,7 +434,7 @@ SPEC CHECKSUMS:
React-RCTVibration: 7549ef7b07aad1cc629f4c6d88c325366f26423c
React-runtimeexecutor: 7ad268dee53d001697e13264c6bc8e95a902352e
ReactCommon: 74a3b8ee497c6d50ce86ef57e15c4c5bf654b83d
RNDevMenu: a823bca21f1d9fd57c14b800a54b36ae7142dea7
RNDevMenu: 40dcdfb0653664c654b5afcf3e77a6fb9f280e34
Yoga: 4935173923cabaa830e195be3e8e4cac045a8f90

PODFILE CHECKSUM: d3751c521525f38e99e762ab2e9ea87a661d0b98
Expand Down
6 changes: 0 additions & 6 deletions index.d.ts

This file was deleted.

8 changes: 8 additions & 0 deletions ios/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Pods/
build/

*/project.xcworkspace/
*/xcuserdata/

.DS_Store
.npmignore
Loading

0 comments on commit 70bb8f1

Please sign in to comment.