Skip to content

Commit

Permalink
Merge pull request #738 from shoutem/release/5.3.0
Browse files Browse the repository at this point in the history
Release/5.3.0
  • Loading branch information
Definitely-Not-Vlad authored Aug 1, 2022
2 parents 55eb192 + 6e5266c commit 0e24c72
Show file tree
Hide file tree
Showing 13 changed files with 26,964 additions and 3,511 deletions.
55 changes: 55 additions & 0 deletions __tests__/View-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import React from 'react';
import renderer from 'react-test-renderer';
import { View } from '../components/View';

test('View renders correctly', () => {
const tree = renderer.create(
<View style={{ height: 40, width: 40, backgroundColor: 'red' }} />,
).toJSON();

expect(tree).toMatchSnapshot();
});

test('View renders children vertically with vertical styleName', () => {
const tree = renderer.create(
<View styleName="vertical">
<View style={{ height: 40, width: 40, backgroundColor: 'red' }} />
<View style={{ height: 40, width: 40, backgroundColor: 'green' }} />
</View>
);
});

test('View centers children horizontally with h-center styleName', () => {
const tree = renderer.create(
<View style={{ width: 100 }} styleName="vertical h-center">
<View style={{ height: 40, width: 40, backgroundColor: 'red' }} />
<View style={{ height: 40, width: 40, backgroundColor: 'green' }} />
</View>
);
});

test('View renders children horizontally with horizontal styleName', () => {
const tree = renderer.create(
<View styleName="horizontal">
<View style={{ height: 40, width: 40, backgroundColor: 'red' }} />
<View style={{ height: 40, width: 40, backgroundColor: 'green' }} />
</View>
);
});

test('View centers children vertically with v-center styleName', () => {
const tree = renderer.create(
<View style={{ height: 100 }} styleName="horizontal v-center">
<View style={{ height: 40, width: 40, backgroundColor: 'red' }} />
<View style={{ height: 40, width: 40, backgroundColor: 'green' }} />
</View>
);
});

test('View fills parent with fill-parent styleName', () => {
const tree = renderer.create(
<View style={{ height: 40, width: 40 }}>
<View style={{ backgroundColor: 'red' }} styleName="fill-parent" />
</View>
);
});
15 changes: 15 additions & 0 deletions __tests__/__snapshots__/View-test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`View renders correctly 1`] = `
<View
animationOptions={Object {}}
onLayout={[Function]}
style={
Object {
"backgroundColor": "red",
"height": 40,
"width": 40,
}
}
/>
`;
82 changes: 0 additions & 82 deletions _tests_/VideoSourceReader.spec.js

This file was deleted.

34 changes: 21 additions & 13 deletions const.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
const IPHONE_X_HOME_INDICATOR_PADDING = 34;
const IPHONE_X_LONG_SIDE = 812;
const IPHONE_X_NOTCH_PADDING = 30;

const IPHONE_XR_LONG_SIDE = 896;
const IPHONE_XR_NOTCH_PADDING = 34;

const IPHONE_12_LONG_SIDE = 844;
const IPHONE_12_MAX_LONG_SIDE = 926;

const NAVIGATION_HEADER_HEIGHT = 64;

