microsoft / FluentDarkModeKit

A library for backporting Dark Mode in iOS
MIT License
1.63k stars 125 forks source link

Usability in Objective-C only Projects #85

Closed levinli303 closed 4 years ago

levinli303 commented 4 years ago

The DarkModeManager related APIs are Swift only and cannot be called from Objective-C. Thus an Objective-C user cannot properly set up the environment and is only allowed to create UIColor/UIImage which are part of DarkModeCore.

Although you should be able to achieve it by adding the modifier @objc, the issue/dilemma about hiding swizzling method makes me feel like maybe it is more sane to move the Swift code to Objective-C instead.

jacksonon commented 4 years ago

All Right . I do follow actions make it private pod

@objc
public final class DarkModeManager: NSObject {
  private static var swizzlingConfigured = false

  @objc public static func setup(with configuration: DMEnvironmentConfiguration) {
    commonSetup(with: configuration)
  }

  @objc public static func register(with application: UIApplication, syncImmediately: Bool = false, animated: Bool = false) {
    DMTraitCollection.register(with: application, syncImmediately: syncImmediately, animated: animated)
  }
  ......
}