Skip to content

Commit

Permalink
- iOS 18 updates for iPad and Mac to prevent tabBar from switching to…
Browse files Browse the repository at this point in the history
… new mode

- disable sentry logging sigterm's
- bug fix discover section display on macs, need to read scene size instead of monitor size
- bug fix scan view controller on mac
- prevent screen from auto locking while waiting for a payload sign
  • Loading branch information
simonmcl committed Nov 4, 2024
1 parent 54e0677 commit e4c1b8d
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Kukai Mobile.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2814,7 +2814,7 @@
repositoryURL = "https://github.com/getsentry/sentry-cocoa";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 8.26.0;
minimumVersion = 8.39.0;
};
};
C0CB9C1F2A4C512C000E12FA /* XCRemoteSwiftPackageReference "keychain-swift" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/getsentry/sentry-cocoa",
"state" : {
"revision" : "7fc7ca43967e2980d8691a8e017c118a84133aac",
"version" : "8.26.0"
"revision" : "0b8ba88f5fd70062887d55f87a970c59b1ceebcf",
"version" : "8.39.0"
}
},
{
Expand Down
1 change: 1 addition & 0 deletions Kukai Mobile/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
SentrySDK.start { options in
options.dsn = "https://[email protected]/4505443257024512"
options.enableWatchdogTerminationTracking = false
options.enableSigtermReporting = false
options.beforeSend = { (event) -> Event? in

// Scrub any identifiable data to keep users anonymous
Expand Down
9 changes: 9 additions & 0 deletions Kukai Mobile/Controls/ScanViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class ScanViewController: UIViewController, AVCaptureMetadataOutputObjectsDelega
let blurEffectMaskLayer = CAShapeLayer()
let transparentView = UIView()
let modalBackButton = CustomisableButton()
private var isOnMac = ProcessInfo.processInfo.isiOSAppOnMac

public var withTextField: Bool = false
let textfield = ValidatorTextField()
Expand All @@ -42,6 +43,10 @@ class ScanViewController: UIViewController, AVCaptureMetadataOutputObjectsDelega
super.viewDidLoad()
GradientView.add(toView: self.view, withType: .fullScreenBackground)

if UIDevice.current.userInterfaceIdiom == .pad {
self.preferredContentSize = CGSize(width: 400, height: 600)
}

setupNav()
setupPreviewView()
setupClearBox()
Expand All @@ -53,6 +58,8 @@ class ScanViewController: UIViewController, AVCaptureMetadataOutputObjectsDelega

textfield.text = nil

guard !isOnMac else { return }

let status = AVCaptureDevice.authorizationStatus(for: .video)
if status == .authorized {
setupCaptureSession()
Expand Down Expand Up @@ -231,6 +238,8 @@ class ScanViewController: UIViewController, AVCaptureMetadataOutputObjectsDelega
textfield.topAnchor.constraint(equalTo: self.previewContainerView.bottomAnchor, constant: 24),
textfield.heightAnchor.constraint(equalToConstant: 36),

textfield.bottomAnchor.constraint(equalTo: self.scrollView.bottomAnchor, constant: -24),

pasteButton.trailingAnchor.constraint(equalTo: scrollView.trailingAnchor, constant: -16),
pasteButton.centerYAnchor.constraint(equalTo: self.textfield.centerYAnchor, constant: 0),
pasteButton.widthAnchor.constraint(equalToConstant: 36),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class WalletConnectSignViewController: UIViewController, BottomSheetCustomFixedP

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
UIApplication.shared.isIdleTimerDisabled = true

// Monitor connection
Networking.instance.socketConnectionStatusPublisher.sink { [weak self] status in
Expand Down Expand Up @@ -108,6 +109,7 @@ class WalletConnectSignViewController: UIViewController, BottomSheetCustomFixedP

override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
UIApplication.shared.isIdleTimerDisabled = false

if !didSend {
handleRejection(andDismiss: false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DiscoverFeaturedCell: UITableViewCell {

private var discoverGroup: DiscoverGroup = DiscoverGroup(id: UUID(), title: "", items: [])
private var timer: Timer? = nil
private let pageWidth: CGFloat = UIScreen.main.bounds.width
private var pageWidth: CGFloat = 0
private var pageHeight: CGFloat = 0
private var customAspectRatioLogicHasBeenRun = false
private static let estimatedTextHeight: CGFloat = 40
Expand All @@ -47,8 +47,8 @@ class DiscoverFeaturedCell: UITableViewCell {
This cell has very custom aspect ratio sizing business logic, that can't be done via interface builder.
Also couldn't find an easy way to calcualte the actual sizes of other ocmponents, for now just hardcode to known values, can revisit late rif it becomes an issue
*/
static func featuredCellCustomHeight() -> CGFloat {
let screenWidth = UIScreen.main.bounds.width
static func featuredCellCustomHeight(currentWindowBounds: CGRect) -> CGFloat {
let screenWidth = currentWindowBounds.width
let newHeight = Decimal(screenWidth/DiscoverFeaturedCell.customAspectRatio).rounded(scale: 0, roundingMode: .up).intValue()
return CGFloat(newHeight) + DiscoverFeaturedCell.estimatedTextHeight + DiscoverFeaturedCell.estimatedPageControlSize
}
Expand All @@ -57,6 +57,8 @@ class DiscoverFeaturedCell: UITableViewCell {
if !customAspectRatioLogicHasBeenRun {
customAspectRatioLogicHasBeenRun = true

pageWidth = self.parentViewController()?.view.window?.windowScene?.keyWindow?.bounds.width ?? 0

let newHeight = Decimal(pageWidth/DiscoverFeaturedCell.customAspectRatio).rounded(scale: 0, roundingMode: .up).intValue()
pageHeight = CGFloat(newHeight)
(self.collectionView.collectionViewLayout as? UICollectionViewFlowLayout)?.itemSize = CGSize(width: pageWidth, height: pageHeight + DiscoverFeaturedCell.estimatedTextHeight)
Expand Down
3 changes: 2 additions & 1 deletion Kukai Mobile/Modules/Discover/DiscoverViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ class DiscoverViewController: UIViewController, UITableViewDelegate, DiscoverFea

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if indexPath.section == 0 && indexPath.row == (DependencyManager.shared.currentNetworkType == .mainnet ? 1 : 2) {
return DiscoverFeaturedCell.featuredCellCustomHeight()
let currentWindowBounds = self.view.window?.windowScene?.keyWindow?.bounds
return DiscoverFeaturedCell.featuredCellCustomHeight(currentWindowBounds: currentWindowBounds ?? CGRect.zero)
} else {
return UITableView.automaticDimension
}
Expand Down
17 changes: 17 additions & 0 deletions Kukai Mobile/Modules/Home/HomeTabBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class HomeTabBarController: UITabBarController, UITabBarControllerDelegat

public var sideMenuTintView = UIView(frame: CGRect(x: 0, y: 0, width: 1, height: 1))


public override func viewDidLoad() {
super.viewDidLoad()
self.setupAppearence()
Expand Down Expand Up @@ -226,6 +227,22 @@ public class HomeTabBarController: UITabBarController, UITabBarControllerDelegat
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

if #available(iOS 18.0, *), UIDevice.current.userInterfaceIdiom == .pad {

// Both iPad and Mac, as mac is running "Designed for iPad"
traitOverrides.horizontalSizeClass = .unspecified


if ProcessInfo.processInfo.isiOSAppOnMac {
/// Fix for macOS Sequoia: without it, the tabs
/// appear twice and the view crashes regularly.

/// Hides the top tabs
self.mode = .tabSidebar
self.sidebar.isHidden = true
}
}

self.navigationController?.setNavigationBarHidden(false, animated: false)
self.navigationItem.hidesBackButton = true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class SendAbstractConfirmViewController: UIViewController {

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
UIApplication.shared.isIdleTimerDisabled = true

// Monitor connection
if isWalletConnectOp {
Expand Down Expand Up @@ -85,6 +86,7 @@ class SendAbstractConfirmViewController: UIViewController {

override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
UIApplication.shared.isIdleTimerDisabled = false

if !didSend && isWalletConnectOp {
handleRejection(andDismiss: false)
Expand Down

0 comments on commit e4c1b8d

Please sign in to comment.