Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion ios/Classes/NativeTabBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ struct TabBarConfig: Equatable {
var actionButtonSymbol: String = "" // Default to empty
var tintColor: UIColor = .systemBlue
var selectedIndex: Int = 0
var isDark: Bool = false

init(from dict: [String: Any]?) {
guard let dict = dict else { return }
Expand All @@ -64,6 +65,9 @@ struct TabBarConfig: Equatable {
if let idx = dict["selectedIndex"] as? Int {
self.selectedIndex = idx
}
if let isDark = dict["isDark"] as? Bool {
self.isDark = isDark
}
}

func structuralChange(from other: TabBarConfig) -> Bool {
Expand All @@ -83,13 +87,15 @@ struct TabBarConfig: Equatable {
class LiquidGlassTabBarController: UITabBarController, UITabBarControllerDelegate {
private let channel: FlutterMethodChannel
private var config: TabBarConfig
private var currentAppearanceIsDark: Bool

init(viewId: Int64, messenger: FlutterBinaryMessenger, args: Any?) {
self.channel = FlutterMethodChannel(
name: "NativeTabBar_\(viewId)",
binaryMessenger: messenger
)
self.config = TabBarConfig(from: args as? [String: Any])
self.currentAppearanceIsDark = config.isDark
super.init(nibName: nil, bundle: nil)
}

Expand All @@ -103,6 +109,7 @@ class LiquidGlassTabBarController: UITabBarController, UITabBarControllerDelegat
self.view.backgroundColor = .clear
self.view.isOpaque = false
self.delegate = self
overrideUserInterfaceStyle = config.isDark ? .dark : .light

configureAppearance()
performFullRebuild()
Expand All @@ -122,6 +129,7 @@ class LiquidGlassTabBarController: UITabBarController, UITabBarControllerDelegat
appearance.configureWithDefaultBackground()
appearance.backgroundColor = .clear
appearance.shadowColor = .clear
appearance.backgroundEffect = UIBlurEffect(style: config.isDark ? .dark : .light)

let itemAppearance = UITabBarItemAppearance()
itemAppearance.normal.iconColor = .systemGray
Expand Down Expand Up @@ -214,8 +222,14 @@ class LiquidGlassTabBarController: UITabBarController, UITabBarControllerDelegat
}

private func updateSelectionAndColors() {
if tabBar.tintColor != config.tintColor {
let needsAppearanceUpdate =
tabBar.tintColor != config.tintColor
|| currentAppearanceIsDark != config.isDark

if needsAppearanceUpdate {
tabBar.tintColor = config.tintColor
currentAppearanceIsDark = config.isDark
overrideUserInterfaceStyle = config.isDark ? .dark : .light
configureAppearance()
}

Expand Down