Skip to content

Commit

Permalink
Merge pull request #54 from enesozturk/typescript
Browse files Browse the repository at this point in the history
Typescript
  • Loading branch information
enesozturk authored Aug 12, 2020
2 parents 3ed80ae + 2da3e9d commit c03bdb8
Show file tree
Hide file tree
Showing 11 changed files with 187 additions and 240 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ $ yarn add rn-swipeable-panel
## 🚀 How to use

```javascript
import React from "react";
import { StyleSheet, Text, View } from "react-native";
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';

import SwipeablePanel from "rn-swipeable-panel";
import { SwipeablePanel } from 'rn-swipeable-panel';

export default App = () => {
const [panelProps, setPanelProps] = useState({
Expand Down
7 changes: 5 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

import * as React from 'react';

declare var LARGE_PANEL_CONTENT_HEIGHT: number;
declare var SMALL_PANEL_CONTENT_HEIGHT: number;

declare interface SwipeablePanelProps extends React.Props<SwipeablePanel> {
/**
* Required prop for panels actual state. Set true if you want to open panel
Expand Down Expand Up @@ -69,7 +72,7 @@ declare interface SwipeablePanelProps extends React.Props<SwipeablePanel> {
/**
* Use this prop to override bar style
*/
barStyle: object;
barStyle?: object;

/**
* Set true if you want to make toucable outside of panel
Expand All @@ -86,4 +89,4 @@ declare interface SwipeablePanelProps extends React.Props<SwipeablePanel> {

declare class SwipeablePanel extends React.Component<SwipeablePanelProps, any> {}

export default SwipeablePanel;
export { SwipeablePanel, LARGE_PANEL_CONTENT_HEIGHT, SMALL_PANEL_CONTENT_HEIGHT };
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rn-swipeable-panel",
"version": "1.1.12",
"version": "1.1.15",
"description": "Swipeable bottom panel for react native",
"author": "Enes Ozturk",
"license": "MIT",
Expand All @@ -9,6 +9,7 @@
"url": "https://github.com/enesozturk/rn-swipeable-panel"
},
"main": "dist/index.js",
"types": "./index.d.ts",
"module": "dist/index.modern.js",
"source": "src/index.tsx",
"engines": {
Expand Down
Binary file removed rn-swipeable-panel-1.1.12.tgz
Binary file not shown.
Binary file added rn-swipeable-panel-1.1.14.tgz
Binary file not shown.
20 changes: 10 additions & 10 deletions src/Bar.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import * as React from 'react'
import { StyleSheet, View } from 'react-native'
import * as React from 'react';
import { StyleSheet, View } from 'react-native';

type BarProps = {
barStyle?: object
}
barStyle?: object;
};

export const Bar = ({ barStyle }: BarProps) => {
return (
<View style={BarStyles.barContainer}>
<View style={[BarStyles.bar, barStyle]} />
</View>
)
}
);
};

const BarStyles = StyleSheet.create({
barContainer: {
display: 'flex',
justifyContent: 'center',
alignItems: 'center'
alignItems: 'center',
},
bar: {
width: '10%',
height: 5,
borderRadius: 5,
marginTop: 10,
marginBottom: 10,
backgroundColor: '#e2e2e2'
}
})
backgroundColor: '#e2e2e2',
},
});
46 changes: 15 additions & 31 deletions src/Close.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,20 @@
import * as React from 'react'
import { StyleSheet, TouchableOpacity, View } from 'react-native'
import * as React from 'react';
import { StyleSheet, TouchableOpacity, View } from 'react-native';

type CloseProps = {
onPress: () => void
rootStyle?: object
iconStyle?: object
}
onPress: () => void;
rootStyle?: object;
iconStyle?: object;
};

export const Close = ({ onPress, rootStyle, iconStyle }: CloseProps) => {
return (
<TouchableOpacity
activeOpacity={0.5}
onPress={() => onPress()}
style={[CloseStyles.closeButton, rootStyle]}
>
<View
style={[
CloseStyles.iconLine,
iconStyle,
{ transform: [{ rotateZ: '45deg' }] }
]}
/>
<View
style={[
CloseStyles.iconLine,
iconStyle,
{ transform: [{ rotateZ: '135deg' }] }
]}
/>
<TouchableOpacity activeOpacity={0.5} onPress={() => onPress()} style={[CloseStyles.closeButton, rootStyle]}>
<View style={[CloseStyles.iconLine, iconStyle, { transform: [{ rotateZ: '45deg' }] }]} />
<View style={[CloseStyles.iconLine, iconStyle, { transform: [{ rotateZ: '135deg' }] }]} />
</TouchableOpacity>
)
}
);
};

const CloseStyles = StyleSheet.create({
closeButton: {
Expand All @@ -44,13 +28,13 @@ const CloseStyles = StyleSheet.create({
zIndex: 3,
display: 'flex',
justifyContent: 'center',
alignItems: 'center'
alignItems: 'center',
},
iconLine: {
position: 'absolute',
width: 18,
height: 2,
borderRadius: 2,
backgroundColor: 'white'
}
})
backgroundColor: 'white',
},
});
Loading

0 comments on commit c03bdb8

Please sign in to comment.