Theme resources
Sendbird Chat SwiftUI provides themes to help you customize the style of your app. Through simple configurations, you can easily switch between Light and Dark themes and apply custom colors and fonts to the views.
SBUTheme is a singleton class that is used to configure themes. If you don't want to use the default user interfaces provided by SwiftUI, you can customize them by using the SBUTheme class. By customizing the theme of the view controller, you can apply the same custom theme to all its module components.
If you wish to set a global theme to each key function in the client app, you can do so by using setter methods such as setChannel and setChannelList in the corresponding theme class of each view controller.
Set up the default global theme
Sendbird Chat SwiftUI provides two global themes: Light and Dark. The Light theme is the default global theme but you can change it by using the set(theme:) method.
Light theme
This is the default theme for SwiftUI.
Dark theme
You can also apply the Dark theme to your app by following the code below.
Note : The global theme should be configured prior to setting the SwiftUI View.
Customize global theme
Instead of using the provided Light and Dark themes, you can customize the global theme by configuring SBUTheme and passing it as an argument to a parameter in the SBUTheme.set(theme:) method.
Note : The Sendbird Chat SwiftUI consists of the Sendbird Chat UIKit as its core.
SBUThemeis a feature inside UIKit, and the theme of every View in SwiftUI is configured based on SBUTheme. SinceSBUThemeis configured in UIKit, you need to useUIColorandUIFontto set the properties when setting them in SwiftUI.
SwiftUI developers may not be familiar with the use ofUIColororUIFont, so Sendbird Chat SwiftUI provides theasUIColor()andasUIFont()extension functions to convertColorandFontto UIKit values.
Initialize SBUTheme with default values as shown below.
Note :
Thememust be set beforeSendbirdSwiftUIinitialization, and if you change them at runtime, you must callSBUTheme.set(theme:)'to reflect them in the generated theme.