Yalantis / Segmentio

Animated top/bottom segmented control written in Swift.
https://yalantis.com/
MIT License
2.52k stars 322 forks source link

Dark mode support #132

Closed jordanpwood closed 4 years ago

jordanpwood commented 5 years ago

Report

Report a bug

What did you do?

I want to start off by saying that this framework has been very useful to me, and I really appreciate your work!

I am adding dark mode support for iOS 13. I have supplied dynamic colors to setup my Segmentio view. when I change to dark mode and come back to my app, the selected tab is very large, like this:

Screen Shot 2019-07-25 at 4 13 08 PM

If I call Segmentio.setup(...) after the mode has switched between light and dark mode (from traitCollectionDidChange(_ previousTraitCollection:), then everything is drawn in the right location and size, but the selected item color has not been updated; it is showing the same color as the previous mode. Here is a screenshot of the two tabs after switching from dark to light mode. The "A - Z" tab has the correct background and text color, the "Journal Rank" tab has the right text color, but it is supposed to be the lighter version of my dynamic color:

Screen Shot 2019-07-25 at 4 24 32 PM

What did you expect to happen?

There should be some way to update the view such that the layers accurately reflect the correct color for the current mode.

What happened instead?

The old color persists, even after calling setup(..) after the mode changed.

Your Environment

   CocoaPods : 1.7.5
        Ruby : ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin18]
    RubyGems : 2.7.6
        Host : Mac OS X 10.14.5 (18F132)
       Xcode : 10.3 (10G8)
         Git : git version 2.20.1 (Apple Git-117)
Ruby lib dir : /usr/local/Cellar/ruby/2.5.1/lib
Repositories : cocoapod-specs - https://github.com/thirdiron/cocoapod-specs.git @ a054b2725bd540a0511c69e821f771ed7e5294c1
               master - https://github.com/CocoaPods/Specs.git @ 006981cf67ecd10a8f51687295c5af8bad5dc5b8
               mendeley - https://github.com/Mendeley/mendeleykit.git @ 6a401b946c2a2249ef32c84c3e2db78c8ce1a083
               thirdiron - https://github.com/thirdiron/browzine_schema_hub.git @ db57c98faed8f4c932a0520e762a2f7fd13571aa
               thirdiron-1 - https://github.com/thirdiron/Segmentio.git @ 9fc4ab2cc4339dfdac9157ce345ba64014f34ec8

Installation Source

Executable Path: /usr/local/bin/pod

Plugins

cocoapods-deintegrate : 1.0.4
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.0
cocoapods-stats       : 1.1.0
cocoapods-trunk       : 1.3.1
cocoapods-try         : 1.1.0

Podfile

source 'https://github.com/thirdiron/browzine_schema_hub.git'
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '11.0'

# ignore all warnings from all pods
inhibit_all_warnings!

# Required for Swift pods
use_frameworks!

target 'BrowZine' do
    pod 'Fabric', '~> 1.9'
    pod 'Crashlytics', '~> 3.12'
    pod 'GoogleAnalytics', '~> 3.17'
    pod 'CocoaLumberjack/Swift', '~> 3.5'

    pod 'AFNetworking', '~> 3.2'
    pod 'Siesta', '~> 1.4.1'
    pod 'Japx', '~> 2.1'
    pod 'Japx/Codable', '~> 2.1'
    pod 'MulticastDelegateSwift', '~> 2.1'

    pod 'Reachability', '3.2'
    pod 'iVersion', '~> 1.11.4'
    pod 'PDKeychainBindingsController', '0.0.1'
    pod 'SwiftKeychainWrapper', '3.4'

    pod 'browzine_schema_hub', '~> 0.3.5'

    pod 'Mantle', '~> 1'
    pod 'SwiftyJSON', '~> 5.0'

    pod 'Hero', '~> 1.4'
    pod 'RPCircularProgress', '~> 0.4'
    pod 'AwesomeEnum', '~> 2.0'
    pod 'DZNWebViewController', :git => 'https://github.com/dzenbot/DZNWebViewController', :commit => '334fbad'

    pod 'SwiftMessages', '~> 7.0'
    pod 'Segmentio', :git => 'https://github.com/thirdiron/Segmentio.git', :branch => 'feature/item_color'
    pod 'SnapKit', '~> 5.0'

    #pod 'couchbase-lite-ios', '~> 1.2.1'
    pod 'VVJSONSchemaValidation', '~> 1.5.0'

    pod 'JSBadgeView', '~> 2.0.0'
    pod 'uservoice-iphone-sdk', '~> 3.2'
    pod 'NSAttributedString-DDHTML', '~> 1.2.0'
    pod 'NSArray+Functional', '~> 1.0'
    pod 'DDVersion'

    pod 'MendeleyKitiOS', '~> 3.4'
    pod 'OAuthSwift', '~> 1.4.0'

    # Temporary until the ios 11 changes are merged
    pod 'StringExtensionHTML', :git => 'https://github.com/oklasoftLLC/StringExtensionHTML'
    pod 'MRProgress', :git => 'https://github.com/thirdiron/MRProgress.git', :branch => 'ios_11_update'

    target 'BrowZine Tests' do
        inherit! :search_paths

        pod 'Yams', '~> 1.0'
        pod 'URLMock', '~> 1.3.2'
        pod 'URLMock/TestHelpers', '~> 1.3.2'
        pod 'URLMock/SubclassResponsibility', '~> 1.3.2'

        pod 'Quick'
        pod 'Nimble'

        #pod 'couchbase-lite-ios/Listener', '~> 1.2.1pod '
    end
end

post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', 'MendeleyKitiOSFramework']
            config.build_settings['SWIFT_VERSION'] = '5.0'
            #add any other build settings
        end
    end
end
jordanpwood commented 5 years ago

Sorry, I submitted my report before I completed it! I now have all the information entered.

jordanpwood commented 5 years ago

It looks like beta 5 fixed the problem where the layer color wasn't being updated after calling Segmentio.setup(...) from inside traitCollectionDidChange(_ previousTraitCollection:). Before I close this issue, could you tell me if it is a good idea to be calling Segmentio.setup(...) repeatedly for an instance of Segmentio?

Jamonek commented 5 years ago

+1