diff --git a/ios/Classes/MopPlugin.m b/ios/Classes/MopPlugin.m index ef9e9a9..a683d65 100644 --- a/ios/Classes/MopPlugin.m +++ b/ios/Classes/MopPlugin.m @@ -95,7 +95,7 @@ static MopPlugin *_instance; } else if ([@"showShareAppletDialog" isEqualToString:call.method]) { dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - UIImage *image = [MOPTools imageWithScreenshot]; + UIImage *image = [[FATClient sharedClient] getDefaultCurrentAppletImage:400.0f]; MopShareView *view = [MopShareView viewWithData:call.arguments]; view.image = image; [view show]; @@ -127,8 +127,7 @@ static MopPlugin *_instance; [currentVC.view fatHideToastActivity]; [currentVC.view fatHideAllToasts]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - UIImage *image = [MOPTools imageWithScreenshot]; -// UIImage *image = [[FATClient sharedClient] getCurrentAppletImage]; + UIImage *image = [[FATClient sharedClient] getDefaultCurrentAppletImage:0.0f]; NSString *filePtah = [[FATClient sharedClient] saveFile:UIImagePNGRepresentation(image) fileName:[NSString stringWithFormat:@"%@",call.arguments[@"appId"]]]; filePtah = [[FATClient sharedClient] fat_absolutePathWithPath:filePtah]; result(filePtah); diff --git a/ios/Classes/Utils/MOPTools.h b/ios/Classes/Utils/MOPTools.h index f516da9..64c315a 100644 --- a/ios/Classes/Utils/MOPTools.h +++ b/ios/Classes/Utils/MOPTools.h @@ -24,21 +24,16 @@ NS_ASSUME_NONNULL_BEGIN /// @param darkHexString (暗黑模式 的颜色值) + (UIColor *)fat_dynamicColorWithLightHexString:(NSString *)lightHexString darkHexString:(NSString *)darkHexString; - -/// 获取当前页面的截图 -+ (UIImage *)currentPageAppletImage; - - /// 生成image对象 /// @param view 指定的view + (UIImage *)snapshotWithView:(UIView *)view; - /// 根据链接生成二维码图片 /// @param string 二维码的内容 + (UIImage *)makeQRCodeForString:(NSString *)string; -+ (UIImage *)imageWithScreenshot; + + @end NS_ASSUME_NONNULL_END diff --git a/ios/Classes/Utils/MOPTools.m b/ios/Classes/Utils/MOPTools.m index 9f507ed..5283bc8 100644 --- a/ios/Classes/Utils/MOPTools.m +++ b/ios/Classes/Utils/MOPTools.m @@ -194,54 +194,6 @@ } -// 截取当前屏幕 ,返回截取到的图片 -+ (UIImage *)imageWithScreenshot { - - - CGSize imageSize = CGSizeZero; - - - - - UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation; - if (UIInterfaceOrientationIsPortrait(orientation)) { -// imageSize = [UIScreen mainScreen].bounds.size; - imageSize = CGSizeMake([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height - [self getStatusHeight]); - } else { - imageSize = CGSizeMake([UIScreen mainScreen].bounds.size.height, [UIScreen mainScreen].bounds.size.width); - } - // 绘制上下文 - UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0); - CGContextRef context = UIGraphicsGetCurrentContext(); - for (UIWindow *window in [[UIApplication sharedApplication] windows]) { - CGContextSaveGState(context); - CGContextTranslateCTM(context, window.center.x, window.center.y - [self getStatusHeight]); - CGContextConcatCTM(context, window.transform); - CGContextTranslateCTM(context, -window.bounds.size.width * window.layer.anchorPoint.x, -(window.bounds.size.height + [self getStatusHeight] ) * window.layer.anchorPoint.y); - if (orientation == UIInterfaceOrientationLandscapeLeft) { - CGContextRotateCTM(context, M_PI_2); - CGContextTranslateCTM(context, 0, -imageSize.width); - } else if (orientation == UIInterfaceOrientationLandscapeRight) { - CGContextRotateCTM(context, -M_PI_2); - CGContextTranslateCTM(context, -imageSize.height, 0); - } else if (orientation == UIInterfaceOrientationPortraitUpsideDown) { - CGContextRotateCTM(context, M_PI); - CGContextTranslateCTM(context, -imageSize.width, -imageSize.height); - } - if ([window respondsToSelector:@selector(drawViewHierarchyInRect:afterScreenUpdates:)]) { - [window drawViewHierarchyInRect:CGRectMake(0, [self getStatusHeight], window.bounds.size.width, window.bounds.size.height - [self getStatusHeight]) afterScreenUpdates:YES]; - } else { - [window.layer renderInContext:context]; - } - CGContextRestoreGState(context); - } - UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); - NSData *imageData = UIImagePNGRepresentation(image); - return [UIImage imageWithData:imageData]; -} - - /// 顶部状态栏高度(包括安全区) + (CGFloat)getStatusHeight { if (@available(iOS 13.0, *)) { @@ -253,4 +205,6 @@ return [UIApplication sharedApplication].statusBarFrame.size.height; } } + + @end diff --git a/ios/Classes/Utils/MopShareView.h b/ios/Classes/Utils/MopShareView.h index 5fc7df7..0df5bdc 100644 --- a/ios/Classes/Utils/MopShareView.h +++ b/ios/Classes/Utils/MopShareView.h @@ -12,18 +12,26 @@ NS_ASSUME_NONNULL_BEGIN typedef void (^MOPshareBottomViewTypeBlock)(NSString *type); @interface MopShareView : UIView -@property(nonatomic, copy) MOPshareBottomViewTypeBlock didSelcetTypeBlock; +@property (nonatomic, copy) MOPshareBottomViewTypeBlock didSelcetTypeBlock; @property (nonatomic, strong) UIImage *image; -@property(nonatomic, strong) NSDictionary *dataDic; +@property (nonatomic, strong) NSDictionary *dataDic; + (instancetype)viewWithData:(NSDictionary *)data; - (void)show; - (void)dismiss; @end + +@class MOPshareBottomViewCell; + +@protocol MOPCellClickDelegate +- (void)iconBtnDidClick:(MOPshareBottomViewCell *)cell; +@end + @interface MOPshareBottomViewCell : UICollectionViewCell -@property(nonatomic, assign) NSInteger type; -@property(nonatomic, strong) UIImageView *imageView; -@property(nonatomic, strong) UILabel *label; +@property (nonatomic, strong) NSString *type; +@property (nonatomic, strong) UIButton *imageButton; +@property (nonatomic, strong) UILabel *label; +@property (nonatomic, weak) id delegate; @end diff --git a/ios/Classes/Utils/MopShareView.m b/ios/Classes/Utils/MopShareView.m index b89e5f2..857be23 100644 --- a/ios/Classes/Utils/MopShareView.m +++ b/ios/Classes/Utils/MopShareView.m @@ -29,7 +29,7 @@ returnInsets = inset;\ (returnInsets);\ })\ -@interface MopShareView () +@interface MopShareView () @property (nonatomic, strong) UIView *shareView; @@ -56,34 +56,30 @@ returnInsets = inset;\ @{@"lightImage":@"share_link",@"title":@"复制链接", @"type":@"links"}]; self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.4f]; - float proportionWithNumber = self.frame.size.width / 375; - float proportionheightNumber = self.frame.size.height / 667; - - self.shareView = [[UIView alloc] initWithFrame:CGRectMake(52.5 * proportionWithNumber, 46 * proportionheightNumber + kFinoSafeAreaTop, 270 * proportionWithNumber, 380 * proportionheightNumber)]; + self.shareView = [[UIView alloc] initWithFrame:CGRectMake(52.5 , 46 + kFinoSafeAreaTop, 270, 380)]; self.shareView.layer.cornerRadius = 6; self.shareView.backgroundColor = UIColor.whiteColor; - UIImageView *appletImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 6, self.shareView.frame.size.width, 300 * proportionheightNumber)]; - self.appletImageView = appletImageView; + UIImageView *appletImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.shareView.frame.size.width, 300)]; appletImageView.contentMode = UIViewContentModeScaleAspectFit; + self.appletImageView = appletImageView; [self.shareView addSubview:appletImageView]; - - UIButton *saveButton = [[UIButton alloc] initWithFrame:CGRectMake(226 * proportionWithNumber, 12 * proportionheightNumber, 36, 36)]; - [saveButton addTarget:self action:@selector(saveOnClick) forControlEvents:UIControlEventTouchUpInside]; - [saveButton setImage:[UIImage imageNamed:@"share_download"] forState:UIControlStateNormal]; - [self.shareView addSubview:saveButton]; - + float bottomY = appletImageView.frame.size.height + appletImageView.frame.origin.y; + UIView *line0 = [[UIView alloc] initWithFrame:CGRectMake(0, bottomY, self.shareView.frame.size.width, 0.5)]; + line0.backgroundColor = [MOPTools fat_dynamicColorWithLightHexString:@"#E0E0E0" darkHexString:@"#2E2E2E"]; + [self.shareView addSubview:line0]; + UILabel *descLabel = [[UILabel alloc] init]; - descLabel.frame = CGRectMake(15, bottomY + 12, 168, 21); + descLabel.frame = CGRectMake(14, bottomY + 12, 168, 21); descLabel.font = [UIFont fontWithName:@"PingFangSC-Semibold" size:15]; descLabel.textColor = [MOPTools fat_dynamicColorWithLightHexString:@"#222222" darkHexString:@"#222222"]; self.titleLabel = descLabel; [self.shareView addSubview:descLabel]; UILabel *detailLabel = [[UILabel alloc] init]; - detailLabel.frame = CGRectMake(15, bottomY + 26, 168, 44); + detailLabel.frame = CGRectMake(14, self.titleLabel.frame.size.height + self.titleLabel.frame.origin.y + 5, 168, 44); detailLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:11]; detailLabel.numberOfLines = 0; detailLabel.textColor = [MOPTools fat_dynamicColorWithLightHexString:@"#666666" darkHexString:@"#666666"]; @@ -96,7 +92,7 @@ returnInsets = inset;\ [self addSubview:self.shareView]; - self.contentView = [[UIView alloc] initWithFrame:CGRectMake(0, self.shareView.frame.origin.y + self.shareView.frame.size.height + 28 , self.frame.size.width, (221 + kFinoSafeAreaBottom))]; + self.contentView = [[UIView alloc] initWithFrame:CGRectMake(0,self.frame.size.height - (221 + kFinoSafeAreaBottom) , self.frame.size.width, (221 + kFinoSafeAreaBottom))]; self.contentView.backgroundColor = [MOPTools fat_dynamicColorWithLightHexString:@"#F0F0F0" darkHexString:@"#1A1A1A"]; [self addSubview:self.contentView]; @@ -119,7 +115,7 @@ returnInsets = inset;\ [self.contentView addSubview:self.cancelButton]; self.cancelButton.frame = CGRectMake(0, self.contentView.frame.size.height - kFinoSafeAreaBottom - 56, self.contentView.frame.size.width, 56 ); [self.cancelButton addTarget:self action:@selector(dismiss) forControlEvents:UIControlEventTouchUpInside]; - + [self.contentView addSubview:self.collectionView]; self.collectionView.frame = CGRectMake(0, 58.5, frame.size.width, 107); @@ -131,7 +127,13 @@ returnInsets = inset;\ maskLayer.frame = self.contentView.bounds; maskLayer.path = maskPath.CGPath; self.contentView.layer.mask = maskLayer; - + + self.shareView.frame = CGRectMake(52.5, self.contentView.frame.origin.y - 400 , 270 , 380); + + UIButton *saveButton = [[UIButton alloc] initWithFrame:CGRectMake(278.5, self.shareView.frame.origin.y + 12, 36, 36)]; + [saveButton addTarget:self action:@selector(saveOnClick) forControlEvents:UIControlEventTouchUpInside]; + [saveButton setImage:[UIImage imageNamed:@"share_download"] forState:UIControlStateNormal]; + [self addSubview:saveButton]; [self p_addNotifications]; } return self; @@ -209,12 +211,21 @@ returnInsets = inset;\ static NSString *cellID = @"cellid"; - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { MOPshareBottomViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath]; -// cell.type = [self.dataArray[indexPath.row] intValue]; - cell.imageView.image = [UIImage imageNamed:self.dataArray[indexPath.row][@"lightImage"]]; + [cell.imageButton setImage:[UIImage imageNamed:self.dataArray[indexPath.row][@"lightImage"]] forState:UIControlStateNormal]; cell.label.text = self.dataArray[indexPath.row][@"title"]; + cell.type = self.dataArray[indexPath.row][@"type"]; + cell.delegate = self; return cell; } +- (void)iconBtnDidClick:(MOPshareBottomViewCell *)cell { + if (self.didSelcetTypeBlock) { + NSString *typeString = cell.type; + self.didSelcetTypeBlock(typeString); + } + [self dismiss]; +} + - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { if (self.didSelcetTypeBlock) { NSString *typeString = self.dataArray[indexPath.row][@"type"]; @@ -268,14 +279,15 @@ static NSString *cellID = @"cellid"; if (self) { self.backgroundColor = [MOPTools fat_dynamicColorWithLightHexString:@"#F0F0F0" darkHexString:@"#1A1A1A"]; - UIView *imageBgView = [[UIView alloc] initWithFrame:CGRectMake(18, 20, 48, 48)]; - imageBgView.backgroundColor = [MOPTools fat_dynamicColorWithLightHexString:@"#FFFFFF " darkHexString:@"#2C2C2C"]; - [self.contentView addSubview:imageBgView]; - - self.imageView = [UIImageView new]; - self.imageView.frame = CGRectMake(9, 9, 30, 30); - [imageBgView addSubview:self.imageView]; - + UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(18, 20, 48, 48)]; + button.backgroundColor = [MOPTools fat_dynamicColorWithLightHexString:@"#FFFFFF " darkHexString:@"#2C2C2C"]; + [self.contentView addSubview:button]; + button.layer.masksToBounds = YES; + button.layer.cornerRadius = 6; + UIImage *highBgImage = [UIImage fat_imageWithColor:[MOPTools fat_dynamicColorWithLightHexString:@"#D7D7D7 " darkHexString:@"#4A4A4A"]]; + [button setBackgroundImage:highBgImage forState:UIControlStateHighlighted]; + [button addTarget:self action:@selector(iconBtnClick:) forControlEvents:UIControlEventTouchUpInside]; + self.imageButton = button; // self.label = [[UILabel alloc] initWithFrame:CGRectMake((frame.size.width-50)/2, 65, frame.size.width, 30)]; self.label = [[UILabel alloc] initWithFrame:CGRectMake(18, 75, 48, 12)]; self.label.font = [UIFont systemFontOfSize:10]; @@ -287,5 +299,11 @@ static NSString *cellID = @"cellid"; return self; } +- (void)iconBtnClick:(UIButton *)btn { + if (self.delegate && [self.delegate respondsToSelector:@selector(iconBtnDidClick:)]) { + [self.delegate iconBtnDidClick:self]; + } +} + @end diff --git a/ios/mop.podspec b/ios/mop.podspec index b6bbd2a..20f2956 100644 --- a/ios/mop.podspec +++ b/ios/mop.podspec @@ -17,7 +17,7 @@ A finclip miniprogram flutter sdk. s.dependency 'Flutter' s.ios.deployment_target = '9.0' - s.dependency 'FinApplet' , '2.39.2-alpha20230103v04' - s.dependency 'FinAppletExt' , '2.39.2-alpha20230103v04' + s.dependency 'FinApplet' , '2.39.2-alpha20230105v08' + s.dependency 'FinAppletExt' , '2.39.2-alpha20230105v08' end