master
wangzhaoyao 2023-01-05 18:47:26 +08:00
parent e25f744df4
commit 64bd5f8496
6 changed files with 67 additions and 93 deletions

View File

@ -95,7 +95,7 @@ static MopPlugin *_instance;
} }
else if ([@"showShareAppletDialog" isEqualToString:call.method]) { else if ([@"showShareAppletDialog" isEqualToString:call.method]) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 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]; MopShareView *view = [MopShareView viewWithData:call.arguments];
view.image = image; view.image = image;
[view show]; [view show];
@ -127,8 +127,7 @@ static MopPlugin *_instance;
[currentVC.view fatHideToastActivity]; [currentVC.view fatHideToastActivity];
[currentVC.view fatHideAllToasts]; [currentVC.view fatHideAllToasts];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 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:0.0f];
// UIImage *image = [[FATClient sharedClient] getCurrentAppletImage];
NSString *filePtah = [[FATClient sharedClient] saveFile:UIImagePNGRepresentation(image) fileName:[NSString stringWithFormat:@"%@",call.arguments[@"appId"]]]; NSString *filePtah = [[FATClient sharedClient] saveFile:UIImagePNGRepresentation(image) fileName:[NSString stringWithFormat:@"%@",call.arguments[@"appId"]]];
filePtah = [[FATClient sharedClient] fat_absolutePathWithPath:filePtah]; filePtah = [[FATClient sharedClient] fat_absolutePathWithPath:filePtah];
result(filePtah); result(filePtah);

View File

@ -24,21 +24,16 @@ NS_ASSUME_NONNULL_BEGIN
/// @param darkHexString ( ) /// @param darkHexString ( )
+ (UIColor *)fat_dynamicColorWithLightHexString:(NSString *)lightHexString darkHexString:(NSString *)darkHexString; + (UIColor *)fat_dynamicColorWithLightHexString:(NSString *)lightHexString darkHexString:(NSString *)darkHexString;
///
+ (UIImage *)currentPageAppletImage;
/// image /// image
/// @param view view /// @param view view
+ (UIImage *)snapshotWithView:(UIView *)view; + (UIImage *)snapshotWithView:(UIView *)view;
/// ///
/// @param string /// @param string
+ (UIImage *)makeQRCodeForString:(NSString *)string; + (UIImage *)makeQRCodeForString:(NSString *)string;
+ (UIImage *)imageWithScreenshot;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

View File

@ -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 { + (CGFloat)getStatusHeight {
if (@available(iOS 13.0, *)) { if (@available(iOS 13.0, *)) {
@ -253,4 +205,6 @@
return [UIApplication sharedApplication].statusBarFrame.size.height; return [UIApplication sharedApplication].statusBarFrame.size.height;
} }
} }
@end @end

View File

@ -12,18 +12,26 @@ NS_ASSUME_NONNULL_BEGIN
typedef void (^MOPshareBottomViewTypeBlock)(NSString *type); typedef void (^MOPshareBottomViewTypeBlock)(NSString *type);
@interface MopShareView : UIView @interface MopShareView : UIView
@property(nonatomic, copy) MOPshareBottomViewTypeBlock didSelcetTypeBlock; @property (nonatomic, copy) MOPshareBottomViewTypeBlock didSelcetTypeBlock;
@property (nonatomic, strong) UIImage *image; @property (nonatomic, strong) UIImage *image;
@property(nonatomic, strong) NSDictionary *dataDic; @property (nonatomic, strong) NSDictionary *dataDic;
+ (instancetype)viewWithData:(NSDictionary *)data; + (instancetype)viewWithData:(NSDictionary *)data;
- (void)show; - (void)show;
- (void)dismiss; - (void)dismiss;
@end @end
@class MOPshareBottomViewCell;
@protocol MOPCellClickDelegate <NSObject>
- (void)iconBtnDidClick:(MOPshareBottomViewCell *)cell;
@end
@interface MOPshareBottomViewCell : UICollectionViewCell @interface MOPshareBottomViewCell : UICollectionViewCell
@property(nonatomic, assign) NSInteger type; @property (nonatomic, strong) NSString *type;
@property(nonatomic, strong) UIImageView *imageView; @property (nonatomic, strong) UIButton *imageButton;
@property(nonatomic, strong) UILabel *label; @property (nonatomic, strong) UILabel *label;
@property (nonatomic, weak) id<MOPCellClickDelegate> delegate;
@end @end

View File

