-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1255 from novasamatech/feature/updated-receive-sc…
…reen Feature/updated receive screen
- Loading branch information
Showing
34 changed files
with
1,165 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
novawallet/Assets.xcassets/colors/text/colorTextPrimaryOnWhite.colorset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"colors" : [ | ||
{ | ||
"color" : { | ||
"color-space" : "srgb", | ||
"components" : { | ||
"alpha" : "1.000", | ||
"blue" : "0x00", | ||
"green" : "0x00", | ||
"red" : "0x00" | ||
} | ||
}, | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
novawallet/Assets.xcassets/colors/text/colorTextSecondaryOnWhite.colorset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"colors" : [ | ||
{ | ||
"color" : { | ||
"color-space" : "srgb", | ||
"components" : { | ||
"alpha" : "0.560", | ||
"blue" : "0x00", | ||
"green" : "0x00", | ||
"red" : "0x00" | ||
} | ||
}, | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
novawallet/Common/IconRetrieve/IconRetrieveOperationFactory.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import Foundation | ||
import Kingfisher | ||
import Operation_iOS | ||
|
||
protocol IconRetrieveOperationFactoryProtocol { | ||
func checkCacheOperation(using cacheKey: String) -> ClosureOperation<Bool> | ||
|
||
func downloadImageOperation( | ||
using logoInfo: IconInfo | ||
) -> AsyncClosureOperation<UIImage> | ||
|
||
func retrieveImageOperation(using cacheKey: String) -> AsyncClosureOperation<UIImage> | ||
} | ||
|
||
enum ImageRetrievingError: Error { | ||
case logoDownloadError | ||
case logoRetrievingError | ||
} |
111 changes: 111 additions & 0 deletions
111
novawallet/Common/IconRetrieve/KingfisherIconRetrieveOperationFactory.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import Foundation | ||
import Kingfisher | ||
import Operation_iOS | ||
|
||
struct KingfisherIconRetrieveOperationFactory { | ||
let imageManager: KingfisherManager | ||
let operationQueue: OperationQueue | ||
|
||
init( | ||
imageManager: KingfisherManager = KingfisherManager.shared, | ||
operationQueue: OperationQueue | ||
) { | ||
self.imageManager = imageManager | ||
self.operationQueue = operationQueue | ||
} | ||
} | ||
|
||
// MARK: IconRetrieveOperationFactoryProtocol | ||
|
||
extension KingfisherIconRetrieveOperationFactory: IconRetrieveOperationFactoryProtocol { | ||
func checkCacheOperation(using cacheKey: String) -> Operation_iOS.ClosureOperation<Bool> { | ||
let cache = imageManager.cache | ||
|
||
return ClosureOperation { | ||
let cachedType = cache.imageCachedType(forKey: cacheKey) | ||
|
||
return cachedType.cached | ||
} | ||
} | ||
|
||
func downloadImageOperation(using iconInfo: IconInfo) -> Operation_iOS.AsyncClosureOperation<UIImage> { | ||
let downloader = imageManager.downloader | ||
|
||
return AsyncClosureOperation { resultClosure in | ||
let scale = UIScreen.main.scale | ||
|
||
let scaledSize = CGSize( | ||
width: iconInfo.size.width * scale, | ||
height: iconInfo.size.height * scale | ||
) | ||
|
||
guard let url = iconInfo.url else { | ||
resultClosure(.failure(ImageRetrievingError.logoDownloadError)) | ||
|
||
return | ||
} | ||
|
||
let processor = SVGImageProcessor() |> ResizingImageProcessor(referenceSize: scaledSize) | ||
|
||
let options: KingfisherOptionsInfo = [.processor(processor)] | ||
|
||
downloader.downloadImage(with: url, options: options) { result in | ||
var resultImage: UIImage | ||
|
||
switch result { | ||
case let .success(imageResult) where imageResult.image.cgImage != nil: | ||
resultImage = imageResult.image | ||
default: | ||
resultClosure(.failure(ImageRetrievingError.logoDownloadError)) | ||
|
||
return | ||
} | ||
|
||
let sizeBeforeProcessing = resultImage.size | ||
|
||
if case .remoteTransparent = iconInfo.type { | ||
resultImage = resultImage.redrawWithBackground( | ||
color: R.color.colorTextPrimaryOnWhite()!, | ||
shape: .circle | ||
) | ||
} | ||
|
||
if let cacheKey = iconInfo.type?.cacheKey { | ||
let cacheOptions = KingfisherOptionsInfo.cacheOptions | ||
|
||
imageManager.cache.store( | ||
resultImage, | ||
forKey: cacheKey, | ||
options: KingfisherParsedOptionsInfo(cacheOptions) | ||
) | ||
} | ||
|
||
resultClosure(.success(resultImage)) | ||
} | ||
} | ||
} | ||
|
||
func retrieveImageOperation(using cacheKey: String) -> Operation_iOS.AsyncClosureOperation<UIImage> { | ||
let cache = imageManager.cache | ||
|
||
return AsyncClosureOperation { resultClosure in | ||
cache.retrieveImage(forKey: cacheKey) { result in | ||
if | ||
case let .success(cacheResult) = result, | ||
let image = cacheResult.image { | ||
resultClosure(.success(image)) | ||
} else { | ||
resultClosure(.failure(ImageRetrievingError.logoRetrievingError)) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
extension KingfisherOptionsInfo { | ||
static let cacheOptions: KingfisherOptionsInfo = [ | ||
.cacheSerializer(RemoteImageSerializer.shared), | ||
.cacheOriginalImage, | ||
.diskCacheExpiration(.days(1)) | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import UIKit | ||
|
||
protocol CopyAddressPresentable { | ||
func copyAddress( | ||
from view: ControllerBackedProtocol?, | ||
address: String, | ||
locale: Locale | ||
) | ||
} | ||
|
||
extension CopyAddressPresentable where Self: ModalAlertPresenting { | ||
func copyAddress( | ||
from view: ControllerBackedProtocol?, | ||
address: String, | ||
locale: Locale | ||
) { | ||
UIPasteboard.general.string = address | ||
|
||
let title = R.string.localizable.commonAddressCoppied(preferredLanguages: locale.rLanguages) | ||
|
||
presentSuccessNotification( | ||
title, | ||
from: view | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
enum BarcodeCreationError: Error { | ||
case generatorUnavailable | ||
case generatedImageInvalid | ||
case bitmapImageCreationFailed | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import Foundation | ||
import UIKit | ||
|
||
struct IconInfo { | ||
let size: CGSize | ||
let type: IconType? | ||
|
||
var url: URL? { | ||
type?.url | ||
} | ||
|
||
func byChangingToLocal(_ image: UIImage) -> IconInfo? { | ||
switch type { | ||
case .remoteColored: | ||
IconInfo( | ||
size: size, | ||
type: .localColored(image) | ||
) | ||
case .remoteTransparent: | ||
IconInfo( | ||
size: size, | ||
type: .localTransparent(image) | ||
) | ||
default: | ||
IconInfo( | ||
size: size, | ||
type: nil | ||
) | ||
} | ||
} | ||
|
||
func withNoLogo() -> IconInfo { | ||
IconInfo( | ||
size: size, | ||
type: nil | ||
) | ||
} | ||
} |
Oops, something went wrong.