@propbinder/mobile-design 0.2.47 → 0.2.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (221) hide show
  1. package/ng-package.json +24 -0
  2. package/package.json +3 -39
  3. package/src/animations/page-transitions.ts +165 -0
  4. package/src/assets/fonts/brockmann-mediumitalic-webfont.woff2 +0 -0
  5. package/src/assets/fonts/brockmann-regularitalic-webfont.woff2 +0 -0
  6. package/src/assets/fonts/brockmann-semibolditalic-webfont.woff2 +0 -0
  7. package/src/components/action-list-item/ds-mobile-action-list-item.ts +102 -0
  8. package/src/components/action-list-item/index.ts +2 -0
  9. package/src/components/app-icon/ds-app-icon.ts +133 -0
  10. package/src/components/app-icon/index.ts +2 -0
  11. package/src/components/attachment-preview/ds-mobile-attachment-preview.css +139 -0
  12. package/src/components/attachment-preview/ds-mobile-attachment-preview.ts +164 -0
  13. package/src/components/attachment-preview/index.ts +1 -0
  14. package/src/components/avatar-with-badge/ds-avatar-with-badge.ts +142 -0
  15. package/src/components/avatar-with-badge/index.ts +2 -0
  16. package/src/components/booking-modal/ds-mobile-booking-confirmation-wrapper.ts +71 -0
  17. package/src/components/booking-modal/ds-mobile-booking-modal.service.ts +121 -0
  18. package/src/components/booking-modal/ds-mobile-booking-modal.ts +598 -0
  19. package/src/components/booking-modal/ds-mobile-booking-summary.ts +161 -0
  20. package/src/components/booking-modal/index.ts +4 -0
  21. package/src/components/bottom-sheet/ds-mobile-actions-bottom-sheet.ts +266 -0
  22. package/src/components/bottom-sheet/ds-mobile-bottom-sheet-header.ts +146 -0
  23. package/src/components/bottom-sheet/ds-mobile-bottom-sheet-wrapper.ts +156 -0
  24. package/src/components/bottom-sheet/ds-mobile-bottom-sheet.css +101 -0
  25. package/src/components/bottom-sheet/ds-mobile-bottom-sheet.service.ts +169 -0
  26. package/src/components/bottom-sheet/ds-mobile-confirmation-sheet.ts +211 -0
  27. package/src/components/bottom-sheet/ds-mobile-post-create-bottom-sheet.ts +578 -0
  28. package/src/components/bottom-sheet/ds-mobile-profile-actions-sheet.ts +614 -0
  29. package/src/components/bottom-sheet/index.ts +8 -0
  30. package/src/components/bottom-sheet/modal-shadow-fix.ts +42 -0
  31. package/src/components/card-inline/ds-mobile-card-inline.ts +301 -0
  32. package/src/components/card-inline/index.ts +2 -0
  33. package/src/components/card-inline-banner/ds-mobile-card-inline-banner.ts +118 -0
  34. package/src/components/card-inline-banner/index.ts +1 -0
  35. package/src/components/card-inline-contact/ds-mobile-card-inline-contact.ts +120 -0
  36. package/src/components/card-inline-contact/index.ts +1 -0
  37. package/src/components/card-inline-file/ds-mobile-card-inline-file.ts +141 -0
  38. package/src/components/card-inline-file/index.ts +1 -0
  39. package/src/components/chat-modal/ds-mobile-chat-modal.css +159 -0
  40. package/src/components/chat-modal/ds-mobile-chat-modal.service.ts +105 -0
  41. package/src/components/chat-modal/ds-mobile-chat-modal.ts +918 -0
  42. package/src/components/chat-modal/index.ts +8 -0
  43. package/src/components/comment/ds-mobile-comment.ts +568 -0
  44. package/src/components/comment/index.ts +2 -0
  45. package/src/components/contact-list-item/ds-mobile-contact-list-item.ts +182 -0
  46. package/src/components/contact-list-item/index.ts +2 -0
  47. package/src/components/content/ds-mobile-content.ts +139 -0
  48. package/src/components/content/index.ts +2 -0
  49. package/src/components/dropdown/ds-mobile-dropdown.css +199 -0
  50. package/src/components/dropdown/ds-mobile-dropdown.ts +340 -0
  51. package/src/components/dropdown/index.ts +2 -0
  52. package/src/components/ds-mobile-tabs.css +407 -0
  53. package/src/components/ds-mobile-tabs.ts +216 -0
  54. package/src/components/empty-state/ds-mobile-empty-state.ts +120 -0
  55. package/src/components/empty-state/index.ts +2 -0
  56. package/src/components/fab/ds-mobile-fab.ts +315 -0
  57. package/src/components/fab/index.ts +1 -0
  58. package/src/components/facility-creation-modal/ds-mobile-facility-creation-confirmation-wrapper.ts +121 -0
  59. package/src/components/facility-creation-modal/ds-mobile-facility-creation-modal.css +189 -0
  60. package/src/components/facility-creation-modal/ds-mobile-facility-creation-modal.service.ts +135 -0
  61. package/src/components/facility-creation-modal/ds-mobile-facility-creation-modal.ts +656 -0
  62. package/src/components/facility-creation-modal/index.ts +9 -0
  63. package/src/components/facility-creation-modal/sheets/ds-mobile-access-sheet.ts +105 -0
  64. package/src/components/facility-creation-modal/sheets/ds-mobile-price-sheet.ts +188 -0
  65. package/src/components/facility-creation-modal/sheets/ds-mobile-when-can-book-sheet.ts +460 -0
  66. package/src/components/facility-creation-modal/sheets/ds-mobile-who-can-book-sheet.ts +134 -0
  67. package/src/components/facility-detail-modal/ds-mobile-facility-detail-modal.service.ts +69 -0
  68. package/src/components/facility-detail-modal/ds-mobile-facility-detail-modal.ts +379 -0
  69. package/src/components/facility-detail-modal/index.ts +2 -0
  70. package/src/components/file-attachment/ds-mobile-file-attachment.ts +164 -0
  71. package/src/components/file-attachment/index.ts +2 -0
  72. package/src/components/handbook-detail-modal/ds-mobile-handbook-detail-modal.css +214 -0
  73. package/src/components/handbook-detail-modal/ds-mobile-handbook-detail-modal.service.ts +84 -0
  74. package/src/components/handbook-detail-modal/ds-mobile-handbook-detail-modal.ts +424 -0
  75. package/src/components/handbook-detail-modal/index.ts +3 -0
  76. package/src/components/handbook-folder/ds-mobile-handbook-folder-mini.ts +175 -0
  77. package/src/components/handbook-folder/ds-mobile-handbook-folder.ts +533 -0
  78. package/src/components/handbook-folder/index.ts +4 -0
  79. package/src/components/header-content/ds-mobile-header-content.ts +222 -0
  80. package/src/components/header-content/index.ts +2 -0
  81. package/src/components/illustration/ds-mobile-illustration.ts +124 -0
  82. package/src/components/illustration/index.ts +2 -0
  83. package/src/components/index.ts +124 -0
  84. package/src/components/inline-photo/ds-mobile-inline-photo.ts +361 -0
  85. package/src/components/inline-photo/index.ts +1 -0
  86. package/src/components/inline-tabs/ds-mobile-inline-tabs.ts +132 -0
  87. package/src/components/inline-tabs/index.ts +2 -0
  88. package/src/components/interactive-list-item-booking/ds-mobile-interactive-list-item-booking.ts +350 -0
  89. package/src/components/interactive-list-item-booking/index.ts +1 -0
  90. package/src/components/interactive-list-item-inquiry/ds-mobile-interactive-list-item-inquiry.ts +321 -0
  91. package/src/components/interactive-list-item-inquiry/index.ts +2 -0
  92. package/src/components/interactive-list-item-message/ds-mobile-interactive-list-item-message.ts +237 -0
  93. package/src/components/interactive-list-item-message/index.ts +2 -0
  94. package/src/components/interactive-list-item-post/ds-mobile-interactive-list-item-post.ts +549 -0
  95. package/src/components/interactive-list-item-post/ds-mobile-post-pdf-attachment.ts +124 -0
  96. package/src/components/interactive-list-item-post/index.ts +13 -0
  97. package/src/components/lightbox/ds-mobile-lightbox-footer.ts +315 -0
  98. package/src/components/lightbox/ds-mobile-lightbox-header.ts +202 -0
  99. package/src/components/lightbox/ds-mobile-lightbox-image.ts +484 -0
  100. package/src/components/lightbox/ds-mobile-lightbox-pdf.css +377 -0
  101. package/src/components/lightbox/ds-mobile-lightbox-pdf.ts +374 -0
  102. package/src/components/lightbox/ds-mobile-lightbox.css +587 -0
  103. package/src/components/lightbox/ds-mobile-lightbox.service.ts +296 -0
  104. package/src/components/lightbox/ds-mobile-lightbox.ts +529 -0
  105. package/src/components/lightbox/index.ts +22 -0
  106. package/src/components/list-item/ds-mobile-list-item.ts +603 -0
  107. package/src/components/list-item/index.ts +2 -0
  108. package/src/components/list-item-static/ds-mobile-list-item-static.ts +133 -0
  109. package/src/components/list-item-static/index.ts +2 -0
  110. package/src/components/loader-overlay/ds-mobile-loader-overlay.css +49 -0
  111. package/src/components/loader-overlay/ds-mobile-loader-overlay.ts +77 -0
  112. package/src/components/loader-overlay/index.ts +1 -0
  113. package/src/components/logo/ds-logo.ts +95 -0
  114. package/src/components/logo/index.ts +2 -0
  115. package/src/components/message-bubble/ds-mobile-message-bubble.ts +633 -0
  116. package/src/components/message-bubble/index.ts +7 -0
  117. package/src/components/message-composer/ds-mobile-message-composer.ts +1146 -0
  118. package/src/components/message-composer/index.ts +7 -0
  119. package/src/components/modal/ds-mobile-modal.css +163 -0
  120. package/src/components/modal/ds-mobile-modal.service.ts +329 -0
  121. package/src/components/modal/index.ts +8 -0
  122. package/src/components/modal-base/ds-mobile-modal-base.css +378 -0
  123. package/src/components/modal-base/ds-mobile-modal-base.ts +261 -0
  124. package/src/components/modal-base/index.ts +2 -0
  125. package/src/components/new-inquiry-modal/ds-mobile-new-inquiry-modal.css +112 -0
  126. package/src/components/new-inquiry-modal/ds-mobile-new-inquiry-modal.service.ts +93 -0
  127. package/src/components/new-inquiry-modal/ds-mobile-new-inquiry-modal.ts +442 -0
  128. package/src/components/new-inquiry-modal/index.ts +4 -0
  129. package/src/components/offline-banner/ds-mobile-offline-banner.ts +135 -0
  130. package/src/components/offline-banner/index.ts +1 -0
  131. package/src/components/page-details/ds-mobile-page-details.css +83 -0
  132. package/src/components/page-details/ds-mobile-page-details.ts +282 -0
  133. package/src/components/page-details/index.ts +2 -0
  134. package/src/components/page-main/ds-mobile-page-main.css +68 -0
  135. package/src/components/page-main/ds-mobile-page-main.ts +421 -0
  136. package/src/components/page-main/index.ts +2 -0
  137. package/src/components/post-composer/ds-mobile-post-composer.ts +140 -0
  138. package/src/components/post-composer/index.ts +2 -0
  139. package/src/components/post-detail-modal/ds-mobile-post-detail-modal.css +390 -0
  140. package/src/components/post-detail-modal/ds-mobile-post-detail-modal.service.ts +108 -0
  141. package/src/components/post-detail-modal/ds-mobile-post-detail-modal.ts +722 -0
  142. package/src/components/post-detail-modal/index.ts +9 -0
  143. package/src/components/property-banner/ds-mobile-property-banner.ts +95 -0
  144. package/src/components/property-banner/index.ts +2 -0
  145. package/src/components/section/ds-mobile-section.ts +263 -0
  146. package/src/components/section/index.ts +2 -0
  147. package/src/components/shared/directives/index.ts +2 -0
  148. package/src/components/shared/directives/long-press.directive.ts +212 -0
  149. package/src/components/shared/index.ts +3 -0
  150. package/src/components/shared/mobile-modal-base.ts +457 -0
  151. package/src/components/shared/mobile-page-base.ts +204 -0
  152. package/src/components/swiper/ds-mobile-swiper-with-nav.ts +160 -0
  153. package/src/components/swiper/ds-mobile-swiper.ts +327 -0
  154. package/src/components/swiper/index.ts +3 -0
  155. package/src/components/system-message-banner/ds-mobile-system-message-banner.ts +129 -0
  156. package/src/components/system-message-banner/index.ts +2 -0
  157. package/src/components/tab-bar/ds-mobile-tab-bar.css +533 -0
  158. package/src/components/tab-bar/ds-mobile-tab-bar.ts +735 -0
  159. package/src/components/tab-bar/index.ts +2 -0
  160. package/src/components/tabs/ds-mobile-tabs.css +25 -0
  161. package/src/components/tabs/ds-mobile-tabs.ts +89 -0
  162. package/src/components/tabs/index.ts +2 -0
  163. package/src/components/text-input/ds-text-input.ts +287 -0
  164. package/src/components/text-input/index.ts +2 -0
  165. package/src/examples/booking.page.ts +434 -0
  166. package/src/examples/community.page.ts +776 -0
  167. package/src/examples/handbook.page.ts +324 -0
  168. package/src/examples/home.page.ts +347 -0
  169. package/src/examples/index.ts +12 -0
  170. package/src/examples/inquiries.example.ts +273 -0
  171. package/src/examples/inquiry-detail.example.css +189 -0
  172. package/src/examples/inquiry-detail.example.ts +415 -0
  173. package/src/examples/mobile-tabs-example.component.ts +208 -0
  174. package/src/examples/post-create.page.ts +311 -0
  175. package/src/examples/post-detail.page.ts +296 -0
  176. package/src/examples/sign-in.page.ts +291 -0
  177. package/src/examples/whitelabel-demo-modal.component.ts +1094 -0
  178. package/src/examples/whitelabel-demo-modal.service.ts +77 -0
  179. package/src/models/index.ts +7 -0
  180. package/src/models/post.model.ts +41 -0
  181. package/src/pages/community.page.ts +769 -0
  182. package/src/pages/handbook.page.ts +388 -0
  183. package/src/pages/home.page.ts +303 -0
  184. package/src/pages/index.ts +11 -0
  185. package/src/pages/inquiries.example.ts +273 -0
  186. package/src/pages/inquiry-detail.example.css +189 -0
  187. package/src/pages/inquiry-detail.example.ts +415 -0
  188. package/src/pages/mobile-tabs-example.component.ts +179 -0
  189. package/src/pages/post-create.page.ts +311 -0
  190. package/src/pages/post-detail.page.ts +296 -0
  191. package/src/pages/sign-in.page.ts +291 -0
  192. package/src/pages/whitelabel-demo-modal.component.ts +1094 -0
  193. package/src/pages/whitelabel-demo-modal.service.ts +77 -0
  194. package/src/public-api.ts +6 -0
  195. package/src/services/base-modal.service.ts +101 -0
  196. package/src/services/index.ts +11 -0
  197. package/src/services/posts.service.ts +542 -0
  198. package/src/services/tracking-permission.service.ts +88 -0
  199. package/src/services/user.service.ts +60 -0
  200. package/src/services/whitelabel.service.ts +675 -0
  201. package/{styles → src/styles}/ionic.css +25 -0
  202. package/tsconfig.lib.json +17 -0
  203. package/tsconfig.lib.prod.json +9 -0
  204. package/tsconfig.spec.json +13 -0
  205. package/fesm2022/propbinder-mobile-design.mjs +0 -26136
  206. package/fesm2022/propbinder-mobile-design.mjs.map +0 -1
  207. package/index.d.ts +0 -8154
  208. /package/{assets → src/assets}/fonts/Brockmann-Bold.otf +0 -0
  209. /package/{assets → src/assets}/fonts/Brockmann-BoldItalic.otf +0 -0
  210. /package/{assets → src/assets}/fonts/Brockmann-Medium.otf +0 -0
  211. /package/{assets → src/assets}/fonts/Brockmann-MediumItalic.otf +0 -0
  212. /package/{assets → src/assets}/fonts/Brockmann-Regular.otf +0 -0
  213. /package/{assets → src/assets}/fonts/Brockmann-RegularItalic.otf +0 -0
  214. /package/{assets → src/assets}/fonts/Brockmann-SemiBold.otf +0 -0
  215. /package/{assets → src/assets}/fonts/Brockmann-SemiBoldItalic.otf +0 -0
  216. /package/{assets → src/assets}/fonts/Brockmann_desktop_license.pdf +0 -0
  217. /package/{assets → src/assets}/fonts/brockmann-medium-webfont.woff2 +0 -0
  218. /package/{assets → src/assets}/fonts/brockmann-regular-webfont.woff2 +0 -0
  219. /package/{assets → src/assets}/fonts/brockmann-semibold-webfont.woff2 +0 -0
  220. /package/{styles → src/components/shared}/mobile-common.css +0 -0
  221. /package/{styles → src/components/shared}/mobile-page-base.css +0 -0
