Skip to content
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

feat: add topInsetEnabled prop when StatusBar is translucent #1372

Merged
merged 22 commits into from
Mar 18, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b5c2eee
fix: add change orientation event with modal render
Feb 7, 2021
2ac98ef
update: change forceRender method, make it private
Feb 10, 2021
dfb762d
update: rename method regarding event listener meaning
Feb 11, 2021
9140755
Merge branch 'master' into update/modal
malashkevich Feb 12, 2021
020c842
feat: add topInsetEnabled prop when StatusBar is translucent
Mar 11, 2021
a8e168d
update(measure component): rollback changes
Mar 14, 2021
c2c2a07
update(modalServie): add method for statusbar config height
Mar 14, 2021
a78f4b5
fix(modalService): fix accordingly comments
Mar 15, 2021
ddd5742
fix: resolve comments
Mar 16, 2021
6c0cb8e
updaet(measureElement): make props optional, add default prop value
Mar 17, 2021
b7c6ac8
fix: update default props types realisation
Mar 17, 2021
d360a18
feat(modalService): add access modifiers
Mar 18, 2021
56b5c2b
feat: add topInsetEnabled prop when StatusBar is translucent
Mar 11, 2021
fb628da
update(measure component): rollback changes
Mar 14, 2021
0d63474
update(modalServie): add method for statusbar config height
Mar 14, 2021
e773075
fix(modalService): fix accordingly comments
Mar 15, 2021
94725f3
fix: resolve comments
Mar 16, 2021
3e71020
updaet(measureElement): make props optional, add default prop value
Mar 17, 2021
0634a89
fix: update default props types realisation
Mar 17, 2021
2f67d20
feat(modalService): add access modifiers
Mar 18, 2021
c68a526
Merge branch 'update/modalService' of https://github.com/whitestrange…
Mar 18, 2021
d3401e0
merge: master merge & resolve conflicts
Mar 18, 2021
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
15 changes: 10 additions & 5 deletions src/components/devsupport/components/measure/measure.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@ import React from 'react';
import {
findNodeHandle,
UIManager,
StatusBar,
} from 'react-native';
import { Frame } from './type';

export interface MeasureElementProps<P = any> {
force?: boolean;
shouldUseTopInsets: boolean;
onMeasure: (frame: Frame) => void;
children: React.ReactElement<P>;
}

export type MeasuringElement<P = any> = React.ReactElement;

