Skip to content

Commit

Permalink
Merge branch 'chore/remove-main-storyboard-WPB-9727' into chore/use-u…
Browse files Browse the repository at this point in the history
…isplitviewcontroller-WPB-9727
  • Loading branch information
caldrian committed Aug 15, 2024
2 parents c0690a3 + a366caf commit 696ec85
Show file tree
Hide file tree
Showing 21 changed files with 31 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final class CharacterInputFieldSnapshotTests: XCTestCase {
private var sut: CharacterInputField! = nil

private var rootViewController: UIViewController! {
(UIApplication.shared.delegate as? AppDelegate)?.keyWindow?.rootViewController
(UIApplication.shared.delegate as? AppDelegate)?.mainWindow?.rootViewController
}

override func setUp() {
Expand Down
2 changes: 1 addition & 1 deletion wire-ios/Wire-iOS Tests/CharacterInputFieldTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ final class CharacterInputFieldTests: XCTestCase {
private var delegate: TestCharacterInputFieldDelegate! = nil

private var rootViewController: UIViewController! {
(UIApplication.shared.delegate as? AppDelegate)?.keyWindow?.rootViewController
(UIApplication.shared.delegate as? AppDelegate)?.mainWindow?.rootViewController
}

override func setUp() {
Expand Down
4 changes: 2 additions & 2 deletions wire-ios/Wire-iOS Tests/MessagePresenterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ final class MessagePresenterTests: XCTestCase {
var userSession: UserSessionMock!

private var rootViewController: UIViewController! {
get { (UIApplication.shared.delegate as? AppDelegate)?.keyWindow?.rootViewController }
set { (UIApplication.shared.delegate as? AppDelegate)?.keyWindow?.rootViewController = newValue }
get { (UIApplication.shared.delegate as? AppDelegate)?.mainWindow?.rootViewController }
set { (UIApplication.shared.delegate as? AppDelegate)?.mainWindow?.rootViewController = newValue }
}

override func setUp() {
Expand Down
8 changes: 4 additions & 4 deletions wire-ios/Wire-iOS/Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {
// MARK: - Public Set Property

// TODO: [WPB-8778] make private [not private(set)]
/*private*/ private(set) var keyWindow: UIWindow!
/*private*/ private(set) var mainWindow: UIWindow!

// Singletons
var unauthenticatedSession: UnauthenticatedSession? {
Expand All @@ -82,7 +82,7 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {

var launchOptions: LaunchOptions = [:]

// TODO: [WPB-8778] remove, don't access anything regarding UIApplication, delegate, windows etc., but inject whatever is needed instead
// TODO: [WPB-8778] remove this property
@available(*, deprecated, message: "Will be removed")
static var shared: AppDelegate {
return UIApplication.shared.delegate as! AppDelegate
Expand Down Expand Up @@ -113,7 +113,7 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {
guard application.connectedScenes.count == 1, let windowScene = application.connectedScenes.first as? UIWindowScene else {
fatalError("Expected a single scene of type `UIWindowScene`")
}
keyWindow = .init(windowScene: windowScene)
mainWindow = .init(windowScene: windowScene)

// enable logs
_ = Settings.shared
Expand Down Expand Up @@ -335,7 +335,7 @@ private extension AppDelegate {
}

appRootRouter = AppRootRouter(
windowScene: keyWindow.windowScene!,
windowScene: mainWindow.windowScene!,
sessionManager: sessionManager,
appStateCalculator: appStateCalculator
)
Expand Down
2 changes: 1 addition & 1 deletion wire-ios/Wire-iOS/Sources/AppRootRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ extension AppRootRouter: ApplicationStateObserving {
if let size {
screenCurtain.frame.size = size
} else {
screenCurtain.frame = AppDelegate.shared.keyWindow?.frame ?? UIScreen.main.bounds
screenCurtain.frame = AppDelegate.shared.mainWindow?.frame ?? UIScreen.main.bounds
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ extension ResponderContainer: TextContainer where Child: TextContainer {

extension VerificationCodeFieldDescription: ViewDescriptor {
func create() -> UIView {
// Get the with from keyWindow for iPad non full screen modes.
let window = AppDelegate.shared.keyWindow
// Get the with from window for iPad non full screen modes.
let window = AppDelegate.shared.mainWindow
let width = window?.frame.width ?? UIScreen.main.bounds.size.width
let size = CGSize(width: width, height: AuthenticationStepController.mainViewHeight)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ extension UIAlertController {

UIAlertController.newsletterSubscriptionDialogWasDisplayed = true
viewController.present(alertController, animated: true) {
AppDelegate.shared.keyWindow?.endEditing(true)
AppDelegate.shared.mainWindow?.endEditing(true)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ final class DeveloperDebugActionsViewModel: ObservableObject {

private func sendDebugLogs() {

var presentingViewController = AppDelegate.shared.keyWindow!.rootViewController!
var presentingViewController = AppDelegate.shared.mainWindow!.rootViewController!
while let presentedViewController = presentingViewController.presentedViewController {
presentingViewController = presentedViewController
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ extension UIApplication: ApplicationProtocol {
(currentResponder as? UIView)?.endEditing(true)

let alert = UIAlertController.cameraPermissionAlert(completion: completion)
AppDelegate.shared.keyWindow.rootViewController?.present(alert, animated: true)
AppDelegate.shared.mainWindow.rootViewController?.present(alert, animated: true)
}

private class func wr_warnAboutMicrophonePermission() {
let alert = UIAlertController.microphonePermissionAlert
AppDelegate.shared.keyWindow.rootViewController?.present(alert, animated: true)
AppDelegate.shared.mainWindow.rootViewController?.present(alert, animated: true)
}

private class func wr_warnAboutPhotoLibraryRestricted() {
Expand All @@ -108,11 +108,11 @@ extension UIApplication: ApplicationProtocol {
style: .cancel
))

AppDelegate.shared.keyWindow.rootViewController?.present(alert, animated: true)
AppDelegate.shared.mainWindow.rootViewController?.present(alert, animated: true)
}

private class func wr_warnAboutPhotoLibaryDenied() {
let alert = UIAlertController.photoLibraryPermissionAlert
AppDelegate.shared.keyWindow.rootViewController?.present(alert, animated: true)
AppDelegate.shared.mainWindow.rootViewController?.present(alert, animated: true)
}
}
6 changes: 3 additions & 3 deletions wire-ios/Wire-iOS/Sources/Helpers/UIScreen+SafeArea.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ extension UIScreen {
@available(*, deprecated, message: "Use `safeAreaInsets` of UIView.")
static var safeArea: UIEdgeInsets {
if hasNotch {
return AppDelegate.shared.keyWindow.safeAreaInsets
return AppDelegate.shared.mainWindow.safeAreaInsets
}
return UIEdgeInsets(top: 20.0, left: 0.0, bottom: 0.0, right: 0.0)
}

@available(*, deprecated, message: "Will be removed")
static var hasBottomInset: Bool {
guard let window = AppDelegate.shared.keyWindow else { return false }
guard let window = AppDelegate.shared.mainWindow else { return false }
let insets = window.safeAreaInsets

return insets.bottom > 0
Expand All @@ -42,7 +42,7 @@ extension UIScreen {
static var hasNotch: Bool {
// On iOS12 insets.top == 20 on device without notch.
// insets.top == 44 on device with notch.
guard let window = AppDelegate.shared.keyWindow else { return false }
guard let window = AppDelegate.shared.mainWindow else { return false }
let insets = window.safeAreaInsets

return insets.top > 20 || insets.bottom > 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ extension UITraitEnvironment {
return conversationHorizontalMargins()
}

func conversationHorizontalMargins(windowWidth: CGFloat? = AppDelegate.shared.keyWindow?.frame.width) -> HorizontalMargins {
func conversationHorizontalMargins(windowWidth: CGFloat? = AppDelegate.shared.mainWindow?.frame.width) -> HorizontalMargins {

let userInterfaceSizeClass: UIUserInterfaceSizeClass

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ extension ZMConversation {
style: .cancel
))

AppDelegate.shared.keyWindow.rootViewController?.present(alert, animated: true)
AppDelegate.shared.mainWindow.rootViewController?.present(alert, animated: true)

return true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ extension BlockerViewController {
private func enrollCertificate() async throws {
guard
let activeUserSession = sessionManager?.activeUserSession,
let rootViewController = AppDelegate.shared.keyWindow.rootViewController
let rootViewController = AppDelegate.shared.mainWindow.rootViewController
else {
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ extension UIDevice {
if orientation.isPortrait || orientation.isLandscape {
return orientation
}
guard let interfaceOrientation = AppDelegate.shared.keyWindow?.windowScene?.interfaceOrientation else {
guard let interfaceOrientation = AppDelegate.shared.mainWindow?.windowScene?.interfaceOrientation else {
return .portrait
}
return interfaceOrientation.isLandscape ? .landscapeLeft : .portrait
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ final class SavableImage: NSObject {
style: .cancel
))

AppDelegate.shared.keyWindow.rootViewController?.present(alert, animated: true)
AppDelegate.shared.mainWindow.rootViewController?.present(alert, animated: true)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ final class AudioRecordKeyboardViewController: UIViewController, AudioRecordBase
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
recorder.stopRecording()
if isAppLockActive { AppDelegate.shared.keyWindow?.endEditing(true) }
if isAppLockActive { AppDelegate.shared.mainWindow?.endEditing(true) }
}

// MARK: - View Configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ final class AssetCell: UICollectionViewCell {
return
}

guard let keyWindow = AppDelegate.shared.keyWindow else { return }
guard let keyWindow = AppDelegate.shared.mainWindow else { return }
let maxDimensionRetina = max(bounds.size.width, bounds.size.height) * (window ?? keyWindow).screen.scale

representedAssetIdentifier = asset.localIdentifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ extension ConversationInputBarViewController: WireCallCenterCallStateObserver {
let rightViewController = splitViewController.rightViewController,
splitViewController.isRightViewControllerRevealed,
rightViewController.isVisible,
AppDelegate.shared.keyWindow.isKeyWindow
AppDelegate.shared.mainWindow.isKeyWindow
else { return }

self.wasRecordingBeforeCall = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ final class PasscodeSetupViewController: UIViewController {
self.context = context

self.useCompactLayout = useCompactLayout ??
(AppDelegate.shared.keyWindow.frame.height <= CGFloat.iPhone4Inch.height)
(AppDelegate.shared.mainWindow.frame.height <= CGFloat.iPhone4Inch.height)

super.init(nibName: nil, bundle: nil)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ extension UIApplication {

@available(*, deprecated, message: "Don't use this property!")
static var userInterfaceStyle: UIUserInterfaceStyle? {
AppDelegate.shared.keyWindow?.rootViewController?.traitCollection.userInterfaceStyle
AppDelegate.shared.mainWindow?.rootViewController?.traitCollection.userInterfaceStyle
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ extension ZClientViewController: UserObserving {

func userDidChange(_ changeInfo: UserChangeInfo) {
if changeInfo.accentColorValueChanged {
AppDelegate.shared.keyWindow?.tintColor = UIColor.accent()
AppDelegate.shared.mainWindow?.tintColor = UIColor.accent()
}
}

Expand Down

0 comments on commit 696ec85

Please sign in to comment.