This commit is contained in:
srgooglo 2020-03-05 21:54:50 +01:00
parent 56259e3fbc
commit c44eeff8f1
2 changed files with 60 additions and 21 deletions

View File

@ -48,12 +48,13 @@ class PostCreator extends React.PureComponent{
} }
handleFileUpload = info => { handleFileUpload = info => {
console.log('handle') console.log(info.file.originFileObj)
if (info.file.status === 'uploading') { if (info.file.status === 'uploading') {
this.setState({ loading: true }); this.setState({ loading: true });
return; return;
} }
if (info.file.status === 'done') { if (info.file.status === 'done') {
this.ToogleUpload()
// Get this url from response in real world. // Get this url from response in real world.
getBase64(info.file.originFileObj, imageUrl => getBase64(info.file.originFileObj, imageUrl =>
this.setState({ this.setState({
@ -93,7 +94,7 @@ class PostCreator extends React.PureComponent{
} }
handlePublishPost = (e) => { handlePublishPost = (e) => {
const { rawtext, shareWith, imageUrl} = this.state; const { rawtext, shareWith, imageUrl } = this.state;
let postFile; let postFile;
if (imageUrl) { if (imageUrl) {
console.log('EXIST ',imageUrl) console.log('EXIST ',imageUrl)
@ -114,6 +115,21 @@ class PostCreator extends React.PureComponent{
RefreshFeed() RefreshFeed()
}) })
} }
OpenControl = () =>{
let controls = [(
<div> <antd.Button onClick={() => this.ResetUpload()} icon={<Icons.DeleteOutlined />} /> </div>
)]
ycore.ControlBar.set(controls)
}
CloseControl = () =>{
ycore.ControlBar.close()
}
ResetUpload (){
this.setState({
imageUrl: null
})
this.ToogleUpload()
}
render(){ render(){
const { keys_remaining, visible } = this.state; const { keys_remaining, visible } = this.state;
@ -122,7 +138,6 @@ class PostCreator extends React.PureComponent{
this.setState({ shareWith: key }) this.setState({ shareWith: key })
} }
const shareOptionsMenu = ( const shareOptionsMenu = (
<antd.Menu onClick={changeShare}> <antd.Menu onClick={changeShare}>
<antd.Menu.Item key="any">{ycore.GetPostPrivacy.decorator("any")}</antd.Menu.Item> <antd.Menu.Item key="any">{ycore.GetPostPrivacy.decorator("any")}</antd.Menu.Item>
@ -130,40 +145,45 @@ class PostCreator extends React.PureComponent{
<antd.Menu.Item key="only_followers">{ycore.GetPostPrivacy.decorator("only_followers")}</antd.Menu.Item> <antd.Menu.Item key="only_followers">{ycore.GetPostPrivacy.decorator("only_followers")}</antd.Menu.Item>
<antd.Menu.Item key="private">{ycore.GetPostPrivacy.decorator("private")}</antd.Menu.Item> <antd.Menu.Item key="private">{ycore.GetPostPrivacy.decorator("private")}</antd.Menu.Item>
</antd.Menu> </antd.Menu>
) )
if (visible) { if (visible) {
return( return(
<div className={styles.cardWrapper}> <div className={styles.cardWrapper}>
<antd.Card bordered="false"> <antd.Card bordered="false">
<div className={styles.inputWrapper}> <div className={styles.inputWrapper}>
{this.state.UploadActive? {this.state.UploadActive?
<div className={styles.uploader}>
<antd.Upload.Dragger <antd.Upload.Dragger
multiple= {true} multiple={false}
listType="picture-card" listType="picture"
className="avatar-uploader"
showUploadList={false} showUploadList={false}
beforeUpload={this.beforeUpload} beforeUpload={this.beforeUpload}
onChange={this.handleFileUpload} onChange={this.handleFileUpload}
> >
<p className="ant-upload-drag-icon"> <div>
<Icons.InboxOutlined /> <p className="ant-upload-drag-icon">
</p> <Icons.InboxOutlined />
<p className="ant-upload-text">Click or drag file to this area to upload</p> </p>
<p className="ant-upload-hint"> <p className="ant-upload-text">Click or drag file to this area to upload</p>
Support for a single or bulk upload. </div>
</p>
</antd.Upload.Dragger> </antd.Upload.Dragger>
</div>
: :
<div> <>
<div className={styles.titleAvatar}><img src={userData.avatar} /></div> <div className={styles.titleAvatar}><img src={userData.avatar} /></div>
<antd.Input.TextArea disabled={this.state.posting? true : false} onPressEnter={this.handlePublishPost} value={this.state.rawtext} autoSize={{ minRows: 3, maxRows: 5 }} dragable="false" placeholder="What are you thinking?" onChange={this.handleChanges} allowClear maxLength={ycore.DevOptions.MaxLengthPosts} rows={4} /> <antd.Input.TextArea disabled={this.state.posting? true : false} onPressEnter={this.handlePublishPost} value={this.state.rawtext} autoSize={{ minRows: 3, maxRows: 5 }} dragable="false" placeholder="What are you thinking?" onChange={this.handleChanges} allowClear maxLength={ycore.DevOptions.MaxLengthPosts} rows={4} />
<div><antd.Button disabled={this.state.posting? true : (keys_remaining < 512? false : true)} onClick={this.handlePublishPost} type="primary" icon={this.state.posting_ok? <Icons.CheckCircleOutlined/> : (this.state.posting? <Icons.LoadingOutlined /> : <Icons.ExportOutlined /> )} /></div> <div><antd.Button disabled={this.state.posting? true : (keys_remaining < 512? false : true)} onClick={this.handlePublishPost} type="primary" icon={this.state.posting_ok? <Icons.CheckCircleOutlined/> : (this.state.posting? <Icons.LoadingOutlined /> : <Icons.ExportOutlined /> )} /></div>
</div>} </>}
</div> </div>
<div className={styles.progressHandler}><antd.Progress strokeWidth="4px" className={this.state.posting? styles.proccessUnset : (keys_remaining < 512? styles.proccessSet : styles.proccessUnset)} status={this.handleKeysProgressBar()} showInfo={false} percent={percent} /></div> <div className={styles.progressHandler}><antd.Progress strokeWidth="4px" className={this.state.posting? styles.proccessUnset : (keys_remaining < 512? styles.proccessSet : styles.proccessUnset)} status={this.handleKeysProgressBar()} showInfo={false} percent={percent} /></div>
<div className={styles.postExtra} > <div className={styles.postExtra} >
{ this.state.imageUrl?
<div className={styles.imagePreviewWrapper}>
<img className={styles.imagePreview} src={this.state.imageUrl} />
</div> : null
}
<antd.Button type="ghost" onClick={() => this.ToogleUpload()} > <Icons.CameraFilled /></antd.Button> <antd.Button type="ghost" onClick={() => this.ToogleUpload()} > <Icons.CameraFilled /></antd.Button>
<antd.Button type="ghost"> <Icons.VideoCameraFilled /></antd.Button> <antd.Button type="ghost"> <Icons.VideoCameraFilled /></antd.Button>
<antd.Button onClick={this.handleToggleToolbox} type="ghost"><Icons.PlusCircleOutlined /></antd.Button> <antd.Button onClick={this.handleToggleToolbox} type="ghost"><Icons.PlusCircleOutlined /></antd.Button>

View File

@ -158,12 +158,31 @@
} }
} }
.avatar-uploader > .ant-upload { .uploader {
width: 128px; display: flex;
height: 128px; position: relative;
z-index: 30;
width: 100%;
height: 100%;
span{
width: 100%;
}
} }
.imagePreviewWrapper{
display: flex;
position: relative;
z-index: 30;
width: 100%;
height: 100%;
margin: 15px 0 15px 0;
.imagePreview{
margin: auto;
max-width: 300px;
object-fit: cover;
border-radius: 8px;
}
}
.proccessUnset{ .proccessUnset{
opacity: 0; opacity: 0;