Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Adding barStyle support to control dark mode on android & iOS #67

Closed

Conversation

shubhamguptadream11
Copy link
Contributor

No description provided.

@shubhamguptadream11
Copy link
Contributor Author

Hi @okwasniewski

We tried using the standard approach for setting the barStyle like this:

UITabBar.appearance().barStyle = UIBarStyle.black

However, this didn't seem to work as expected.

As an alternative, we’re considering manually implementing it like so:

if props.barStyle != nil {
    if props.barStyle == "black" {
        appearance.backgroundColor = UIColor.black
        appearance.selectionIndicatorTintColor = UIColor.white
    } else {
        appearance.backgroundColor = UIColor.white
        appearance.selectionIndicatorTintColor = UIColor.gray
    }
}

Would this be a correct approach for manually handling the barStyle behavior, or is there a better way to handle this?

Thanks for your insights!

@okwasniewski
Copy link
Owner

Hey, @shubhamguptadream11

I think this should work:

.preferredColorScheme(.dark) or .preferredColorScheme(.light)

@shubhamguptadream11
Copy link
Contributor Author

@okwasniewski
It didn't worked, I tried applying this to TabView and Item level both.

I found this: https://www.hackingwithswift.com/forums/swiftui/preferredcolorscheme-not-affecting-datepicker-and-confirmationdialog/11796

As per this it's suggested to use this:

private func setupColorScheme(_ isDarkMode: Bool) {
  UIApplication.shared.keyWindow?.overrideUserInterfaceStyle = isDarkMode ? .dark : .light
}

With this things are working.

@okwasniewski
Copy link
Owner

@shubhamguptadream11 This will force every native component, to change apperance

I'd like to know if Appearance.setColorScheme won't do the same. Maybe we don't need this prop if this can't be forced on the component level?

@shubhamguptadream11
Copy link
Contributor Author

By using Appearance.setColorScheme('dark') it enforces dark mode on bottom tab.

@okwasniewski
Copy link
Owner

@shubhamguptadream11 I also tried both approaches with UITabBarAppreance and SwiftUI and nothing seems to work. Let's skip this prop for now as it can be forced with Apperance.setColorScheme()

Thanks for working on this anyways!

@shubhamguptadream11
Copy link
Contributor Author

@okwasniewski Closing this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants