From 1fa200e0fda73c7031bf2384c52f4bbc29be77cb Mon Sep 17 00:00:00 2001 From: simba Date: Tue, 16 Jun 2020 18:19:21 +0800 Subject: [PATCH] mobile matter list handles expanding --- src/pages/matter/widget/MatterPanel.tsx | 151 +++++++++++++----------- src/pages/widget/Expanding.less | 0 src/pages/widget/Expanding.tsx | 41 +++++++ src/react-app-env.d.ts | 5 + 4 files changed, 127 insertions(+), 70 deletions(-) create mode 100644 src/pages/widget/Expanding.less create mode 100644 src/pages/widget/Expanding.tsx diff --git a/src/pages/matter/widget/MatterPanel.tsx b/src/pages/matter/widget/MatterPanel.tsx index 07f1218..2cd43bb 100644 --- a/src/pages/matter/widget/MatterPanel.tsx +++ b/src/pages/matter/widget/MatterPanel.tsx @@ -1,6 +1,5 @@ import React from "react"; import copy from "copy-to-clipboard"; -import { CSSTransition } from "react-transition-group"; import Matter from "../../../common/model/matter/Matter"; import TankComponent from "../../../common/component/TankComponent"; import Director from "./Director"; @@ -10,6 +9,7 @@ import StringUtil from "../../../common/util/StringUtil"; import DateUtil from "../../../common/util/DateUtil"; import AnimateUtil from "../../../common/util/AnimateUtil"; import MessageBoxUtil from "../../../common/util/MessageBoxUtil"; +import Expanding from "../../widget/Expanding"; import { LockFilled, UnlockFilled, @@ -45,6 +45,7 @@ export default class MatterPanel extends TankComponent { renamingLoading: boolean = false; // 小屏幕下操作栏 showMore: boolean = false; + transitionStatus: boolean = false; inputRef = React.createRef(); @@ -203,17 +204,23 @@ export default class MatterPanel extends TankComponent { }; toggleHandles = () => { - this.showMore = !this.showMore; + this.transitionStatus = !this.transitionStatus; + if (this.transitionStatus) this.showMore = true; + this.updateUI(); + }; + + onExited = () => { + this.showMore = false; this.updateUI(); }; render() { - console.log(this.showMore); const { matter } = this.props; + return (
SafeUtil.stopPropagationWrap(e)(this.clickRow())}> -
+
@@ -335,86 +342,90 @@ export default class MatterPanel extends TankComponent {
- -
-
- {DateUtil.simpleDateHourMinute(matter.updateTime)} - - {StringUtil.humanFileSize(matter.size)} - -
+ + {this.showMore ? ( +
+
+ {DateUtil.simpleDateHourMinute(matter.updateTime)} + + {StringUtil.humanFileSize(matter.size)} + +
+ + {!matter.dir && matter.privacy && ( +
+ SafeUtil.stopPropagationWrap(e)(this.changePrivacy(false)) + } + > + + 设置为公有文件 +
+ )} + + {!matter.dir && !matter.privacy && ( +
+ SafeUtil.stopPropagationWrap(e)(this.changePrivacy(true)) + } + > + + 设置为私有文件 +
+ )} - {!matter.dir && matter.privacy && (
- SafeUtil.stopPropagationWrap(e)(this.changePrivacy(false)) + SafeUtil.stopPropagationWrap(e)( + Sun.navigateTo("/matter/detail/" + matter.uuid) + ) } > - - 设置为公有文件 + + 文件详情
- )} - - {!matter.dir && !matter.privacy && (
- SafeUtil.stopPropagationWrap(e)(this.changePrivacy(true)) + SafeUtil.stopPropagationWrap(e)(this.prepareRename()) } > - - 设置为私有文件 + + 重命名 +
+
+ SafeUtil.stopPropagationWrap(e)(this.clipboard()) + } + > + + 复制下载链接 +
+
+ SafeUtil.stopPropagationWrap(e)(matter.download()) + } + > + + 下载 +
+
+ SafeUtil.stopPropagationWrap(e)(this.deleteMatter()) + } + > + + 删除
- )} - -
- SafeUtil.stopPropagationWrap(e)( - Sun.navigateTo("/matter/detail/" + matter.uuid) - ) - } - > - - 文件详情
-
- SafeUtil.stopPropagationWrap(e)(this.prepareRename()) - } - > - - 重命名 -
-
SafeUtil.stopPropagationWrap(e)(this.clipboard())} - > - - 复制下载链接 -
-
- SafeUtil.stopPropagationWrap(e)(matter.download()) - } - > - - 下载 -
-
- SafeUtil.stopPropagationWrap(e)(this.deleteMatter()) - } - > - - 删除 -
-
- + ) : null} +
); } diff --git a/src/pages/widget/Expanding.less b/src/pages/widget/Expanding.less new file mode 100644 index 0000000..e69de29 diff --git a/src/pages/widget/Expanding.tsx b/src/pages/widget/Expanding.tsx new file mode 100644 index 0000000..b92f731 --- /dev/null +++ b/src/pages/widget/Expanding.tsx @@ -0,0 +1,41 @@ +import React, { Component } from "react"; +import { Transition } from "react-transition-group"; +import Velocity from "velocity-animate"; +import SafeUtil from "../../common/util/SafeUtil"; + +interface IProps { + inStatus: boolean; + onExited?: () => any +} + +interface IState {} + +export default class Expanding extends Component { + onEnter = (el: HTMLElement) => { + Velocity(el, "slideDown"); + }; + + onExit = (el: HTMLElement) => { + Velocity(el, "slideUp"); + }; + + onExited = () => { + SafeUtil.safeCallback(this.props.onExited)(); + }; + + render() { + return ( + + <> + {this.props.children} + + + ); + } +} diff --git a/src/react-app-env.d.ts b/src/react-app-env.d.ts index 981cd73..fc788c1 100644 --- a/src/react-app-env.d.ts +++ b/src/react-app-env.d.ts @@ -64,3 +64,8 @@ declare module '*.module.sass' { const classes: { readonly [key: string]: string }; export default classes; } + +declare module 'velocity-animate' { + import Velocity from 'velocity-animate'; + export default Velocity; +}