@ -29,7 +29,7 @@ returnInsets = inset;\
(returnInsets);\ (returnInsets);\
})\ })\
@interface MopShareView ()<UICollectionViewDelegate, UICollectionViewDataSource> @interface MopShareView ()<UICollectionViewDelegate, UICollectionViewDataSource, MOPCellClickDelegate>
@property (nonatomic, strong) UIView *shareView; @property (nonatomic, strong) UIView *shareView;
@ -56,34 +56,30 @@ returnInsets = inset;\
@{@"lightImage":@"share_link",@"title":@"复制链接", @"type":@"links"}]; @{@"lightImage":@"share_link",@"title":@"复制链接", @"type":@"links"}];
self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.4f]; self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.4f];
float proportionWithNumber = self.frame.size.width / 375; self.shareView = [[UIView alloc] initWithFrame:CGRectMake(52.5 , 46 + kFinoSafeAreaTop, 270, 380)];
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.layer.cornerRadius = 6; self.shareView.layer.cornerRadius = 6;
self.shareView.backgroundColor = UIColor.whiteColor; self.shareView.backgroundColor = UIColor.whiteColor;
UIImageView *appletImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 6, self.shareView.frame.size.width, 300 * proportionheightNumber)]; UIImageView *appletImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.shareView.frame.size.width, 300)];
self.appletImageView = appletImageView;
appletImageView.contentMode = UIViewContentModeScaleAspectFit; appletImageView.contentMode = UIViewContentModeScaleAspectFit;
self.appletImageView = appletImageView;
[self.shareView addSubview: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; 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]; 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.font = [UIFont fontWithName:@"PingFangSC-Semibold" size:15];
descLabel.textColor = [MOPTools fat_dynamicColorWithLightHexString:@"#222222" darkHexString:@"#222222"]; descLabel.textColor = [MOPTools fat_dynamicColorWithLightHexString:@"#222222" darkHexString:@"#222222"];
self.titleLabel = descLabel; self.titleLabel = descLabel;
[self.shareView addSubview:descLabel]; [self.shareView addSubview:descLabel];
UILabel *detailLabel = [[UILabel alloc] init]; 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.font = [UIFont fontWithName:@"PingFangSC-Regular" size:11];
detailLabel.numberOfLines = 0; detailLabel.numberOfLines = 0;
detailLabel.textColor = [MOPTools fat_dynamicColorWithLightHexString:@"#666666" darkHexString:@"#666666"]; detailLabel.textColor = [MOPTools fat_dynamicColorWithLightHexString:@"#666666" darkHexString:@"#666666"];
@ -96,7 +92,7 @@ returnInsets = inset;\
[self addSubview:self.shareView]; [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.contentView.backgroundColor = [MOPTools fat_dynamicColorWithLightHexString:@"#F0F0F0" darkHexString:@"#1A1A1A"];
[self addSubview:self.contentView]; [self addSubview:self.contentView];
@ -132,6 +128,12 @@ returnInsets = inset;\
maskLayer.path = maskPath.CGPath; maskLayer.path = maskPath.CGPath;
self.contentView.layer.mask = maskLayer; 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]; [self p_addNotifications];
} }
return self; return self;
@ -209,12 +211,21 @@ returnInsets = inset;\
static NSString *cellID = @"cellid"; static NSString *cellID = @"cellid";
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
MOPshareBottomViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath]; MOPshareBottomViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath];
// cell.type = [self.dataArray[indexPath.row] intValue]; [cell.imageButton setImage:[UIImage imageNamed:self.dataArray[indexPath.row][@"lightImage"]] forState:UIControlStateNormal];
cell.imageView.image = [UIImage imageNamed:self.dataArray[indexPath.row][@"lightImage"]];
cell.label.text = self.dataArray[indexPath.row][@"title"]; cell.label.text = self.dataArray[indexPath.row][@"title"];
cell.type = self.dataArray[indexPath.row][@"type"];
cell.delegate = self;
return cell; 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 { - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
if (self.didSelcetTypeBlock) { if (self.didSelcetTypeBlock) {
NSString *typeString = self.dataArray[indexPath.row][@"type"]; NSString *typeString = self.dataArray[indexPath.row][@"type"];
@ -268,14 +279,15 @@ static NSString *cellID = @"cellid";
if (self) { if (self) {
self.backgroundColor = [MOPTools fat_dynamicColorWithLightHexString:@"#F0F0F0" darkHexString:@"#1A1A1A"]; self.backgroundColor = [MOPTools fat_dynamicColorWithLightHexString:@"#F0F0F0" darkHexString:@"#1A1A1A"];
UIView *imageBgView = [[UIView alloc] initWithFrame:CGRectMake(18, 20, 48, 48)]; UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(18, 20, 48, 48)];
imageBgView.backgroundColor = [MOPTools fat_dynamicColorWithLightHexString:@"#FFFFFF " darkHexString:@"#2C2C2C"]; button.backgroundColor = [MOPTools fat_dynamicColorWithLightHexString:@"#FFFFFF " darkHexString:@"#2C2C2C"];
[self.contentView addSubview:imageBgView]; [self.contentView addSubview:button];
button.layer.masksToBounds = YES;
self.imageView = [UIImageView new]; button.layer.cornerRadius = 6;
self.imageView.frame = CGRectMake(9, 9, 30, 30); UIImage *highBgImage = [UIImage fat_imageWithColor:[MOPTools fat_dynamicColorWithLightHexString:@"#D7D7D7 " darkHexString:@"#4A4A4A"]];
[imageBgView addSubview:self.imageView]; [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((frame.size.width-50)/2, 65, frame.size.width, 30)];
self.label = [[UILabel alloc] initWithFrame:CGRectMake(18, 75, 48, 12)]; self.label = [[UILabel alloc] initWithFrame:CGRectMake(18, 75, 48, 12)];
self.label.font = [UIFont systemFontOfSize:10]; self.label.font = [UIFont systemFontOfSize:10];
@ -287,5 +299,11 @@ static NSString *cellID = @"cellid";
return self; return self;
} }
- (void)iconBtnClick:(UIButton *)btn {
if (self.delegate && [self.delegate respondsToSelector:@selector(iconBtnDidClick:)]) {
[self.delegate iconBtnDidClick:self];
}
}
@end @end

View File

@ -17,7 +17,7 @@ A finclip miniprogram flutter sdk.
s.dependency 'Flutter' s.dependency 'Flutter'
s.ios.deployment_target = '9.0' s.ios.deployment_target = '9.0'
s.dependency 'FinApplet' , '2.39.2-alpha20230103v04' s.dependency 'FinApplet' , '2.39.2-alpha20230105v08'
s.dependency 'FinAppletExt' , '2.39.2-alpha20230103v04' s.dependency 'FinAppletExt' , '2.39.2-alpha20230105v08'
end end