-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix FXIOS-9174 [Multi-window] Fix theme bugs (#20373)
* [9174] Fix several bugs with theme changes across multiple iPad windows. * [9174] Comment * [9174] Minor cleanup for readability * Fix missing import * [9174] Cleanup * [9174] Cleanup and comments * [9174] Comments
- Loading branch information
1 parent
d75cea1
commit f97204a
Showing
8 changed files
with
69 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
firefox-ios/Client/Extensions/UIView+ThemeUUIDIdentifiable.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/ | ||
|
||
import UIKit | ||
import Common | ||
import Shared | ||
|
||
extension UIView: ThemeUUIDIdentifiable { | ||
/// Convenience that allows most UIViews to automatically reference their parent window UUID. | ||
/// If the view is installed in a view hierarchy that is part of a window, or is a type | ||
/// that has its UUID injected, this returns the window UUID. If not, returns nil. | ||
public var currentWindowUUID: WindowUUID? { | ||
// If the view has opted in to InjectedThemeUUIDIdentifiable, we prefer that UUID | ||
// since it is injected and should always be correct even if the view isn't installed | ||
// in a window or view hierarchy. | ||
if let injectedUUID = (self as? InjectedThemeUUIDIdentifiable)?.windowUUID { | ||
return injectedUUID | ||
} | ||
|
||
// Edge-case: if the view is a UITableView, allow delegates to opt-in to InjectedThemeUUIDIdentifiable. | ||
if let tableView = self as? UITableView, | ||
let uuidProvider = tableView.delegate as? InjectedThemeUUIDIdentifiable { | ||
return uuidProvider.windowUUID | ||
} | ||
|
||
// Finally, for most views, we can simply return the associated UUID of the window the | ||
// view is installed in. This covers 99% of use cases, however care needs to be used with | ||
// UI that is not always inserted into a view hierarchy. In those situations, the view | ||
// can opt-in to `InjectedThemeUUIDIdentifiable`. | ||
return (self.window as? BrowserWindow)?.uuid | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters