This repository was archived by the owner on Feb 6, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +37
-12
lines changed
popovers/editor/app-slide-type Expand file tree Collapse file tree 4 files changed +37
-12
lines changed Original file line number Diff line number Diff line change 11import { Component , Element , Listen , State } from '@stencil/core' ;
22
3+ import { EditorUtils } from '../../../utils/editor-utils' ;
4+
35import { GifService } from '../../../services/gif/gif.service' ;
46
57@Component ( {
@@ -39,6 +41,17 @@ export class AppGif {
3941 await ( this . el . closest ( 'ion-modal' ) as HTMLIonModalElement ) . dismiss ( ) ;
4042 }
4143
44+ private addSlide ( gif : TenorGif ) : Promise < void > {
45+ return new Promise < void > ( async ( resolve ) => {
46+ const url : string = gif . media [ 0 ] . gif . url ;
47+
48+ const slide : any = await EditorUtils . createSlideGif ( url ) ;
49+ await ( this . el . closest ( 'ion-modal' ) as HTMLIonModalElement ) . dismiss ( slide ) ;
50+
51+ resolve ( ) ;
52+ } ) ;
53+ }
54+
4255 render ( ) {
4356 return [
4457 < ion-header >
@@ -73,8 +86,12 @@ export class AppGif {
7386 if ( gifs && gifs . length > 0 ) {
7487 return (
7588 gifs . map ( ( gif : TenorGif ) => {
76- if ( gif . media && gif . media . length > 0 && gif . media [ 0 ] . tinygif && gif . media [ 0 ] . tinygif . url ) {
77- return < img src = { gif . media [ 0 ] . tinygif . url } alt = { gif . title ? gif . title : gif . url } > </ img >
89+ if ( gif . media && gif . media . length > 0
90+ && gif . media [ 0 ] . tinygif && gif . media [ 0 ] . tinygif . url
91+ && gif . media [ 0 ] . gif && gif . media [ 0 ] . gif . url ) {
92+ return < div custom-tappable onClick = { ( ) => this . addSlide ( gif ) } >
93+ < img src = { gif . media [ 0 ] . tinygif . url } alt = { gif . title ? gif . title : gif . url } > </ img >
94+ </ div >
7895 } else {
7996 return undefined ;
8097 }
Original file line number Diff line number Diff line change @@ -291,21 +291,29 @@ export class AppEditor {
291291 }
292292
293293 if ( detail . data . slide ) {
294- await this . concatSlide ( detail . data . slide ) ;
295- await this . slideToLastSlide ( ) ;
294+ await this . addSlide ( detail . data . slide ) ;
296295 }
297296 } ) ;
298297
299298 await popover . present ( ) ;
300299 }
301300
301+ private async addSlide ( slide : any ) {
302+ await this . concatSlide ( slide ) ;
303+ await this . slideToLastSlide ( ) ;
304+ }
305+
302306 private async openGifPicker ( ) {
303307 const modal : HTMLIonModalElement = await this . modalController . create ( {
304308 component : 'app-gif'
305309 } ) ;
306310
307- modal . onDidDismiss ( ) . then ( async ( _detail : OverlayEventDetail ) => {
308- // TODO: apply gif
311+ modal . onDidDismiss ( ) . then ( async ( detail : OverlayEventDetail ) => {
312+ if ( detail . data ) {
313+ await this . addSlide ( detail . data ) ;
314+
315+ // TODO: call lazy load
316+ }
309317 } ) ;
310318
311319 await modal . present ( ) ;
Original file line number Diff line number Diff line change @@ -33,10 +33,10 @@ export class AppSlideType {
3333
3434 private async addSlide ( template : SlideTemplate ) {
3535 const slide : any = await EditorUtils . createSlide ( template ) ;
36- await this . closePopover ( slide , template ) ;
36+ await this . closePopover ( template , slide ) ;
3737 }
3838
39- async closePopover ( slide : any , template : SlideTemplate ) {
39+ async closePopover ( template : SlideTemplate , slide ?: any ) {
4040 await ( this . el . closest ( 'ion-popover' ) as HTMLIonModalElement ) . dismiss ( {
4141 slide : slide ,
4242 template : template
@@ -63,7 +63,7 @@ export class AppSlideType {
6363 < p slot = "end" > Content</ p >
6464 </ deckgo-slide-split >
6565 </ div >
66- < div class = "item" custom-tappable onClick = { ( ) => this . addSlide ( SlideTemplate . GIF ) } >
66+ < div class = "item" custom-tappable onClick = { ( ) => this . closePopover ( SlideTemplate . GIF ) } >
6767 < deckgo-slide-gif src = "./assets/img/example.gif" alt = "Slide Gif" >
6868 < p slot = "footer" style = { { "font-size" : "var(--font-size-very-small)" , padding : "2px" , "border-radius" : "4px" } } > GIFs</ p >
6969 </ deckgo-slide-gif >
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ export class EditorUtils {
2727 } else if ( template === SlideTemplate . SPLIT ) {
2828 resolve ( await this . createSlideSplit ( ) ) ;
2929 } else if ( template === SlideTemplate . GIF ) {
30- resolve ( await this . createSlideGif ( ) ) ;
30+ resolve ( await this . createSlideGif ( './assets/img/example.gif' ) ) ;
3131 } else {
3232 resolve ( null ) ;
3333 }
@@ -106,7 +106,7 @@ export class EditorUtils {
106106 } ) ;
107107 }
108108
109- private static createSlideGif ( ) : Promise < any > {
109+ static createSlideGif ( src : string ) : Promise < any > {
110110 return new Promise < any > ( ( resolve ) => {
111111 if ( ! document ) {
112112 resolve ( ) ;
@@ -121,7 +121,7 @@ export class EditorUtils {
121121 { this . DEFAULT_CAPTION }
122122 </ h2 > ;
123123
124- const slide : any = < deckgo-slide-gif src = "./assets/img/example.gif" >
124+ const slide : any = < deckgo-slide-gif src = { src } >
125125 { title }
126126 { content }
127127 </ deckgo-slide-gif > ;
You can’t perform that action at this time.
0 commit comments