RMDateSelectionViewController icon indicating copy to clipboard operation
RMDateSelectionViewController copied to clipboard

Date Selector Doesn't handle iOS 13 dark mode

Open chris-hut opened this issue 5 years ago • 3 comments

Hello friend!

We've noticed that on iOS 13 with Dark Mode enabled, the selector is invisible: IMG_3737B3100AAE-1

I've gotten this to work for me by adding a:

if #available(iOS 13.0, *) {
    actionController.overrideUserInterfaceStyle = .light
}

Right before presenting calendar selector!

I also notice that I can't seem to set the style to anything dark, I was going to add a

if #available(iOS 13.0, *) {
  puts("!: we are 13")
  if self.webViewController?.traitCollection.userInterfaceStyle == .dark {
       puts("!: We are dark")
      style = RMActionControllerStyle.black
   }
}
// then initialize the actionController
let actionController: RMDateSelectionViewController = RMDateSelectionViewController(style: style)!

However, even hardcoding it to .black seems to make keep it white!

chris-hut avatar Oct 17 '19 22:10 chris-hut

Hi there!

The current master branch contains new styles for RMDateSelectionController, which automatically adapt to the current environment.

In addition, the master branch contains some bugfixes which are not yet available in the latest release.

Can you give the master branch a try to see if it improves the situation for you?

Best regards, Roland

CooperRS avatar Oct 18 '19 12:10 CooperRS

Hey Roland!

I tried both master and this commit directly https://github.com/CooperRS/RMDateSelectionViewController/commit/7d3d785221447e3e14277cad0fc1e4e00aaa5fd7, but didn't seem like in either way I was able to theme it black or have have the text show up in Dark mode.

var data = message.body as! Dictionary<String, AnyObject>
let date: Date

if let year = data["year"], let month = data["month"], let day = data["day"] {
    let dateFormatter = DateFormatter()
    dateFormatter.dateFormat = "yyyy,MM,dd"
    // Need to add 1 to month, since iOS wants months to start at 1 instead of 0
    date = dateFormatter.date(from: "\(year),\((month as! UInt) + 1),\(day)") ?? Date()
} else {
    // Fallback to today's date
    date = Date()
}

let selectAction = RMAction<UIDatePicker>(title: "Set Date", style: RMActionStyle.done) { controller in
    self.setDate(controller.contentView.date)

}

let cancelAction = RMAction(title: "Cancel", style: RMActionStyle.cancel) { _ in
    print("Date cancelled")
    self.webViewController?.queueDispatchableAction(DispatchableAction(action: "updateDate", payload: nil))
}


let actionController: RMDateSelectionViewController = RMDateSelectionViewController(style: RMActionControllerStyle.black)!

actionController.title = "Select a Date"

// Actions have to be added separately, opposed to in the constructor in order to stack them
actionController.addAction(selectAction! )
actionController.addAction(cancelAction! as! RMAction<UIDatePicker>)
actionController.disableBlurEffects = true
actionController.disableBouncingEffects = true

actionController.datePicker.date = date
actionController.datePicker.datePickerMode = UIDatePicker.Mode.date


self.webViewController!.present(actionController, animated: true, completion: nil)

Is how I'm trying to make it black!

Thanks,

Chris

chris-hut avatar Oct 18 '19 15:10 chris-hut

The key is that you can't set disableBlurEffects = YES, the default NO works well.

internalG avatar Feb 08 '20 03:02 internalG