Skip to content

Instantly share code, notes, and snippets.

🌴
On vacation

Dimka Vasilyev gHashTag

🌴
On vacation
Block or report user

Report or block gHashTag

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@gHashTag
gHashTag / StyleSheet.js
Created Jul 30, 2019
MediaQuery React Native
View StyleSheet.js
export const Device = {
select(variants) {
if (W >= 300 && W <= 314) return variants.mobile300 || {}
if (W >= 315 && W <= 341) return variants.iphone5 || {}
if (W >= 342 && W <= 359) return variants.mobile342 || {}
if (W >= 360 && W <= 374) return variants.mi5 || {}
if (W >= 375 && W <= 399) return variants.iphone678 || {}
if (W >= 400 && W <= 409) return variants.mobile400 || {}
if (W >= 410 && W <= 414) return variants.googlePixel || {}
if (W >= 415 && W <= 434) return variants.mobile415 || {}
@gHashTag
gHashTag / Counter.js
Created Jul 30, 2019
CurrentIndex - React Hook
View Counter.js
const App = () => {
const { container } = styles
const [currentIndex, setCurrentIndex] = useState(0)
const array = [{ title: "Today" }, { title: "Week" }, { title: "Month" }]
return (
<View style={container}>
<Text>{${currentIndex}}</Text>
{array.map(({ title }, i) => (
<TouchableOpacity key={title} onPress={() => setCurrentIndex(i)}>
View Toggle.js
this.setState(prevState => ({ check: !prevState.check}))
@gHashTag
gHashTag / Picker.js
Created Jul 30, 2019
Пикер (выбор одного из множества)
View Picker.js
import React, { Component } from 'react'
import { View, StyleSheet } from 'react-native'
import ButtonTransactionItem from './ButtonTransactionItem'
const styles = StyleSheet.create({
container: {
flexDirection: 'row',
backgroundColor: 'white',
height: 50
}
@gHashTag
gHashTag / App.js
Last active Jul 30, 2019
Apollo Link State. Set local storage.
View App.js
import { useApolloClient } from 'react-apollo-hooks'
const App = () => {
const client = useApolloClient()
const onPress = elem => () => client.writeData({ data: { elem } })
return (
<View>
<TouchableOpacity onPress={onPress('text')}>
<Text>Set</Text>
View stargate3.md

Продолжаем курс по Redux или клонируем репу: git clone https://github.com/react-native-village/react-native-init.git

Окончательный код проекта дуступен здесь

Переходим в папку проекта cd react-native-init/stargate2

Удалям редакс из проекта

View defaults.js
export default {
test: 'Hello',
history: [
{
id: 0,
up: false,
},
{
id: 1,
up: false,
View App.js
import React from 'react'
import { Provider } from 'react-redux'
import { composeWithDevTools } from 'redux-devtools-extension'
import { createStore, applyMiddleware } from 'redux'
import ReduxThunk from 'redux-thunk'
import reducers from './src/reducers'
import AppNavigator from './src/AppNavigator'
const store = createStore(reducers, composeWithDevTools(applyMiddleware(ReduxThunk)))
View AppNavigator.js
import React from 'react'
import {
createStackNavigator,
createAppContainer,
createBottomTabNavigator
} from 'react-navigation'
import { Reg, Settings, Wallet, Send, Recieve, History, Scan } from './screens'
import { ButtonTab } from './components'
import SettingsPassword from './screens/Settings/SettingsPassword'
import SendMain from './screens/Send/SendMain'
View CheckToken.js
import React from 'react'
import { AsyncStorage } from 'react-native'
import { Query } from 'react-apollo'
import gql from 'graphql-tag'
import { TOKEN_KEY } from '../constants'
import { Spinner } from '../components'
const REFRESH_TOKEN_QUERY = gql`
query($token: String!) {
update_token(token: $token) {
You can’t perform that action at this time.