mirror of
https://gitlab.com/wheres-the-tp/ui-mobile.git
synced 2026-01-25 07:24:56 -06:00
54 lines
1 KiB
JavaScript
54 lines
1 KiB
JavaScript
// @flow
|
|
import React, { Component } from 'react';
|
|
import { View } from 'react-native';
|
|
import Modal, { TextInputHeader } from '../components/Modal';
|
|
import typeof PlaceRecord from '../records/PlaceRecord';
|
|
|
|
class PlaceModal extends Component {
|
|
static displayName = 'PlaceModal';
|
|
|
|
props: {
|
|
isVisible: boolean,
|
|
onClose: () => void,
|
|
onUpdate: (place: PlaceRecord) => void,
|
|
};
|
|
|
|
state: {
|
|
place: ?PlaceRecord,
|
|
};
|
|
|
|
state = {
|
|
place: null,
|
|
};
|
|
|
|
save = () => {
|
|
const { place } = this.state;
|
|
const { onClose, onUpdate } = this.props;
|
|
|
|
if (!place) {
|
|
return;
|
|
}
|
|
|
|
onUpdate(place);
|
|
onClose();
|
|
};
|
|
|
|
setText = (place: PlaceRecord) => {
|
|
this.setState({ place });
|
|
};
|
|
|
|
render() {
|
|
const { isVisible, onClose } = this.props;
|
|
const { place } = this.state;
|
|
const text = (place || {}).name;
|
|
return (
|
|
<Modal isVisible={isVisible}>
|
|
<View style={{ alignItems: 'stretch' }}>
|
|
<TextInputHeader value={text} onChange={this.setText} onClose={onClose} />
|
|
</View>
|
|
</Modal>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default PlaceModal;
|