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

SwipeableFlatList, SwipeableQuickActions: Remove PropTypes #21384

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 12 additions & 24 deletions Libraries/Experimental/SwipeableRow/SwipeableFlatList.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,31 @@ const React = require('React');
const SwipeableRow = require('SwipeableRow');
const FlatList = require('FlatList');

// TODO: Make this $ReadOnly and Exact. Will require doing the same to the props in
// Libraries/Lists/*
type SwipableListProps = {
/**
* To alert the user that swiping is possible, the first row can bounce
* on component mount.
*/
bounceFirstRowOnMount: boolean,
// Maximum distance to open to after a swipe

/**
* Maximum distance to open to after a swipe
*/
maxSwipeDistance: number | (Object => number),
// Callback method to render the view that will be unveiled on swipe

/**
* Callback method to render the view that will be unveiled on swipe
*/
renderQuickActions: renderItemType,
};

type Props<ItemT> = SwipableListProps & FlatListProps<ItemT>;

type State = {
type State = {|
openRowKey: ?string,
};
|};

/**
* A container component that renders multiple SwipeableRow's in a FlatList
Expand All @@ -53,29 +61,9 @@ type State = {
*/

class SwipeableFlatList<ItemT> extends React.Component<Props<ItemT>, State> {
props: Props<ItemT>;
state: State;

_flatListRef: ?FlatList<ItemT> = null;
_shouldBounceFirstRowOnMount: boolean = false;

static propTypes = {
...FlatList.propTypes,

/**
* To alert the user that swiping is possible, the first row can bounce
* on component mount.
*/
bounceFirstRowOnMount: PropTypes.bool.isRequired,

// Maximum distance to open to after a swipe
maxSwipeDistance: PropTypes.oneOfType([PropTypes.number, PropTypes.func])
.isRequired,

// Callback method to render the view that will be unveiled on swipe
renderQuickActions: PropTypes.func.isRequired,
};

static defaultProps = {
...FlatList.defaultProps,
bounceFirstRowOnMount: true,
Expand Down
13 changes: 7 additions & 6 deletions Libraries/Experimental/SwipeableRow/SwipeableQuickActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@

'use strict';

const DeprecatedViewPropTypes = require('DeprecatedViewPropTypes');
const React = require('React');
const StyleSheet = require('StyleSheet');
const View = require('View');

import type {ViewStyleProp} from 'StyleSheet';

type Props = $ReadOnly<{|
style?: ?ViewStyleProp,
|}>;

/**
* A thin wrapper around standard quick action buttons that can, if the user
* chooses, be used with SwipeableListView. Sample usage is as follows, in the
Expand All @@ -25,11 +30,7 @@ const View = require('View');
* <SwipeableQuickActionButton {..props} />
* </SwipeableQuickActions>
*/
class SwipeableQuickActions extends React.Component<{style?: $FlowFixMe}> {
static propTypes = {
style: DeprecatedViewPropTypes.style,
};

class SwipeableQuickActions extends React.Component<Props> {
render(): React.Node {
// $FlowFixMe found when converting React.createClass to ES6
const children = this.props.children;
Expand Down