screenshot / screen recording buttons
Reviewed By: lblasa Differential Revision: D47443316 fbshipit-source-id: 01a7d0d54cda8f8425bcbeb95047aa3aa5857cc8
This commit is contained in:
committed by
Facebook GitHub Bot
parent
13c88ccb11
commit
0dad5ee993
@@ -14,15 +14,15 @@ import {CameraOutlined, VideoCameraOutlined} from '@ant-design/icons';
|
|||||||
import {useStore} from '../utils/useStore';
|
import {useStore} from '../utils/useStore';
|
||||||
import {getRenderHostInstance} from 'flipper-frontend-core';
|
import {getRenderHostInstance} from 'flipper-frontend-core';
|
||||||
import {path} from 'flipper-plugin';
|
import {path} from 'flipper-plugin';
|
||||||
|
import {NavbarButton} from '../sandy-chrome/Navbar';
|
||||||
|
|
||||||
async function openFile(path: string) {
|
async function openFile(path: string) {
|
||||||
getRenderHostInstance().flipperServer.exec('open-file', path);
|
getRenderHostInstance().flipperServer.exec('open-file', path);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ScreenCaptureButtons() {
|
export function NavbarScreenshotButton() {
|
||||||
const selectedDevice = useStore((state) => state.connections.selectedDevice);
|
const selectedDevice = useStore((state) => state.connections.selectedDevice);
|
||||||
const [isTakingScreenshot, setIsTakingScreenshot] = useState(false);
|
const [isTakingScreenshot, setIsTakingScreenshot] = useState(false);
|
||||||
const [isRecording, setIsRecording] = useState(false);
|
|
||||||
|
|
||||||
const handleScreenshot = useCallback(() => {
|
const handleScreenshot = useCallback(() => {
|
||||||
setIsTakingScreenshot(true);
|
setIsTakingScreenshot(true);
|
||||||
@@ -37,6 +37,24 @@ export default function ScreenCaptureButtons() {
|
|||||||
});
|
});
|
||||||
}, [selectedDevice]);
|
}, [selectedDevice]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<NavbarButton
|
||||||
|
icon={CameraOutlined}
|
||||||
|
label="Screenshot"
|
||||||
|
onClick={handleScreenshot}
|
||||||
|
disabled={
|
||||||
|
!selectedDevice ||
|
||||||
|
!selectedDevice.description.features.screenshotAvailable
|
||||||
|
}
|
||||||
|
toggled={isTakingScreenshot}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function NavbarScreenRecordButton() {
|
||||||
|
const selectedDevice = useStore((state) => state.connections.selectedDevice);
|
||||||
|
const [isRecording, setIsRecording] = useState(false);
|
||||||
|
|
||||||
const handleRecording = useCallback(() => {
|
const handleRecording = useCallback(() => {
|
||||||
if (!selectedDevice) {
|
if (!selectedDevice) {
|
||||||
return;
|
return;
|
||||||
@@ -68,29 +86,15 @@ export default function ScreenCaptureButtons() {
|
|||||||
}, [selectedDevice, isRecording]);
|
}, [selectedDevice, isRecording]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<NavbarButton
|
||||||
<AntButton
|
icon={VideoCameraOutlined}
|
||||||
icon={<CameraOutlined />}
|
label="Record"
|
||||||
title="Take Screenshot"
|
onClick={handleRecording}
|
||||||
type="ghost"
|
disabled={
|
||||||
onClick={handleScreenshot}
|
!selectedDevice ||
|
||||||
disabled={
|
!selectedDevice.description.features.screenCaptureAvailable
|
||||||
!selectedDevice ||
|
}
|
||||||
!selectedDevice.description.features.screenshotAvailable
|
toggled={isRecording}
|
||||||
}
|
/>
|
||||||
loading={isTakingScreenshot}
|
|
||||||
/>
|
|
||||||
<AntButton
|
|
||||||
icon={<VideoCameraOutlined />}
|
|
||||||
title="Make Screen Recording"
|
|
||||||
type={isRecording ? 'primary' : 'ghost'}
|
|
||||||
onClick={handleRecording}
|
|
||||||
disabled={
|
|
||||||
!selectedDevice ||
|
|
||||||
!selectedDevice.description.features.screenCaptureAvailable
|
|
||||||
}
|
|
||||||
danger={isRecording}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ import {
|
|||||||
AppstoreAddOutlined,
|
AppstoreAddOutlined,
|
||||||
BellOutlined,
|
BellOutlined,
|
||||||
BugOutlined,
|
BugOutlined,
|
||||||
CameraOutlined,
|
|
||||||
FileExclamationOutlined,
|
FileExclamationOutlined,
|
||||||
LayoutOutlined,
|
LayoutOutlined,
|
||||||
LoginOutlined,
|
LoginOutlined,
|
||||||
@@ -44,7 +43,6 @@ import {
|
|||||||
MobileOutlined,
|
MobileOutlined,
|
||||||
RocketOutlined,
|
RocketOutlined,
|
||||||
SettingOutlined,
|
SettingOutlined,
|
||||||
VideoCameraOutlined,
|
|
||||||
WarningOutlined,
|
WarningOutlined,
|
||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
import {
|
import {
|
||||||
@@ -77,6 +75,11 @@ import {StyleGuide} from './StyleGuide';
|
|||||||
import {openDeeplinkDialog} from '../deeplink';
|
import {openDeeplinkDialog} from '../deeplink';
|
||||||
import SettingsSheet from '../chrome/SettingsSheet';
|
import SettingsSheet from '../chrome/SettingsSheet';
|
||||||
import WelcomeScreen from './WelcomeScreen';
|
import WelcomeScreen from './WelcomeScreen';
|
||||||
|
import {AppSelector} from './appinspect/AppSelector';
|
||||||
|
import {
|
||||||
|
NavbarScreenRecordButton,
|
||||||
|
NavbarScreenshotButton,
|
||||||
|
} from '../chrome/ScreenCaptureButtons';
|
||||||
|
|
||||||
export const Navbar = withTrackingScope(function Navbar({
|
export const Navbar = withTrackingScope(function Navbar({
|
||||||
toplevelSelection,
|
toplevelSelection,
|
||||||
@@ -103,9 +106,9 @@ export const Navbar = withTrackingScope(function Navbar({
|
|||||||
setToplevelSelection('appinspect');
|
setToplevelSelection('appinspect');
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<button>device picker</button>
|
<DevicePicker />
|
||||||
<NavbarButton label="Screenshot" icon={CameraOutlined} />
|
<NavbarScreenshotButton />
|
||||||
<NavbarButton label="Record" icon={VideoCameraOutlined} />
|
<NavbarScreenRecordButton />
|
||||||
<LaunchEmulatorButton />
|
<LaunchEmulatorButton />
|
||||||
{getRenderHostInstance().GK('flipper_connection_troubleshoot') && (
|
{getRenderHostInstance().GK('flipper_connection_troubleshoot') && (
|
||||||
<ConnectionTroubleshootButton
|
<ConnectionTroubleshootButton
|
||||||
@@ -423,7 +426,7 @@ const badgeCountClassname = css`
|
|||||||
margin-top: 8px;
|
margin-top: 8px;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
function NavbarButton({
|
export function NavbarButton({
|
||||||
icon: Icon,
|
icon: Icon,
|
||||||
label,
|
label,
|
||||||
toggled = false,
|
toggled = false,
|
||||||
@@ -492,6 +495,10 @@ function NavbarButton({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function DevicePicker() {
|
||||||
|
return <AppSelector />;
|
||||||
|
}
|
||||||
|
|
||||||
function LoginConnectivityButton() {
|
function LoginConnectivityButton() {
|
||||||
const loggedIn = useValue(currentUser());
|
const loggedIn = useValue(currentUser());
|
||||||
const user = useStore((state) => state.user);
|
const user = useStore((state) => state.user);
|
||||||
|
|||||||
@@ -12,9 +12,7 @@ import {Typography} from 'antd';
|
|||||||
import {LeftSidebar, SidebarTitle, InfoIcon} from '../LeftSidebar';
|
import {LeftSidebar, SidebarTitle, InfoIcon} from '../LeftSidebar';
|
||||||
import {Layout, Link, styled} from '../../ui';
|
import {Layout, Link, styled} from '../../ui';
|
||||||
import {theme, useValue} from 'flipper-plugin';
|
import {theme, useValue} from 'flipper-plugin';
|
||||||
import {AppSelector} from './AppSelector';
|
|
||||||
import {PluginList} from './PluginList';
|
import {PluginList} from './PluginList';
|
||||||
import ScreenCaptureButtons from '../../chrome/ScreenCaptureButtons';
|
|
||||||
import MetroButton from '../../chrome/MetroButton';
|
import MetroButton from '../../chrome/MetroButton';
|
||||||
import {BookmarkSection} from './BookmarkSection';
|
import {BookmarkSection} from './BookmarkSection';
|
||||||
import Client from '../../Client';
|
import Client from '../../Client';
|
||||||
@@ -56,7 +54,6 @@ export function AppInspect() {
|
|||||||
App Inspect
|
App Inspect
|
||||||
</SidebarTitle>
|
</SidebarTitle>
|
||||||
<Layout.Container padv="small" padh="medium" gap={theme.space.large}>
|
<Layout.Container padv="small" padh="medium" gap={theme.space.large}>
|
||||||
<AppSelector />
|
|
||||||
{renderStatusMessage(
|
{renderStatusMessage(
|
||||||
isDeviceConnected,
|
isDeviceConnected,
|
||||||
activeDevice,
|
activeDevice,
|
||||||
@@ -68,7 +65,6 @@ export function AppInspect() {
|
|||||||
{isDeviceConnected && activeDevice && (
|
{isDeviceConnected && activeDevice && (
|
||||||
<Toolbar gap>
|
<Toolbar gap>
|
||||||
<MetroButton />
|
<MetroButton />
|
||||||
<ScreenCaptureButtons />
|
|
||||||
<div style={{flex: 1}} />
|
<div style={{flex: 1}} />
|
||||||
<PluginActionsMenu />
|
<PluginActionsMenu />
|
||||||
</Toolbar>
|
</Toolbar>
|
||||||
|
|||||||
Reference in New Issue
Block a user