Skip to content

Commit

Permalink
[RN] Simplify styles which fill the parent view
Browse files Browse the repository at this point in the history
Turns out React Native offers an object with the following definition:

{
    bottom: 0,
    left: 0,
    position: 'absolute',
    right: 0,
    top: 0
}
  • Loading branch information
saghul committed May 23, 2018
1 parent 31864b9 commit bbb1dce
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 62 deletions.
16 changes: 5 additions & 11 deletions react/features/base/dialog/components/styles.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { StyleSheet } from 'react-native';

import { ColorPalette, createStyleSheet } from '../../styles';

/**
Expand Down Expand Up @@ -32,11 +34,7 @@ export const bottomSheetStyles = createStyleSheet({
* view instead, so the modal animation doesn't affect the backdrop.
*/
backdrop: {
bottom: 0,
left: 0,
position: 'absolute',
right: 0,
top: 0
...StyleSheet.absoluteFillObject
},

/**
Expand All @@ -53,12 +51,8 @@ export const bottomSheetStyles = createStyleSheet({
* Style for an overlay on top of which the sheet will be displayed.
*/
overlay: {
backgroundColor: 'rgba(0, 0, 0, 0.8)',
bottom: 0,
left: 0,
position: 'absolute',
right: 0,
top: 0
...StyleSheet.absoluteFillObject,
backgroundColor: 'rgba(0, 0, 0, 0.8)'
},

/**
Expand Down
10 changes: 4 additions & 6 deletions react/features/base/jwt/components/styles.native.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { StyleSheet } from 'react-native';

import { ColorPalette, createStyleSheet } from '../../styles';

export default createStyleSheet({
Expand All @@ -8,17 +10,13 @@ export default createStyleSheet({
* The style of {@code CalleeInfo}.
*/
ringing: {
...StyleSheet.absoluteFillObject,
alignItems: 'center',
backgroundColor: ColorPalette.black,
bottom: 0,
flex: 0,
flexDirection: 'column',
justifyContent: 'center',
left: 0,
opacity: 0.8,
position: 'absolute',
right: 0,
top: 0
opacity: 0.8
},

'ringing__avatar': {
Expand Down
8 changes: 2 additions & 6 deletions react/features/base/media/components/native/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ export default StyleSheet.create({
* and create a fade-in effect.
*/
videoCover: {
backgroundColor: ColorPalette.black,
bottom: 0,
left: 0,
position: 'absolute',
right: 0,
top: 0
...StyleSheet.absoluteFillObject,
backgroundColor: ColorPalette.black
}
});
10 changes: 3 additions & 7 deletions react/features/base/react/components/native/TintedView.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
// @flow

import React, { Component } from 'react';
import { View } from 'react-native';
import { StyleSheet, View } from 'react-native';

import { ColorPalette } from '../../../styles';

/**
* Base style for the {@code TintedView} component.
*/
const BASE_STYLE = {
...StyleSheet.absoluteFillObject,
alignItems: 'center',
bottom: 0,
justifyContent: 'center',
left: 0,
position: 'absolute',
right: 0,
top: 0
justifyContent: 'center'
};

/**
Expand Down
10 changes: 4 additions & 6 deletions react/features/base/react/components/native/styles.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { StyleSheet } from 'react-native';

import {
BoxModel,
ColorPalette,
Expand Down Expand Up @@ -47,15 +49,11 @@ const HEADER_STYLES = {
* The top-level element of a page.
*/
page: {
...StyleSheet.absoluteFillObject,
alignItems: 'stretch',
bottom: 0,
flex: 1,
flexDirection: 'column',
left: 0,
overflow: 'hidden',
position: 'absolute',
right: 0,
top: 0
overflow: 'hidden'
},

/**
Expand Down
10 changes: 4 additions & 6 deletions react/features/large-video/components/styles.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { StyleSheet } from 'react-native';

import { ColorPalette, createStyleSheet } from '../../base/styles';

/**
Expand All @@ -10,14 +12,10 @@ export default createStyleSheet({
* Large video container style.
*/
largeVideo: {
...StyleSheet.absoluteFillObject,
alignItems: 'stretch',
backgroundColor: ColorPalette.appBackground,
bottom: 0,
flex: 1,
justifyContent: 'center',
left: 0,
position: 'absolute',
right: 0,
top: 0
justifyContent: 'center'
}
});
22 changes: 7 additions & 15 deletions react/features/overlay/components/styles.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { StyleSheet } from 'react-native';

import { BoxModel, ColorPalette, createStyleSheet } from '../../base/styles';

/**
Expand All @@ -14,12 +16,8 @@ export const overlayFrame = createStyleSheet({
* rendered.
*/
container: {
backgroundColor: ColorPalette.red,
bottom: 0,
left: 0,
position: 'absolute',
right: 0,
top: 0
...StyleSheet.absoluteFillObject,
backgroundColor: ColorPalette.red
}
});

Expand Down Expand Up @@ -52,22 +50,16 @@ export const pageReloadOverlay = createStyleSheet({
*/
container: {
flex: 1,
marginBottom: BoxModel.margin,
marginHorizontal: BoxModel.margin,
marginTop: BoxModel.margin * 3
margin: BoxModel.margin * 2
},

/**
* Style for the {@code LoadingIndicator}.
*/
loadingIndicator: {
...StyleSheet.absoluteFillObject,
alignItems: 'center',
bottom: 0,
justifyContent: 'center',
left: 0,
position: 'absolute',
right: 0,
top: 0
justifyContent: 'center'
},

/**
Expand Down
7 changes: 2 additions & 5 deletions react/features/toolbox/components/native/styles.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @flow
import { StyleSheet } from 'react-native';

import { BoxModel, ColorPalette, createStyleSheet } from '../../../base/styles';

Expand Down Expand Up @@ -98,11 +99,7 @@ const styles = createStyleSheet({
* of the screen.
*/
toolboxWide: {
bottom: 0,
left: 0,
position: 'absolute',
right: 0,
top: 0
...StyleSheet.absoluteFillObject
},

/**
Expand Down

0 comments on commit bbb1dce

Please sign in to comment.