diff options
author | 2022-10-26 09:47:11 +0530 | |
---|---|---|
committer | 2022-10-26 10:15:16 +0530 | |
commit | 354ffea92be3a1030c730b6bb8ece7f680e01b12 (patch) | |
tree | 6425e972752c9b250e861b16da1a3120bc6db13c /src/components/services/tabs/Tabbar.js | |
parent | 6.2.1-nightly.29 [skip ci] (diff) | |
download | ferdium-app-354ffea92be3a1030c730b6bb8ece7f680e01b12.tar.gz ferdium-app-354ffea92be3a1030c730b6bb8ece7f680e01b12.tar.zst ferdium-app-354ffea92be3a1030c730b6bb8ece7f680e01b12.zip |
refactor: convert TabBar to typescript
Diffstat (limited to 'src/components/services/tabs/Tabbar.js')
-rw-r--r-- | src/components/services/tabs/Tabbar.js | 123 |
1 files changed, 0 insertions, 123 deletions
diff --git a/src/components/services/tabs/Tabbar.js b/src/components/services/tabs/Tabbar.js deleted file mode 100644 index 0eaf641e3..000000000 --- a/src/components/services/tabs/Tabbar.js +++ /dev/null | |||
@@ -1,123 +0,0 @@ | |||
1 | import { Component } from 'react'; | ||
2 | import PropTypes from 'prop-types'; | ||
3 | import { observer, PropTypes as MobxPropTypes } from 'mobx-react'; | ||
4 | |||
5 | import TabBarSortableList from './TabBarSortableList'; | ||
6 | |||
7 | class TabBar extends Component { | ||
8 | static propTypes = { | ||
9 | services: MobxPropTypes.arrayOrObservableArray.isRequired, | ||
10 | setActive: PropTypes.func.isRequired, | ||
11 | openSettings: PropTypes.func.isRequired, | ||
12 | enableToolTip: PropTypes.func.isRequired, | ||
13 | disableToolTip: PropTypes.func.isRequired, | ||
14 | reorder: PropTypes.func.isRequired, | ||
15 | reload: PropTypes.func.isRequired, | ||
16 | toggleNotifications: PropTypes.func.isRequired, | ||
17 | toggleAudio: PropTypes.func.isRequired, | ||
18 | toggleDarkMode: PropTypes.func.isRequired, | ||
19 | deleteService: PropTypes.func.isRequired, | ||
20 | updateService: PropTypes.func.isRequired, | ||
21 | hibernateService: PropTypes.func.isRequired, | ||
22 | wakeUpService: PropTypes.func.isRequired, | ||
23 | useHorizontalStyle: PropTypes.bool.isRequired, | ||
24 | showMessageBadgeWhenMutedSetting: PropTypes.bool.isRequired, | ||
25 | showServiceNameSetting: PropTypes.bool.isRequired, | ||
26 | showMessageBadgesEvenWhenMuted: PropTypes.bool.isRequired, | ||
27 | }; | ||
28 | |||
29 | onSortEnd = ({ oldIndex, newIndex }) => { | ||
30 | const { enableToolTip, reorder } = this.props; | ||
31 | |||
32 | enableToolTip(); | ||
33 | reorder({ oldIndex, newIndex }); | ||
34 | }; | ||
35 | |||
36 | shouldPreventSorting = event => event.target.tagName !== 'LI'; | ||
37 | |||
38 | toggleService = ({ serviceId, isEnabled }) => { | ||
39 | const { updateService } = this.props; | ||
40 | |||
41 | if (serviceId) { | ||
42 | updateService({ | ||
43 | serviceId, | ||
44 | serviceData: { | ||
45 | isEnabled, | ||
46 | isMediaPlaying: false, | ||
47 | }, | ||
48 | redirect: false, | ||
49 | }); | ||
50 | } | ||
51 | }; | ||
52 | |||
53 | disableService({ serviceId }) { | ||
54 | this.toggleService({ serviceId, isEnabled: false }); | ||
55 | } | ||
56 | |||
57 | enableService({ serviceId }) { | ||
58 | this.toggleService({ serviceId, isEnabled: true }); | ||
59 | } | ||
60 | |||
61 | hibernateService({ serviceId }) { | ||
62 | if (serviceId) { | ||
63 | this.props.hibernateService({ serviceId }); | ||
64 | } | ||
65 | } | ||
66 | |||
67 | wakeUpService({ serviceId }) { | ||
68 | if (serviceId) { | ||
69 | this.props.wakeUpService({ serviceId }); | ||
70 | } | ||
71 | } | ||
72 | |||
73 | render() { | ||
74 | const { | ||
75 | services, | ||
76 | setActive, | ||
77 | openSettings, | ||
78 | disableToolTip, | ||
79 | reload, | ||
80 | toggleNotifications, | ||
81 | toggleAudio, | ||
82 | toggleDarkMode, | ||
83 | deleteService, | ||
84 | useHorizontalStyle, | ||
85 | showMessageBadgeWhenMutedSetting, | ||
86 | showServiceNameSetting, | ||
87 | showMessageBadgesEvenWhenMuted, | ||
88 | } = this.props; | ||
89 | |||
90 | const axis = useHorizontalStyle ? 'x' : 'y'; | ||
91 | |||
92 | return ( | ||
93 | <div> | ||
94 | <TabBarSortableList | ||
95 | services={services} | ||
96 | setActive={setActive} | ||
97 | onSortEnd={this.onSortEnd} | ||
98 | onSortStart={disableToolTip} | ||
99 | shouldCancelStart={this.shouldPreventSorting} | ||
100 | reload={reload} | ||
101 | toggleNotifications={toggleNotifications} | ||
102 | toggleAudio={toggleAudio} | ||
103 | toggleDarkMode={toggleDarkMode} | ||
104 | deleteService={deleteService} | ||
105 | disableService={args => this.disableService(args)} | ||
106 | enableService={args => this.enableService(args)} | ||
107 | hibernateService={args => this.hibernateService(args)} | ||
108 | wakeUpService={args => this.wakeUpService(args)} | ||
109 | openSettings={openSettings} | ||
110 | distance={20} | ||
111 | axis={axis} | ||
112 | lockAxis={axis} | ||
113 | helperClass="is-reordering" | ||
114 | showMessageBadgeWhenMutedSetting={showMessageBadgeWhenMutedSetting} | ||
115 | showServiceNameSetting={showServiceNameSetting} | ||
116 | showMessageBadgesEvenWhenMuted={showMessageBadgesEvenWhenMuted} | ||
117 | /> | ||
118 | </div> | ||
119 | ); | ||
120 | } | ||
121 | } | ||
122 | |||
123 | export default observer(TabBar); | ||