diff --git a/src/views/room/widgets/camera/CameraWidgetView.scss b/src/views/room/widgets/camera/CameraWidgetView.scss index 244d7be6..7274426d 100644 --- a/src/views/room/widgets/camera/CameraWidgetView.scss +++ b/src/views/room/widgets/camera/CameraWidgetView.scss @@ -88,8 +88,8 @@ width: 600px; .content-area { - min-height: 350px; - height: 350px; + min-height: 441px; + height: 441px; resize: vertical; .picture-preview { diff --git a/src/views/room/widgets/camera/CameraWidgetView.tsx b/src/views/room/widgets/camera/CameraWidgetView.tsx index 85b535b9..1a15b828 100644 --- a/src/views/room/widgets/camera/CameraWidgetView.tsx +++ b/src/views/room/widgets/camera/CameraWidgetView.tsx @@ -25,6 +25,7 @@ export const CameraWidgetView: FC<{}> = props => const [ selectedEffects, setSelectedEffects ] = useState([]); const [ isZoomed, setIsZoomed ] = useState(false); const [ myLevel, setMyLevel ] = useState(1); + const [ savedPictureUrl, setSavedPictureUrl ] = useState(null); const [ price, setPrice ] = useState<{ credits: number, duckets: number, publishDucketPrice: number }>(null); const onNitroEvent = useCallback((event: RoomWidgetCameraEvent) => @@ -102,17 +103,20 @@ export const CameraWidgetView: FC<{}> = props => case 'editor_cancel': setMode(MODE_CAPTURE); return; - case 'checkout': - setMode(MODE_CHECKOUT); - return; } }, [ selectedPictureIndex ]); + const checkoutPictureUrl = useCallback((pictureUrl: string) => + { + setSavedPictureUrl(pictureUrl); + setMode(MODE_CHECKOUT); + }, []); + return ( { (mode === MODE_CAPTURE) && processAction('close') } onEdit={ () => processAction('edit') } onDelete={ () => processAction('delete') } /> } - { (mode === MODE_EDITOR) && processAction('close') } onCancel={ () => processAction('editor_cancel') } onCheckout={ () => processAction('checkout') } availableEffects={ availableEffects } /> } - { (mode === MODE_CHECKOUT) && processAction('close') } onCancelClick={ () => processAction('editor_cancel') } price={ price }> } + { (mode === MODE_EDITOR) && processAction('close') } onCancel={ () => processAction('editor_cancel') } onCheckout={ checkoutPictureUrl } availableEffects={ availableEffects } /> } + { (mode === MODE_CHECKOUT) && processAction('close') } onCancelClick={ () => processAction('editor_cancel') } price={ price }> } ); } diff --git a/src/views/room/widgets/camera/views/checkout/CameraWidgetCheckoutView.tsx b/src/views/room/widgets/camera/views/checkout/CameraWidgetCheckoutView.tsx index 64355107..a6400007 100644 --- a/src/views/room/widgets/camera/views/checkout/CameraWidgetCheckoutView.tsx +++ b/src/views/room/widgets/camera/views/checkout/CameraWidgetCheckoutView.tsx @@ -1,7 +1,7 @@ /* eslint-disable jsx-a11y/anchor-is-valid */ import { CameraPublishStatusMessageEvent, CameraPurchaseOKMessageEvent, PublishPhotoMessageComposer, PurchasePhotoMessageComposer } from '@nitrots/nitro-renderer'; -import { FC, useCallback, useState } from 'react'; -import { GetRoomCameraWidgetManager } from '../../../../../../api/nitro/camera/GetRoomCameraWidgetManager'; +import { FC, useCallback, useEffect, useState } from 'react'; +import { GetRoomEngine } from '../../../../../../api'; import { CreateMessageHook, SendMessageHook } from '../../../../../../hooks/messages/message-event'; import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../../../layout'; import { LocalizeText } from '../../../../../../utils/LocalizeText'; @@ -11,15 +11,25 @@ import { CameraWidgetCheckoutViewProps } from './CameraWidgetCheckoutView.types' export const CameraWidgetCheckoutView: FC = props => { - const { onCloseClick = null, onCancelClick = null, price = null } = props; + const { pictureUrl = null, onCloseClick = null, onCancelClick = null, price = null } = props; const [ picturesBought, setPicturesBought ] = useState(0); const [ wasPicturePublished, setWasPicturePublished ] = useState(false); const [ isWaiting, setIsWaiting ] = useState(false); const [ publishCooldown, setPublishCooldown ] = useState(0); const { cameraRoll = null, selectedPictureIndex = -1, selectedEffects = null, isZoomed = false } = useCameraWidgetContext(); + useEffect(() => + { + if(!pictureUrl) return; + + console.log(pictureUrl); + + GetRoomEngine().saveBase64AsScreenshot(pictureUrl); + }, [ pictureUrl ]); + const onCameraPurchaseOKMessageEvent = useCallback((event: CameraPurchaseOKMessageEvent) => { + console.log(event); setPicturesBought(value => value + 1); setIsWaiting(false); }, []); @@ -30,6 +40,8 @@ export const CameraWidgetCheckoutView: FC = props { const parser = event.getParser(); + console.log(parser); + setPublishCooldown(parser.secondsToWait); setWasPicturePublished(parser.ok); setIsWaiting(false); @@ -37,11 +49,6 @@ export const CameraWidgetCheckoutView: FC = props CreateMessageHook(CameraPublishStatusMessageEvent, onCameraPublishStatusMessageEvent); - const getCurrentPicture = useCallback(() => - { - return GetRoomCameraWidgetManager().applyEffects(cameraRoll[selectedPictureIndex].texture, selectedEffects, isZoomed); - }, [ cameraRoll, selectedPictureIndex, selectedEffects, isZoomed ]); - const processAction = useCallback((type: string, value: string | number = null) => { switch(type) @@ -73,7 +80,7 @@ export const CameraWidgetCheckoutView: FC = props processAction('close') } /> -
+
{ LocalizeText('camera.purchase.header') }{ price.credits > 0 && <>: { price.credits } }
diff --git a/src/views/room/widgets/camera/views/checkout/CameraWidgetCheckoutView.types.ts b/src/views/room/widgets/camera/views/checkout/CameraWidgetCheckoutView.types.ts index dbbac494..4698df7d 100644 --- a/src/views/room/widgets/camera/views/checkout/CameraWidgetCheckoutView.types.ts +++ b/src/views/room/widgets/camera/views/checkout/CameraWidgetCheckoutView.types.ts @@ -1,5 +1,6 @@ export interface CameraWidgetCheckoutViewProps { + pictureUrl: string; onCloseClick: () => void; onCancelClick: () => void; price: { credits: number, duckets: number, publishDucketPrice: number }; diff --git a/src/views/room/widgets/camera/views/editor/CameraWidgetEditorView.tsx b/src/views/room/widgets/camera/views/editor/CameraWidgetEditorView.tsx index 8cb13259..6ee965b9 100644 --- a/src/views/room/widgets/camera/views/editor/CameraWidgetEditorView.tsx +++ b/src/views/room/widgets/camera/views/editor/CameraWidgetEditorView.tsx @@ -1,5 +1,6 @@ import { IRoomCameraWidgetSelectedEffect, RoomCameraWidgetSelectedEffect } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useMemo, useState } from 'react'; +import ReactSlider from 'react-slider'; import { GetRoomCameraWidgetManager } from '../../../../../../api'; import { NitroCardContentView, NitroCardHeaderView, NitroCardTabsItemView, NitroCardTabsView, NitroCardView } from '../../../../../../layout'; import { LocalizeText } from '../../../../../../utils/LocalizeText'; @@ -57,7 +58,7 @@ export const CameraWidgetEditorView: FC = props => return (selectedEffects[getCurrentEffectIndex] || null); }, [ selectedEffectName, getCurrentEffectIndex, selectedEffects ]); - const setCurrentEffectAlpha = useCallback((alpha: number) => + const setSelectedEffectAlpha = useCallback((alpha: number) => { const index = getCurrentEffectIndex; @@ -90,7 +91,7 @@ export const CameraWidgetEditorView: FC = props => onCancel(); return; case 'checkout': - onCheckout(); + onCheckout(getCurrentPictureUrl); return; case 'change_tab': setCurrentTab(String(effectName)); @@ -140,7 +141,7 @@ export const CameraWidgetEditorView: FC = props => setIsZoomed(!isZoomed); return; } - }, [ isZoomed, availableEffects, getSelectedEffectIndex, selectedEffectName, onCancel, onCheckout, onClose, setIsZoomed, setSelectedEffects ]); + }, [ isZoomed, availableEffects, selectedEffectName, getCurrentPictureUrl, getSelectedEffectIndex, onCancel, onCheckout, onClose, setIsZoomed, setSelectedEffects ]); useEffect(() => { @@ -172,6 +173,35 @@ export const CameraWidgetEditorView: FC = props =>
+ { selectedEffectName && +
+
{ LocalizeText('camera.effect.name.' + selectedEffectName) }
+ setSelectedEffectAlpha(event) } + renderThumb={ (props, state) =>
{ state.valueNow }
} /> +
} +
+
+ + + +
+
+ + +
+
diff --git a/src/views/room/widgets/camera/views/editor/CameraWidgetEditorView.types.ts b/src/views/room/widgets/camera/views/editor/CameraWidgetEditorView.types.ts index c33ba910..4bd58fbc 100644 --- a/src/views/room/widgets/camera/views/editor/CameraWidgetEditorView.types.ts +++ b/src/views/room/widgets/camera/views/editor/CameraWidgetEditorView.types.ts @@ -8,7 +8,7 @@ export interface CameraWidgetEditorViewProps myLevel: number; onClose: () => void; onCancel: () => void; - onCheckout: () => void; + onCheckout: (pictureUrl: string) => void; } export class CameraWidgetEditorTabs