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 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import React from 'react';
import React, { useContext } from 'react';
import {
findNodeHandle,
UIManager,
StatusBar,
} from 'react-native';
import { Frame } from './type';
import { ApplicationContext } from '../../../theme/application/applicationProvider.component';
whitestranger7 marked this conversation as resolved.
Show resolved Hide resolved

export interface MeasureElementProps<P = any> {
force?: boolean;
Expand Down Expand Up @@ -44,6 +46,7 @@ export type MeasuringElement<P = any> = React.ReactElement;
export const MeasureElement = (props: MeasureElementProps): MeasuringElement => {

const ref = React.useRef<any>();
const { topInsetEnabled } = useContext(ApplicationContext);

const bindToWindow = (frame: Frame, window: Frame): Frame => {
if (frame.origin.x < window.size.width) {
Expand All @@ -61,7 +64,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 = topInsetEnabled && StatusBar.currentHeight ? y + StatusBar.currentHeight : y;
whitestranger7 marked this conversation as resolved.
Show resolved Hide resolved
const frame: Frame = bindToWindow(new Frame(x, originY, w, h), Frame.window());
props.onMeasure(frame);
};

Expand Down
30 changes: 21 additions & 9 deletions src/components/theme/application/applicationProvider.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import React from 'react';
import React, { createContext } from 'react';
import merge from 'lodash.merge';
import { SchemaProcessor } from '@eva-design/processor';
import {
Expand All @@ -25,9 +25,13 @@ interface EvaBuildtimeProcessingProps {
styles: ThemeStyleType;
}

interface ProviderProps {
topInsetEnabled?: boolean;
}

type EvaProcessingProps = EvaRuntimeProcessingProps | EvaBuildtimeProcessingProps;

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

interface State {
Expand Down Expand Up @@ -55,6 +59,9 @@ interface State {
* @property {ThemeStyleType} styles - Styles compiled by bootstrapping Eva packages.
* If provided, will replace runtime styles processing.
* Usually, can be provided by `@ui-kitten/metro-config` package.
*
* @property {boolean} topInsetEnabled - Applies an additional margin to modal components.
* Designed to be provided when StatusBar is translucent.
*
* @overview-example Simple Usage
* ApplicationProvider is designed to be the root component of the application.
Expand Down Expand Up @@ -94,6 +101,9 @@ interface State {
* );
* ```
*/

export const ApplicationContext = createContext({ topInsetEnabled: false });
whitestranger7 marked this conversation as resolved.
Show resolved Hide resolved

export class ApplicationProvider extends React.Component<ApplicationProviderProps, State> {

public state: State = {
Expand All @@ -118,13 +128,15 @@ export class ApplicationProvider extends React.Component<ApplicationProviderProp

public render(): React.ReactNode {
return (
<StyleProvider
theme={this.props.theme}
styles={this.state.styles}>
<ModalPanel>
{this.props.children}
</ModalPanel>
</StyleProvider>
<ApplicationContext.Provider value={{topInsetEnabled: this.props?.topInsetEnabled || false}}>
<StyleProvider
theme={this.props.theme}
styles={this.state.styles}>
<ModalPanel>
{this.props.children}
</ModalPanel>
</StyleProvider>
</ApplicationContext.Provider>
);
}
}