SAPcpmsThemeManager
public class SAPcpmsThemeManager
The SAPcpmsThemeManager
downloads a theme from Mobile Services.
It uses the SAP Mobile Services Theme Service API endpoint for that.
This sample code demonstrates how to download the theme from SAP Mobile Services:
var urlSession = SAPURLSession()
let settingsParameters = SAPcpmsSettingsParameters(backendURL: <#URL only with domain#>, applicationID: <#appid#>)
let response = try SAPcpmsThemeManager.downloadTheme(sapURLSession: urlSession, settingsParameters: settingsParameters)
NOTE:
Theme updates will be reflected in the UI components after relaunching the application.
-
Downloads theme files from Mobile Services into a folder.
Throws
error in case of failure.Declaration
Swift
public static func downloadTheme(sapURLSession: SAPURLSession, settingsParameters: SAPcpmsSettingsParameters) async throws -> HTTPURLResponse
Parameters
sapURLSession
an SAPURLSession implementation that can be used to communicate with the SAP Mobile Services
settingsParameters
SAPcpms settings metadata that is used to identify SAPcpms URL
Return Value
received http response.
-
Deletes all theme related files, folders and configuration.
Throws
fileManager related errors.Declaration
Swift
public static func deleteTheme() throws
-
This method returns the theme directory URL where all the theme related files get stored. If such a directory doesn’t exist, then it will be created.
Throws
FileManager related errors.Declaration
Swift
public static func getThemeDirectoryURL() throws -> URL
Return Value
the root directory URL where all the theme related files are stored
-
This method returns the file URL of the theme if it was downloaded. If such file doesn’t exist then an error will be thrown.
Throws
FileManager related errors.Declaration
Swift
public static func getThemeFileURL() throws -> URL
Return Value
the file URL of the downloaded theme / stylesheet file
-
Apply function to apply the theme for the subsequent steps.
The function will call
resetTheme
internally to ensure theme correctness.Throws
Error if it encounters error while applying theme.Declaration
Swift
public static func applyTheme() throws
-
This method will reset the color definitions to the default
SAPFiori
color palette.SAPFiori
controls will use the defaultSAPFiori
color palette the next time those UI controls are rendered. This method has no effect on currently-presented UI controls.Throws
an error if resetting is not possible for any reasonsDeclaration
Swift
public static func resetTheme() throws