Skip to content

Instantly share code, notes, and snippets.

@vizbee
Created August 7, 2023 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vizbee/323c92699007ca1e523650afc2434619 to your computer and use it in GitHub Desktop.
Save vizbee/323c92699007ca1e523650afc2434619 to your computer and use it in GitHub Desktop.

Scenario

Setup both Light and Dark themes for styling of Vizbee cards to match the app's color pallete and fonts.

  1. Create a VizbeeStyles.swift file and update the lightTheme and rightTheme with the values which matches app's light/dark theme as specified here
  2. Update the style to light/dark theme as per the corresponding appearance setting on the user's device as shown below

Example

Light Theme

rectangular overlay

rectangular overlay

rectangular overlay

## Dark Theme

rectangular overlay

rectangular overlay

rectangular overlay

import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func applicationDidBecomeActive(_ application: UIApplication) {
...
// [Vizbee Begin] - Style Update
let isLightTheme = AppDelegate.window().traitCollection.userInterfaceStyle == .light
if isLightTheme {
Vizbee.setUIConfig(VizbeeStyles.lightTheme)
} else {
Vizbee.setUIConfig(VizbeeStyles.darkTheme)
}
// [Vizbee End] - Style Update
...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment