Skip to content

Commit

Permalink
Improve design overall & only 1 step in dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementPasteau committed Nov 22, 2024
1 parent 005ea4b commit d3ad24b
Show file tree
Hide file tree
Showing 15 changed files with 594 additions and 361 deletions.
14 changes: 7 additions & 7 deletions newIDE/app/src/AssetStore/ExampleStore/ExampleInformationPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,11 @@ const ExampleInformationPage = ({ exampleShortHeader }: Props) => {
</Trans>
</AlertMessage>
)}
<ResponsiveLineStackLayout
alignItems="center"
noMargin
noResponsiveLandscape
>
<ResponsiveLineStackLayout noMargin noResponsiveLandscape>
{hasIcon ? (
<ExampleThumbnailOrIcon exampleShortHeader={exampleShortHeader} />
<Line>
<ExampleThumbnailOrIcon exampleShortHeader={exampleShortHeader} />
</Line>
) : null}
<Column expand>
{
Expand All @@ -107,7 +105,9 @@ const ExampleInformationPage = ({ exampleShortHeader }: Props) => {
</div>
</Line>
}
<Text noMargin>{exampleShortHeader.shortDescription}</Text>
<Text size="body" displayInlineAsSpan>
<MarkdownText source={exampleShortHeader.shortDescription} />
</Text>
</Column>
</ResponsiveLineStackLayout>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ import { CorsAwareImage } from '../../UI/CorsAwareImage';
import { useResponsiveWindowSize } from '../../UI/Responsive/ResponsiveWindowMeasurer';
import { iconWithBackgroundStyle } from '../../UI/IconContainer';

const iconPadding = 1;

const styles = {
iconBackground: {
flex: 0,
display: 'flex',
justifyContent: 'left',
},
icon: {
...iconWithBackgroundStyle,
padding: 1,
padding: iconPadding,
},
};

Expand All @@ -29,7 +30,8 @@ export const ExampleThumbnailOrIcon = ({ exampleShortHeader }: Props) => {
const aspectRatio = iconUrl.endsWith('square-icon.png') ? '1 / 1' : '16 / 9';
// Make the icon be full width on mobile.
const height = isMobile && !isLandscape ? undefined : ICON_DESKTOP_HEIGHT;
const width = isMobile && !isLandscape ? '100%' : undefined;
const width =
isMobile && !isLandscape ? `calc(100% - ${2 * iconPadding}px)` : undefined;

return (
<div style={styles.iconBackground}>
Expand Down
5 changes: 4 additions & 1 deletion newIDE/app/src/AssetStore/ExampleStore/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { PrivateGameTemplateStoreContext } from '../PrivateGameTemplates/Private
import { GridList } from '@material-ui/core';
import { getExampleAndTemplateTiles } from '../../MainFrame/EditorContainers/HomePage/BuildSection/utils';
import BackgroundText from '../../UI/BackgroundText';
import { ColumnStackLayout } from '../../UI/Layout';

const styles = {
grid: {
Expand Down Expand Up @@ -235,7 +236,9 @@ const ExampleStore = ({
{rowToInsert && <Line>{rowToInsert.element}</Line>}
</Column>
) : (
nodesToDisplay
<ColumnStackLayout noMargin expand>
{nodesToDisplay}
</ColumnStackLayout>
)}
</Column>
</React.Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ type Props = {|
onAssetPackOpen?: PrivateAssetPackListingData => void,
onCreateWithGameTemplate?: PrivateGameTemplateListingData => void,
simulateAppStoreProduct?: boolean,
hideOpenAction?: boolean,
|};

const PrivateGameTemplateInformationPage = ({
Expand All @@ -131,7 +130,6 @@ const PrivateGameTemplateInformationPage = ({
onAssetPackOpen,
onCreateWithGameTemplate,
simulateAppStoreProduct,
hideOpenAction,
}: Props) => {
const { id, name, sellerId } = privateGameTemplateListingData;
const { privateGameTemplateListingDatas } = React.useContext(
Expand Down Expand Up @@ -545,7 +543,7 @@ const PrivateGameTemplateInformationPage = ({
/>
)}
</>
) : !hideOpenAction && onCreateWithGameTemplate ? (
) : onCreateWithGameTemplate ? (
<OpenProductButton
productListingData={privateGameTemplateListingData}
onClick={() =>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// @flow
import * as React from 'react';
import { type PrivateGameTemplateListingData } from '../../Utils/GDevelopServices/Shop';
import Text from '../../UI/Text';
import { Trans } from '@lingui/macro';
import { ResponsiveLineStackLayout } from '../../UI/Layout';
import { Column, Line } from '../../UI/Grid';
import { MarkdownText } from '../../UI/MarkdownText';
import { shouldUseAppStoreProduct } from '../../Utils/AppStorePurchases';
import AuthenticatedUserContext from '../../Profile/AuthenticatedUserContext';
import { PrivateGameTemplateStoreContext } from './PrivateGameTemplateStoreContext';
import { getUserProductPurchaseUsageType } from '../ProductPageHelper';
import ProductLicenseOptions from '../ProductLicense/ProductLicenseOptions';
import HelpIcon from '../../UI/HelpIcon';
import PrivateGameTemplateThumbnail from './PrivateGameTemplateThumbnail';

type Props = {|
privateGameTemplateListingData: PrivateGameTemplateListingData,
simulateAppStoreProduct?: boolean,
|};

const PrivateGameTemplateOwnedInformationPage = ({
privateGameTemplateListingData,
simulateAppStoreProduct,
}: Props) => {
const { privateGameTemplateListingDatas } = React.useContext(
PrivateGameTemplateStoreContext
);
const { receivedGameTemplates, gameTemplatePurchases } = React.useContext(
AuthenticatedUserContext
);
const [selectedUsageType, setSelectedUsageType] = React.useState<string>(
privateGameTemplateListingData.prices[0].usageType
);
const shouldUseOrSimulateAppStoreProduct =
shouldUseAppStoreProduct() || !!simulateAppStoreProduct;

const userGameTemplatePurchaseUsageType = React.useMemo(
() =>
getUserProductPurchaseUsageType({
productId: privateGameTemplateListingData
? privateGameTemplateListingData.id
: null,
receivedProducts: receivedGameTemplates,
productPurchases: gameTemplatePurchases,
allProductListingDatas: privateGameTemplateListingDatas,
}),
[
gameTemplatePurchases,
privateGameTemplateListingData,
privateGameTemplateListingDatas,
receivedGameTemplates,
]
);

return (
<Column expand noMargin>
<ResponsiveLineStackLayout noMargin noResponsiveLandscape>
<Line>
<PrivateGameTemplateThumbnail
privateGameTemplateListingData={privateGameTemplateListingData}
simulateAppStoreProduct={shouldUseOrSimulateAppStoreProduct}
/>
</Line>
<Column noMargin>
<Line noMargin>
<Text size="sub-title">
<Trans>Licensing</Trans>
</Text>
<HelpIcon
size="small"
helpPagePath="https://gdevelop.io/page/asset-store-license-agreement"
/>
</Line>
<ProductLicenseOptions
value={selectedUsageType}
onChange={setSelectedUsageType}
product={privateGameTemplateListingData}
ownedLicense={userGameTemplatePurchaseUsageType}
/>
<Text size="body" displayInlineAsSpan noMargin>
<MarkdownText
source={privateGameTemplateListingData.description}
allowParagraphs
/>
</Text>
</Column>
</ResponsiveLineStackLayout>
</Column>
);
};

export default PrivateGameTemplateOwnedInformationPage;
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// @flow
import * as React from 'react';
import { type PrivateGameTemplateListingData } from '../../Utils/GDevelopServices/Shop';
import { CorsAwareImage } from '../../UI/CorsAwareImage';
import { useResponsiveWindowSize } from '../../UI/Responsive/ResponsiveWindowMeasurer';
import { iconWithBackgroundStyle } from '../../UI/IconContainer';

const iconPadding = 1;

const styles = {
iconBackground: {
display: 'flex',
justifyContent: 'left',
},
icon: {
...iconWithBackgroundStyle,
padding: iconPadding,
aspectRatio: '16 / 9',
},
};

const ICON_DESKTOP_HEIGHT = 120;

type Props = {|
privateGameTemplateListingData: PrivateGameTemplateListingData,
simulateAppStoreProduct: boolean,
|};

const PrivateGameTemplateThumbnail = ({
privateGameTemplateListingData,
simulateAppStoreProduct,
}: Props) => {
const { isMobile, isLandscape } = useResponsiveWindowSize();
const iconUrl = React.useMemo(
() =>
(simulateAppStoreProduct &&
privateGameTemplateListingData.appStoreThumbnailUrls &&
privateGameTemplateListingData.appStoreThumbnailUrls[0]) ||
privateGameTemplateListingData.thumbnailUrls[0],
[privateGameTemplateListingData, simulateAppStoreProduct]
);

// Make the icon be full width on mobile.
const height = isMobile && !isLandscape ? undefined : ICON_DESKTOP_HEIGHT;
const width =
isMobile && !isLandscape ? `calc(100% - ${2 * iconPadding}px)` : undefined;

return (
<div style={styles.iconBackground}>
<CorsAwareImage
style={{ ...styles.icon, height, width }}
src={iconUrl}
alt={privateGameTemplateListingData.name}
/>
</div>
);
};

export default PrivateGameTemplateThumbnail;
4 changes: 3 additions & 1 deletion newIDE/app/src/AssetStore/ShopTiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ export const ExampleTile = ({
onSelect,
style,
customTitle,
centerTitle,
useQuickCustomizationThumbnail,
disabled,
}: {|
Expand All @@ -558,6 +559,7 @@ export const ExampleTile = ({
/** Props needed so that GridList component can adjust tile size */
style?: any,
customTitle?: string,
centerTitle?: boolean,
useQuickCustomizationThumbnail?: boolean,
disabled?: boolean,
|}) => {
Expand Down Expand Up @@ -617,7 +619,7 @@ export const ExampleTile = ({
/>
)}
<Column>
<Line justifyContent="flex-start" noMargin>
<Line justifyContent={centerTitle ? 'center' : 'flex-start'} noMargin>
<Text
style={styles.packTitle}
size="body2"
Expand Down
10 changes: 0 additions & 10 deletions newIDE/app/src/MainFrame/UseNewProjectDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ const useExampleOrGameTemplateDialogs = ({
setSelectedExampleShortHeader,
] = React.useState<?ExampleShortHeader>(null);
const [preventBackHome, setPreventBackHome] = React.useState(true);
const [preventBackDetails, setPreventBackDetails] = React.useState(false);

const { receivedGameTemplates } = React.useContext(AuthenticatedUserContext);
const { privateGameTemplateListingDatas } = React.useContext(
Expand All @@ -66,7 +65,6 @@ const useExampleOrGameTemplateDialogs = ({
const closeNewProjectDialog = React.useCallback(
() => {
setPreventBackHome(false);
setPreventBackDetails(false);
setSelectedExampleShortHeader(null);
setSelectedPrivateGameTemplateListingData(null);
setNewProjectSetupDialogOpen(false);
Expand All @@ -76,7 +74,6 @@ const useExampleOrGameTemplateDialogs = ({
const openNewProjectDialog = React.useCallback(
() => {
setPreventBackHome(false);
setPreventBackDetails(false);
setSelectedExampleShortHeader(null);
setSelectedPrivateGameTemplateListingData(null);
setNewProjectSetupDialogOpen(true);
Expand Down Expand Up @@ -119,15 +116,12 @@ const useExampleOrGameTemplateDialogs = ({
({
privateGameTemplateListingData,
preventBackHome,
preventBackDetails,
}: {|
privateGameTemplateListingData: ?PrivateGameTemplateListingData,
preventBackHome?: boolean,
preventBackDetails?: boolean,
|}) => {
setSelectedPrivateGameTemplateListingData(privateGameTemplateListingData);
setPreventBackHome(!!preventBackHome);
setPreventBackDetails(!!preventBackDetails);
if (privateGameTemplateListingData) {
setNewProjectSetupDialogOpen(true);
}
Expand All @@ -139,15 +133,12 @@ const useExampleOrGameTemplateDialogs = ({
({
exampleShortHeader,
preventBackHome,
preventBackDetails,
}: {|
exampleShortHeader: ?ExampleShortHeader,
preventBackHome?: boolean,
preventBackDetails?: boolean,
|}) => {
setSelectedExampleShortHeader(exampleShortHeader);
setPreventBackHome(!!preventBackHome);
setPreventBackDetails(!!preventBackDetails);
if (exampleShortHeader) {
setNewProjectSetupDialogOpen(true);
}
Expand Down Expand Up @@ -225,7 +216,6 @@ const useExampleOrGameTemplateDialogs = ({
privateGameTemplateListingDatasFromSameCreator
}
preventBackHome={preventBackHome}
preventBackDetails={preventBackDetails}
/>
)}
</>
Expand Down
1 change: 0 additions & 1 deletion newIDE/app/src/MainFrame/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3681,7 +3681,6 @@ const MainFrame = (props: Props) => {
onSelectPrivateGameTemplateListingData({
privateGameTemplateListingData,
preventBackHome: true,
preventBackDetails: true,
});
},
onCreateProjectFromExample: createProjectFromExample,
Expand Down
Loading

0 comments on commit d3ad24b

Please sign in to comment.