@@ -0,0 +1,374 @@
1
+ import {
2
+ Component,
3
+ OnInit,
4
+ CUSTOM_ELEMENTS_SCHEMA
5
+ } from '@angular/core';
6
+ import { CommonModule } from '@angular/common';
7
+ import {
8
+ IonContent,
9
+ IonSpinner
10
+ } from '@ionic/angular/standalone';
11
+ import { Filesystem, Directory } from '@capacitor/filesystem';
12
+ import { Browser } from '@capacitor/browser';
13
+ import { Share } from '@capacitor/share';
14
+ import { DsAvatarComponent } from '@propbinder/design-system';
15
+ import { DsButtonComponent } from '@propbinder/design-system';
16
+ import { DsMobileLightboxHeaderComponent } from './ds-mobile-lightbox-header';
17
+ import { DsMobileLightboxFooterComponent } from './ds-mobile-lightbox-footer';
18
+ import type { LightboxPdf, LightboxAuthor } from './ds-mobile-lightbox.service';
19
+
20
+ /**
21
+ * DsMobileLightboxPdfComponent
22
+ *
23
+ * PDF viewer component that displays PDF info and allows users to open PDFs in the native device viewer.
24
+ * Shows a lightbox with PDF details first, then user can choose to open in native viewer.
25
+ *
26
+ * This component is typically not used directly - use DsMobileLightboxService instead.
27
+ *
28
+ * Features:
29
+ * - PDF info preview (title, size, icon)
30
+ * - User-initiated native PDF viewing (iOS/Android)
31
+ * - Download and cache support
32
+ * - Share functionality
33
+ * - Loading states
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * // Don't instantiate directly - use the service:
38
+ * constructor(private lightbox: DsMobileLightboxService) {}
39
+ *
40
+ * openPdf() {
41
+ * this.lightbox.openPdf({
42
+ * pdf: { type: 'pdf', src: 'document.pdf', title: 'My Document' }
43
+ * });
44
+ * }
45
+ * ```
46
+ */
47
+ @Component({
48
+ selector: 'ds-mobile-lightbox-pdf',
49
+ standalone: true,
50
+ imports: [
51
+ CommonModule,
52
+ IonContent,
53
+ IonSpinner,
54
+ DsAvatarComponent,
55
+ DsButtonComponent,
56
+ DsMobileLightboxHeaderComponent,
57
+ DsMobileLightboxFooterComponent
58
+ ],
59
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
60
+ template: `
61
+ <ion-content
62
+ [fullscreen]="true"
63
+ class="lightbox-content pdf-viewer">
64
+
65
+ <div class="lightbox-wrapper">
66
+ <!-- Header with author info and close button -->
67
+ <ds-mobile-lightbox-header
68
+ [author]="author"
69
+ (closeClick)="close()"
70
+ />
71
+
72
+ <!-- PDF Info & Actions -->
73
+ <div class="pdf-container">
74
+ @if (isLoading) {
75
+ <div class="loading-state">
76
+ <ion-spinner name="crescent"></ion-spinner>
77
+ <p>Loading PDF...</p>
78
+ </div>
79
+ } @else if (hasError) {
80
+ <div class="error-state">
81
+ <svg width="64" height="64" viewBox="0 0 24 24" fill="none">
82
+ <path d="M12 8V12M12 16H12.01M21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
83
+ </svg>
84
+ <h3>Failed to Load PDF</h3>
85
+ <p>{{ errorMessage }}</p>
86
+ <button class="retry-button" (click)="openPdfInNativeViewer()">
87
+ Try Again
88
+ </button>
89
+ </div>
90
+ } @else {
91
+ <div class="pdf-content">
92
+ <!-- PDF Icon -->
93
+ <ds-avatar
94
+ type="icon"
95
+ iconName="remixFileTextLine"
96
+ size="xl"
97
+ />
98
+
99
+ <!-- PDF Title (same as attachment fileName) -->
100
+ <h2 class="pdf-title">{{ getDisplayTitle() }}</h2>
101
+
102
+ <!-- PDF Metadata (same format as attachment: PDF · fileSize) -->
103
+ <div class="pdf-meta">
104
+ PDF · {{ pdf.fileSize ? formatFileSize(pdf.fileSize) : '' }}
105
+ </div>
106
+
107
+ <!-- Open Button -->
108
+ <ds-button
109
+ variant="secondary"
110
+ size="lg"
111
+ (clicked)="openPdfInNativeViewer()"
112
+ class="open-pdf-button">
113
+ Open Preview
114
+ </ds-button>
115
+ </div>
116
+ }
117
+ </div>
118
+
119
+ <!-- Bottom actions -->
120
+ <ds-mobile-lightbox-footer
121
+ [isLiked]="false"
122
+ [likeCount]="0"
123
+ [commentCount]="0"
124
+ (likeClick)="onLikeToggle()"
125
+ (commentClick)="onReply()"
126
+ (shareClick)="onShare()"
127
+ />
128
+ </div>
129
+ </ion-content>
130
+ `,
131
+ styleUrl: './ds-mobile-lightbox-pdf.css'
132
+ })
133
+ export class DsMobileLightboxPdfComponent implements OnInit {
134
+ // Inputs (passed from service as regular properties)
135
+ pdf!: LightboxPdf;
136
+ author?: LightboxAuthor;
137
+ onCloseRequested?: () => void;
138
+
139
+ // State
140
+ isLoading = false;
141
+ hasError = false;
142
+ errorMessage = '';
143
+ cachedFilePath?: string;
144
+
145
+ constructor() {}
146
+
147
+ ngOnInit(): void {
148
+ console.log('[PDF Lightbox] Initializing with PDF:', this.pdf);
149
+
150
+ // Don't automatically open - let user click the "Open" button
151
+ // this.openPdfInNativeViewer();
152
+ }
153
+
154
+ /**
155
+ * Open the PDF in the native device viewer
156
+ */
157
+ async openPdfInNativeViewer(): Promise<void> {
158
+ if (!this.pdf?.src) {
159
+ console.error('[PDF Lightbox] No PDF source provided');
160
+ this.hasError = true;
161
+ this.errorMessage = 'No PDF file provided';
162
+ return;
163
+ }
164
+
165
+ this.isLoading = true;
166
+ this.hasError = false;
167
+ this.errorMessage = '';
168
+
169
+ try {
170
+ console.log('[PDF Lightbox] Opening PDF:', this.pdf.src);
171
+
172
+ // Check if it's already a full URL
173
+ let pdfUrl: string;
174
+
175
+ if (this.pdf.src.startsWith('http://') || this.pdf.src.startsWith('https://')) {
176
+ // Already a full URL
177
+ pdfUrl = this.pdf.src;
178
+ } else {
179
+ // Relative path - construct full URL
180
+ // Use current origin (which includes the dev server URL in Capacitor)
181
+ // Remove leading slash if present to avoid double slashes
182
+ const cleanPath = this.pdf.src.startsWith('/') ? this.pdf.src.slice(1) : this.pdf.src;
183
+ pdfUrl = `${window.location.origin}/${cleanPath}`;
184
+ }
185
+
186
+ console.log('[PDF Lightbox] Opening PDF at URL:', pdfUrl);
187
+
188
+ // Use Browser to open the PDF
189
+ await Browser.open({
190
+ url: pdfUrl,
191
+ presentationStyle: 'fullscreen'
192
+ });
193
+
194
+ this.isLoading = false;
195
+
196
+ // Close the modal after opening browser
197
+ setTimeout(() => {
198
+ this.close();
199
+ }, 500);
200
+ } catch (error: any) {
201
+ console.error('[PDF Lightbox] Error opening PDF:', error);
202
+ this.isLoading = false;
203
+ this.hasError = true;
204
+ this.errorMessage = error?.message || 'Failed to open PDF';
205
+ }
206
+ }
207
+
208
+ /**
209
+ * Download a remote PDF and open it
210
+ */
211
+ private async downloadAndOpenPdf(): Promise<void> {
212
+ try {
213
+ console.log('[PDF Lightbox] Downloading PDF from:', this.pdf.src);
214
+
215
+ // Fetch the PDF
216
+ const response = await fetch(this.pdf.src);
217
+ if (!response.ok) {
218
+ throw new Error(`Failed to download PDF: ${response.statusText}`);
219
+ }
220
+
221
+ const blob = await response.blob();
222
+ const base64Data = await this.blobToBase64(blob);
223
+
224
+ // Generate a filename
225
+ const fileName = this.pdf.title
226
+ ? `${this.pdf.title.replace(/[^a-z0-9]/gi, '_')}.pdf`
227
+ : 'document.pdf';
228
+
229
+ // Save to cache directory
230
+ const result = await Filesystem.writeFile({
231
+ path: fileName,
232
+ data: base64Data,
233
+ directory: Directory.Cache
234
+ });
235
+
236
+ console.log('[PDF Lightbox] PDF saved to cache:', result.uri);
237
+ this.cachedFilePath = result.uri;
238
+
239
+ // Open using Browser
240
+ await Browser.open({
241
+ url: result.uri,
242
+ presentationStyle: 'fullscreen'
243
+ });
244
+
245
+ console.log('[PDF Lightbox] PDF opened successfully');
246
+ } catch (error) {
247
+ console.error('[PDF Lightbox] Error downloading/opening PDF:', error);
248
+ throw error;
249
+ }
250
+ }
251
+
252
+ /**
253
+ * Open a local PDF file
254
+ */
255
+ private async openLocalPdf(): Promise<void> {
256
+ try {
257
+ // Remove leading slash if present to avoid double slashes
258
+ const cleanPath = this.pdf.src.startsWith('/') ? this.pdf.src.slice(1) : this.pdf.src;
259
+ const fullUrl = window.location.origin + '/' + cleanPath;
260
+
261
+ await Browser.open({
262
+ url: fullUrl,
263
+ presentationStyle: 'fullscreen'
264
+ });
265
+
266
+ console.log('[PDF Lightbox] Local PDF opened successfully');
267
+ } catch (error) {
268
+ console.error('[PDF Lightbox] Error opening local PDF:', error);
269
+ throw error;
270
+ }
271
+ }
272
+
273
+ /**
274
+ * Convert Blob to base64 string
275
+ */
276
+ private blobToBase64(blob: Blob): Promise<string> {
277
+ return new Promise((resolve, reject) => {
278
+ const reader = new FileReader();
279
+ reader.onloadend = () => {
280
+ const base64String = reader.result as string;
281
+ // Remove the data URL prefix
282
+ const base64Data = base64String.split(',')[1];
283
+ resolve(base64Data);
284
+ };
285
+ reader.onerror = reject;
286
+ reader.readAsDataURL(blob);
287
+ });
288
+ }
289
+
290
+ /**
291
+ * Get display title with file extension
292
+ * If title is provided, ensure it has .pdf extension
293
+ * Otherwise, extract filename from src
294
+ */
295
+ getDisplayTitle(): string {
296
+ if (this.pdf.title) {
297
+ // If title doesn't end with .pdf, add it
298
+ return this.pdf.title.endsWith('.pdf') ? this.pdf.title : `${this.pdf.title}.pdf`;
299
+ }
300
+
301
+ // Extract filename from src
302
+ if (this.pdf.src) {
303
+ const filename = this.pdf.src.split('/').pop() || 'PDF Document.pdf';
304
+ return filename;
305
+ }
306
+
307
+ return 'PDF Document.pdf';
308
+ }
309
+
310
+ /**
311
+ * Format file size for display
312
+ */
313
+ formatFileSize(bytes: number): string {
314
+ if (bytes === 0) return '0 Bytes';
315
+
316
+ const k = 1024;
317
+ const sizes = ['Bytes', 'KB', 'MB', 'GB'];
318
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
319
+
320
+ return Math.round((bytes / Math.pow(k, i)) * 100) / 100 + ' ' + sizes[i];
321
+ }
322
+
323
+ /**
324
+ * Share the PDF
325
+ */
326
+ async onShare(): Promise<void> {
327
+ console.log('[PDF Lightbox] Share button clicked');
328
+
329
+ if (!this.pdf?.src) return;
330
+
331
+ try {
332
+ await Share.share({
333
+ title: this.pdf.title || 'PDF Document',
334
+ text: this.pdf.description || '',
335
+ url: this.pdf.src,
336
+ dialogTitle: 'Share PDF'
337
+ });
338
+
339
+ console.log('[PDF Lightbox] PDF shared successfully');
340
+ } catch (error) {
341
+ console.error('[PDF Lightbox] Error sharing PDF:', error);
342
+ }
343
+ }
344
+
345
+ /**
346
+ * Close the PDF viewer
347
+ */
348
+ close(): void {
349
+ if (this.onCloseRequested) {
350
+ this.onCloseRequested();
351
+ }
352
+ }
353
+
354
+ /**
355
+ * Handle like toggle
356
+ */
357
+ onLikeToggle(): void {
358
+ console.log('[PDF Lightbox] Like toggled');
359
+ // TODO: Implement like logic for PDFs if needed
360
+ }
361
+
362
+ /**
363
+ * Handle reply/comment
364
+ * Close the lightbox and signal to open post detail with comment focus
365
+ */
366
+ onReply(): void {
367
+ console.log('[PDF Lightbox] Reply button clicked');
368
+ if (this.onCloseRequested) {
369
+ this.onCloseRequested();
370
+ // The calling code should handle opening the post detail modal
371
+ }
372
+ }
373
+ }
374
+