Skip to content

Commit

Permalink
Merge branch 'feature/modern-ui-base' into feature/add-keyboard-suppo…
Browse files Browse the repository at this point in the history
…rt-to-the-new-settings-panel

# Conflicts:
#	src/ts/components/settings/DynamicSettingsPanelItem.ts
#	src/ts/components/settings/SettingsPanelSelectOption.ts
  • Loading branch information
stonko1994 committed Jan 27, 2025
2 parents dd95930 + e23920b commit df575c4
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/scss/bitmovinplayer-ui.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
@import 'components/title-bar';
@import 'components/overlays/recommendation-overlay';
@import 'components/overlays/click-overlay';
@import 'components/overlays/click-to-dismiss-overlay';
@import 'components/buttons/huge-replay-button';
@import 'components/buttons/replay-button';
@import 'components/labels/playback-time-label';
Expand Down
7 changes: 7 additions & 0 deletions src/scss/components/overlays/_click-to-dismiss-overlay.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@import '../../variables';
@import '../../mixins';

.#{$prefix}-ui-dismiss-click-overlay {
@include layout-cover;
@include hidden;
}
5 changes: 4 additions & 1 deletion src/ts/UIFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import { EcoModeContainer } from './components/EcoModeContainer';
import { DynamicSettingsPanelItem } from './components/settings/DynamicSettingsPanelItem';
import { TouchControlOverlay } from './components/overlays/TouchControlOverlay';
import { AdStatusOverlay } from './components/ads/AdStatusOverlay';
import { DismissClickOverlay } from './components/overlays/DismissClickOverlay';

/**
* Provides factory methods to create Bitmovin provided UIs.
Expand Down Expand Up @@ -321,8 +322,9 @@ function uiLayout(config: UIConfig) {
controlBar,
new TitleBar(),
new RecommendationOverlay(),
settingsPanel,
...conditionalComponents,
new DismissClickOverlay({ target: settingsPanel }),
settingsPanel,
new ErrorMessageOverlay(),
],
hideDelay: 2000,
Expand Down Expand Up @@ -488,6 +490,7 @@ function smallScreenUILayout() {
new VRToggleButton(),
],
}),
new DismissClickOverlay({ target: settingsPanel }),
settingsPanel,
new ErrorMessageOverlay(),
],
Expand Down
2 changes: 1 addition & 1 deletion src/ts/components/buttons/Button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class Button<Config extends ButtonConfig> extends Component<Config> {
}).html(i18n.performLocalization(this.config.text)));

// Listen for the click event on the button element and trigger the corresponding event on the button component
buttonElement.on('click touchend', (e) => {
buttonElement.on('click', (e) => {
e.preventDefault();
e.stopPropagation();
this.onClickEvent();
Expand Down
32 changes: 32 additions & 0 deletions src/ts/components/overlays/DismissClickOverlay.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { ButtonConfig } from '../buttons/Button';
import { Component, ComponentConfig } from '../Component';
import { Container } from '../Container';
import { PlayerAPI } from 'bitmovin-player';
import { UIInstanceManager } from '../../UIManager';

export interface DismissClickOverlayConfig extends ButtonConfig {
target: Component<ComponentConfig>;
}

export class DismissClickOverlay extends Container<DismissClickOverlayConfig> {
constructor(config: DismissClickOverlayConfig) {
super(config);

this.config = this.mergeConfig(config, {
cssClass: 'ui-dismiss-click-overlay',
role: this.config.role,
}, <DismissClickOverlayConfig>this.config);
}

configure(player: PlayerAPI, uimanager: UIInstanceManager) {
super.configure(player, uimanager);

this.config.target.onShow.subscribe(() => { this.show(); });
this.config.target.onHide.subscribe(() => { this.hide(); });

let element = this.getDomElement();
element.on('click', () => {
this.config.target.hide();
});
}
}
13 changes: 13 additions & 0 deletions src/ts/components/settings/SettingsPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { SettingsPanelPage, SettingsPanelPageConfig } from './SettingsPanelPage'
import { SettingsPanelItem, SettingsPanelItemConfig } from './SettingsPanelItem';
import { PlayerAPI } from 'bitmovin-player';
import { Component, ComponentConfig } from '../Component';
import { getKeyMapForPlatform } from '../../spatialnavigation/getKeyMapForPlatform';
import { Action } from '../../spatialnavigation/types';

/**
* Configuration interface for a {@link SettingsPanel}.
Expand Down Expand Up @@ -124,6 +126,13 @@ export class SettingsPanel extends Container<SettingsPanelConfig> {
player.on(player.exports.PlayerEvent.PlayerResized, handleResize);
}

const maybeCloseSettingsPanel = (event: KeyboardEvent) => {
const action = getKeyMapForPlatform()[event.keyCode];
if (action === Action.BACK) {
this.hide();
}
};

this.onHide.subscribe(() => {
if (config.hideDelay > -1) {
// Clear timeout when hidden from outside
Expand All @@ -133,6 +142,8 @@ export class SettingsPanel extends Container<SettingsPanelConfig> {
// Since we don't reset the actual navigation here we need to simulate a onInactive event in case some panel
// needs to do something when they become invisible / inactive.
this.activePage.onInactiveEvent();

document.removeEventListener('keyup', maybeCloseSettingsPanel);
});

this.onShow.subscribe(() => {
Expand All @@ -146,6 +157,8 @@ export class SettingsPanel extends Container<SettingsPanelConfig> {
// Activate timeout when shown
this.hideTimeout.start();
}

document.addEventListener('keyup', maybeCloseSettingsPanel);
});

// pass event from root page through
Expand Down

0 comments on commit df575c4

Please sign in to comment.