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:
1
target 'my-target' do
2
pod 'DriveKitCommonUI'
3
end
Copied!
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.
1
import DriveKitCoreModule
2
import DriveKitCommonUI
3
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
4
DriveKit.shared.initialize()
5
DriveKitUI.shared.initialize()
6
...
7
}
Copied!
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.
1
import DriveKitCommonUI
2
class Colors : DKDefaultColors {
3
override func primaryColor() -> UIColor {
4
return UIColor.red
5
}
6
}
7
8
9
import DriveKitCoreModule
10
import DriveKitCommonUI
11
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
12
DriveKit.shared.initialize()
13
DriveKitUI.shared.initialize()
14
DriveKitUI.shared.configureColors(Colors())
15
...
16
}
Copied!

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:
1
import DriveKitCommonUI
2
class Fonts : DKDefaultFonts {
3
override func primaryFont() -> String {return "Impact"}
4
}
5
6
7
import DriveKitCoreModule
8
import DriveKitCommonUI
9
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
10
DriveKit.shared.initialize()
11
DriveKitUI.shared.initialize()
12
DriveKitUI.shared.configureFonts(Fonts())
13
...
14
}
Copied!
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.
1
import DriveKitCoreModule
2
import DriveKitCommonUI
3
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
4
DriveKit.shared.initialize()
5
DriveKitUI.shared.initialize()
6
DriveKitUI.shared.configureStringsFileName("OverridedStrings")
7
...
8
}
Copied!

Add language

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

Get analytics

For analytics purposes, you can tag screens of any DriveKit UI component by providing to this following method an instance of an object conforming to DKAnalytics protocol:
1
DriveKitUI.shared.configureAnalytics(Analytics())
Copied!
Where the Analytics object is for instance:
1
class Analytics : DKAnalytics {
2
func trackScreen(_ screen: String, viewController: UIViewController) {
3
// TODO: manage screen tracking here with the tool of your choice.
4
}
5
6
func trackEvent(_ event: DKAnalyticsEvent, parameters: [String : Any]?) {
7
// TODO: manage event tracking here with the tool of your choice.
8
}
9
}
Copied!
The screen String received in the trackScreen method is the value associated to one of the keys in this array, corresponding to the visited screen. If you want to customize screen tags, you can provide the path to a plist file (see the default tags file) with your custom values in the configuration method:
1
DriveKitUI.shared.configureAnalytics(Analytics(), tagsFileName: "CustomAnalyticsTags")
Copied!
If, in the plist, a value is empty, the tracking is disabled for this screen.
The trackEvent method allows you to add additional information that may be useful for analysis. For example, that method is called each time the user opens the trip detail screen.
Last modified 1mo ago