Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
hoanglam10499 committed Aug 25, 2023
1 parent b8610a4 commit 6d23c65
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 48 deletions.
10 changes: 4 additions & 6 deletions android/src/main/java/com/dropShadow/DropShadowPackage.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,20 @@
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class DropShadowPackage implements ReactPackage {
@NonNull
@Override
public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();
modules.add(new DropShadowModule());
return modules;
return Collections.emptyList();
}

@NonNull
@Override
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
return Collections.emptyList();
return Arrays.<ViewManager>asList(new DropShadowModule());
}
}
}
34 changes: 19 additions & 15 deletions example/src/App.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
import * as React from 'react';

import { View } from 'react-native';
import DropShadow from '../..';
import { View, StyleSheet } from 'react-native';
import DropShadow from 'react-native-drop-shadow';

export default function App() {
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<DropShadow
style={{
shadowColor: '#000',
shadowOffset: {
width: 0,
height: 0,
},
shadowOpacity: 1,
shadowRadius: 5,
}}
>
<View style={{ height: 50, width: 50, backgroundColor: 'red' }} />
<View style={styles.container}>
<DropShadow style={styles.shadow}>
<View style={styles.box} />
</DropShadow>
</View>
);
}

const styles = StyleSheet.create({
box: { height: 50, width: 50, backgroundColor: 'red' },
shadow: {
shadowColor: '#000',
shadowOffset: {
width: 0,
height: 0,
},
shadowOpacity: 1,
shadowRadius: 5,
},
container: { flex: 1, alignItems: 'center', justifyContent: 'center' },
});
10 changes: 5 additions & 5 deletions lefthook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ pre-commit:
files: git diff --name-only @{push}
glob: "*.{js,ts, jsx, tsx}"
run: npx tsc --noEmit
commit-msg:
parallel: true
commands:
commitlint:
run: npx commitlint --edit
# commit-msg:
# parallel: false
# commands:
# commitlint:
# run: npx commitlint --edit
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false
"useTabs": false,
"endOfLine": "auto"
},
"react-native-builder-bob": {
"source": "src",
Expand All @@ -168,4 +169,4 @@
]
]
}
}
}
21 changes: 19 additions & 2 deletions src/DropShadow.android.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
import React from 'react';
import { type ViewProps } from 'react-native';
import { NativeShadow } from './NativeShadow';
import { type ViewProps, requireNativeComponent, Platform } from 'react-native';

const NativeShadow = requireNativeComponent<ViewProps>('DropShadow');

const LINKING_ERROR =
`The package 'react-native-drop-shadow' doesn't seem to be linked. Make sure: \n\n` +
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
'- You rebuilt the app after installing the package\n' +
'- You are not using Expo Go\n';

export class DropShadow extends React.Component<ViewProps> {
render(): React.ReactNode {
if (NativeShadow == null) {
return new Proxy(
{},
{
get() {
throw new Error(LINKING_ERROR);
},
}
);
}
return <NativeShadow {...this.props} />;
}
}
18 changes: 0 additions & 18 deletions src/NativeShadow.ts

This file was deleted.

0 comments on commit 6d23c65

Please sign in to comment.