Browse Source

Faded picker

pull/8/head
Tim Glasgow 2 years ago
parent
commit
ff475a5238
  1. 31
      squarenotsquare/src/components/ScrollingPicker.js
  2. 2
      squarenotsquare/src/screens/Home.js

31
squarenotsquare/src/components/ScrollingPicker.js

@ -8,11 +8,10 @@ import Icons from '../themes/Icons';
import Colors from "../themes/Colors"; import Colors from "../themes/Colors";
import Metrics from "../themes/Metrics"; import Metrics from "../themes/Metrics";
import { styles } from "../screens/styles/AppStyles"; import { styles } from "../screens/styles/AppStyles";
import finalPropsSelectorFactory from "react-redux/es/connect/selectorFactory"; import Fade from "./Fade";
function ScrollingPicker(props) { function ScrollingPicker(props) {
const scrollX = useRef(new Animated.Value(0)).current; const scrollX = useRef(new Animated.Value(0)).current;
const [selected, setSelected] = useState(0);
function onScroll(event){ function onScroll(event){
if (event.nativeEvent.contentOffset.x === 0) { if (event.nativeEvent.contentOffset.x === 0) {
@ -40,18 +39,22 @@ function ScrollingPicker(props) {
onScroll={onScroll} onScroll={onScroll}
scrollEventThrottle={0} scrollEventThrottle={0}
> >
<MaterialIcon <Fade faded={props.mode !== 0} duration={250}>
name={Icons.squareIcons.square} <MaterialIcon
color={Colors.material.dark} name={Icons.squareIcons.square}
size={Metrics.icons.buttonIcon} color={Colors.material.dark}
style={styles.modePickerMargin} size={Metrics.icons.buttonIcon}
/> style={styles.modePickerMargin}
<MaterialIcon />
name={Icons.squareIcons.plus} </Fade>
color={Colors.material.dark} <Fade faded={props.mode !== 1} duration={250}>
size={Metrics.icons.buttonIcon} <MaterialIcon
style={styles.modePickerMargin} name={Icons.squareIcons.plus}
/> color={Colors.material.dark}
size={Metrics.icons.buttonIcon}
style={styles.modePickerMargin}
/>
</Fade>
</ScrollView> </ScrollView>
); );
} }

2
squarenotsquare/src/screens/Home.js

@ -51,7 +51,7 @@ function Home(){
</Text> </Text>
</View> </View>
<View style={[styles.flex, styles.centeredSelf]}> <View style={[styles.flex, styles.centeredSelf]}>
<ModePicker modeSetter={setMode}/> <ModePicker mode={mode} modeSetter={setMode}/>
<Text style={[styles.largeFont, styles.darkText, styles.centeredText]}> <Text style={[styles.largeFont, styles.darkText, styles.centeredText]}>
{mode === 0 ? 'Squares' : 'Addition'} {mode === 0 ? 'Squares' : 'Addition'}
</Text> </Text>

Loading…
Cancel
Save