From 838ee4d55d740b599493e5fd8079bb0ce1e8e367 Mon Sep 17 00:00:00 2001
From: LittleSheep <littlesheep.code@hotmail.com>
Date: Mon, 3 Feb 2025 22:56:49 +0800
Subject: [PATCH] :sparkles: Click to zoom in sticker

---
 api/Paperclip/Stickers/Create Sticker.bru    |  8 ++---
 api/Paperclip/Stickers/Get Sticker Packs.bru | 11 +++++++
 api/Paperclip/Stickers/Get Stickers.bru      | 15 ++++++++++
 lib/widgets/markdown_content.dart            | 31 ++++++++++++++------
 4 files changed, 52 insertions(+), 13 deletions(-)
 create mode 100644 api/Paperclip/Stickers/Get Sticker Packs.bru
 create mode 100644 api/Paperclip/Stickers/Get Stickers.bru

diff --git a/api/Paperclip/Stickers/Create Sticker.bru b/api/Paperclip/Stickers/Create Sticker.bru
index 61a9079..a5c4591 100644
--- a/api/Paperclip/Stickers/Create Sticker.bru	
+++ b/api/Paperclip/Stickers/Create Sticker.bru	
@@ -12,9 +12,9 @@ post {
 
 body:json {
   {
-    "alias": "AteChip",
-    "name": "Cat ate chips",
-    "attachment_id": "d0b692cc64054463",
-    "pack_id": 2
+    "alias": "Meltdown",
+    "name": "Meltdown",
+    "attachment_id": "IpDPHEbWDDCbBofX",
+    "pack_id": 4
   }
 }
diff --git a/api/Paperclip/Stickers/Get Sticker Packs.bru b/api/Paperclip/Stickers/Get Sticker Packs.bru
new file mode 100644
index 0000000..54ce538
--- /dev/null
+++ b/api/Paperclip/Stickers/Get Sticker Packs.bru	
@@ -0,0 +1,11 @@
+meta {
+  name: Get Sticker Packs
+  type: http
+  seq: 3
+}
+
+get {
+  url: {{endpoint}}/cgi/uc/stickers/packs
+  body: none
+  auth: none
+}
diff --git a/api/Paperclip/Stickers/Get Stickers.bru b/api/Paperclip/Stickers/Get Stickers.bru
new file mode 100644
index 0000000..0473f8a
--- /dev/null
+++ b/api/Paperclip/Stickers/Get Stickers.bru	
@@ -0,0 +1,15 @@
+meta {
+  name: Get Stickers
+  type: http
+  seq: 4
+}
+
+get {
+  url: {{endpoint}}/cgi/uc/stickers?take=10
+  body: none
+  auth: none
+}
+
+params:query {
+  take: 10
+}
diff --git a/lib/widgets/markdown_content.dart b/lib/widgets/markdown_content.dart
index 8c614fb..8b2d067 100644
--- a/lib/widgets/markdown_content.dart
+++ b/lib/widgets/markdown_content.dart
@@ -129,14 +129,27 @@ class MarkdownTextContent extends StatelessWidget {
                     future: st.lookupSticker(alias),
                     builder: (context, snapshot) {
                       if (snapshot.hasData) {
-                        return UniversalImage(
-                          sn.getAttachmentUrl(snapshot.data!.attachment.rid),
-                          fit: BoxFit.cover,
-                          width: size,
-                          height: size,
-                          cacheHeight: size,
-                          cacheWidth: size,
-                        );
+                        return GestureDetector(
+                            child: UniversalImage(
+                              sn.getAttachmentUrl(snapshot.data!.attachment.rid),
+                              fit: BoxFit.cover,
+                              width: size,
+                              height: size,
+                              cacheHeight: size,
+                              cacheWidth: size,
+                            ),
+                            onTap: () {
+                              if (snapshot.data == null) return;
+                              context.pushTransparentRoute(
+                                AttachmentZoomView(
+                                  data: [snapshot.data!.attachment],
+                                  initialIndex: 0,
+                                  heroTags: [const Uuid().v4()],
+                                ),
+                                backgroundColor: Colors.black.withOpacity(0.7),
+                                rootNavigator: true,
+                              );
+                            });
                       }
                       return const SizedBox.shrink();
                     },
@@ -145,7 +158,7 @@ class MarkdownTextContent extends StatelessWidget {
               );
             case 'attachments':
               final attachment = attachments?.firstWhere(
-                    (ele) => ele?.rid == segments[1],
+                (ele) => ele?.rid == segments[1],
                 orElse: () => null,
               );
               if (attachment != null) {