diff --git a/src/Components/Header.js b/src/Components/Header.js index a43324c5e..4e083a944 100644 --- a/src/Components/Header.js +++ b/src/Components/Header.js @@ -16,7 +16,6 @@ import RefreshIcon from '@material-ui/icons/Refresh'; import FormatPaintIcon from '@material-ui/icons/FormatPaint'; import EditIcon from '@material-ui/icons/Edit'; import CheckIcon from '@material-ui/icons/Check'; -import RadioIcon from '@material-ui/icons/Radio'; import ExitToAppIcon from '@material-ui/icons/ExitToApp'; import BorderTopIcon from '@material-ui/icons/BorderTop'; import CodeIcon from '@material-ui/icons/Code'; @@ -361,20 +360,6 @@ class Header extends React.PureComponent { )} - {!editing && ( - - - - - - )} {editing && ( this.updateProps(); - - componentDidUpdate = prevProps => - prevProps.value !== this.props.value && this.updateProps(); - - updateProps = () => this.setState({ value: this.props.value }); - - handleEntering = () => this.radioGroup.focus(); - - handleCancel = () => this.props.handleChange(this.props.value); - - handleOk = () => - this.props.handleChange( - this.state.sources.find(source => source.guide_id === this.state.value) - ); - - handleChange = (_event, value) => this.setState({ value }); - - handleSearch = () => { - // request - // .post(`${this.props.apiUrl}/radio/search`) - // .send({ query: this.state.search }) - // .set('Accept', 'application/json') - // .then(res => { - // this.setState({ sources: res.body.slice(0, 100) }); - // }) - // .catch(err => { - // console.error(err); - // }); - }; - - handleSearchChange = search => this.setState({ search }); - - render() { - const { fullScreen, open } = this.props; - const { sources } = this.state; - - return ( - - Select Source - -
- - Search Radio Stations.. - { - this.handleSearchChange(event.target.value); - clearTimeout(searchTimeout); - searchTimeout = setTimeout(() => { - this.handleSearch(); - }, 1000); - }} - endAdornment={ - - - - - - } - /> - -
- { - this.radioGroup = node; - }} - aria-label="Ringtone" - name="ringtone" - value={this.state.value} - onChange={this.handleChange}> - {sources.map(source => ( - } - label={source.text} - /> - ))} - -
- - - - -
- ); - } -} - -InputDialog.propTypes = { - fullScreen: PropTypes.bool.isRequired, - open: PropTypes.bool.isRequired, - value: PropTypes.string, - handleChange: PropTypes.func.isRequired -}; - -export default withMobileDialog()(InputDialog); diff --git a/src/Components/Radio/Radio.js b/src/Components/Radio/Radio.js deleted file mode 100644 index 6e00bf65e..000000000 --- a/src/Components/Radio/Radio.js +++ /dev/null @@ -1,247 +0,0 @@ -import React from 'react'; -// import request from 'superagent'; -import classNames from 'classnames'; -import PropTypes from 'prop-types'; -import Sound from 'react-sound'; -import withStyles from '@material-ui/core/styles/withStyles'; -import Slide from '@material-ui/core/Slide'; -import Paper from '@material-ui/core/Paper'; -import Fab from '@material-ui/core/Fab'; -import ButtonBase from '@material-ui/core/ButtonBase'; -import PauseIcon from '@material-ui/icons/Pause'; -import PlayArrowIcon from '@material-ui/icons/PlayArrow'; -import SkipPreviousIcon from '@material-ui/icons/SkipPrevious'; -import SkipNextIcon from '@material-ui/icons/SkipNext'; -import RepeatIcon from '@material-ui/icons/Repeat'; -import ShuffleIcon from '@material-ui/icons/Shuffle'; -import sourcePlaceholder from '../../resources/source.svg'; -import InputDialog from './InputDialog'; - -const styles = theme => ({ - root: { - position: 'fixed', - bottom: theme.spacing.unit * 2.2, - left: '50%', - transform: 'translate(-25%, 100vh) translate(-25%, 0px) !important', - transition: 'transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms', - zIndex: '1000', - width: '18rem', - height: '18rem' - }, - rootShown: { - transform: 'translate(-50%, 0px) !important' - }, - backgroundOuter: { - position: 'fixed', - left: '50%', - transform: 'translateX(-50%)', - height: '18rem', - width: '100%' - }, - background: { - maxHeight: '18rem' - }, - controls: { - position: 'fixed', - display: 'flex', - bottom: theme.spacing.unit * 5.8 - }, - controlsMain: { - position: 'fixed', - display: 'flex', - alignItems: 'flex-end', - left: '50%', - transform: 'translateX(-50%)' - }, - button: { - margin: `0 ${theme.spacing.unit}px`, - marginBottom: theme.spacing.unit / 4, - backgroundColor: '' - } -}); - -const defaultSource = { - source: { - image: sourcePlaceholder - }, - playing: Sound.status.STOPPED, - shuffle: false, - repeat: false -}; - -class Radio extends React.PureComponent { - state = { - source: defaultSource, - dialogOpen: false - }; - - handleRadioChange = action => { - var source = this.state.source; - switch (action) { - default: - break; - case 'play': - source.playing = Sound.status.PLAYING; - break; - case 'pause': - source.playing = Sound.status.PAUSED; - break; - case 'stop': - source.playing = Sound.status.STOPPED; - break; - case 'next': - break; - case 'previous': - break; - case 'repeat': - break; - case 'shuffle': - break; - } - this.setState({ source }); - }; - - handleInputDialog = () => { - this.setState({ dialogOpen: true }); - }; - - handleInputDialogChange = (value = null) => { - var source = this.state.source; - if (value) source.source = value; - this.setState({ dialogOpen: false, source }, () => - this.handleGetSource(this.state.source.source) - ); - }; - - handleGetSource = source => { - // request - // .post(`${this.props.apiUrl}/radio/get`) - // .send(source) - // .set('Accept', 'application/json') - // .then(res => { - // var source = this.state.source; - // source.source = res.body; - // source.playing = Sound.status.PLAYING; - // this.setState({ source }); - // }) - // .catch(err => { - // console.error(err); - // }); - }; - - render() { - const { - handleRadioChange, - handleInputDialog, - handleInputDialogChange - } = this; - const { classes, show } = this.props; - const { dialogOpen } = this.state; - const { - source, - playing, - canSkip, - canShuffle, - canRepeat - } = this.state.source; - const { image, streams } = source; - - return ( - - - {streams && ( - - )} - - background - - -
-
- {canRepeat && ( - handleRadioChange('repeat')}> - - - )} - {canSkip && ( - handleRadioChange('previous')}> - - - )} - {playing === Sound.status.PLAYING ? ( - handleRadioChange('pause')}> - - - ) : ( - handleRadioChange('play')}> - - - )} - {canSkip && ( - handleRadioChange('next')}> - - - )} - {canShuffle && ( - handleRadioChange('shuffle')}> - - - )} -
-
-
-
- ); - } -} - -Radio.propTypes = { - classes: PropTypes.object.isRequired, - show: PropTypes.bool.isRequired, - handleRadioHide: PropTypes.func.isRequired -}; - -export default withStyles(styles)(Radio);