NowUIColoring para o tema NowWebTheme e NowChatTheme
. NowUIColoring A interface contém todas as cores usadas por todos os módulos NowSDK.
Para cenários em que você usa variáveis de cor semelhantes em vários módulos do SDK, você pode implementar o. NowUIColoring interface. Usando esta interface, você pode substituir valores de cor e usar essa implementação para substituir os valores nowUIColoring dentro das classes de tema NowWebTheme e. NowChatTheme . Se as variáveis de cor não forem substituídas, o NowUIColoring a interface usa as cores padrão.
O exemplo de código a seguir mostra como substituir cores para uma IU da Web e uma IU de bate-papo.
// Implement the NowUIColoring and override desired color variables
val nowUIColoringImpl = object : NowUIColoring {
override val brand: Int
get() = Color.BLUE
override val textPrimary: Int
get() = Color.WHITE
//override the rest of color variables
}
// Override the nowUIColoring for NowWeb value using the NowUIColoring implementation
lifecycleScope.launch {
sdkManager.getNowWebService()?.launch(activity, URL("https://instance-name.service-now.com"), object : NowWebTheme {
override val nowUIColoring: NowUIColoring
get() = nowUIColoringImpl
})
}
//Override the nowUIColoring for NowChat value using the NowUIColoring implementation
lifecycleScope.launch {
sdkManager.getNowChatService()?.start(activity, object : NowChatTheme {
override val nowUIColoring: NowUIColoring
get() = nowUIColoringImpl
})
}
Suporte ao tema escuro
Para oferecer suporte a um tema escuro no NowChat, você pode fornecer sua própria implementação de tema escuro do NowChatTheme e usá-la no NowChatService.start() e. NowChatService.updateTheme() funções. Ou você pode usar uma classe NowChatThemeDark que implementa a interface NowChatTheme com cores de tema escuro padrão. Você também pode usar essa classe como base para sua implementação de tema escuro personalizado.
val chatService = serviceManager.getNowChatService()
val chatThemeLight = object : NowChatTheme {
override val backgroundPrimary: Int
get() = Color.WHITE
override val textPrimary: Int
get() = Color.BLACK
// Override remaining theme colors
}
//create dark theme using the NowChatThemeDark class
val chatThemeDark = object : NowChatThemeDark(){
override val backgroundPrimary: Int
get() = Color.BLACK
override val textPrimary: Int
get() = Color.WHITE
// Override remaining theme colors
}
//start NowChat with light theme
chatService?.start(activity, chatThemeLight)
//update NowChat theme to dark theme
chatService?.updateTheme(chatThemeDark)