-
Notifications
You must be signed in to change notification settings - Fork 24
fix: support iOS 26 #764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
fix: support iOS 26 #764
Changes from 8 commits
20cb477
19a5d88
c268c59
ca983d8
b5ae4eb
405dfc9
cfef5e1
f870628
a7d6776
3031917
37ebbca
c85a865
c57de5e
a74a184
b12f1c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,10 +29,6 @@ private enum MainTabbarTabs: Int, CaseIterable { | |
| } | ||
|
|
||
| extension MainTabbarTabs { | ||
| var isEmpty: Bool { | ||
| self == .payment | ||
| } | ||
|
|
||
| var icon: UIImage { | ||
| let name: String | ||
|
|
||
|
|
@@ -42,7 +38,7 @@ extension MainTabbarTabs { | |
| case .contacts: | ||
| name = "tabbar_contacts_icon" | ||
| case .payment: | ||
| return UIImage() | ||
| name = "tabbar_pay_button" | ||
| case .explore: | ||
| name = "tabbar_discover_icon" | ||
| case .more: | ||
|
|
@@ -51,7 +47,7 @@ extension MainTabbarTabs { | |
|
|
||
| return UIImage(named: name)!.withRenderingMode(.alwaysOriginal) | ||
| } | ||
|
|
||
| var selectedIcon: UIImage { | ||
| let name: String | ||
|
|
||
|
|
@@ -61,7 +57,7 @@ extension MainTabbarTabs { | |
| case .contacts: | ||
| name = "tabbar_contacts_selected" | ||
| case .payment: | ||
| return UIImage() | ||
| name = "tabbar_pay_button" | ||
| case .explore: | ||
| name = "tabbar_discover_selected" | ||
| case .more: | ||
|
|
@@ -84,7 +80,7 @@ class MainTabbarController: UITabBarController { | |
|
|
||
| weak var homeController: HomeViewController? | ||
| weak var menuNavigationController: MainMenuViewController? | ||
|
|
||
| #if DASHPAY | ||
| weak var contactsNavigationController: DWRootContactsViewController? | ||
| weak var exploreNavigationController: ExploreViewController? | ||
|
|
@@ -94,7 +90,7 @@ class MainTabbarController: UITabBarController { | |
| @objc | ||
| weak var wipeDelegate: DWWipeDelegate? | ||
|
|
||
| private var paymentButton: PaymentButton! | ||
| private var paymentIsOpened = false | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Check if paymentIsOpened is read anywhere in the codebase
rg -n 'paymentIsOpened' --type swift -C2Repository: dashpay/dashwallet-ios Length of output: 1829 Remove the unused This property is assigned in 🤖 Prompt for AI Agents |
||
|
|
||
| @objc | ||
| var isDemoMode = false | ||
|
|
@@ -105,7 +101,7 @@ class MainTabbarController: UITabBarController { | |
| // TODO: Move it out from here and initialize the model inside home view controller | ||
| @objc | ||
| var homeModel: DWHomeProtocol! | ||
|
|
||
| #if DASHPAY | ||
| // TODO: MOCK_DASHPAY remove when not mocked | ||
| private var blockchainIdentity: DSBlockchainIdentity? { | ||
|
|
@@ -146,35 +142,15 @@ class MainTabbarController: UITabBarController { | |
| fatalError("init(coder:) has not been implemented") | ||
| } | ||
|
|
||
| // MARK: Actions | ||
|
|
||
| @objc | ||
| private func paymentButtonAction() { | ||
| showPaymentsController(withActivePage: .none) | ||
| } | ||
|
|
||
| // MARK: Life Cycle | ||
|
|
||
| override func viewDidLayoutSubviews() { | ||
| super.viewDidLayoutSubviews() | ||
|
|
||
| tabBar.addSubview(paymentButton) | ||
| } | ||
|
|
||
| override func viewDidLoad() { | ||
| super.viewDidLoad() | ||
|
|
||
| delegate = self | ||
| configureHierarchy() | ||
| tabBar.barTintColor = .dw_background() | ||
| setupRatesErrorHandling() | ||
| } | ||
|
|
||
| override func viewDidAppear(_ animated: Bool) { | ||
| super.viewDidAppear(animated) | ||
|
|
||
| // Add Payment Button again to make sure it's at the top | ||
| tabBar.addSubview(paymentButton) | ||
| } | ||
| } | ||
|
|
||
| // MARK: - Private | ||
|
|
@@ -212,13 +188,15 @@ extension MainTabbarController { | |
| } | ||
| #endif | ||
|
|
||
| // Payment | ||
| item = UITabBarItem(title: "", image: UIImage(), tag: 2) | ||
| // Payment (tapping this tab opens the payment modal instead of switching tabs) | ||
| let paymentImage = Self.makePaymentTabImage() | ||
| item = UITabBarItem(title: nil, image: paymentImage, selectedImage: paymentImage) | ||
| item.imageInsets = UIEdgeInsets(top: 6, left: 0, bottom: -6, right: 0) | ||
| item.accessibilityIdentifier = "tabbar_payments_button" | ||
|
|
||
| let vc = EmptyController() | ||
| vc.tabBarItem = item | ||
| viewControllers.append(vc) | ||
| let paymentVC = EmptyController() | ||
| paymentVC.tabBarItem = item | ||
| viewControllers.append(paymentVC) | ||
|
|
||
| #if DASHPAY | ||
| if identity != nil { | ||
|
|
@@ -256,25 +234,30 @@ extension MainTabbarController { | |
| self.viewControllers = viewControllers | ||
| } | ||
|
|
||
| private func configureHierarchy() { | ||
| paymentButton = PaymentButton() | ||
| paymentButton.translatesAutoresizingMaskIntoConstraints = false | ||
| paymentButton.addTarget(self, action: #selector(paymentButtonAction), for: .touchUpInside) | ||
| tabBar.addSubview(paymentButton) | ||
| /// Creates a tab bar image with a blue circle background and the payment icon centered on top. | ||
| private static func makePaymentTabImage() -> UIImage { | ||
| let size: CGFloat = 47 | ||
| let rect = CGRect(x: 0, y: 0, width: size, height: size) | ||
|
|
||
| NSLayoutConstraint.activate([ | ||
| paymentButton.centerXAnchor.constraint(equalTo: tabBar.centerXAnchor), | ||
| paymentButton.topAnchor.constraint(equalTo: tabBar.topAnchor, constant: UIDevice.hasHomeIndicator ? 4 : 1), | ||
| let renderer = UIGraphicsImageRenderer(size: rect.size) | ||
| let image = renderer.image { context in | ||
| // Draw blue circle background | ||
| UIColor.dw_dashBlue().setFill() | ||
| UIBezierPath(ovalIn: rect).fill() | ||
|
|
||
| paymentButton.widthAnchor.constraint(equalToConstant: PaymentButton.kCenterCircleSize), | ||
| paymentButton.heightAnchor.constraint(equalToConstant: PaymentButton.kCenterCircleSize), | ||
| ]) | ||
| // Draw icon centered | ||
| if let icon = UIImage(named: "tabbar_pay_button") { | ||
| let iconSize = CGSize(width: 22, height: 22) | ||
| let iconOrigin = CGPoint(x: (size - iconSize.width) / 2, y: (size - iconSize.height) / 2) | ||
| icon.draw(in: CGRect(origin: iconOrigin, size: iconSize)) | ||
| } | ||
| } | ||
|
|
||
| tabBar.barTintColor = .dw_background() | ||
| return image.withRenderingMode(.alwaysOriginal) | ||
| } | ||
|
|
||
| private func closePayments(completion: (() -> Void)? = nil) { | ||
| paymentButton.isOpened = false | ||
| paymentIsOpened = false | ||
|
|
||
| guard let top = selectedViewController?.topController(), | ||
| top != selectedViewController | ||
|
|
@@ -378,7 +361,7 @@ extension MainTabbarController: PaymentsViewControllerDelegate { | |
| } | ||
|
|
||
| func paymentsViewControllerWantsToImportPrivateKey(_ controller: PaymentsViewController) { | ||
| paymentButton.isOpened = false | ||
| paymentIsOpened = false | ||
|
|
||
| controller.dismiss(animated: true) { | ||
| self.performScanQRCodeAction() | ||
|
|
@@ -398,7 +381,7 @@ extension MainTabbarController: HomeViewControllerDelegate { | |
| } | ||
|
|
||
| func showPaymentsController(withActivePage pageIndex: PaymentsViewControllerState) { | ||
| paymentButton.isOpened = true | ||
| paymentIsOpened = true | ||
|
|
||
| let receiveModel = DWReceiveModel() | ||
| let payModel = DWPayModel() | ||
|
|
@@ -427,7 +410,12 @@ extension MainTabbarController: HomeViewControllerDelegate { | |
|
|
||
| extension MainTabbarController: UITabBarControllerDelegate { | ||
| func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool { | ||
| !(viewController is EmptyController) | ||
| if viewController is EmptyController { | ||
| // Intercept the payment tab tap — show the payment modal instead of switching tabs | ||
| showPaymentsController(withActivePage: .none) | ||
| return false | ||
| } | ||
| return true | ||
| } | ||
| } | ||
|
|
||
|
|
||
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.
Fix trailing newline lint warning.
SwiftLint reports the file ending does not satisfy the single trailing newline rule.
✂️ Minimal formatting fix
As per coding guidelines:
**/*.swift: Use SwiftFormat and SwiftLint for Swift code formatting and linting as configured in.swiftformatand.swiftlint.ymlfiles.📝 Committable suggestion
🧰 Tools
🪛 SwiftLint (0.63.2)
[Warning] 325-325: Files should have a single trailing newline
(trailing_newline)
🤖 Prompt for AI Agents