HyM attachments resolve: #2 #3
					 1 changed files with 16 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -1,3 +1,5 @@
 | 
			
		|||
import "dart:typed_data";
 | 
			
		||||
 | 
			
		||||
import "package:crab_ui/structs.dart";
 | 
			
		||||
import "package:flutter/material.dart";
 | 
			
		||||
import 'package:pdfrx/pdfrx.dart';
 | 
			
		||||
| 
						 | 
				
			
			@ -14,7 +16,16 @@ class AttachmentWidget extends StatelessWidget {
 | 
			
		|||
    if (extension == "jpg") {
 | 
			
		||||
      return Image.memory(att.data);
 | 
			
		||||
    } else if (extension == "pdf") {
 | 
			
		||||
      return PdfViewer.data(att.data, sourceName: att.name);
 | 
			
		||||
      PdfViewer pdf = PdfViewer.data(
 | 
			
		||||
        Uint8List.fromList(att.data),
 | 
			
		||||
        sourceName: att.name,
 | 
			
		||||
        params: const PdfViewerParams(
 | 
			
		||||
          enableTextSelection: true,
 | 
			
		||||
          scrollByMouseWheel: 0.5,
 | 
			
		||||
        )
 | 
			
		||||
      );
 | 
			
		||||
      
 | 
			
		||||
      return pdf;
 | 
			
		||||
    }
 | 
			
		||||
    return Text(
 | 
			
		||||
      "Attachment not supported for preview, you'll need to download",
 | 
			
		||||
| 
						 | 
				
			
			@ -39,19 +50,17 @@ class AttachmentWidget extends StatelessWidget {
 | 
			
		|||
                      CloseButton(onPressed: () => {Navigator.pop(context)}),
 | 
			
		||||
                      Text(
 | 
			
		||||
                        attachment.name
 | 
			
		||||
                            .toString(), //its alr a string but incase ¯\(ツ)/¯
 | 
			
		||||
                            .toString(), //its alr a string but incase ¯\(ツ)/¯ //update: i did that everywhere lol
 | 
			
		||||
                        style: TextStyle(
 | 
			
		||||
                            color: Colors.black,
 | 
			
		||||
                            fontSize: 20,
 | 
			
		||||
                            decoration:
 | 
			
		||||
                                TextDecoration.none), //TODO: personalize your fonts
 | 
			
		||||
                            decoration: TextDecoration
 | 
			
		||||
                                .none), //TODO: personalize your fonts
 | 
			
		||||
                      ),
 | 
			
		||||
                    ],
 | 
			
		||||
                  ),
 | 
			
		||||
                
 | 
			
		||||
                  Expanded(
 | 
			
		||||
 | 
			
		||||
                        child: attachmentViewer(attachment),
 | 
			
		||||
                    child: attachmentViewer(attachment),
 | 
			
		||||
                  )
 | 
			
		||||
                ],
 | 
			
		||||
              ),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue