2021-01-04 23:01:43 +03:00
|
|
|
/*
|
|
|
|
Copyright 2021 The Matrix.org Foundation C.I.C.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import React from 'react';
|
2021-07-15 11:55:58 +03:00
|
|
|
import AccessibleButton from "../elements/AccessibleButton";
|
2021-01-04 23:01:43 +03:00
|
|
|
import { ContextMenu, IProps as IContextMenuProps } from '../../structures/ContextMenu';
|
|
|
|
import { MatrixCall } from 'matrix-js-sdk/src/webrtc/call';
|
2021-04-28 00:16:43 +03:00
|
|
|
import Field from "../elements/Field";
|
2021-07-15 11:55:58 +03:00
|
|
|
import DialPad from '../voip/DialPad';
|
2021-06-29 15:11:58 +03:00
|
|
|
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
2021-01-04 23:01:43 +03:00
|
|
|
|
|
|
|
interface IProps extends IContextMenuProps {
|
|
|
|
call: MatrixCall;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface IState {
|
|
|
|
value: string;
|
|
|
|
}
|
|
|
|
|
2021-03-09 05:45:39 +03:00
|
|
|
@replaceableComponent("views.context_menus.DialpadContextMenu")
|
2021-01-04 23:01:43 +03:00
|
|
|
export default class DialpadContextMenu extends React.Component<IProps, IState> {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
value: '',
|
2021-06-29 15:11:58 +03:00
|
|
|
};
|
2021-01-04 23:01:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
onDigitPress = (digit) => {
|
|
|
|
this.props.call.sendDtmfDigit(digit);
|
2021-06-29 15:11:58 +03:00
|
|
|
this.setState({ value: this.state.value + digit });
|
|
|
|
};
|
2021-01-04 23:01:43 +03:00
|
|
|
|
2021-07-15 11:55:58 +03:00
|
|
|
onCancelClick = () => {
|
|
|
|
this.props.onFinished();
|
|
|
|
};
|
|
|
|
|
2021-08-02 12:18:35 +03:00
|
|
|
onKeyDown = (ev) => {
|
|
|
|
// Prevent Backspace and Delete keys from functioning in the entry field
|
|
|
|
if (ev.code === "Backspace" || ev.code === "Delete") {
|
|
|
|
ev.preventDefault();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-04-28 00:16:43 +03:00
|
|
|
onChange = (ev) => {
|
2021-06-29 15:11:58 +03:00
|
|
|
this.setState({ value: ev.target.value });
|
|
|
|
};
|
2021-04-28 00:16:43 +03:00
|
|
|
|
2021-01-04 23:01:43 +03:00
|
|
|
render() {
|
|
|
|
return <ContextMenu {...this.props}>
|
2021-07-15 11:55:58 +03:00
|
|
|
<div className="mx_DialPadContextMenuWrapper">
|
2021-01-04 23:01:43 +03:00
|
|
|
<div>
|
2021-07-15 11:55:58 +03:00
|
|
|
<AccessibleButton className="mx_DialPadContextMenu_cancel" onClick={this.onCancelClick} />
|
|
|
|
</div>
|
|
|
|
<div className="mx_DialPadContextMenu_header">
|
2021-07-23 12:23:45 +03:00
|
|
|
<Field
|
|
|
|
className="mx_DialPadContextMenu_dialled"
|
|
|
|
value={this.state.value}
|
|
|
|
autoFocus={true}
|
2021-08-02 12:18:35 +03:00
|
|
|
onKeyDown={this.onKeyDown}
|
2021-07-15 11:55:58 +03:00
|
|
|
onChange={this.onChange}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className="mx_DialPadContextMenu_dialPad">
|
|
|
|
<DialPad onDigitPress={this.onDigitPress} hasDial={false} />
|
2021-01-04 23:01:43 +03:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</ContextMenu>;
|
|
|
|
}
|
|
|
|
}
|