Skip to content

Commit 1384c0a

Browse files
igor-signalmax-signal
authored andcommitted
Workaround for dysfunctional UIKeyboardLayoutGuide on iOS 15.
• bring back keyboard frame tracking to OWSViewController if running on iOS 15. • add our own layout guide to OWSViewController that is updated based on keyboard frame notifications on iOS 15; on newer iOS versions it's a proxy to view.keyboardLayoutGuide. • use OWSViewController.keyboardLayoutGuide where needed. • in media composer screen (not OWSVIewController subclass) we already track keyboard frame - use that to position bottom toolbar on iOS 15. I have also discovered that profile avatar editing screen was somewhat broken on older (15, 16) iOS versions. Fixed that here.
1 parent 5d8abf8 commit 1384c0a

22 files changed

+166
-24
lines changed

Signal/Registration/UserInterface/RegistrationPhoneNumberViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ class RegistrationPhoneNumberViewController: OWSViewController {
247247
cancelButton.translatesAutoresizingMaskIntoConstraints = false
248248
NSLayoutConstraint.activate([
249249
cancelButton.centerXAnchor.constraint(equalTo: view.centerXAnchor),
250-
cancelButton.bottomAnchor.constraint(equalTo: view.keyboardLayoutGuide.topAnchor, constant: -24),
250+
cancelButton.bottomAnchor.constraint(equalTo: keyboardLayoutGuide.topAnchor, constant: -24),
251251
])
252252

253253
render()

Signal/Registration/UserInterface/RegistrationPinViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ class RegistrationPinViewController: OWSViewController {
365365
scrollView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
366366
scrollView.leadingAnchor.constraint(equalTo: view.layoutMarginsGuide.leadingAnchor),
367367
scrollView.trailingAnchor.constraint(equalTo: view.layoutMarginsGuide.trailingAnchor),
368-
scrollView.bottomAnchor.constraint(equalTo: view.keyboardLayoutGuide.topAnchor),
368+
scrollView.bottomAnchor.constraint(equalTo: keyboardLayoutGuide.topAnchor),
369369
])
370370

371371
scrollView.addSubview(stackView)

Signal/Registration/UserInterface/RegistrationProfileViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ class RegistrationProfileViewController: OWSViewController {
263263
scrollView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
264264
scrollView.leadingAnchor.constraint(equalTo: view.layoutMarginsGuide.leadingAnchor),
265265
scrollView.trailingAnchor.constraint(equalTo: view.layoutMarginsGuide.trailingAnchor),
266-
scrollView.bottomAnchor.constraint(equalTo: view.keyboardLayoutGuide.topAnchor),
266+
scrollView.bottomAnchor.constraint(equalTo: keyboardLayoutGuide.topAnchor),
267267
])
268268

269269
let stackView = UIStackView()

Signal/Registration/UserInterface/RegistrationVerificationViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ class RegistrationVerificationViewController: OWSViewController {
259259
scrollView.topAnchor.constraint(equalTo: view.layoutMarginsGuide.topAnchor),
260260
scrollView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
261261
scrollView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
262-
scrollView.bottomAnchor.constraint(equalTo: view.keyboardLayoutGuide.topAnchor),
262+
scrollView.bottomAnchor.constraint(equalTo: keyboardLayoutGuide.topAnchor),
263263
])
264264

265265
let stackView = UIStackView()

Signal/Usernames/Selection/UsernameSelectionViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ class UsernameSelectionViewController: OWSViewController, OWSNavigationChildCont
317317
wrapperScrollView.topAnchor.constraint(equalTo: view.layoutMarginsGuide.topAnchor),
318318
wrapperScrollView.leadingAnchor.constraint(equalTo: view.layoutMarginsGuide.leadingAnchor),
319319
wrapperScrollView.trailingAnchor.constraint(equalTo: view.layoutMarginsGuide.trailingAnchor),
320-
wrapperScrollView.bottomAnchor.constraint(equalTo: view.keyboardLayoutGuide.topAnchor),
320+
wrapperScrollView.bottomAnchor.constraint(equalTo: keyboardLayoutGuide.topAnchor),
321321
])
322322

323323
let contentLayoutGuide = wrapperScrollView.contentLayoutGuide

