LogoLogo
ProductsUse casesDocsSupport
  • Introducing DriveKit
  • DriveKit Guides
  • Get started with drivekit
    • Trip recording lifecycle
    • iOS
      • 🚀Quick start
      • Advanced configurations
      • References
      • iOS DriveKit Demo App
    • Android
      • 🚀Quick start
      • Advanced configurations
      • References
      • Android DriveKit Demo App
      • Android 15 Migration guide
      • Android 14 Migration guide
      • Troubleshooting
  • Trip analysis
    • Introduction
    • iOS
      • Permissions
      • Trip management
      • TripListener
      • Crash Detection
      • Beacon usage
      • Bluetooth usage
      • Custom metadata
      • References (iOS)
    • Android
      • Runtime permissions
      • Trip management
      • TripListener
      • Crash Detection
      • Beacon usage
      • Bluetooth usage
      • Custom metadata
      • References (Android)
    • User interface
      • iOS
        • Get started
        • Working hours
        • Driver alert in case of crash
        • Trip recording widget
        • Location sharing
      • Android
        • Get started
        • Working hours
        • Driver alert in case of crash
        • Trip recording widget
        • Location sharing
    • REST services
      • Trip
      • References
    • Trip Simulator
      • iOS
      • Android
  • PERMISSIONS UTILS
    • Introduction
    • User interface
      • iOS
        • Get started
        • Main configurations
      • Android
        • Get started
        • Main configurations
  • COMMON UI
    • Introduction
    • iOS
      • Get started
    • Android
      • Get started
    • References
  • DRIVER DATA
    • Introduction
    • iOS
      • Get started
      • References (iOS)
    • Android
      • Get started
      • References (Android)
    • User interface
      • iOS
        • Get started
        • Advanced configurations
        • Trips widgets
        • My Synthesis
        • My Driver Profile
      • Android
        • Get Started
        • Advanced configurations
        • Trips widgets
        • My Synthesis
        • My Driver Profile
  • Driver Data Timeline UI
    • Introduction
    • iOS
      • Get started
    • Android
      • Get started
  • Vehicle
    • Introduction
    • iOS
      • Get started
      • Vehicle management
      • Beacon management
      • Bluetooth device management
      • Odometer
      • References (iOS)
    • Android
      • Get started
      • Vehicle management
      • Beacon management
      • Bluetooth device management
      • Odometer
      • References (Android)
    • User interface
      • iOS
        • Get started
        • Main configurations
        • Advanced configurations
      • Android
        • Get started
        • Main configurations
        • Advanced configurations
  • DRIVER ACHIEVEMENT
    • Introduction
    • iOS
      • Get started
    • Android
      • Get Started
    • User interface
      • iOS
      • Android
  • CHALLENGE
    • Introduction
    • Important challenge rules
    • iOS
      • Get started
      • References (iOS)
    • Android
      • Get started
      • References (Android)
    • User interface
      • iOS
        • Get started
      • Android
        • Get started
  • GROUP
    • Introduction
    • iOS
      • Get started
    • Android
      • Get started
  • React Native
    • Get started
    • Integration
  • Flutter
    • Get started
    • Integration
  • Push services
    • Introduction
    • Push Trip Data
    • Push Deleted trip
    • Push Crash Data
    • Push Diagnosis Data
  • ADMIN SERVICES
    • Beacon
      • Add
      • Replace
      • Delete
      • Configuration
    • Challenges
      • List of challenges
      • Challenge details
      • Registered users
      • Challenge ranking
      • Users' progress
      • Definitions
    • Customer
      • Activity timeline
    • Driver
      • Timeline
      • Synthesis
      • Identity
      • Status
      • Add or update a metadata
      • Vehicles
      • Profile
      • Application diagnoses
    • Drivers
      • Account
      • Statistics
      • Ranking
      • Expired accounts
    • Group
      • Timeline
      • Synthesis
    • Trips
      • Add or update a metadata
      • Delete a metadata
    • Vehicle
      • Create
      • Characteristics
      • Configuration
      • Statistics
      • Update mileage
      • Tire and brake wear update
      • References
  • Crashes
    • Annotate a crash
    • Revoke crash location URL
  • ENTERPRISE SERVICES
    • Introduction
    • Teams
      • Create a team
      • List of teams
      • Enable or disable a team
    • Hyper-admins
      • Create a hyper-admin
      • List of hyper-admins
      • Delete a hyper-admin
    • Monitoring
      • Get a push trip data report
      • Get a push crash data report
      • Request to retry failed trips
      • Request to retry failed crashes
      • Get the status of a task
  • Release notes
    • Changelog
      • iOS
      • Android
      • UI iOS
      • UI Android
Powered by GitBook
On this page
  • Integration
  • Initialization
  • Configurations
  • Colors
  • Fonts
  • Text Localization
  • Text customization
  • Add language
  • Get analytics

Was this helpful?

Export as PDF
  1. COMMON UI
  2. iOS

Get started

PreviousiOSNextAndroid

Last updated 11 months ago

Was this helpful?

Integration

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

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

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

Then, run pod install

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

Initialization

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

import DriveKitCoreModule
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

#77E2B0

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

navBarElementColor

Color of elements (title and items) in the navigation bar

fontColorOnPrimaryColor

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 DriveKitCoreModule
import DriveKitCommonUI

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

class Colors: DKDefaultColors {
    override func primaryColor() -> UIColor {
        return UIColor.red
    }
}

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 DriveKitCoreModule
import DriveKitCommonUI

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

class Fonts: DKDefaultFonts {
    override func primaryFont() -> String {
        return "Impact"
    }
}

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 7 languages: English, French, German, Spanish, Italian, Danish and Portuguese.

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

import DriveKitCoreModule
import DriveKitCommonUI

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

Add language

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:

DriveKitUI.shared.configureAnalytics(Analytics())

Where the Analytics object is for instance:

class Analytics: DKAnalytics {
    func trackScreen(_ screen: String, viewController: UIViewController) {
        // TODO: manage screen tracking here with the tool of your choice.
    }

    func trackEvent(_ event: DKAnalyticsEvent, parameters: [String : Any]?) {
        // TODO: manage event tracking here with the tool of your choice.
    }
}
DriveKitUI.shared.configureAnalytics(Analytics(), tagsFileName: "CustomAnalyticsTags")

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.

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 , in the Localizable folder of each module.

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

The screen String received in the trackScreen method is the value associated to one of the keys, corresponding to the visited screen. If you want to customize screen tags, you can provide the path to a plist file (see the ) with your custom values in the configuration method:

Github
GitHub
in this array
default tags file
Github repository
disabled the SDK auto-initialization