This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useState, useRef } from 'react'; | |
| import { | |
| SafeAreaView, | |
| StyleSheet, | |
| View, | |
| Text, | |
| StatusBar, | |
| Image, | |
| Switch, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const App = () => { | |
| const [isDarkMode, setDarkMode] = useState(false); | |
| return ( | |
| <> | |
| <StatusBar barStyle="dark-content" /> | |
| <SafeAreaView style={{ flex: 1 }}> | |
| { | |
| isDarkMode && <View style={{ ...StyleSheet.absoluteFillObject, backgroundColor: 'black' }} /> | |
| } | |
| <View style={{ marginVertical: 40, marginHorizontal: 20 }}> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useState } from 'react'; | |
| import { | |
| SafeAreaView, | |
| StyleSheet, | |
| View, | |
| Text, | |
| StatusBar, | |
| Image, | |
| Switch, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const App = () => { | |
| const [sliderState, setSliderState] = useState({ currentPage: 0 }); | |
| const { width, height } = Dimensions.get('window'); | |
| const setSliderPage = (event: any) => { | |
| const { currentPage } = sliderState; | |
| const { x } = event.nativeEvent.contentOffset; | |
| const indexOfNextScreen = Math.floor(x / width); | |
| if (indexOfNextScreen !== currentPage) { | |
| setSliderState({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const App = () => { | |
| const { width, height } = Dimensions.get('window'); | |
| return ( | |
| <> | |
| <StatusBar barStyle="dark-content" /> | |
| <SafeAreaView style={{ flex: 1 }}> | |
| <ScrollView | |
| style={{ flex: 1 }} | |
| horizontal={true} | |
| scrollEventThrottle={16} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const App = () => { | |
| const { width, height } = Dimensions.get('window'); | |
| return ( | |
| <> | |
| <StatusBar barStyle="dark-content" /> | |
| <SafeAreaView style={{ flex: 1 }}> | |
| <ScrollView | |
| style={{ flex: 1 }} | |
| horizontal={true} | |
| scrollEventThrottle={16} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def multi_add(*args): | |
| result = 0 | |
| for x in args: | |
| result = result + x | |
| return result | |
| print(1, 2, 3, 4, 5) # 15 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def power(num, x=1): | |
| result = 1 | |
| for i in range(x): | |
| result = result * num | |
| return result | |
| power(4) # 4 | |
| power(4, 2) # 16 | |
| power(4, 3) # 64 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def cube(num): | |
| return num*num*num | |
| print(3 + cube(3)) #30 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def addNumbers(arg1, arg2): | |
| print(arg1 + arg2) | |
| addNumbers(4, 5) #9 |
NewerOlder