Signal/src/ViewControllers/AppSettings/Payments/PaymentsRestoreWalletWordViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public class PaymentsRestoreWalletWordViewController: OWSViewController {
6565
rootView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
6666
rootView.leadingAnchor.constraint(equalTo: view.layoutMarginsGuide.leadingAnchor),
6767
rootView.trailingAnchor.constraint(equalTo: view.layoutMarginsGuide.trailingAnchor),
68-
rootView.bottomAnchor.constraint(equalTo: view.keyboardLayoutGuide.topAnchor),
68+
rootView.bottomAnchor.constraint(equalTo: keyboardLayoutGuide.topAnchor),
6969
])
7070

7171
updateContents()

Signal/src/ViewControllers/Avatars/AvatarEditViewController.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import SignalServiceKit
77
import SignalUI
88

9-
class AvatarEditViewController: OWSViewController {
9+
class AvatarEditViewController: OWSViewController, OWSNavigationChildController {
1010
private let originalModel: AvatarModel
1111
private var model: AvatarModel {
1212
didSet {
@@ -32,9 +32,15 @@ class AvatarEditViewController: OWSViewController {
3232
return UIDevice.current.isIPad ? .all : .portrait
3333
}
3434

35+
var preferredNavigationBarStyle: OWSNavigationBarStyle { .solid }
36+
37+
var navbarBackgroundColorOverride: UIColor? { UIColor.Signal.groupedBackground }
38+
3539
override func viewDidLoad() {
3640
super.viewDidLoad()
3741

42+
view.backgroundColor = UIColor.Signal.groupedBackground
43+
3844
updateNavigation()
3945
updateHeaderViewState()
4046
updateFooterViewState()
@@ -46,7 +52,7 @@ class AvatarEditViewController: OWSViewController {
4652
scrollView.frameLayoutGuide.topAnchor.constraint(equalTo: view.layoutMarginsGuide.topAnchor),
4753
scrollView.frameLayoutGuide.leadingAnchor.constraint(equalTo: view.readableContentGuide.leadingAnchor),
4854
scrollView.frameLayoutGuide.trailingAnchor.constraint(equalTo: view.readableContentGuide.trailingAnchor),
49-
scrollView.frameLayoutGuide.bottomAnchor.constraint(equalTo: view.keyboardLayoutGuide.topAnchor, constant: -8),
55+
scrollView.frameLayoutGuide.bottomAnchor.constraint(equalTo: keyboardLayoutGuide.topAnchor, constant: -8),
5056
])
5157

5258
scrollView.addSubview(topHeader)

Signal/src/ViewControllers/Donations/DonateViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class DonateViewController: OWSViewController, OWSNavigationChildController {
105105
scrollView.topAnchor.constraint(equalTo: view.topAnchor),
106106
scrollView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
107107
scrollView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
108-
scrollView.bottomAnchor.constraint(equalTo: view.keyboardLayoutGuide.topAnchor),
108+
scrollView.bottomAnchor.constraint(equalTo: keyboardLayoutGuide.topAnchor),
109109
])
110110

111111
NotificationCenter.default.addObserver(

Signal/src/ViewControllers/GifPicker/GifPickerViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
295295
bottomBanner.topAnchor.constraint(equalTo: bottomBannerContainer.topAnchor),
296296
bottomBanner.leadingAnchor.constraint(equalTo: bottomBannerContainer.leadingAnchor),
297297
bottomBanner.trailingAnchor.constraint(equalTo: bottomBannerContainer.trailingAnchor),
298-
bottomBanner.bottomAnchor.constraint(equalTo: view.keyboardLayoutGuide.topAnchor),
298+
bottomBanner.bottomAnchor.constraint(equalTo: keyboardLayoutGuide.topAnchor),
299299
])
300300

301301
// The Giphy API requires us to "show their trademark prominently" in our GIF experience.

Signal/src/ViewControllers/HomeView/Stories/Replies & Views Sheets/Group Reply Sheet/StoryGroupReplyViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class StoryGroupReplyViewController: OWSViewController, StoryReplySheet {
8989
bottomBar.topAnchor.constraint(equalTo: tableView.bottomAnchor),
9090
bottomBar.leadingAnchor.constraint(equalTo: view.leadingAnchor),
9191
bottomBar.trailingAnchor.constraint(equalTo: view.trailingAnchor),
92-
bottomBar.bottomAnchor.constraint(equalTo: view.keyboardLayoutGuide.topAnchor),
92+
bottomBar.bottomAnchor.constraint(equalTo: keyboardLayoutGuide.topAnchor),
9393
])
9494
// Its a bit silly but this is the easiest way to capture touches
9595
// and not let them pass up to any parent scrollviews. pans inside the

0 commit comments

Comments
 (0)