-
Notifications
You must be signed in to change notification settings - Fork 1
CitrusGraphics Library
The CitrusGraphics library is a lightweight, pure-Swift library for on-demand downloading and caching checkout assets from the Citrus Cloud.
CitrusGraphics will be available as a separate package which can be consumed by any SDK module for its asset requirements. All the assets will be hosted on the cloud. The SDK will have both default and low resolution assets which will be replaced by high resolution assets once the specific asset is downloaded and cached. The assets are selected and downloaded based on the device specifications.
The SDK is logically belongs to UI layers or interfacing to UI
- CitrusGraphics - support Card / Bank / Citrus branding Assets for merchant app.
- Swift Version 3.1 Support with Xcode 8.3
- Asynchronous image downloading and caching
- Prefetching images and showing them from cache later when necessary
- Extensions for UIImageView to directly set an image from a URL
- Built-in transition animation when setting images
The simplest use-case is setting an image to an image view with the UIImageView
extension:
Swift
imageView.loadCitrusCard(cardScheme:"VISA")
Objective-C
[imageView loadCitrusCardWithCardScheme:@"VISA"];
CitrusGraphics will download the image from url, send it to both the memory cache and the disk cache, and display it in imageView. When you reuse the asset, it will be retrieved from cache and displayed immediately.
HTML documentation is hosted on our CitrusPay Developer Guide.
Git Wiki documentation is available on the Git Wiki Documentation.
Feel free to copy & paste code below.
This documentation will describe some most common usage of CitrusGraphics. The code snippets are for iOS.
Some convenient extensions are supplied in CitrusGraphics. It covers most used features, and supports all regular image related UI components: UIImageView. We recommend usage of these methods to keep your code simple.
Swift
imageView.loadCitrusCard(cardScheme:"VISA")
Objective-C
[imageView loadCitrusCardWithCardScheme:@"VISA"];
CitrusGraphics will try to get the image from cache first. If not found, download and cache it for later use.
Swift
imageView.loadCitrusLargeCard(cardScheme:"VISA")
Objective-C
[imageView loadCitrusLargeCardWithCardScheme:@"VISA"];
Swift
imageView.loadCitrusBank(bankCID:"CID001")
Or
imageView.loadCitrusBank(IFSCCode:"ICIC0000985")
Objective-C
[imageView loadCitrusBankWithBankCID:@"CID001"];
Or
[imageView loadCitrusBankWithIFSCCode:@"ICIC0000985"];
Swift
imageView.loadCitrusLargeBank(bankCID:"CID001")
Or
imageView.loadCitrusLargeBank(IFSCCode:"ICIC0000985")
Objective-C
[imageView loadCitrusLargeBankWithBankCID:@"CID001"];
Or
[imageView loadCitrusLargeBankWithIFSCCode:@"ICIC0000985"];
Swift
imageView.setSystemActivity()
Objective-C
[imageView setSystemActivity];
You can also prefetch images and cache them before displaying them on the screen. This is useful when you know a list of image resources which will likely be displayed later.
Swift
CitrusGraphics.imagePrefetcherForCard()
CitrusGraphics.imagePrefetcherForBank()
Objective-C
[CitrusGraphics imagePrefetcherForCard];
[CitrusGraphics imagePrefetcherForBank];
Swift
CitrusGraphics.clearCache()
Objective-C
[CitrusGraphics clearCache];
CitrusGraphics will purge the memory cache when received a memory warning, as well as clean the expired and size exceeded cache when needed. Normally there is no need to clean cache yourself. These methods exist in case of you want your users have more control on the cache.