Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #627 from deckgo/shape-gif-custom
Browse files Browse the repository at this point in the history
feat(#610): add gif or custom image as shapes
  • Loading branch information
peterpeterparker authored Feb 20, 2020
2 parents 7080e73 + e498e09 commit 4f8918a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class AppActionsElement {
});

this.imageHelper = new ImageHelper(this.slideDidChange, this.blockSlide, this.signIn);
this.shapeHelper = new ShapeHelper(this.slideDidChange);
this.shapeHelper = new ShapeHelper(this.slideDidChange, this.signIn);
}

async componentDidLoad() {
Expand Down
26 changes: 22 additions & 4 deletions studio/src/app/helpers/editor/shape.helper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ import {DeckgoImgAction, ImageActionUtils} from '../../utils/editor/image-action
import {EditAction} from '../../utils/editor/edit-action';

import {BusyService} from '../../services/editor/busy/busy.service';
import {AnonymousService} from '../../services/editor/anonymous/anonymous.service';

export class ShapeHelper {
private busyService: BusyService;
private anonymousService: AnonymousService;

constructor(private didChange: EventEmitter<HTMLElement>) {
constructor(private didChange: EventEmitter<HTMLElement>, private signIn: EventEmitter<void>) {
this.busyService = BusyService.getInstance();
this.anonymousService = AnonymousService.getInstance();
}

async appendShape(slideElement: HTMLElement, shapeAction: ShapeAction) {
Expand All @@ -33,7 +36,11 @@ export class ShapeHelper {

private async appendShapeImage(slideElement: HTMLElement, imageAction: ImageAction) {
if (imageAction.action === EditAction.OPEN_PHOTOS) {
await this.openModal(slideElement);
await this.openModal(slideElement, 'app-photo');
} else if (imageAction.action === EditAction.OPEN_GIFS) {
await this.openModal(slideElement, 'app-gif');
} else if (imageAction.action === EditAction.OPEN_CUSTOM) {
await this.openModalRestricted(slideElement);
} else if (imageAction.action === EditAction.ADD_IMAGE) {
await this.appendContentShapeImage(slideElement, imageAction.image);
}
Expand All @@ -55,9 +62,20 @@ export class ShapeHelper {
}
}

private async openModal(slideElement: HTMLElement) {
private async openModalRestricted(slideElement: HTMLElement) {
const isAnonymous: boolean = await this.anonymousService.isAnonymous();

if (isAnonymous) {
this.signIn.emit();
return;
}

await this.openModal(slideElement, 'app-custom-images');
}

private async openModal(slideElement: HTMLElement, componentTag: string) {
const modal: HTMLIonModalElement = await modalController.create({
component: 'app-photo'
component: componentTag
});

modal.onDidDismiss().then(async (detail: OverlayEventDetail) => {
Expand Down

0 comments on commit 4f8918a

Please sign in to comment.