Skip to content

CitrusGraphics Library

Mukesh Patil - Sr. iOS Engineer edited this page Mar 31, 2017 · 2 revisions

CitrusGraphics Library (Version 1.1.2)

The CitrusGraphics library is a lightweight, pure-Swift library for on-demand downloading and caching checkout assets from the Citrus Cloud.

SDK Modularization with Dynamic Assets

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.

Features

  • 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.

Documentation

HTML documentation is hosted on our CitrusPay Developer Guide.

Git Wiki documentation is available on the Git Wiki Documentation.

Cheat Sheet

Feel free to copy & paste code below. This documentation will describe some most common usage of CitrusGraphics. The code snippets are for iOS.

Working with CitrusGraphics extensions for UI component

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.

Simply set an image for a credit/debit card to an image view

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.

Or set an image for card large to an image view

Swift

imageView.loadCitrusLargeCard(cardScheme:"VISA")

Objective-C

[imageView loadCitrusLargeCardWithCardScheme:@"VISA"];

Set an image for bank to an image view

Swift

imageView.loadCitrusBank(bankCID:"CID001")

Or

imageView.loadCitrusBank(IFSCCode:"ICIC0000985")

Objective-C

[imageView loadCitrusBankWithBankCID:@"CID001"];

Or

[imageView loadCitrusBankWithIFSCCode:@"ICIC0000985"];

Or set an image for bank large to an image view

Swift

imageView.loadCitrusLargeBank(bankCID:"CID001")

Or

imageView.loadCitrusLargeBank(IFSCCode:"ICIC0000985")

Objective-C

[imageView loadCitrusLargeBankWithBankCID:@"CID001"];

Or

[imageView loadCitrusLargeBankWithIFSCCode:@"ICIC0000985"];

With a loading indicator while downloading

Swift

imageView.setSystemActivity()

Objective-C

[imageView setSystemActivity];

Prefetch

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.

Set an prefetch for card and Bank

Swift

CitrusGraphics.imagePrefetcherForCard()
CitrusGraphics.imagePrefetcherForBank()

Objective-C

[CitrusGraphics imagePrefetcherForCard];
[CitrusGraphics imagePrefetcherForBank];

Clear cache manually

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.

Clone this wiki locally