@@ -19,6 +19,7 @@ import ResizeBar from 'components-react/root/ResizeBar';
19
19
import antdThemes from 'styles/antd/index' ;
20
20
import { getPlatformService } from 'services/platforms' ;
21
21
import { IModalOptions } from 'services/windows' ;
22
+ import { EStreamingState } from 'services/streaming' ;
22
23
import { TApplicationTheme } from 'services/customization' ;
23
24
import styles from './Main.m.less' ;
24
25
import { StatefulService } from 'services' ;
@@ -43,6 +44,7 @@ class MainController {
43
44
private platformAppsService = Services . PlatformAppsService ;
44
45
private editorCommandsService = Services . EditorCommandsService ;
45
46
private sideNavService = Services . SideNavService ;
47
+ private streamingService = Services . StreamingService ;
46
48
47
49
modalOptions : IModalOptions = {
48
50
renderFn : null ,
@@ -60,6 +62,7 @@ class MainController {
60
62
minDockWidth : 290 ,
61
63
maxDockWidth : 290 ,
62
64
minEditorWidth : 500 ,
65
+ canAnimate : false ,
63
66
} ) ;
64
67
65
68
get title ( ) {
@@ -82,6 +85,10 @@ class MainController {
82
85
return this . sideNavService . state . compactView ;
83
86
}
84
87
88
+ get streamingStatus ( ) {
89
+ return this . streamingService . state . streamingStatus ;
90
+ }
91
+
85
92
theme ( bulkLoadFinished : boolean ) : TApplicationTheme {
86
93
if ( bulkLoadFinished ) {
87
94
return this . customizationService . currentTheme ;
@@ -114,10 +121,6 @@ class MainController {
114
121
) ;
115
122
}
116
123
117
- get isDockCollapsed ( ) {
118
- return this . customizationService . state . livedockCollapsed ;
119
- }
120
-
121
124
get leftDock ( ) {
122
125
return this . customizationService . state . leftDock ;
123
126
}
@@ -214,6 +217,20 @@ class MainController {
214
217
updateStyleBlockers ( val : boolean ) {
215
218
this . windowsService . actions . updateStyleBlockers ( 'main' , val ) ;
216
219
}
220
+
221
+ setCollapsed ( livedockCollapsed : boolean ) {
222
+ this . store . setState ( s => {
223
+ s . canAnimate = true ;
224
+ } ) ;
225
+ this . windowsService . actions . updateStyleBlockers ( 'main' , true ) ;
226
+ this . customizationService . actions . setSettings ( { livedockCollapsed } ) ;
227
+ setTimeout ( ( ) => {
228
+ this . store . setState ( s => {
229
+ s . canAnimate = false ;
230
+ } ) ;
231
+ this . windowsService . actions . updateStyleBlockers ( 'main' , false ) ;
232
+ } , 300 ) ;
233
+ }
217
234
}
218
235
219
236
export default function MainWithContext ( ) : ReactElement < { } > {
@@ -245,8 +262,6 @@ function Main() {
245
262
leftDock,
246
263
applicationLoading,
247
264
page,
248
- maxDockWidth,
249
- minDockWidth,
250
265
hideStyleBlockers,
251
266
compactView,
252
267
sideNavCollapsed,
@@ -260,8 +275,6 @@ function Main() {
260
275
hasLiveDock : ctrl . store . hasLiveDock ,
261
276
applicationLoading : ctrl . applicationLoading ,
262
277
page : ctrl . page ,
263
- maxDockWidth : ctrl . store . maxDockWidth ,
264
- minDockWidth : ctrl . store . minDockWidth ,
265
278
hideStyleBlockers : ctrl . hideStyleBlockers ,
266
279
compactView : ctrl . store . compactView ,
267
280
sideNavCollapsed : ctrl . sideNavCollapsed ,
@@ -270,6 +283,7 @@ function Main() {
270
283
) ;
271
284
272
285
const dockWidth = useRealmObject ( Services . CustomizationService . state ) . livedockSize ;
286
+ const isDockCollapsed = useRealmObject ( Services . CustomizationService . state ) . livedockCollapsed ;
273
287
274
288
function windowSizeHandler ( ) {
275
289
if ( ! hideStyleBlockers ) {
@@ -350,6 +364,7 @@ function Main() {
350
364
} > = ( appPages as Dictionary < React . FunctionComponent > ) [ page ] ;
351
365
352
366
const sideBarSize = sideNavCollapsed ? 70 : 220 ;
367
+ const liveDockSize = isDockCollapsed ? 20 : dockWidth ;
353
368
354
369
return (
355
370
< div
@@ -371,24 +386,10 @@ function Main() {
371
386
< SideNav />
372
387
</ div >
373
388
) }
374
- { renderDock && leftDock && (
375
- < ResizeBar
376
- position = "left"
377
- onInput = { ( val : number ) => ctrl . setLiveDockWidth ( val ) }
378
- max = { maxDockWidth }
379
- min = { minDockWidth }
380
- value = { dockWidth }
381
- transformScale = { 1 }
382
- >
383
- < div className = { styles . liveDockContainer } style = { { width : dockWidth } } >
384
- < LiveDock />
385
- </ div >
386
- </ ResizeBar >
387
- ) }
388
-
389
+ { leftDock && < LiveDockContainer onLeft /> }
389
390
< div
390
391
className = { cx ( styles . mainMiddle , { [ styles . mainMiddleCompact ] : compactView } ) }
391
- style = { { width : `calc(100% - ${ dockWidth + sideBarSize } px)` } }
392
+ style = { { width : `calc(100% - ${ liveDockSize + sideBarSize } px)` } }
392
393
ref = { mainMiddleEl }
393
394
>
394
395
{ ! showLoadingSpinner && (
@@ -405,21 +406,7 @@ function Main() {
405
406
</ div >
406
407
) }
407
408
</ div >
408
-
409
- { renderDock && ! leftDock && (
410
- < ResizeBar
411
- position = "right"
412
- onInput = { ( val : number ) => ctrl . setLiveDockWidth ( val ) }
413
- max = { maxDockWidth }
414
- min = { minDockWidth }
415
- value = { dockWidth }
416
- transformScale = { 1 }
417
- >
418
- < div className = { styles . liveDockContainer } style = { { width : `${ dockWidth } px` } } >
419
- < LiveDock />
420
- </ div >
421
- </ ResizeBar >
422
- ) }
409
+ { ! leftDock && < LiveDockContainer /> }
423
410
</ div >
424
411
< ModalWrapper renderFn = { ctrl . modalOptions . renderFn } />
425
412
< Animation transitionName = "ant-fade" >
@@ -432,3 +419,67 @@ function Main() {
432
419
</ div >
433
420
) ;
434
421
}
422
+
423
+ function LiveDockContainer ( p : { onLeft ?: boolean } ) {
424
+ const ctrl = useController ( MainCtx ) ;
425
+
426
+ const { maxDockWidth, minDockWidth, renderDock, streamingStatus } = useVuex (
427
+ ( ) => ( {
428
+ maxDockWidth : ctrl . store . maxDockWidth ,
429
+ minDockWidth : ctrl . store . minDockWidth ,
430
+ renderDock : ctrl . renderDock ,
431
+ streamingStatus : ctrl . streamingStatus ,
432
+ } ) ,
433
+ true ,
434
+ ) ;
435
+
436
+ useEffect ( ( ) => {
437
+ if ( streamingStatus === EStreamingState . Starting && isDockCollapsed ) {
438
+ ctrl . setCollapsed ( false ) ;
439
+ }
440
+ } , [ streamingStatus ] ) ;
441
+
442
+ const dockWidth = useRealmObject ( Services . CustomizationService . state ) . livedockSize ;
443
+ const isDockCollapsed = useRealmObject ( Services . CustomizationService . state ) . livedockCollapsed ;
444
+
445
+ function Chevron ( ) {
446
+ return (
447
+ < div className = { styles . liveDockChevron } onClick = { ( ) => ctrl . setCollapsed ( ! isDockCollapsed ) } >
448
+ < i
449
+ className = { cx ( {
450
+ [ styles . chevronCollapsed ] : isDockCollapsed ,
451
+ 'icon-back' : ( ! p . onLeft && isDockCollapsed ) || ( p . onLeft && ! isDockCollapsed ) ,
452
+ [ 'icon-down icon-right' ] :
453
+ ( p . onLeft && isDockCollapsed ) || ( ! p . onLeft && ! isDockCollapsed ) ,
454
+ } ) }
455
+ />
456
+ </ div >
457
+ ) ;
458
+ }
459
+
460
+ if ( ! renderDock ) return < > </ > ;
461
+
462
+ if ( isDockCollapsed ) {
463
+ return (
464
+ < div className = { styles . liveDockCollapsed } >
465
+ < Chevron />
466
+ </ div >
467
+ ) ;
468
+ }
469
+
470
+ return (
471
+ < ResizeBar
472
+ position = { p . onLeft ? 'left' : 'right' }
473
+ onInput = { ( val : number ) => ctrl . setLiveDockWidth ( val ) }
474
+ max = { maxDockWidth }
475
+ min = { minDockWidth }
476
+ value = { dockWidth }
477
+ transformScale = { 1 }
478
+ >
479
+ < div className = { styles . liveDockContainer } style = { { width : `${ dockWidth } px` } } >
480
+ < LiveDock />
481
+ < Chevron />
482
+ </ div >
483
+ </ ResizeBar >
484
+ ) ;
485
+ }
0 commit comments