-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: mixing warning on the contacts screen
- Loading branch information
Showing
6 changed files
with
177 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
165 changes: 165 additions & 0 deletions
165
DashWallet/Sources/UI/DashPay/Contacts/ContactsPlaceholderViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
} |
36 changes: 0 additions & 36 deletions
36
DashWallet/Sources/UI/DashPay/Contacts/DWContactsPlaceholderViewController.h
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.