From 3e4be5ed4d2c0395dd60e392baf86c59762059b1 Mon Sep 17 00:00:00 2001
From: Davin <591807572@qq.com>
Date: 星期五, 30 六月 2023 10:14:50 +0800
Subject: [PATCH] feature 猫眼全屏布局调整 && UI细节适配

---
 EZSDK/EZSDK/EZ/TempPassword/Controllers/HDLEZDeviceMsgListViewController.m |  104 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 102 insertions(+), 2 deletions(-)

diff --git a/EZSDK/EZSDK/EZ/TempPassword/Controllers/HDLEZDeviceMsgListViewController.m b/EZSDK/EZSDK/EZ/TempPassword/Controllers/HDLEZDeviceMsgListViewController.m
index 0c1ca3e..baac279 100644
--- a/EZSDK/EZSDK/EZ/TempPassword/Controllers/HDLEZDeviceMsgListViewController.m
+++ b/EZSDK/EZSDK/EZ/TempPassword/Controllers/HDLEZDeviceMsgListViewController.m
@@ -10,7 +10,10 @@
 #import "MJRefreshNormalHeader.h"
 #import "MJRefreshAutoNormalFooter.h"
 #import "HDLEZDevMsgListModel.h"
-@interface HDLEZDeviceMsgListViewController ()
+#import "MWPhotoBrowser.h"
+#import "SDWebImageManager.h"
+#import <Photos/Photos.h>
+@interface HDLEZDeviceMsgListViewController ()<MWPhotoBrowserDelegate>
 @property (nonatomic, strong) HDLEZDeviceMsgListView *msgListV;//娑堟伅鍒楄〃view
 
 @property (nonatomic, strong) MJRefreshNormalHeader *header;//鍒锋柊header
@@ -25,6 +28,9 @@
 
 @property (nonatomic, assign) NSInteger pageSize;//鍒嗛〉瀹归噺
 
+@property (nonatomic, strong) NSMutableArray <MWPhoto *>*photos;    // 棰勮鍥剧墖淇℃伅
+@property (nonatomic, strong) NSString *currentPreviewPhoto;        // 褰撳墠棰勮鐨勫浘鐗�
+    
 @end
 
 @implementation HDLEZDeviceMsgListViewController
@@ -45,7 +51,10 @@
         make.top.equalTo(self.view).offset(HDLEZ_APP_TOP_BAR_HEIGHT);
         make.left.bottom.right.equalTo(self.view);
     }];
-//    _msgListV.choseDelegate=self;
+    __weak __typeof(self)weakSelf = self;
+    [_msgListV previewPicture:^(NSString * _Nonnull pictureUrl) {
+        [weakSelf previewPictureWithUrl:pictureUrl];
+    }];
     
     //涓嬫媺鍒锋柊
     // 璁剧疆鍥炶皟锛堜竴鏃﹁繘鍏ュ埛鏂扮姸鎬侊紝灏辫皟鐢╰arget鐨刟ction锛屼篃灏辨槸璋冪敤self鐨刲oadNewData鏂规硶锛�
