From 79631a9646c38dc091dd87f56c00d5280f7abdd5 Mon Sep 17 00:00:00 2001 From: Andrei Ashikhmin Date: Wed, 16 Oct 2024 19:05:10 +0700 Subject: [PATCH] feat: mixing warning on the contacts screen --- DashWallet.xcodeproj/project.pbxproj | 19 +- .../ContactsPlaceholderViewController.swift | 165 ++++++++++++++++++ .../DWContactsPlaceholderViewController.h | 36 ---- .../DWContactsPlaceholderViewController.m | 125 ------------- .../Contacts/DWRootContactsViewController.m | 2 +- .../RootEditProfileViewController.swift | 4 +- 6 files changed, 177 insertions(+), 174 deletions(-) create mode 100644 DashWallet/Sources/UI/DashPay/Contacts/ContactsPlaceholderViewController.swift delete mode 100644 DashWallet/Sources/UI/DashPay/Contacts/DWContactsPlaceholderViewController.h delete mode 100644 DashWallet/Sources/UI/DashPay/Contacts/DWContactsPlaceholderViewController.m diff --git a/DashWallet.xcodeproj/project.pbxproj b/DashWallet.xcodeproj/project.pbxproj index ddb076636..2a0877507 100644 --- a/DashWallet.xcodeproj/project.pbxproj +++ b/DashWallet.xcodeproj/project.pbxproj @@ -678,6 +678,7 @@ 75EBAA2A2BBBE385004488E3 /* ZenLedgerViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75EBAA282BBBE385004488E3 /* ZenLedgerViewModel.swift */; }; 75EE38D32CBE9EFC00845FFF /* MainMenuContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75EE38D22CBE9EFC00845FFF /* MainMenuContentView.swift */; }; 75EE38D42CBE9EFC00845FFF /* MainMenuContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75EE38D22CBE9EFC00845FFF /* MainMenuContentView.swift */; }; + 75EE38D82CBFE52E00845FFF /* ContactsPlaceholderViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75EE38D72CBFE52B00845FFF /* ContactsPlaceholderViewController.swift */; }; 75F3F00D2C48F819004470EA /* RootEditProfileViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 759063EC2C42687F002F2AA9 /* RootEditProfileViewController.swift */; }; 75F51AAD2ABD8C800057B499 /* IntegrationViewController+Uphold.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F51AAC2ABD8C800057B499 /* IntegrationViewController+Uphold.swift */; }; 75F51AAF2ABD8D070057B499 /* IntegrationViewController+Coinbase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F51AAE2ABD8D070057B499 /* IntegrationViewController+Coinbase.swift */; }; @@ -771,7 +772,6 @@ C943B3462A409FFA00AF23C5 /* DWDPAvatarView.m in Sources */ = {isa = PBXBuildFile; fileRef = C943B3442A409FFA00AF23C5 /* DWDPAvatarView.m */; }; C943B34D2A40A4C500AF23C5 /* DWInfoPopupViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C943B34A2A40A4C500AF23C5 /* DWInfoPopupViewController.m */; }; C943B34E2A40A4C500AF23C5 /* DWInfoPopupContentView.m in Sources */ = {isa = PBXBuildFile; fileRef = C943B34B2A40A4C500AF23C5 /* DWInfoPopupContentView.m */; }; - C943B4AB2A40A54600AF23C5 /* DWContactsPlaceholderViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C943B3522A40A54500AF23C5 /* DWContactsPlaceholderViewController.m */; }; C943B4AC2A40A54600AF23C5 /* DWContactsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C943B3542A40A54500AF23C5 /* DWContactsViewController.m */; }; C943B4AD2A40A54600AF23C5 /* DWBaseContactsContentViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C943B3552A40A54500AF23C5 /* DWBaseContactsContentViewController.m */; }; C943B4AE2A40A54600AF23C5 /* DWNoContactsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C943B3572A40A54500AF23C5 /* DWNoContactsViewController.m */; }; @@ -2536,6 +2536,7 @@ 75EBAA282BBBE385004488E3 /* ZenLedgerViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZenLedgerViewModel.swift; sourceTree = ""; }; 75EDC78DE1686E55AE12233C /* Pods-DashWalletScreenshotsUITests.testnet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DashWalletScreenshotsUITests.testnet.xcconfig"; path = "Pods/Target Support Files/Pods-DashWalletScreenshotsUITests/Pods-DashWalletScreenshotsUITests.testnet.xcconfig"; sourceTree = ""; }; 75EE38D22CBE9EFC00845FFF /* MainMenuContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainMenuContentView.swift; sourceTree = ""; }; + 75EE38D72CBFE52B00845FFF /* ContactsPlaceholderViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContactsPlaceholderViewController.swift; sourceTree = ""; }; 75F2E0B61BE2D5F000EAE861 /* Accelerate.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accelerate.framework; path = System/Library/Frameworks/Accelerate.framework; sourceTree = SDKROOT; }; 75F51AAC2ABD8C800057B499 /* IntegrationViewController+Uphold.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "IntegrationViewController+Uphold.swift"; sourceTree = ""; }; 75F51AAE2ABD8D070057B499 /* IntegrationViewController+Coinbase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "IntegrationViewController+Coinbase.swift"; sourceTree = ""; }; @@ -2680,7 +2681,6 @@ C943B34B2A40A4C500AF23C5 /* DWInfoPopupContentView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DWInfoPopupContentView.m; sourceTree = ""; }; C943B34C2A40A4C500AF23C5 /* DWInfoPopupViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DWInfoPopupViewController.h; sourceTree = ""; }; C943B3512A40A54500AF23C5 /* DWBaseContactsViewController+DWProtected.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DWBaseContactsViewController+DWProtected.h"; sourceTree = ""; }; - C943B3522A40A54500AF23C5 /* DWContactsPlaceholderViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DWContactsPlaceholderViewController.m; sourceTree = ""; }; C943B3532A40A54500AF23C5 /* DWRootContactsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DWRootContactsViewController.h; sourceTree = ""; }; C943B3542A40A54500AF23C5 /* DWContactsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DWContactsViewController.m; sourceTree = ""; }; C943B3552A40A54500AF23C5 /* DWBaseContactsContentViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DWBaseContactsContentViewController.m; sourceTree = ""; }; @@ -2715,7 +2715,6 @@ C943B3782A40A54600AF23C5 /* DWRequestsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DWRequestsViewController.m; sourceTree = ""; }; C943B3792A40A54600AF23C5 /* DWRootContactsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DWRootContactsViewController.m; sourceTree = ""; }; C943B37A2A40A54600AF23C5 /* DWBaseContactsContentViewController+DWProtected.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DWBaseContactsContentViewController+DWProtected.h"; sourceTree = ""; }; - C943B37B2A40A54600AF23C5 /* DWContactsPlaceholderViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DWContactsPlaceholderViewController.h; sourceTree = ""; }; C943B37C2A40A54600AF23C5 /* DWContactsContentViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DWContactsContentViewController.h; sourceTree = ""; }; C943B37D2A40A54600AF23C5 /* DWBaseContactsContentViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DWBaseContactsContentViewController.h; sourceTree = ""; }; C943B37E2A40A54600AF23C5 /* DWContactsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DWContactsViewController.h; sourceTree = ""; }; @@ -6171,6 +6170,7 @@ EBFC2EA47915CD4F5BA81564 /* Pods */, ); sourceTree = ""; + wrapsLines = 0; }; 75D5F3BF191EC270004AB296 /* Products */ = { isa = PBXGroup; @@ -6630,8 +6630,8 @@ C943B3502A40A54500AF23C5 /* Contacts */ = { isa = PBXGroup; children = ( + 75EE38D72CBFE52B00845FFF /* ContactsPlaceholderViewController.swift */, C943B3512A40A54500AF23C5 /* DWBaseContactsViewController+DWProtected.h */, - C943B3522A40A54500AF23C5 /* DWContactsPlaceholderViewController.m */, C943B3532A40A54500AF23C5 /* DWRootContactsViewController.h */, C943B3542A40A54500AF23C5 /* DWContactsViewController.m */, C943B3552A40A54500AF23C5 /* DWBaseContactsContentViewController.m */, @@ -6642,7 +6642,6 @@ C943B3712A40A54600AF23C5 /* Requests */, C943B3792A40A54600AF23C5 /* DWRootContactsViewController.m */, C943B37A2A40A54600AF23C5 /* DWBaseContactsContentViewController+DWProtected.h */, - C943B37B2A40A54600AF23C5 /* DWContactsPlaceholderViewController.h */, C943B37C2A40A54600AF23C5 /* DWContactsContentViewController.h */, C943B37D2A40A54600AF23C5 /* DWBaseContactsContentViewController.h */, C943B37E2A40A54600AF23C5 /* DWContactsViewController.h */, @@ -9260,6 +9259,7 @@ C943B4B02A40A54600AF23C5 /* DWContactsContentViewController.m in Sources */, C9D2C7242A320AA000D15901 /* WKWebView+CrowdNode.swift in Sources */, C9D2C7252A320AA000D15901 /* SyncingActivityMonitor.swift in Sources */, + 75EE38D82CBFE52E00845FFF /* ContactsPlaceholderViewController.swift in Sources */, C9D2C7262A320AA000D15901 /* EmptyView.swift in Sources */, C9D2C7272A320AA000D15901 /* (null) in Sources */, C9D2C7282A320AA000D15901 /* DWQRScanModel.m in Sources */, @@ -9322,7 +9322,6 @@ C9D2C74E2A320AA000D15901 /* ExploreMapView.swift in Sources */, C943B32F2A408CED00AF23C5 /* DWSaveAlertViewController.m in Sources */, C930784C2A6AD59700906E4B /* TitleValueCell.swift in Sources */, - C943B4AB2A40A54600AF23C5 /* DWContactsPlaceholderViewController.m in Sources */, 7566F48B2BB6CAF2005238D2 /* MenuItem.swift in Sources */, C9D2C74F2A320AA000D15901 /* DWSeedPhraseRow.m in Sources */, C943B5132A40A54600AF23C5 /* DWHistoryFilterContentView.m in Sources */, @@ -10751,7 +10750,7 @@ CLIENT_ID = 0c38beb67db0c68191326be347d7ec0abd7d77adb02a79db1abeba343f16a0f7; CLIENT_SECRET = cc980185754f905e24250f877792817c03540b3d0e0959721df291c816797e59; CODE_SIGN_ENTITLEMENTS = dashwallet/dashwallet.entitlements; - CURRENT_PROJECT_VERSION = 171; + CURRENT_PROJECT_VERSION = 173; DEVELOPMENT_TEAM = 44RJ69WHFF; EXCLUDED_ARCHS = ""; "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = ""; @@ -10887,7 +10886,7 @@ CLIENT_ID = 0c38beb67db0c68191326be347d7ec0abd7d77adb02a79db1abeba343f16a0f7; CLIENT_SECRET = cc980185754f905e24250f877792817c03540b3d0e0959721df291c816797e59; CODE_SIGN_ENTITLEMENTS = dashwallet/dashwallet.entitlements; - CURRENT_PROJECT_VERSION = 171; + CURRENT_PROJECT_VERSION = 173; DEVELOPMENT_TEAM = 44RJ69WHFF; EXCLUDED_ARCHS = ""; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -11022,7 +11021,7 @@ CLIENT_ID = 0c38beb67db0c68191326be347d7ec0abd7d77adb02a79db1abeba343f16a0f7; CLIENT_SECRET = cc980185754f905e24250f877792817c03540b3d0e0959721df291c816797e59; CODE_SIGN_ENTITLEMENTS = dashwallet/dashwallet.entitlements; - CURRENT_PROJECT_VERSION = 171; + CURRENT_PROJECT_VERSION = 173; DEVELOPMENT_TEAM = 44RJ69WHFF; EXCLUDED_ARCHS = ""; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -11167,7 +11166,7 @@ CLIENT_ID = 0c38beb67db0c68191326be347d7ec0abd7d77adb02a79db1abeba343f16a0f7; CLIENT_SECRET = cc980185754f905e24250f877792817c03540b3d0e0959721df291c816797e59; CODE_SIGN_ENTITLEMENTS = dashwallet/dashwallet.entitlements; - CURRENT_PROJECT_VERSION = 171; + CURRENT_PROJECT_VERSION = 173; DEVELOPMENT_TEAM = 44RJ69WHFF; EXCLUDED_ARCHS = ""; GCC_PRECOMPILE_PREFIX_HEADER = YES; diff --git a/DashWallet/Sources/UI/DashPay/Contacts/ContactsPlaceholderViewController.swift b/DashWallet/Sources/UI/DashPay/Contacts/ContactsPlaceholderViewController.swift new file mode 100644 index 000000000..03378ce49 --- /dev/null +++ b/DashWallet/Sources/UI/DashPay/Contacts/ContactsPlaceholderViewController.swift @@ -0,0 +1,165 @@ +// +// Created by Andrew Podkovyrin +// Copyright © 2020 Dash Core Group. All rights reserved. +// +// Licensed under the MIT License (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://opensource.org/licenses/MIT +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import UIKit +import SwiftUI + +@objc(DWContactsPlaceholderViewController) +class ContactsPlaceholderViewController: ActionButtonViewController { + + // MARK: - Properties + + private let dashPayModel: DWDashPayProtocol + private let dashPayReady: DWDashPayReadyProtocol + + // MARK: - Initializers + + @objc + init(dashPayModel: DWDashPayProtocol, dashPayReady: DWDashPayReadyProtocol) { + self.dashPayModel = dashPayModel + self.dashPayReady = dashPayReady + super.init(nibName: nil, bundle: nil) + } + + @available(*, unavailable, message: "init(coder:) is not available. Use init(dashPayModel:dashPayReady:) instead.") + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + @available(*, unavailable, message: "init(nibName:bundle:) is not available. Use init(dashPayModel:dashPayReady:) instead.") + override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { + fatalError("init(nibName:bundle:) has not been implemented") + } + + // MARK: - Overrides + + override var actionButtonTitle: String { + return NSLocalizedString("Upgrade", comment: "Title for the upgrade action button") + } + + override func viewDidLoad() { + super.viewDidLoad() + + setupView() + setupNotifications() + update() + } + + // MARK: - Setup Methods + + private func setupView() { + view.backgroundColor = UIColor.dw_secondaryBackground() + + let imageView = UIImageView(image: UIImage(named: "contacts_placeholder_icon")) + imageView.translatesAutoresizingMaskIntoConstraints = false + imageView.contentMode = .center + + let titleLabel = UILabel() + titleLabel.translatesAutoresizingMaskIntoConstraints = false + titleLabel.textAlignment = .center + titleLabel.font = UIFont.dw_font(forTextStyle: .title3) + titleLabel.adjustsFontForContentSizeCategory = true + titleLabel.text = NSLocalizedString("Upgrade to Evolution", comment: "Title label text") + titleLabel.textColor = UIColor.dw_darkTitle() + titleLabel.numberOfLines = 0 + + let descriptionLabel = UILabel() + descriptionLabel.translatesAutoresizingMaskIntoConstraints = false + descriptionLabel.textAlignment = .center + descriptionLabel.font = UIFont.dw_font(forTextStyle: .subheadline) + descriptionLabel.adjustsFontForContentSizeCategory = true + descriptionLabel.text = NSLocalizedString("Create your Username, find friends & family with their usernames and add them to your contacts", comment: "Description label text") + descriptionLabel.textColor = UIColor.dw_tertiaryText() + descriptionLabel.numberOfLines = 0 + + let verticalStackView = UIStackView(arrangedSubviews: [imageView, titleLabel, descriptionLabel]) + verticalStackView.translatesAutoresizingMaskIntoConstraints = false + verticalStackView.axis = .vertical + verticalStackView.spacing = 4.0 + verticalStackView.setCustomSpacing(26.0, after: imageView) + + let contentView = UIView() + contentView.translatesAutoresizingMaskIntoConstraints = false + contentView.backgroundColor = view.backgroundColor + contentView.addSubview(verticalStackView) + + NSLayoutConstraint.activate([ + verticalStackView.centerYAnchor.constraint(equalTo: contentView.centerYAnchor), + verticalStackView.topAnchor.constraint(greaterThanOrEqualTo: contentView.topAnchor), + contentView.bottomAnchor.constraint(greaterThanOrEqualTo: verticalStackView.bottomAnchor), + verticalStackView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor), + contentView.trailingAnchor.constraint(equalTo: verticalStackView.trailingAnchor) + ]) + + setupContentView(contentView) + } + + private func setupNotifications() { + let notificationCenter = NotificationCenter.default + notificationCenter.addObserver(self, + selector: #selector(update), + name: .DWDashPayRegistrationStatusUpdatedNotification, + object: nil) + + // TODO: This notification is never posted. Check if needed + // notificationCenter.addObserver(self, + // selector: #selector(update), + // name: .DWDashPayAvailabilityStatusUpdatedNotification, + // object: nil) + } + + // MARK: - Actions + + @objc override func actionButtonAction(sender: UIView) { + let swiftUIView = MixDashDialog( + positiveAction: { + let controller = CoinJoinLevelsViewController.controller(isFullScreen: true) + self.present(controller, animated: true, completion: nil) + }, negativeAction: { + let controller = DashPaySetupFlowController(dashPayModel: self.dashPayModel, + invitationURL: nil, + definedUsername: nil) + controller.modalPresentationStyle = .fullScreen + self.present(controller, animated: true, completion: nil) + } + ) + let hostingController = UIHostingController(rootView: swiftUIView) + + if #available(iOS 16.0, *) { + if let sheet = hostingController.sheetPresentationController { + let fitId = UISheetPresentationController.Detent.Identifier("fit") + let fitDetent = UISheetPresentationController.Detent.custom(identifier: fitId) { _ in + 250 + } + sheet.detents = [fitDetent] + } + } + + present(hostingController, animated: true, completion: nil) + } + + @objc func update() { + actionButton?.isEnabled = dashPayReady.shouldShowCreateUserNameButton() + } +} + +// MARK: - Notification Names + +extension Notification.Name { + static let DWDashPayRegistrationStatusUpdatedNotification = Notification.Name("DWDashPayRegistrationStatusUpdatedNotification") + // static let DWDashPayAvailabilityStatusUpdatedNotification = Notification.Name("DWDashPayAvailabilityStatusUpdatedNotification") +} diff --git a/DashWallet/Sources/UI/DashPay/Contacts/DWContactsPlaceholderViewController.h b/DashWallet/Sources/UI/DashPay/Contacts/DWContactsPlaceholderViewController.h deleted file mode 100644 index bd817cc93..000000000 --- a/DashWallet/Sources/UI/DashPay/Contacts/DWContactsPlaceholderViewController.h +++ /dev/null @@ -1,36 +0,0 @@ -// -// Created by Andrew Podkovyrin -// Copyright © 2020 Dash Core Group. All rights reserved. -// -// Licensed under the MIT License (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://opensource.org/licenses/MIT -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#import "DWBaseActionButtonViewController.h" - -#import "DWDashPayProtocol.h" -#import "DWDashPayReadyProtocol.h" - -NS_ASSUME_NONNULL_BEGIN - -@interface DWContactsPlaceholderViewController : DWBaseActionButtonViewController - -- (instancetype)initWithDashPayModel:(id)dashPayModel dashPayReady:(id)dashPayReady; - -- (instancetype)initWithNibName:(nullable NSString *)nibNameOrNil bundle:(nullable NSBundle *)nibBundleOrNil NS_UNAVAILABLE; -- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_UNAVAILABLE; -- (instancetype)init NS_UNAVAILABLE; -+ (instancetype)new NS_UNAVAILABLE; - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashWallet/Sources/UI/DashPay/Contacts/DWContactsPlaceholderViewController.m b/DashWallet/Sources/UI/DashPay/Contacts/DWContactsPlaceholderViewController.m deleted file mode 100644 index 9005d4ef9..000000000 --- a/DashWallet/Sources/UI/DashPay/Contacts/DWContactsPlaceholderViewController.m +++ /dev/null @@ -1,125 +0,0 @@ -// -// Created by Andrew Podkovyrin -// Copyright © 2020 Dash Core Group. All rights reserved. -// -// Licensed under the MIT License (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://opensource.org/licenses/MIT -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#import "DWContactsPlaceholderViewController.h" - -#import "DWDashPayModel.h" -#import "DWUIKit.h" -#import "dashwallet-Swift.h" - -@interface DWContactsPlaceholderViewController () - -@property (readonly, nonatomic, strong) id dashPayModel; -@property (readonly, nonatomic, strong) id dashPayReady; - -@end - -@implementation DWContactsPlaceholderViewController - -- (instancetype)initWithDashPayModel:(id)dashPayModel dashPayReady:(id)dashPayReady { - self = [super init]; - if (self) { - _dashPayModel = dashPayModel; - _dashPayReady = dashPayReady; - } - return self; -} - -- (NSString *)actionButtonTitle { - return NSLocalizedString(@"Upgrade", nil); -} - -- (void)viewDidLoad { - [super viewDidLoad]; - - self.view.backgroundColor = [UIColor dw_secondaryBackgroundColor]; - - UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"contacts_placeholder_icon"]]; - imageView.translatesAutoresizingMaskIntoConstraints = NO; - imageView.contentMode = UIViewContentModeCenter; - - UILabel *titleLabel = [[UILabel alloc] init]; - titleLabel.translatesAutoresizingMaskIntoConstraints = NO; - titleLabel.textAlignment = NSTextAlignmentCenter; - titleLabel.font = [UIFont dw_fontForTextStyle:UIFontTextStyleTitle3]; - titleLabel.adjustsFontForContentSizeCategory = YES; - titleLabel.text = NSLocalizedString(@"Upgrade to Evolution", nil); - titleLabel.textColor = [UIColor dw_darkTitleColor]; - titleLabel.numberOfLines = 0; - - UILabel *descriptionLabel = [[UILabel alloc] init]; - descriptionLabel.translatesAutoresizingMaskIntoConstraints = NO; - descriptionLabel.textAlignment = NSTextAlignmentCenter; - descriptionLabel.font = [UIFont dw_fontForTextStyle:UIFontTextStyleSubheadline]; - descriptionLabel.adjustsFontForContentSizeCategory = YES; - descriptionLabel.text = NSLocalizedString(@"Create your Username, find friends & family with their usernames and add them to your contacts", nil); - descriptionLabel.textColor = [UIColor dw_tertiaryTextColor]; - descriptionLabel.numberOfLines = 0; - - UIStackView *verticalStackView = [[UIStackView alloc] initWithArrangedSubviews:@[ imageView, titleLabel, descriptionLabel ]]; - verticalStackView.translatesAutoresizingMaskIntoConstraints = NO; - verticalStackView.axis = UILayoutConstraintAxisVertical; - verticalStackView.spacing = 4.0; - [verticalStackView setCustomSpacing:26.0 afterView:imageView]; - - UIView *contentView = [[UIView alloc] init]; - contentView.translatesAutoresizingMaskIntoConstraints = NO; - contentView.backgroundColor = self.view.backgroundColor; - [contentView addSubview:verticalStackView]; - - [NSLayoutConstraint activateConstraints:@[ - [verticalStackView.centerYAnchor constraintEqualToAnchor:contentView.centerYAnchor], - [verticalStackView.topAnchor constraintGreaterThanOrEqualToAnchor:contentView.topAnchor], - [contentView.bottomAnchor constraintGreaterThanOrEqualToAnchor:contentView.bottomAnchor], - [verticalStackView.leadingAnchor constraintEqualToAnchor:contentView.leadingAnchor], - [contentView.trailingAnchor constraintEqualToAnchor:verticalStackView.trailingAnchor], - ]]; - - [self setupContentView:contentView]; - - // Model: - - NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; - [notificationCenter addObserver:self - selector:@selector(update) - name:DWDashPayRegistrationStatusUpdatedNotification - object:nil]; - - // TODO: never posted. Check if needed -// [notificationCenter addObserver:self -// selector:@selector(update) -// name:DWDashPayAvailabilityStatusUpdatedNotification -// object:nil]; - - [self update]; -} - -- (void)actionButtonAction:(id)sender { - DWDashPaySetupFlowController *controller = - [[DWDashPaySetupFlowController alloc] - initWithDashPayModel:self.dashPayModel - invitationURL:nil - definedUsername:nil]; - controller.modalPresentationStyle = UIModalPresentationFullScreen; - [self presentViewController:controller animated:YES completion:nil]; -} - -- (void)update { - self.actionButton.enabled = [self.dashPayReady shouldShowCreateUserNameButton]; -} - -@end diff --git a/DashWallet/Sources/UI/DashPay/Contacts/DWRootContactsViewController.m b/DashWallet/Sources/UI/DashPay/Contacts/DWRootContactsViewController.m index 57e2f933e..e8c73bf21 100644 --- a/DashWallet/Sources/UI/DashPay/Contacts/DWRootContactsViewController.m +++ b/DashWallet/Sources/UI/DashPay/Contacts/DWRootContactsViewController.m @@ -17,11 +17,11 @@ #import "DWRootContactsViewController.h" -#import "DWContactsPlaceholderViewController.h" #import "DWContactsViewController.h" #import "DWDashPayModel.h" #import "DWGlobalOptions.h" #import "DWUIKit.h" +#import "dashwallet-Swift.h" @interface DWRootContactsViewController () diff --git a/DashWallet/Sources/UI/DashPay/Profile/Edit Profile/RootEditProfileViewController.swift b/DashWallet/Sources/UI/DashPay/Profile/Edit Profile/RootEditProfileViewController.swift index c8a768a58..5e00e3c11 100644 --- a/DashWallet/Sources/UI/DashPay/Profile/Edit Profile/RootEditProfileViewController.swift +++ b/DashWallet/Sources/UI/DashPay/Profile/Edit Profile/RootEditProfileViewController.swift @@ -25,7 +25,7 @@ protocol RootEditProfileViewControllerDelegate: AnyObject { } @objc(DWRootEditProfileViewController) -class RootEditProfileViewController: DWBaseActionButtonViewController, DWEditProfileViewControllerDelegate, DWSaveAlertViewControllerDelegate, NavigationBarDisplayable { +class RootEditProfileViewController: ActionButtonViewController, DWEditProfileViewControllerDelegate, DWSaveAlertViewControllerDelegate, NavigationBarDisplayable { var isBackButtonHidden: Bool = false @@ -73,7 +73,7 @@ class RootEditProfileViewController: DWBaseActionButtonViewController, DWEditPro } } - @objc override func actionButtonAction(_ sender: Any) { + @objc override func actionButtonAction(sender: UIView) { performSave() }