Compare commits

...
4 changed files with 63 additions and 7 deletions

No files matched your search

+42 -3
View File
@@ -97,6 +97,9 @@ export class HaCameraPlayer extends LitElement {
@property({ type: Boolean, attribute: "keep-awake" })
public keepAwake = false;
/** Fills the height it is given, with the picture in the middle. */
@property({ type: Boolean, reflect: true }) public fill = false;
@state() private _status: CameraStreamStatus = {
connecting: true,
hasAudio: false,
@@ -284,9 +287,10 @@ export class HaCameraPlayer extends LitElement {
gesture: this._gesture,
})}
style=${styleMap({
aspectRatio: this._fullscreen
? undefined
: String(this._aspectRatio()),
aspectRatio:
this._fullscreen || this.fill
? undefined
: String(this._aspectRatio()),
})}
@pointerdown=${this._pointerDown}
@pointerup=${this._pointerUp}
@@ -303,6 +307,9 @@ export class HaCameraPlayer extends LitElement {
mjpeg-video
measure-poster
style=${styleMap({
"--picture-aspect-ratio": this.fill
? String(this._aspectRatio())
: undefined,
transform: zoomed
? `translate(${this._zoom.x}px, ${this._zoom.y}px) scale(${this._zoom.scale})`
: undefined,
@@ -1030,6 +1037,38 @@ export class HaCameraPlayer extends LitElement {
cursor: none;
}
:host([fill]) {
position: relative;
flex: 1;
min-height: 0;
}
:host([fill]) .player {
position: absolute;
inset: 0;
}
:host([fill]) .viewport {
height: 100%;
max-height: none;
container-type: size;
--video-max-height: 100%;
}
/* As large as the picture fits in the middle, zoomed from the corner of
the viewport like a stream that fills it */
:host([fill]) ha-camera-stream {
--picture-width: min(100cqw, 100cqh * var(--picture-aspect-ratio));
--picture-height: min(100cqh, 100cqw / var(--picture-aspect-ratio));
position: absolute;
top: calc((100cqh - var(--picture-height)) / 2);
left: calc((100cqw - var(--picture-width)) / 2);
width: var(--picture-width);
height: var(--picture-height);
transform-origin: calc((var(--picture-width) - 100cqw) / 2)
calc((var(--picture-height) - 100cqh) / 2);
}
.viewport {
position: relative;
overflow: hidden;
+8 -2
View File
@@ -1,5 +1,6 @@
import { mdiClose } from "@mdi/js";
import type { ContextType } from "@lit/context";
import { createContext, provide } from "@lit/context";
import { css, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import { consume } from "../common/decorators/consume";
@@ -11,7 +12,10 @@ import "./ha-icon-button";
import "./ha-dialog";
import type { DialogWidth } from "./ha-dialog";
type DialogSheetMode = "dialog" | "bottom-sheet";
export type DialogSheetMode = "dialog" | "bottom-sheet";
export const adaptiveDialogModeContext =
createContext<DialogSheetMode>("adaptiveDialogMode");
export const ADAPTIVE_DIALOG_MEDIA_QUERY =
"(max-width: 870px), (max-height: 500px)";
@@ -125,7 +129,9 @@ export class HaAdaptiveDialog extends LitElement {
@property({ type: Boolean, reflect: true, attribute: "flexcontent" })
public flexContent = false;
@state() public mode: DialogSheetMode = "dialog";
@provide({ context: adaptiveDialogModeContext })
@state()
public mode: DialogSheetMode = "dialog";
@state()
@consume({ context: internationalizationContext, subscribe: true })
+1 -1
View File
@@ -46,7 +46,7 @@ export const DOMAINS_WITH_NEW_MORE_INFO = [
"media_player",
];
/** Domains with full height more info dialog */
export const DOMAINS_FULL_HEIGHT_MORE_INFO = ["update"];
export const DOMAINS_FULL_HEIGHT_MORE_INFO = ["camera", "update"];
/** Domains with separate more info dialog. */
export const DOMAINS_WITH_MORE_INFO = [
@@ -9,6 +9,10 @@ import { consumeLocalize } from "../../../common/decorators/consume-context-entr
import type { HASSDomEvent } from "../../../common/dom/fire_event";
import { fireEvent } from "../../../common/dom/fire_event";
import type { LocalizeFunc } from "../../../common/translations/localize";
import {
adaptiveDialogModeContext,
type DialogSheetMode,
} from "../../../components/ha-adaptive-dialog";
import "../../../components/ha-button";
import "../../../components/camera/ha-camera-player";
import type { HaCameraPlayer } from "../../../components/camera/ha-camera-player";
@@ -50,6 +54,10 @@ class MoreInfoCamera extends LitElement {
@state() private _attached = false;
@state()
@consume({ context: adaptiveDialogModeContext, subscribe: true })
private _dialogMode?: DialogSheetMode;
@state() private _microphoneState: WebRtcMicrophoneState = "off";
@state() private _streamType?: CameraStreamType;
@@ -133,6 +141,7 @@ class MoreInfoCamera extends LitElement {
.stateObj=${this.stateObj}
allow-exoplayer
keep-awake
?fill=${this._dialogMode === "bottom-sheet"}
@microphone-changed=${this._microphoneChanged}
@stream-type-changed=${this._streamTypeChanged}
@camera-capabilities-changed=${this._capabilitiesChanged}
@@ -334,7 +343,9 @@ class MoreInfoCamera extends LitElement {
static styles = css`
:host {
display: block;
display: flex;
flex-direction: column;
flex: 1;
}
.buttons {