-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathview.tsx
72 lines (64 loc) · 1.71 KB
/
view.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
* _____ __
* / ___// /_ _____
* \__ \/ / / / / _ \
* ___/ / / /_/ / __/
* /____/_/\__, /\___/
* /____/
* Copyright 2018 Parsa Ghadimi. All Rights Reserved.
* Licence: MIT License
*/
import React, { Component } from "react";
import screenfull from "screenfull";
import { db } from "./fs";
import { Player } from "./player";
import * as types from "./types";
export interface ViewState {
loading: boolean;
presentation: types.Presentation;
}
export class View extends Component<{}, ViewState> {
state = {
loading: true,
presentation: null
};
playerRef: Player;
async componentWillMount() {
const id = (this.props as any).match.params.id;
const presentation = await db.getPresentation(id);
this.setState({ loading: false, presentation });
}
handleFullScreen = () => {
if (screenfull.isEnabled) {
screenfull.request(this.playerRef.playerDiv);
this.playerRef.iFrame.focus();
}
}
render() {
if (this.state.loading) {
return <div className="loader" />;
}
const { owner } = this.state.presentation;
return (
<div id="view">
<div className="player-wrapper">
<Player
ref={r => this.playerRef = r}
onClose={() => null}
presentation={this.state.presentation} />
<div
className="full-screen"
onClick={this.handleFullScreen} />
</div>
<div className="author-info">
<img
className="avatar"
src={this.state.presentation.owner.photoURL} />
<a className="name" href={"#/profile/" + owner.uid}>
{owner.displayName}
</a>
</div>
</div>
);
}
}