yarn add react-native-config
react-native link react-native-config
- Create
.env
files for each configuration. Ex:.env.dev
,.env.prod
, etc Ex:
API_ENDPOINT=https://api.myresource.com/dev
ENV=dev
import { ColorSchemeName, Platform, StyleSheet, ViewStyle } from 'react-native'; | |
// AFAIK, Android has a problem with negative margins. | |
type RhythmSize = 'XXS' | 'XS' | 'Sm' | '' | 'Lg' | 'XL' | 'XXL'; | |
type RhythmProp = | |
| `${ | |
| 'm' | |
| 'p' | |
| `${'m' | 'p'}${'l' | 'r' | 't' | 'b' | 'v' | 'h'}`}${RhythmSize}` | |
| `${'w' | 'h' | `${'max' | 'min'}${'W' | 'H'}`}${RhythmSize}` |
import { pipe } from 'fp-ts/function'; | |
import { lens } from 'monocle-ts'; | |
import { memo, useLayoutEffect, useRef, useState } from 'react'; | |
import { LayoutChangeEvent, Text, View } from 'react-native'; | |
import { useTheme } from '../contexts/ThemeContext'; | |
const isOverflown = ({ | |
clientWidth, | |
clientHeight, | |
scrollWidth, |
// Adapted from http://lukajcb.github.io/blog/functional/2018/01/03/optimizing-tagless-final.html | |
import { Applicative, Applicative1 } from 'fp-ts/lib/Applicative' | |
import { Apply, Apply1, Apply2C, applySecond, liftA4 } from 'fp-ts/lib/Apply' | |
import * as array from 'fp-ts/lib/Array' | |
import * as const_ from 'fp-ts/lib/Const' | |
import { HKT, Type, Type2, URIS, URIS2 } from 'fp-ts/lib/HKT' | |
import { IO, io, URI as IOURI } from 'fp-ts/lib/IO' | |
import { Option, some } from 'fp-ts/lib/Option' | |
import { getProductSemigroup, Semigroup } from 'fp-ts/lib/Semigroup' |
import * as React from 'react'; | |
import { render } from 'react-native-testing-library'; | |
import { Provider } from 'react-redux'; | |
import { createStore } from 'redux'; | |
import { MyContainerComponent, MyPresentationalComponent } from '...'; | |
// Create a real redux store, with your reducers and middleware, and a useful initial | |
// state tree... | |
const store = createStore(...); |
import Control.Concurrent | |
import Control.Monad | |
import Data.Maybe | |
import Data.Time | |
import Network.Browser | |
import Network.HTTP | |
import Network.HTTP.Proxy | |
import Network.URI | |
import System.Locale |
http://miot-spec.org/miot-spec-v2/instances?status=all | |
http://miot-spec.org/miot-spec-v2/instances?status=debug | |
http://miot-spec.org/miot-spec-v2/instances?status=released | |
and for example air purifier 3 cn (zhimi.airpurifier.ma4) | |
https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:air-purifier:0000A007:zhimi-ma4:1 | |
http://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:light:0000A001:philips-bulb:1 | |
http://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:fan:0000A005:zhimi-sa1:1 |
yarn add react-native-config
react-native link react-native-config
.env
files for each configuration. Ex: .env.dev
, .env.prod
, etc
Ex:API_ENDPOINT=https://api.myresource.com/dev
ENV=dev
const widthPercentageToDP = widthPercent => { | |
const screenWidth = Dimensions.get('window').width; | |
const elemWidth = parseFloat(widthPercent); | |
return PixelRatio.roundToNearestPixel(screenWidth * elemWidth / 100); | |
}; | |
const heightPercentageToDP = heightPercent => { | |
const screenHeight = Dimensions.get('window').height; | |
const elemHeight = parseFloat(heightPercent); | |
return PixelRatio.roundToNearestPixel(screenHeight * elemHeight / 100); | |
}; |