From 515723a303fb85157c30d8e2e5c76026020562cf Mon Sep 17 00:00:00 2001 From: Andrei Ashikhmin Date: Sun, 26 Nov 2023 12:12:22 +0700 Subject: [PATCH 1/2] fix: resize dash logo to 22% regardless of QR size --- .../Receive/Models/DWBaseReceiveModel.m | 55 ++++--------------- 1 file changed, 12 insertions(+), 43 deletions(-) diff --git a/DashWallet/Sources/UI/Payments/Receive/Models/DWBaseReceiveModel.m b/DashWallet/Sources/UI/Payments/Receive/Models/DWBaseReceiveModel.m index 94eb76d3b..fbe11d04b 100644 --- a/DashWallet/Sources/UI/Payments/Receive/Models/DWBaseReceiveModel.m +++ b/DashWallet/Sources/UI/Payments/Receive/Models/DWBaseReceiveModel.m @@ -51,40 +51,9 @@ static CGSize QRCodeSizeRequestAmount(void) { } } -static CGSize HoleSize(BOOL hasAmount) { - if (IS_IPAD) { - return CGSizeMake(84.0, 84.0); // 2 + 80(logo size) + 2 - } - else if (IS_IPHONE_5_OR_LESS) { - return CGSizeMake(48.0, 48.0); - } - else { - if (hasAmount) { - return CGSizeMake(58.0, 58.0); - } - else { - return CGSizeMake(84.0, 84.0); - } - } -} - -static CGSize const LOGO_SMALL_SIZE = {54.0, 54.0}; - -static BOOL ShouldResizeLogoToSmall(BOOL hasAmount) { - if (IS_IPAD) { - return NO; - } - if (IS_IPHONE_5_OR_LESS) { - return YES; - } - else { - return hasAmount; - } -} - @interface DWBaseReceiveModel () -@property (readonly, nonatomic, assign) CGSize holeSize; +@property (readonly, nonatomic, assign) CGSize logoSize; @end @@ -106,7 +75,9 @@ - (instancetype)initWithAmount:(uint64_t)amount { else { _qrCodeSize = QRCodeSizeBasic(); } - _holeSize = HoleSize(hasAmount); + + CGFloat logoSize = _qrCodeSize.height * 0.22; + _logoSize = CGSizeMake(logoSize, logoSize); } return self; } @@ -123,15 +94,13 @@ - (UIImage *)qrCodeImageWithRawQRImage:(UIImage *)rawQRImage hasAmount:(BOOL)has #endif const BOOL shouldDrawUser = username != nil; - - if (ShouldResizeLogoToSmall(hasAmount)) { - if (shouldDrawUser) { - size = LOGO_SMALL_SIZE; - } - else { - overlayImage = [overlayImage dw_resize:LOGO_SMALL_SIZE - withInterpolationQuality:kCGInterpolationHigh]; - } + + if (shouldDrawUser) { + size = _logoSize; + } + else { + overlayImage = [overlayImage dw_resize:_logoSize + withInterpolationQuality:kCGInterpolationHigh]; } if (shouldDrawUser) { @@ -181,7 +150,7 @@ - (UIImage *)qrCodeImageWithRawQRImage:(UIImage *)rawQRImage hasAmount:(BOOL)has } UIImage *resizedImage = [rawQRImage dw_resize:self.qrCodeSize withInterpolationQuality:kCGInterpolationNone]; - resizedImage = [resizedImage dw_imageByCuttingHoleInCenterWithSize:self.holeSize]; + resizedImage = [resizedImage dw_imageByCuttingHoleInCenterWithSize:self.logoSize]; UIImage *qrCodeImage = [resizedImage dw_imageByMergingWithImage:overlayImage]; From db28d99d413b262cd95ecdf2b517117d7ba47e7c Mon Sep 17 00:00:00 2001 From: Andrei Ashikhmin Date: Sun, 26 Nov 2023 12:12:47 +0700 Subject: [PATCH 2/2] fix: render Q level QR quality --- Shared/Sources/UIImage+Utils.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Shared/Sources/UIImage+Utils.m b/Shared/Sources/UIImage+Utils.m index 6ef9853ac..918c9665d 100644 --- a/Shared/Sources/UIImage+Utils.m +++ b/Shared/Sources/UIImage+Utils.m @@ -38,7 +38,7 @@ + (instancetype)dw_imageWithQRCodeData:(NSData *)data color:(CIColor *)color { *filter = colorFilter; [qrFilter setValue:data forKey:@"inputMessage"]; - [qrFilter setValue:@"M" forKey:@"inputCorrectionLevel"]; + [qrFilter setValue:@"Q" forKey:@"inputCorrectionLevel"]; if (color.alpha > DBL_EPSILON) { [invertFilter setValue:qrFilter.outputImage forKey:@"inputImage"];