mirror of https://github.com/jitsi/jitsi-meet
parent
c5e693f14a
commit
57d14d9517
@ -0,0 +1,6 @@ |
||||
// @flow
|
||||
|
||||
/** |
||||
* Action type to set the ID of the active modal (or undefined if needs to be hidden). |
||||
*/ |
||||
export const SET_ACTIVE_MODAL_ID = 'SET_ACTIVE_MODAL_ID'; |
@ -0,0 +1,19 @@ |
||||
// @flow
|
||||
|
||||
import { SET_ACTIVE_MODAL_ID } from './actionTypes'; |
||||
|
||||
/** |
||||
* Action to set the ID of the active modal (or undefined if needs to be hidden). |
||||
* |
||||
* @param {string} activeModalId - The new modal ID or undefined. |
||||
* @returns {{ |
||||
* activeModalId: string, |
||||
* type: SET_ACTIVE_MODAL_ID |
||||
* }} |
||||
*/ |
||||
export function setActiveModalId(activeModalId: ?string) { |
||||
return { |
||||
activeModalId, |
||||
type: SET_ACTIVE_MODAL_ID |
||||
}; |
||||
} |
@ -0,0 +1,151 @@ |
||||
// @flow
|
||||
|
||||
import React, { PureComponent } from 'react'; |
||||
import { SafeAreaView, View } from 'react-native'; |
||||
|
||||
import { ColorSchemeRegistry } from '../../color-scheme'; |
||||
import { HeaderWithNavigation, SlidingView } from '../../react'; |
||||
import { connect } from '../../redux'; |
||||
import { StyleType } from '../../styles'; |
||||
|
||||
import { setActiveModalId } from '../actions'; |
||||
|
||||
import styles from './styles'; |
||||
|
||||
type Props = { |
||||
|
||||
/** |
||||
* The color schemed style of the common header component. |
||||
*/ |
||||
_headerStyles: StyleType, |
||||
|
||||
/** |
||||
* True if the modal should be shown, false otherwise. |
||||
*/ |
||||
_show: boolean, |
||||
|
||||
/** |
||||
* The color schemed style of the modal. |
||||
*/ |
||||
_styles: StyleType, |
||||
|
||||
/** |
||||
* The children component(s) of the Modal, to be rendered. |
||||
*/ |
||||
children: React$Node, |
||||
|
||||
/** |
||||
* The Redux Dispatch function. |
||||
*/ |
||||
dispatch: Function, |
||||
|
||||
/** |
||||
* The i18n label key of the header title. |
||||
*/ |
||||
headerLabelKey: string, |
||||
|
||||
/** |
||||
* The ID of the modal that is being rendered. This is used to show/hide the modal. |
||||
*/ |
||||
modalId: string, |
||||
|
||||
/** |
||||
* Callback to be invoked when the modal closes. |
||||
*/ |
||||
onClose?: Function, |
||||
|
||||
/** |
||||
* The position from where the modal should be opened. This is derived from the |
||||
* props of the {@code SlidingView} with the same name. |
||||
*/ |
||||
position?: string |
||||
}; |
||||
|
||||
/** |
||||
* Implements a custom Jitsi Modal that doesn't use the built in native |
||||
* Modal component of React Native. |
||||
*/ |
||||
class JitsiModal extends PureComponent<Props> { |
||||
static defaultProps = { |
||||
position: 'bottom' |
||||
}; |
||||
|
||||
/** |
||||
* Instantiates a new component. |
||||
* |
||||
* @inheritdoc |
||||
*/ |
||||
constructor(props: Props) { |
||||
super(props); |
||||
|
||||
this._onRequestClose = this._onRequestClose.bind(this); |
||||
} |
||||
|
||||
/** |
||||
* Implements {@code PureComponent#render}. |
||||
* |
||||
* @inheritdoc |
||||
*/ |
||||
render() { |
||||
const { _headerStyles, _show, _styles, children, headerLabelKey, position } = this.props; |
||||
|
||||
return ( |
||||
<SlidingView |
||||
onHide = { this._onRequestClose } |
||||
position = { position } |
||||
show = { _show }> |
||||
<View |
||||
style = { [ |
||||
_headerStyles.page, |
||||
_styles.page |
||||
] }> |
||||
<HeaderWithNavigation |
||||
headerLabelKey = { headerLabelKey } |
||||
onPressBack = { this._onRequestClose } /> |
||||
<SafeAreaView style = { styles.safeArea }> |
||||
{ children } |
||||
</SafeAreaView> |
||||
</View> |
||||
</SlidingView> |
||||
); |
||||
} |
||||
|
||||
_onRequestClose: () => boolean; |
||||
|
||||
/** |
||||
* Callback to be invoked when the SlidingView requests closing. |
||||
* |
||||
* @returns {boolean} |
||||
*/ |
||||
_onRequestClose() { |
||||
const { _show, dispatch, onClose } = this.props; |
||||
|
||||
if (_show) { |
||||
if (typeof onClose === 'function') { |
||||
onClose(); |
||||
} |
||||
dispatch(setActiveModalId()); |
||||
|
||||
return true; |
||||
} |
||||
|
||||
return false; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Maps part of the Redix state to the props of this component. |
||||
* |
||||
* @param {Object} state - The Redux state. |
||||
* @param {Props} ownProps - The own props of the component. |
||||
* @returns {Props} |
||||
*/ |
||||
function _mapStateToProps(state, ownProps): $Shape<Props> { |
||||
return { |
||||
_headerStyles: ColorSchemeRegistry.get(state, 'Header'), |
||||
_show: state['features/base/modal'].activeModalId === ownProps.modalId, |
||||
_styles: ColorSchemeRegistry.get(state, 'Modal') |
||||
}; |
||||
} |
||||
|
||||
export default connect(_mapStateToProps)(JitsiModal); |
@ -0,0 +1,3 @@ |
||||
// @flow
|
||||
|
||||
export { default as JitsiModal } from './JitsiModal'; |
@ -0,0 +1,6 @@ |
||||
// @flow
|
||||
|
||||
import { Component } from 'react'; |
||||
|
||||
export const JitsiModal = Component; |
||||
|
@ -0,0 +1,15 @@ |
||||
// @flow
|
||||
|
||||
import { ColorSchemeRegistry, schemeColor } from '../../color-scheme'; |
||||
|
||||
export default { |
||||
safeArea: { |
||||
flex: 1 |
||||
} |
||||
}; |
||||
|
||||
ColorSchemeRegistry.register('Modal', { |
||||
page: { |
||||
backgroundColor: schemeColor('background') |
||||
} |
||||
}); |
@ -0,0 +1,7 @@ |
||||
// @flow
|
||||
|
||||
import './reducer'; |
||||
|
||||
export * from './actions'; |
||||
export * from './actionTypes'; |
||||
export * from './components'; |
@ -0,0 +1,17 @@ |
||||
// @flow
|
||||
|
||||
import { ReducerRegistry } from '../redux'; |
||||
|
||||
import { SET_ACTIVE_MODAL_ID } from './actionTypes'; |
||||
|
||||
ReducerRegistry.register('features/base/modal', (state = {}, action) => { |
||||
switch (action.type) { |
||||
case SET_ACTIVE_MODAL_ID: |
||||
return { |
||||
...state, |
||||
activeModalId: action.activeModalId |
||||
}; |
||||
} |
||||
|
||||
return state; |
||||
}); |
@ -0,0 +1,54 @@ |
||||
// @flow
|
||||
|
||||
import React, { PureComponent } from 'react'; |
||||
import WebView from 'react-native-webview'; |
||||
|
||||
import { JitsiModal } from '../../base/modal'; |
||||
import { connect } from '../../base/redux'; |
||||
|
||||
import { HELP_VIEW_MODAL_ID } from '../constants'; |
||||
|
||||
const DEFAULT_HELP_CENTRE_URL = 'https://web-cdn.jitsi.net/faq/meet-faq.html'; |
||||
|
||||
type Props = { |
||||
|
||||
/** |
||||
* The URL to display in the Help Centre. |
||||
*/ |
||||
_url: string |
||||
} |
||||
|
||||
/** |
||||
* Implements a page that renders the help content for the app. |
||||
*/ |
||||
class HelpView extends PureComponent<Props> { |
||||
/** |
||||
* Implements {@code PureComponent#render()}. |
||||
* |
||||
* @inheritdoc |
||||
* @returns {ReactElement} |
||||
*/ |
||||
render() { |
||||
return ( |
||||
<JitsiModal |
||||
headerLabelKey = 'helpView.header' |
||||
modalId = { HELP_VIEW_MODAL_ID }> |
||||
<WebView source = {{ uri: this.props._url }} /> |
||||
</JitsiModal> |
||||
); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Maps part of the Redux state to the props of this component. |
||||
* |
||||
* @param {Object} state - The Redux state. |
||||
* @returns {Props} |
||||
*/ |
||||
function _mapStateToProps(state) { |
||||
return { |
||||
_url: state['features/base/config'].helpCentreURL || DEFAULT_HELP_CENTRE_URL |
||||
}; |
||||
} |
||||
|
||||
export default connect(_mapStateToProps)(HelpView); |
@ -0,0 +1,3 @@ |
||||
// @flow
|
||||
|
||||
export { default as HelpView } from './HelpView'; |
@ -0,0 +1,3 @@ |
||||
// @flow
|
||||
|
||||
export const HELP_VIEW_MODAL_ID = 'helpView'; |
@ -0,0 +1,4 @@ |
||||
// @flow
|
||||
|
||||
export * from './components'; |
||||
export * from './constants'; |
Loading…
Reference in new issue