module.exports = {
import { Platform, StatusBar } from 'react-native';
import {
IPHONE_12_LONG_SIDE,
IPHONE_12_MAX_LONG_SIDE,
IPHONE_X_HOME_INDICATOR_PADDING,
IPHONE_X_LONG_SIDE,
IPHONE_X_NOTCH_PADDING,
IPHONE_XR_LONG_SIDE,
IPHONE_XR_NOTCH_PADDING,
NAVIGATION_BAR_HEIGHT,
NAVIGATION_HEADER_HEIGHT,
} from './helpers';

const STATUS_BAR_OFFSET =
Platform.OS === 'android' ? -StatusBar.currentHeight : 0;

// TODO: Deprecate and remove exports from here
// Currently leaving for backwards compatibility
export {
IPHONE_12_LONG_SIDE,
IPHONE_12_MAX_LONG_SIDE,
IPHONE_X_HOME_INDICATOR_PADDING,
IPHONE_X_LONG_SIDE,
IPHONE_X_NOTCH_PADDING,
IPHONE_XR_LONG_SIDE,
IPHONE_XR_NOTCH_PADDING,
NAVIGATION_BAR_HEIGHT,
NAVIGATION_HEADER_HEIGHT,
STATUS_BAR_OFFSET,
};
6 changes: 3 additions & 3 deletions examples/RestaurantsApp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions examples/create-react-native-app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 20 additions & 7 deletions helpers/device-selector.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
import { Dimensions, Platform } from 'react-native';
import { Dimensions, Platform, StatusBar } from 'react-native';
import { hasNotch } from 'react-native-device-info';
import _ from 'lodash';
import {
IPHONE_12_LONG_SIDE,
IPHONE_12_MAX_LONG_SIDE,
IPHONE_X_LONG_SIDE,
IPHONE_XR_LONG_SIDE,
} from '../const';

const { OS, isPad, isTVOS } = Platform;
const { width, height } = Dimensions.get('window');

export const IPHONE_X_HOME_INDICATOR_PADDING = 34;
export const IPHONE_X_LONG_SIDE = 812;
export const IPHONE_X_NOTCH_PADDING = 30;

export const IPHONE_XR_LONG_SIDE = 896;
export const IPHONE_XR_NOTCH_PADDING = 34;

export const IPHONE_12_LONG_SIDE = 844;
export const IPHONE_12_MAX_LONG_SIDE = 926;

export const NAVIGATION_HEADER_HEIGHT = 64;

const xDimensionsMatch =
height === IPHONE_X_LONG_SIDE || width === IPHONE_X_LONG_SIDE;

Expand Down Expand Up @@ -58,6 +64,13 @@ function select(settings) {
return _.get(settings, 'default');
}

export const NAVIGATION_BAR_HEIGHT = select({
iPhoneX: NAVIGATION_HEADER_HEIGHT + IPHONE_X_NOTCH_PADDING,
iPhoneXR: NAVIGATION_HEADER_HEIGHT + IPHONE_XR_NOTCH_PADDING,
notchedAndroid: NAVIGATION_HEADER_HEIGHT + StatusBar.currentHeight,
default: NAVIGATION_HEADER_HEIGHT,
});

export const Device = {
isIphoneX,
isIphoneXR,
Expand Down
17 changes: 13 additions & 4 deletions helpers/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
import { Device } from './device-selector';
import Keyboard from './keyboard';

export { Device, Keyboard };
export {
Device,
IPHONE_12_LONG_SIDE,
IPHONE_12_MAX_LONG_SIDE,
IPHONE_X_HOME_INDICATOR_PADDING,
IPHONE_X_LONG_SIDE,
IPHONE_X_NOTCH_PADDING,
IPHONE_XR_LONG_SIDE,
IPHONE_XR_NOTCH_PADDING,
NAVIGATION_BAR_HEIGHT,
NAVIGATION_HEADER_HEIGHT,
} from './device-selector';
export { calculateKeyboardOffset, default as Keyboard } from './keyboard';
6 changes: 5 additions & 1 deletion helpers/keyboard.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Platform, StatusBar } from 'react-native';
import { NAVIGATION_BAR_HEIGHT } from '../theme';
import { NAVIGATION_BAR_HEIGHT } from './device-selector';

export function calculateKeyboardOffset(extraOffset = 0) {
const resolvedOffset = NAVIGATION_BAR_HEIGHT + extraOffset;
Expand All @@ -11,4 +11,8 @@ export function calculateKeyboardOffset(extraOffset = 0) {
return StatusBar.currentHeight + resolvedOffset;
}

// TODO: Deprecate and remove Keyboard.calculateKeyboardOffset
// Replace with direct function call. It's cleaner for any practical use of this
// because we will usually import Keyboard from react-native alongside this, so
// we're forced to rename imports.
export default { calculateKeyboardOffset };
23 changes: 12 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
import { setDefaultThemeStyle } from './init';
import getTheme, {
calculateLineHeight,
defaultThemeVariables,
dimensionRelativeToIphone,
resolveFontFamily,
resolveFontStyle,
resolveFontWeight,
} from './theme';

setDefaultThemeStyle();

Expand All @@ -15,12 +7,13 @@ export {
calculateLineHeight,
defaultThemeVariables,
dimensionRelativeToIphone,
getTheme,
default as getTheme,
resolveFontFamily,
resolveFontStyle,
resolveFontWeight,
};
} from './theme';

// Services
export {
createScopedResolver,
resolveVariable,
Expand Down Expand Up @@ -76,8 +69,14 @@ export { TouchableOpacity } from './components/TouchableOpacity';
export { Video } from './components/Video';
export { View } from './components/View';
export { YearRangePicker } from './components/YearRangePicker';

// Examples
export { Examples } from './examples/components';
export { Device, Keyboard } from './helpers';

// Helpers
export { calculateKeyboardOffset, Device, Keyboard } from './helpers';

// HTML
export { Html } from './html';
export { SimpleHtml } from './html';

Expand All @@ -89,5 +88,7 @@ export {
IPHONE_XR_LONG_SIDE,
IPHONE_XR_NOTCH_PADDING,
nativeDependencies,
NAVIGATION_BAR_HEIGHT,
NAVIGATION_HEADER_HEIGHT,
STATUS_BAR_OFFSET,
} from './const';
Loading

0 comments on commit 0e24c72

Please sign in to comment.