/**
* Measures child element size and it's screen position asynchronously.
* Returns measure result in `onMeasure` callback.
Expand All @@ -32,7 +34,9 @@ export type MeasuringElement<P = any> = React.ReactElement;
* ...
* };
*
* <MeasureElement onMeasure={onMeasure}>
* <MeasureElement
* shouldUseTopInsets={ModalService.getShouldUseTopInsets}
* onMeasure={onMeasure}>
* <ElementToMeasure />
* </MeasureElement>
* ```
Expand Down Expand Up @@ -61,7 +65,8 @@ export const MeasureElement = (props: MeasureElementProps): MeasuringElement =>
};

const onUIManagerMeasure = (x: number, y: number, w: number, h: number): void => {
const frame: Frame = bindToWindow(new Frame(x, y, w, h), Frame.window());
const originY = props.shouldUseTopInsets ? y + StatusBar.currentHeight || 0 : y;
const frame: Frame = bindToWindow(new Frame(x, originY, w, h), Frame.window());
props.onMeasure(frame);
};

Expand All @@ -75,4 +80,4 @@ export const MeasureElement = (props: MeasureElementProps): MeasuringElement =>
}

return React.cloneElement(props.children, { ref, onLayout: measureSelf });
};
};
24 changes: 12 additions & 12 deletions src/components/theme/application/applicationProvider.component.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* @license
* Copyright Akveo. All Rights Reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/
* @license
* Copyright Akveo. All Rights Reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import React from 'react';
import merge from 'lodash.merge';
Expand All @@ -15,25 +15,25 @@ import {
import { StyleProvider } from '../style/styleProvider.component';
import { ThemeProviderProps } from '../theme/themeProvider.component';
import { ModalPanel } from '../modal/modalPanel.component';

whitestranger7 marked this conversation as resolved.
Show resolved Hide resolved
interface EvaRuntimeProcessingProps {
mapping: SchemaType;
customMapping?: CustomSchemaType;
}

interface EvaBuildtimeProcessingProps {
styles: ThemeStyleType;
}

type EvaProcessingProps = EvaRuntimeProcessingProps | EvaBuildtimeProcessingProps;

export type ApplicationProviderProps = EvaProcessingProps & ThemeProviderProps;
export type ApplicationProviderElement = React.ReactElement<ApplicationProviderProps>;

interface State {
styles: ThemeStyleType;
}

/**
* Overall application container.
*
Expand Down Expand Up @@ -110,7 +110,7 @@ export class ApplicationProvider extends React.Component<ApplicationProviderProp
this.state.styles = this.createStyles(mapping, customMapping);
}
}

private createStyles = (mapping: SchemaType, custom: CustomSchemaType): ThemeStyleType => {
const customizedMapping: SchemaType = merge({}, mapping, custom);
return this.schemaProcessor.process(customizedMapping);
Expand All @@ -127,4 +127,4 @@ export class ApplicationProvider extends React.Component<ApplicationProviderProp
</StyleProvider>
);
}
}
}
9 changes: 9 additions & 0 deletions src/components/theme/modal/modal.service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import {
class ModalServiceType {

panel: ModalPresenting | null = null;
private shouldUseTopInsets: boolean = false;

public mount(panel: ModalPresenting | null): void {
this.panel = panel;
Expand All @@ -87,6 +88,14 @@ class ModalServiceType {
return this.panel.hide(identifier);
}
}

set setShouldUseTopInsets(state: boolean) {
whitestranger7 marked this conversation as resolved.
Show resolved Hide resolved
this.shouldUseTopInsets = state;
};

get getShouldUseTopInsets(): boolean {
whitestranger7 marked this conversation as resolved.
Show resolved Hide resolved
return this.shouldUseTopInsets;
}
}

export interface ModalPresentingConfig {
Expand Down
5 changes: 4 additions & 1 deletion src/components/ui/menu/menuGroup.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
MenuItemElement,
MenuItemProps,
} from './menuItem.component';
import { ModalService } from '../../theme';

export interface MenuGroupProps extends MenuItemProps {
children?: ChildrenWithProps<MenuItemProps>;
Expand Down Expand Up @@ -146,7 +147,9 @@ export class MenuGroup extends React.Component<MenuGroupProps, State> {

private renderMeasuringGroupedItems = (evaStyle): MeasuringElement => {
return (
<MeasureElement onMeasure={this.onSubmenuMeasure}>
<MeasureElement
shouldUseTopInsets={ModalService.getShouldUseTopInsets}
whitestranger7 marked this conversation as resolved.
Show resolved Hide resolved
onMeasure={this.onSubmenuMeasure}>
{this.renderGroupedItems(evaStyle)}
</MeasureElement>
);
Expand Down
4 changes: 3 additions & 1 deletion src/components/ui/modal/modal.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ export class Modal extends React.PureComponent<ModalProps, State> {

private renderMeasuringContentElement = (): MeasuringElement => {
return (
<MeasureElement onMeasure={this.onContentMeasure}>
<MeasureElement
shouldUseTopInsets={ModalService.getShouldUseTopInsets}
onMeasure={this.onContentMeasure}>
{this.renderContentElement()}
</MeasureElement>
);
Expand Down
5 changes: 4 additions & 1 deletion src/components/ui/popover/popover.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ export class Popover extends React.Component<PopoverProps, State> {

private renderMeasuringPopoverElement = (): MeasuringElement => {
return (
<MeasureElement onMeasure={this.onContentMeasure}>
<MeasureElement
shouldUseTopInsets={ModalService.getShouldUseTopInsets}
onMeasure={this.onContentMeasure}>
{this.renderPopoverElement()}
</MeasureElement>
);
Expand All @@ -209,6 +211,7 @@ export class Popover extends React.Component<PopoverProps, State> {
public render(): React.ReactElement {
return (
<MeasureElement
shouldUseTopInsets={ModalService.getShouldUseTopInsets}
force={this.state.forceMeasure}
onMeasure={this.onChildMeasure}>
{this.props.anchor()}
Expand Down