-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: launchpad admin marketing edition: finish banner
- Loading branch information
Showing
12 changed files
with
336 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React, { FC } from "react"; | ||
import { TouchableOpacity, View } from "react-native"; | ||
|
||
import chevronLeftSVG from "@/assets/icons/chevron-left.svg"; | ||
import chevronRightSVG from "@/assets/icons/chevron-right.svg"; | ||
import { SVG } from "@/components/SVG"; | ||
|
||
export const LeftRightButtons: FC<{ | ||
onPressPrev?: () => void; | ||
onPressNext?: () => void; | ||
}> = ({ onPressPrev, onPressNext }) => { | ||
return ( | ||
<View style={{ flexDirection: "row", alignItems: "center" }}> | ||
<TouchableOpacity onPress={onPressPrev} style={{ marginRight: 24 }}> | ||
<SVG width={16} height={16} source={chevronLeftSVG} /> | ||
</TouchableOpacity> | ||
|
||
<TouchableOpacity onPress={onPressNext}> | ||
<SVG width={16} height={16} source={chevronRightSVG} /> | ||
</TouchableOpacity> | ||
</View> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React, { FC } from "react"; | ||
|
||
import { Banner } from "@/api/marketplace/v1/marketplace"; | ||
import { Link } from "@/components/Link"; | ||
import { HubBannerImage } from "@/components/hub/HubBanner/HubBannerImage"; | ||
import { useMaxResolution } from "@/hooks/useMaxResolution"; | ||
|
||
export const HubBanner: FC<{ | ||
banner: Banner; | ||
}> = ({ banner }) => { | ||
const { width } = useMaxResolution(); | ||
return ( | ||
<Link to={banner?.url} style={{ width: "100%", maxHeight: 500 }}> | ||
<HubBannerImage sourceURI={banner?.image} width={width} /> | ||
</Link> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React, { FC } from "react"; | ||
|
||
import { OptimizedImage } from "@/components/OptimizedImage"; | ||
|
||
export const HubBannerImage: FC<{ | ||
sourceURI: string; | ||
width: number; | ||
}> = ({ sourceURI, width }) => { | ||
return ( | ||
<OptimizedImage | ||
sourceURI={sourceURI} | ||
width={width} | ||
height={350} | ||
style={{ | ||
height: 350, | ||
width, | ||
borderRadius: 20, | ||
}} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
154 changes: 139 additions & 15 deletions
154
...nchpadAdmin/LaunchpadAdministrationOverview/component/MarketingEdition/BannersEdition.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,156 @@ | ||
import React, { FC, useState } from "react"; | ||
import { useWindowDimensions, View } from "react-native"; | ||
import { zodResolver } from "@hookform/resolvers/zod"; | ||
import React, { FC, useMemo, useState } from "react"; | ||
import { Controller, useForm } from "react-hook-form"; | ||
import { View } from "react-native"; | ||
|
||
import { HubBanner } from "@/components/hub/HubBanner"; | ||
import { Banner } from "@/api/marketplace/v1/marketplace"; | ||
import cameraSVG from "@/assets/icons/camera.svg"; | ||
import { BrandText } from "@/components/BrandText"; | ||
import { SVG } from "@/components/SVG"; | ||
import { BoxStyle } from "@/components/boxes/Box"; | ||
import { CustomPressable } from "@/components/buttons/CustomPressable"; | ||
import { HubBanner } from "@/components/hub/HubBanner/HubBanner"; | ||
import { HubBannerImage } from "@/components/hub/HubBanner/HubBannerImage"; | ||
import { TextInputCustom } from "@/components/inputs/TextInputCustom"; | ||
import { FileUploader } from "@/components/inputs/fileUploader"; | ||
import { SpacerColumn, SpacerRow } from "@/components/spacer"; | ||
import { useBanners } from "@/hooks/marketing/useBanners"; | ||
import { useMaxResolution } from "@/hooks/useMaxResolution"; | ||
import { useSelectedNetworkId } from "@/hooks/useSelectedNetwork"; | ||
import { EditButton } from "@/screens/Launchpad/LaunchpadAdmin/LaunchpadAdministrationOverview/component/MarketingEdition/EditButton"; | ||
import { IMAGE_MIME_TYPES } from "@/utils/mime"; | ||
import { neutral17, primaryColor } from "@/utils/style/colors"; | ||
import { fontSemibold13 } from "@/utils/style/fonts"; | ||
import { layout } from "@/utils/style/layout"; | ||
import { BannerForm, ZodBannerForm } from "@/utils/types/banners"; | ||
|
||
// Multiple Banners ? | ||
// TODO: Multiple Banners ? | ||
export const BannersEdition: FC = () => { | ||
const networkId = useSelectedNetworkId(); | ||
const banners = useBanners(networkId); | ||
const banner = banners?.length ? banners[0] : undefined; | ||
const { width } = useWindowDimensions(); | ||
|
||
const { width } = useMaxResolution(); | ||
const [isEditing, setIsEditing] = useState(false); | ||
const bannerForm = useForm<BannerForm>({ | ||
mode: "all", | ||
resolver: zodResolver(ZodBannerForm), | ||
}); | ||
const url = bannerForm.watch("url"); | ||
const image = bannerForm.watch("image"); | ||
const newBanner: Banner = useMemo(() => { | ||
return { | ||
image: image?.url || banner?.image || "", | ||
url: url || banner?.url || "", | ||
}; | ||
}, [url, image?.url, banner?.url, banner?.image]); | ||
|
||
return ( | ||
<View> | ||
<EditButton | ||
isEditing={isEditing} | ||
setIsEditing={setIsEditing} | ||
saveChanges={() => { | ||
// TODO | ||
<View style={{ width, alignSelf: "center" }}> | ||
<View | ||
style={{ | ||
flexDirection: "row", | ||
alignItems: "center", | ||
justifyContent: "space-between", | ||
}} | ||
/> | ||
> | ||
<EditButton | ||
isEditing={isEditing} | ||
setIsEditing={setIsEditing} | ||
isSaveDisabled={!bannerForm.formState.isValid} | ||
onPressSave={() => { | ||
bannerForm.handleSubmit(() => { | ||
// TODO | ||
bannerForm.reset(); | ||
})(); | ||
}} | ||
onPressCancel={() => bannerForm.reset()} | ||
/> | ||
|
||
{isEditing && ( | ||
<View | ||
style={{ | ||
flexDirection: "row", | ||
alignItems: "center", | ||
flex: 1, | ||
justifyContent: "flex-end", | ||
}} | ||
> | ||
<TextInputCustom | ||
label="" | ||
name="url" | ||
noBrokenCorners | ||
variant="regular" | ||
placeHolder="Banner redirection URL" | ||
control={bannerForm.control} | ||
containerStyle={{ | ||
maxWidth: 400, | ||
width: "100%", | ||
}} | ||
height={40} | ||
/> | ||
<SpacerRow size={2} /> | ||
|
||
<Controller<BannerForm> | ||
control={bannerForm.control} | ||
name="image" | ||
render={({ field: { onChange } }) => ( | ||
<FileUploader | ||
onUpload={(files) => { | ||
onChange(files[0]); | ||
}} | ||
mimeTypes={IMAGE_MIME_TYPES} | ||
> | ||
{({ onPress }) => ( | ||
<CustomPressable | ||
onPress={onPress} | ||
style={changeImageButton} | ||
> | ||
<SVG | ||
width={16} | ||
height={16} | ||
source={cameraSVG} | ||
color={neutral17} | ||
/> | ||
<BrandText | ||
numberOfLines={1} | ||
style={[ | ||
fontSemibold13, | ||
{ | ||
color: neutral17, | ||
marginLeft: layout.spacing_x1_25, | ||
}, | ||
]} | ||
> | ||
Change Banner's image | ||
</BrandText> | ||
</CustomPressable> | ||
)} | ||
</FileUploader> | ||
)} | ||
/> | ||
</View> | ||
)} | ||
</View> | ||
<SpacerColumn size={3} /> | ||
|
||
{/*TODO: Edition*/} | ||
{banner && <HubBanner width={width} banner={banner} />} | ||
{isEditing && ( | ||
<HubBannerImage sourceURI={newBanner.image} width={width} /> | ||
)} | ||
|
||
{!isEditing && banner && <HubBanner banner={banner} />} | ||
</View> | ||
); | ||
}; | ||
|
||
const changeImageButton: BoxStyle = { | ||
flexDirection: "row", | ||
alignSelf: "flex-start", | ||
borderRadius: 6, | ||
alignItems: "center", | ||
justifyContent: "center", | ||
paddingRight: layout.spacing_x1_5, | ||
paddingLeft: layout.spacing_x2, | ||
paddingVertical: layout.spacing_x1, | ||
backgroundColor: primaryColor, | ||
height: 40, | ||
}; |
Oops, something went wrong.