From 9facef83b5c539c177c7537ffcea79dafbd2b302 Mon Sep 17 00:00:00 2001 From: andyboythekid Date: Thu, 4 Jul 2019 12:50:03 -0600 Subject: [PATCH] rewrite pager --- example/src/index.tsx | 73 +++++---- src/create-screen.tsx | 35 +---- src/index.tsx | 4 +- src/link.tsx | 5 +- src/navigator.tsx | 30 ++-- src/pager.tsx | 349 ++++++++++++++++++++++-------------------- src/screen.tsx | 36 ++++- src/stack.tsx | 88 +++++++---- src/stacker.tsx | 342 ----------------------------------------- src/tabs.tsx | 89 +++++++---- src/views.tsx | 8 +- todo.txt | 12 +- 12 files changed, 413 insertions(+), 658 deletions(-) delete mode 100644 src/stacker.tsx diff --git a/example/src/index.tsx b/example/src/index.tsx index 1249409..c36aca6 100644 --- a/example/src/index.tsx +++ b/example/src/index.tsx @@ -1,5 +1,5 @@ // app entry -import React, { useState } from 'react'; +import React, { useState, Children } from 'react'; import { AppRegistry, Platform, @@ -8,21 +8,22 @@ import { ViewStyle, StyleProp, Button, + SafeAreaView, } from 'react-native'; import { Link, Navigator, - Tabs, Pager, - Stack, Tabbar, Tab, + Tabs, + Stack, } from 'react-navigation-library'; import { FlatList, BorderlessButton } from 'react-native-gesture-handler'; function PagerApp() { - const [activeIndex, setActiveIndex] = useState(0); + const [activeIndex, setActiveIndex] = useState(-1); function handleChange(index: number) { setActiveIndex(index); @@ -30,34 +31,40 @@ function PagerApp() { return ( - - + + 0 setActiveIndex(activeIndex + 1)}> Next - - + + 1 setActiveIndex(activeIndex + 1)}> Next - - + + 2 setActiveIndex(activeIndex + 1)}> Next - - + + 3 - - + + 4 - + - +