@@ -106,6 +115,31 @@
                 weakSelf.msgListV.msgList=weakSelf.msgList;
                 weakSelf.currentPageNo+=1;
             }else{
+#warning mock
+            if (weakSelf.msgList.count == 0) {
+                HDLEZDeviceMsgInfoModel *model = [[HDLEZDeviceMsgInfoModel alloc] init];
+                model.title = @"mock title 浣犲ソ浣犲ソ鎴戞槸瓒呴暱鐨勬祴璇曟爣棰橈紝浣犳潵鐪嬩笅鏄惁瓒呭嚭闀垮害锛屼綘濂戒綘濂芥垜鏄秴闀跨殑娴嬭瘯鏍囬锛屼綘鏉ョ湅涓嬫槸鍚﹁秴鍑洪暱搴�";
+                model.createTime = @"2023.06.15";
+                model.content = @"mock content";
+                model.imageUrl = @"https://upload-images.jianshu.io/upload_images/5809200-a99419bb94924e6d.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240";
+                [weakSelf.msgList addObject:model];
+                
+                HDLEZDeviceMsgInfoModel *model1 = [[HDLEZDeviceMsgInfoModel alloc] init];
+                model1.title = @"mock title1锛屼綘濂戒綘濂�";
+                model1.createTime = @"2023.06.15";
+                model1.content = @"mock content1";
+                model1.imageUrl = @"http://b.hiphotos.baidu.com/image/pic/item/e824b899a9014c08878b2c4c0e7b02087af4f4a3.jpg";
+                [weakSelf.msgList addObject:model1];
+            
+                HDLEZDeviceMsgInfoModel *model2 = [[HDLEZDeviceMsgInfoModel alloc] init];
+                model2.title = @"mock title2";
+                model2.createTime = @"2023.06.15";
+                model2.content = @"mock content2";
+                model2.imageUrl = @"https://fastly.picsum.photos/id/452/1000/3000.jpg?hmac=g6GQYs1wmiPeoKOdwI3ot1y4MInIj_dnPk_jCYbVYfk";
+                [weakSelf.msgList addObject:model2];
+                
+            }
+                weakSelf.msgListV.msgList=weakSelf.msgList;
                 [weakSelf.footer endRefreshingWithNoMoreData];
             }
             
@@ -117,5 +151,71 @@
     }];
 }
 
+#pragma mark MWPhotoBrowserDelegate
+- (NSUInteger)numberOfPhotosInPhotoBrowser:(MWPhotoBrowser *)photoBrowser {
+    return self.photos.count;
+}
+
+- (id <MWPhoto>)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index {
+    if (index < self.photos.count) {
+        return [self.photos objectAtIndex:index];
+    }
+    return nil;
+}
+
+- (void)didClickCurrentPhotoBrowserBlank:(MWPhotoBrowser *)photoBrowser {
+    [self.navigationController popToViewController:self animated:NO];
+}
+
+- (void)didClickDownLoad:(MWPhotoBrowser *)photoBrowser {
+    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+        if (!self.currentPreviewPhoto || self.currentPreviewPhoto.length == 0) {
+            [UIView dd_showMessage:NSLocalizedString(@"device_save_gallery_failure", @"涓嬭浇澶辫触")];
+            return;
+        }
+        NSURL *url = [NSURL URLWithString:self.currentPreviewPhoto];
+        SDWebImageManager *manager = [SDWebImageManager sharedManager];
+        UIImage *img;
+        if ([manager diskImageExistsForURL:url]) {
+            img =  [[manager imageCache] imageFromDiskCacheForKey:url.absoluteString];
+        } else {
+            //浠庣綉缁滀笅杞藉浘鐗�
+            NSData *data = [NSData dataWithContentsOfURL:url];
+            img = [UIImage imageWithData:data];
+        }
+        // 淇濆瓨鍥剧墖鍒扮浉鍐屼腑
+        dispatch_async(dispatch_get_main_queue(), ^{
+            UIImageWriteToSavedPhotosAlbum(img,self, @selector(image:didFinishSavingWithError
+                                                               :contextInfo:),nil);
+        });
+    });
+}
+
+//淇濆瓨鍥剧墖瀹屾垚涔嬪悗鐨勫洖璋�
+- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error
+  contextInfo:(void *)contextInfo {
+    // Was there an error?
+    NSString *message = nil;
+    if (!error) {
+        message = NSLocalizedString(@"device_save_gallery", @"宸蹭繚瀛樿嚦鎵嬫満鐩稿唽");
+    }
+    else
+    {
+        message = [error description];
+    }
+    [UIView dd_showMessage:message];
+}
+
+#pragma mark PrivateMethod
+- (void)previewPictureWithUrl:(NSString *)picUrl {
+    self.currentPreviewPhoto = picUrl;
+    self.photos = [NSMutableArray array];
+    [self.photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:picUrl]]];
+    MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];
+    [browser showDownloadBtn];
+
+    [self.navigationController pushViewController:browser animated:NO];
+}
+
 
 @end

--
Gitblit v1.8.0