Skip to content

Commit 431e705

Browse files
author
FalkWolsky
committed
Adapting Mobile Preview
1 parent 496c100 commit 431e705

File tree

2 files changed

+39
-15
lines changed

2 files changed

+39
-15
lines changed

client/packages/lowcoder/src/pages/common/previewHeader.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ const PreviewHeaderComp = () => {
220220
/>
221221

222222
{/* Orientation */}
223-
{editorState.deviceType !== 'desktop' && (
223+
{/* editorState.deviceType !== 'desktop' && (
224224
<Segmented<DeviceOrientation>
225225
options={[
226226
{ value: 'portrait', label: "Portrait" },
@@ -231,7 +231,7 @@ const PreviewHeaderComp = () => {
231231
editorState.setDeviceOrientation(value);
232232
}}
233233
/>
234-
)}
234+
) */}
235235
</>
236236
);
237237

client/packages/lowcoder/src/pages/editor/editorView.tsx

+37-13
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ export const EditorWrapper = styled.div`
255255
`;
256256

257257
const DeviceWrapperInner = styled(Flex)`
258-
margin: 20px 0 0;
258+
margin: 2% 0 0;
259259
.screen {
260260
overflow: auto;
261261
}
@@ -323,8 +323,8 @@ const DeviceWrapper = ({
323323
const loadWrapper = async () => {
324324
if (deviceType === "tablet") {
325325
await import('html5-device-mockups/dist/device-mockups.min.css');
326-
const { IPad } = await import("react-device-mockups");
327-
setWrapper(() => IPad);
326+
const { IPadPro } = await import("react-device-mockups");
327+
setWrapper(() => IPadPro);
328328
} else if (deviceType === "mobile") {
329329
await import('html5-device-mockups/dist/device-mockups.min.css');
330330
const { IPhone7 } = await import("react-device-mockups");
@@ -342,20 +342,20 @@ const DeviceWrapper = ({
342342
return 700;
343343
}
344344
if (deviceType === 'tablet' && deviceOrientation === 'landscape') {
345-
return 1000;
345+
return 900;
346346
}
347347
if (deviceType === 'mobile' && deviceOrientation === 'portrait') {
348-
return 400;
348+
return 450;
349349
}
350350
if (deviceType === 'mobile' && deviceOrientation === 'landscape') {
351-
return 800;
351+
return 900;
352352
}
353353
}, [deviceType, deviceOrientation]);
354354

355355
if (!Wrapper) return <>{children}</>;
356356

357357
return (
358-
<DeviceWrapperInner justify="center">
358+
<DeviceWrapperInner justify="center" >
359359
<Wrapper
360360
orientation={deviceOrientation}
361361
width={deviceWidth}
@@ -488,12 +488,36 @@ function EditorView(props: EditorViewProps) {
488488
if (isViewMode) return uiComp.getView();
489489

490490
return (
491-
<DeviceWrapper
492-
deviceType={editorState.deviceType}
493-
deviceOrientation={editorState.deviceOrientation}
494-
>
495-
{uiComp.getView()}
496-
</DeviceWrapper>
491+
editorState.deviceType === "mobile" || editorState.deviceType === "tablet" ? (
492+
<div style={{
493+
display: "flex",
494+
flexDirection: "row", // Arrange side by side
495+
gap: "20px", // Spacing between the two DeviceWrappers
496+
justifyContent: "center", // Center horizontally
497+
alignItems: "center", // Center vertically
498+
height: "auto", // Full viewport height for vertical centering
499+
width: "100%", // Full viewport width
500+
501+
}}>
502+
<DeviceWrapper
503+
deviceType={editorState.deviceType}
504+
deviceOrientation="portrait"
505+
>
506+
{uiComp.getView()}
507+
</DeviceWrapper>
508+
509+
<DeviceWrapper
510+
deviceType={editorState.deviceType}
511+
deviceOrientation="landscape"
512+
>
513+
{uiComp.getView()}
514+
</DeviceWrapper>
515+
</div>
516+
) : (
517+
<div>
518+
{uiComp.getView()}
519+
</div>
520+
)
497521
)
498522
}, [
499523
uiComp,

0 commit comments

Comments
 (0)