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]) {
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);

View File

@ -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

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

View File

@ -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 <NSObject>
- (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<MOPCellClickDelegate> delegate;
@end

View File

@ -29,7 +29,7 @@ returnInsets = inset;\
(returnInsets);\
})\
@interface MopShareView ()<UICollectionViewDelegate, UICollectionViewDataSource>
@interface MopShareView ()<UICollectionViewDelegate, UICollectionViewDataSource, MOPCellClickDelegate>
@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

View File

@ -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