From 158abfe8bfd20d05cd67c6e861d5db02b4420916 Mon Sep 17 00:00:00 2001 From: Su Min Kim Date: Sat, 5 Dec 2020 16:03:19 -0800 Subject: [PATCH] Add scrollview example (#30454) Summary: Add missing examples to ScrollView for RNTester. ## Changelog [General] [Added] - Add missing examples to ScrollView for RNTester. Pull Request resolved: https://github.com/facebook/react-native/pull/30454 Test Plan: There are a lot of examples that have been added that affects the UI (see RNCore Excel sheet for details). Reviewed By: sammy-SC Differential Revision: D25310613 Pulled By: rickhanlonii fbshipit-source-id: 64a771aa8d3c3683eed983b0c36625078e5533fe --- .../examples/ScrollView/ScrollViewExample.js | 815 ++++++++++++++++++ 1 file changed, 815 insertions(+) diff --git a/packages/rn-tester/js/examples/ScrollView/ScrollViewExample.js b/packages/rn-tester/js/examples/ScrollView/ScrollViewExample.js index 7aa352b4228..ecb390db26e 100644 --- a/packages/rn-tester/js/examples/ScrollView/ScrollViewExample.js +++ b/packages/rn-tester/js/examples/ScrollView/ScrollViewExample.js @@ -15,14 +15,18 @@ const React = require('react'); const { Platform, ScrollView, + Picker, StyleSheet, Text, TouchableOpacity, View, + TextInput, + RefreshControl, } = require('react-native'); const nullthrows = require('nullthrows'); +import {useState, useCallback} from 'react'; import type {ViewStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet'; exports.displayName = 'ScrollViewExample'; @@ -165,6 +169,98 @@ exports.examples = [ return ; }, }, + { + title: ' Content\n', + description: 'Adjust properties of content inside ScrollView.', + render: function(): React.Node { + return ; + }, + }, + { + title: ' Deceleration Rate\n', + description: + 'Determines how quickly the scroll view decelerates after the user lifts their finger.', + render: function(): React.Node { + return ; + }, + }, + { + title: ' Enable & Disable Scrolling Behavior\n', + description: + 'DirectionalLockEnabled (iOS), disableIntervalMomentum, disableScrollViewPanResponder can be enabled or disabled.', + render: function(): React.Node { + return ; + }, + }, + { + title: ' Invert Sticky Headers\n', + description: + 'If sticky headers should stick at the bottom instead of the top of the ScrollView. This is usually used with inverted ScrollViews.', + render: function(): React.Node { + return ; + }, + }, + { + title: ' Keyboard Options\n', + description: + 'Toggle the keyboard using the search bar and determine keyboard behavior in response to drag and tap.', + render: function(): React.Node { + return ; + }, + }, + { + title: ' OnContentSizeChange\n', + description: + 'The text below will change when scrollable content view of the ScrollView changes.', + render: function(): React.Node { + return ; + }, + }, + { + title: ' OnMomentumScroll\n', + description: + 'An alert will be called when the momentum scroll starts or ends.', + render: function(): React.Node { + return ; + }, + }, + { + title: ' OnScroll Options\n', + description: + 'Change the behavior of onScroll using these options: onScrollBeginDrag, onScrollEndDrag, onScrollToTop (iOS), and overScrollMode (Android).', + render: function(): React.Node { + return ; + }, + }, + { + title: ' RefreshControl\n', + description: 'Pull down to see RefreshControl indicator.', + render: function(): React.Node { + return ; + }, + }, + { + title: ' Remove Clipped Subviews\n', + description: + 'When true, offscreen child views (whose overflow value is hidden) are removed from their native backing superview when offscreen.', + render: function(): React.Node { + return ; + }, + }, + { + title: ' Scroll Indicator\n', + description: 'Adjust properties of the scroll indicator.', + render: function(): React.Node { + return ; + }, + }, + { + title: ' SnapTo Options\n', + description: 'Adjust properties of snapping to the scroll view.', + render: function(): React.Node { + return ; + }, + }, ]; if (Platform.OS === 'ios') { exports.examples.push({ @@ -321,8 +417,712 @@ if (Platform.OS === 'ios') { return ; }, }); + exports.examples.push({ + title: ' Always Bounces\n', + description: 'Always bounce vertically or horizontally.', + render: function(): React.Node { + return ( + <> + Vertical + + Horizontal + + + ); + }, + }); + exports.examples.push({ + title: ' Bounces & Bounces Zoom\n', + description: 'There are different options for bouncing behavior.', + render: function(): React.Node { + return ; + }, + }); + exports.examples.push({ + title: ' Indicator Style\n', + description: 'There are different options for indicator style colors.', + render: function(): React.Node { + return ; + }, + }); + exports.examples.push({ + title: ' Maximum & Minimum Zoom Scale\n', + description: 'Set the maximum and minimum allowed zoom scale.', + render: function(): React.Node { + return ; + }, + }); + exports.examples.push({ + title: ' Maximum & Minimum Zoom Scale\n', + description: 'Set the maximum and minimum allowed zoom scale.', + render: function(): React.Node { + return ; + }, + }); + exports.examples.push({ + title: ' ScrollTo Options\n', + description: + 'Toggle scrollToOverflowEnabled and scrollsToTop. When scrollToOverflowEnabled is true, the scroll view can be programmatically scrolled beyond its content size. When scrollsToTop is true, the scroll view scrolls to top when the status bar is tapped.', + render: function(): React.Node { + return ; + }, + }); +} else { + exports.examples.push({ + title: ' EndFillColor & FadingEdgeLength\n', + description: 'Toggle to set endFillColor and fadingEdgeLength.', + render: function(): React.Node { + return ; + }, + }); } +const AndroidScrollBarOptions = () => { + const [persistentScrollBar, setPersistentScrollBar] = useState(false); + return ( + + + {ITEMS.map(createItemRow)} + +