Skip to content

Table sub windows - fix constants and compomponents #2785

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions demo/src/screens/componentScreens/ExpandableSectionScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ExpandableSectionScreen extends PureComponent {
return (
<View margin-10 spread row>
<Text grey10 text60>
ExpandableSection's sectionHeader
ExpandableSection sectionHeader
</Text>
<Image style={styles.icon} source={this.getChevron()}/>
</View>
Expand All @@ -73,7 +73,7 @@ class ExpandableSectionScreen extends PureComponent {

getBodyElement() {
return (
<Carousel pageWidth={350} itemSpacings={Spacings.s2}>
<Carousel>
{_.map(this.elements, (element, key) => {
return (
<View key={key} margin-12>
Expand Down
5 changes: 3 additions & 2 deletions ios/rnuilib/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<true/>
</dict>
</plist>
12 changes: 8 additions & 4 deletions src/commons/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ let windowWidth: number = Dimensions.get('window').width;
let breakpoints: Breakpoint[];
let defaultMargin = 0;

const isSubWindow = windowWidth < screenWidth;
//@ts-ignore
isTablet = Platform.isPad || (getAspectRatio() < 1.6 && Math.max(screenWidth, screenHeight) >= 900);

Expand Down Expand Up @@ -114,12 +115,18 @@ const constants = {
get windowHeight() {
return windowHeight;
},
get isSmallWindow() {
return windowWidth <= 340;
},
get isSmallScreen() {
return screenWidth <= 340;
},
get isShortScreen() {
return screenHeight <= 600;
},
get isWideScreen() {
return isTablet && !isSubWindow || this.isLandscape;
},
get screenAspectRatio() {
return getAspectRatio();
},
Expand All @@ -141,16 +148,13 @@ const constants = {
}

for (let i = breakpoints.length - 1; i >= 0; --i) {
if (screenWidth > breakpoints[i].breakpoint) {
if (windowWidth > breakpoints[i].breakpoint) {
return breakpoints[i].pageMargin;
}
}

return defaultMargin;
},
get isWideScreen() {
return isTablet || this.isLandscape;
},
getSafeAreaInsets: () => {
const orientation = getOrientation(screenHeight, screenWidth);
return orientation === orientations.LANDSCAPE
Expand Down
2 changes: 1 addition & 1 deletion src/components/colorPalette/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class ColorPalette extends PureComponent<Props, State> {

get containerWidth() {
const {containerWidth} = this.props;
return containerWidth || Constants.screenWidth;
return containerWidth || Constants.windowWidth;
}

getUniqueColors = memoize(colors => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/connectionStatusBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class ConnectionStatusBar extends PureComponent<ConnectionStatusBarProps, Connec
}

function createStyles() {
const typography = Constants.isSmallScreen ? Typography.text90 : Typography.text80;
const typography = Constants.isSmallWindow ? Typography.text90 : Typography.text80;
return StyleSheet.create({
topContainer: {
backgroundColor: Colors.grey30
Expand Down
2 changes: 1 addition & 1 deletion src/components/gridList/useGridLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const useGridLayout = (props: GridListBaseProps) => {
const {orientation} = useOrientation();

const _containerWidth = useMemo(() => {
return (containerWidth ?? Constants.screenWidth - Constants.getPageMargins()) - listPadding * 2;
return (containerWidth ?? Constants.windowWidth - Constants.getPageMargins()) - listPadding * 2;
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [listPadding, orientation, containerWidth]);

Expand Down
2 changes: 1 addition & 1 deletion src/components/gridView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class GridView extends UIComponent<GridViewProps, GridViewState> {
};

getDefaultViewWidth() {
return Constants.screenWidth - (Constants.getPageMargins() || Spacings.s5) * 2;
return Constants.windowWidth - (Constants.getPageMargins() || Spacings.s5) * 2;
}

getGridContainerWidth() {
Expand Down
6 changes: 3 additions & 3 deletions src/components/hint/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ class Hint extends Component<HintProps, HintState> {
}

get containerWidth() {
const {containerWidth = Constants.screenWidth} = this.props;
const {containerWidth = Constants.windowWidth} = this.props;
return containerWidth;
}

Expand Down Expand Up @@ -626,7 +626,7 @@ const styles = StyleSheet.create({
},
overlay: {
position: 'absolute',
width: Constants.screenWidth,
width: Constants.windowWidth,
height: Constants.screenHeight
},
animatedContainer: {
Expand All @@ -636,7 +636,7 @@ const styles = StyleSheet.create({
position: 'absolute'
},
hint: {
maxWidth: Math.min(Constants.screenWidth - 2 * Spacings.s4, 400),
maxWidth: Math.min(Constants.windowWidth - 2 * Spacings.s4, 400),
borderRadius: BorderRadiuses.br60,
backgroundColor: DEFAULT_COLOR
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/stackAggregator/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ const StackAggregator = (props: StackAggregatorProps) => {
alignSelf: 'center',
zIndex: itemsCount - index,
transform: [{scaleX: animatedScaleArray[index]}],
width: Constants.screenWidth - 40,
width: Constants.windowWidth - 40,
height: isCollapsed ? firstItemHeight : undefined
}
]}
Expand Down
6 changes: 3 additions & 3 deletions src/components/wizard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ class Wizard extends Component<WizardProps, State> {
getMaxWidth() {
if (Constants.isTablet) {
if (Constants.isLandscape) {
return Constants.screenWidth * 0.2;
return Constants.windowWidth * 0.2;
} else {
return Constants.screenWidth * 0.26;
return Constants.windowWidth * 0.26;
}
} else {
return Constants.screenWidth * 0.4;
return Constants.windowWidth * 0.4;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/incubator/Calendar/CalendarItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default React.memo(CalendarItem);

const styles = StyleSheet.create({
container: {
width: Constants.screenWidth,
width: Constants.windowWidth,
borderBottomWidth: 1
}
});