Get started

Integration

The Common UI SDK is a core configuration module for all DriveKit UI SDKs.

To add Common UI module to your app, add the following pod to your podfile:

target 'my-target' do
pod 'DriveKitCommonUI'
end

On a Github repository, you have a demo app and source code that you can use as an example.

Initialization

An initialization phase is required to ensure that Common UI SDK works perfectly. To initialize Common UI SDK in your app, you must call the initialization method in didFinishLaunchingWithOptions method of your AppDelegate file.

import DriveKitCore
import DriveKitCommonUI
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
DriveKit.shared.initialize()
DriveKitUI.shared.initialize()
...
}

This method will initialize the SDK with the default configuration set up by DriveQuant.

It is possible (from Swift, not Objective-C) to provide some parameters to this DriveKitUI initialization method in order to set custom values for colors (colors: DKColors), fonts (fonts: DKFonts), and/or text localization (overridedStringsFileName: String?).

Configurations

Colors

The colors that can be configured are listed in the table below:

Name

Description

Default value

primaryColor

Main app color

#0B4D6E

secondaryColor

Call to action color

#00EBB8

mainFontColor

Main font color

#161616

complementaryFontColor

Secondary font color

#9E9E9E

fontColorOnPrimaryColor

Color of a text displayed on an element whose color is primaryColor

#FFFFFF

fontColorOnSecondaryColor

Color of a text displayed on an element whose color is secondaryColor

#FFFFFF

backgroundViewColor

Background color

#FAFAFA

neutralColor

Color of the separating lines

#F0F0F0

warningColor

Warning color (non-critical hint)

#F7A334

criticalColor

Alert color (critical hint)

#E52027

To override the default colors configuration, you should create a subclass of DKDefaultColors and override the colors that you want to change (or you can create an object implementing the DKColors protocol, necessary if your project is in Objective-C for instance). Then pass an instance of this object as a parameter of the configureColors method.

import DriveKitCommonUI
class Colors : DKDefaultColors {
public func primaryColor() -> UIColor {
return UIColor.red
}
}
import DriveKitCore
import DriveKitCommonUI
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
DriveKit.shared.initialize()
DriveKitUI.shared.initialize()
DriveKitUI.shared.configureColors(Colors())
...
}

Fonts

The Common UI configuration module allows to set up two fonts:

  1. primaryFont: this is the main font used in the application. The default value is Roboto.

  2. secondaryFont: this is the font used on the page titles or to emphasize a specific point. The default value is Roboto.

To override the fonts, you can add the primary and secondary fonts to the CommonUI SDK by calling the configureFonts method as in this following example:

import DriveKitCommonUI
class Fonts : DKDefaultFonts {
func primaryFont() -> String {return "Impact"}
}
import DriveKitCore
import DriveKitCommonUI
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
DriveKit.shared.initialize()
DriveKitUI.shared.initialize()
DriveKitUI.shared.configureFonts(Fonts())
...
}

Note: From Objective-C, it is not possible to subclass the DKDefaultFonts class. To override the fonts, it is thus necessary to create a class implementing the DKFonts protocol.

Text Localization

Contents of each DriveKit UI module are translated into 5 languages: English, French, German, Spanish and Italian.

DriveKit simplifies the internationalization of your application and it is possible to add other languages.

DriveKit Common UI contains a number of basic text keys used in other DriveKit UI modules. You can override these keys to customize your application.

To help make the text keys in the code easier to read, a specific nomenclature has been set up: dk_<module name>_<key description>.

For the Common UI module, all localizable keys are prefixed with: dk_common.

There are several files containing text keys:

  • A .strings file in the common UI module containing generic keys to all modules.

  • One file per UI module containing module-specific text keys.

Text customization

To override a text key in the common UI module, simply define the keys to be modified in a .strings file at the application level and configure the filename in the common UI module. The text keys can be directly retrieved on Github, in the Localizable folder of each module.

import DriveKitCore
import DriveKitCommonUI
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
DriveKit.shared.initialize()
DriveKitUI.shared.initialize()
DriveKitUI.shared.configureStringsFileName("OverridedStrings")
...
}

Add language

The translation file can be retrieved from GitHub. Add it to your application after adding the appropriate translation(s).