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

Fix adjacent views polishing #1289

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
73 changes: 73 additions & 0 deletions examples/components/HorizantalAdjacentViews/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import React, { useRef } from 'react'
import { StyleSheet, Text, View, ActivityIndicator } from 'react-native'
import Swiper from 'react-native-swiper'

const data = []
for (let i = 1; i <= 10; i++) {
data.push(i)
}
export default function App() {
const ref = useRef()
return (
<View style={styles.container}>
<Swiper
ref={ref}
showsButtons={true}
horizontal={true}
loop={true}
onIndexChanged={i => {
console.log('painted ', i)
}}
loadMinimal={true}
loadMinimalSize={3}
loadMinimalLoader={<Loading />}
showAdjacentViews={true}
adjacentViewsWidth={40}
adjacentViewsPadding={2}
decelerationRate={0.7}
>
{data.map((item, index) => {
return (
<View
style={{
width: '100%',
height: '100%',
backgroundColor: 'red',
justifyContent: 'center',
alignItems: 'center'
}}
key={index}
>
<Text style={{ color: 'white', fontSize: 30 }}>{item}</Text>
</View>
)
})}
</Swiper>
</View>
)
}

const styles = StyleSheet.create({
container: {
flex: 1,
paddingTop: 20,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center'
}
})

const Loading = () => (
<View
style={{
width: '100%',
height: '100%',
backgroundColor: 'blue',
justifyContent: 'center',
alignItems: 'center',
elevation: 4
}}
>
<ActivityIndicator size="large" color="orange" />
</View>
)
73 changes: 73 additions & 0 deletions examples/components/VerticalAdjacentViews/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import React, { useRef } from 'react'
import { StyleSheet, Text, View, ActivityIndicator } from 'react-native'
import Swiper from 'react-native-swiper'

const data = []
for (let i = 1; i <= 10; i++) {
data.push(i)
}
export default function App() {
const ref = useRef()
return (
<View style={styles.container}>
<Swiper
ref={ref}
showsButtons={true}
horizontal={false}
loop={true}
onIndexChanged={i => {
console.log('painted ', i)
}}
loadMinimal={true}
loadMinimalSize={3}
loadMinimalLoader={<Loading />}
showAdjacentViews={true}
adjacentViewsWidth={40}
adjacentViewsPadding={2}
decelerationRate={0.7}
>
{data.map((item, index) => {
return (
<View
style={{
width: '100%',
height: '100%',
backgroundColor: 'red',
justifyContent: 'center',
alignItems: 'center'
}}
key={index}
>
<Text style={{ color: 'white', fontSize: 30 }}>{item}</Text>
</View>
)
})}
</Swiper>
</View>
)
}

const styles = StyleSheet.create({
container: {
flex: 1,
paddingTop: 20,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center'
}
})

const Loading = () => (
<View
style={{
width: '100%',
height: '100%',
backgroundColor: 'blue',
justifyContent: 'center',
alignItems: 'center',
elevation: 4
}}
>
<ActivityIndicator size="large" color="orange" />
</View>
)
14 changes: 12 additions & 2 deletions examples/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import Phone from './components/Phone'
// import PhotoView from './components/PhotoView/'; // not working
import Swiper from './components/Swiper' // working but no title displayed, direction vertical not work well on android
import SwiperNumber from './components/SwiperNumber' // working but no title displayed
import VerticalAdjacentViews from './components/VerticalAdjacentViews'
import HorizantalAdjacentViews from './components/HorizantalAdjacentViews'
import { createAppContainer } from 'react-navigation'

const DATA = [
Expand Down Expand Up @@ -57,7 +59,13 @@ const DATA = [
},
{
name: 'SwiperNumber'
}
},
{
name: 'HorizantalAdjacentViews'
},
{
name: 'VerticalAdjacentViews'
},
]

function Item({ title, navigation }) {
Expand Down Expand Up @@ -96,7 +104,9 @@ const AppNavigator = createStackNavigator(
NestSwiper,
Phone,
Swiper,
SwiperNumber
SwiperNumber,
VerticalAdjacentViews,
HorizantalAdjacentViews
},
{
initialRouteName: 'Home'
Expand Down
Loading