Adopt theme in newly created windows automatically #81
Conversation
Let's break down the task into pieces. This PR is ready now. @zhuorantan @li-bei do you have the bandwidth to review this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Good job
window?.makeKeyAndVisible() | ||
|
||
return true | ||
} | ||
|
||
class func createNewWindow(with window: UIWindow) -> UIWindow { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: should we use static
? Which should we prefer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes little difference here, but probably static is preferred because static
func cannot be overridden in subclass whereas class
func can
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, it would be better to choose static
over class
whenever possible. I think Swift prefers static
. There might be a best practice for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's go ahead with static here.
use static func wherever possible
We observe UIWindowDidBecomeVisibleNotification notification, and apply theme to the window, since it is possible to just create a UIWindow and make it key/visible without using UIScene API.
The example app is also updated with multi-window support on iPad.