Skip to content

Commit

Permalink
MOB-2058 - Revise copy and move Login CTA (#604)
Browse files Browse the repository at this point in the history
* Updated place to login/logout to view vaulted domains

* Updated Vaulted domains found view UI

* Finalise UI
  • Loading branch information
Oleg-Pecheneg authored Jul 9, 2024
1 parent d7b13fe commit 6f0c160
Show file tree
Hide file tree
Showing 22 changed files with 197 additions and 381 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ typealias ResponseV2 = String
typealias SessionV2Proxy = String

final class WalletConnectServiceV2: WalletConnectServiceV2Protocol {
static let supportedNetworks: [BlockchainType] = [.Ethereum, .Matic]

func sendSignTx(sessions: [WCConnectedAppsStorageV2.SessionProxy], chainId: Int, tx: EthereumTransaction, address: HexAddress, in wallet: UDWallet) async throws -> ResponseV2 {
throw NSError()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct DomainItem: DomainEntity {

func doesRequirePayment() -> Bool {
switch self.getBlockchainType() {
case .Ethereum: return true
case .Ethereum, .Base: return true
case .Matic: return false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ extension MockEntitiesFabric {
domains.append(domain)
}
}

return domains
}

Expand Down Expand Up @@ -105,6 +105,10 @@ extension MockEntitiesFabric {
ownerAddress: "123")
]
}

static func mockFirebaseDomainsDisplayInfo() -> [FirebaseDomainDisplayInfo] {
mockFirebaseDomains().map { FirebaseDomainDisplayInfo(firebaseDomain: $0) }
}
}
}

Expand Down
11 changes: 3 additions & 8 deletions unstoppable-ios-app/domains-manager-ios/Entities/Toast.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ enum Toast: Hashable {
case failedToUpdateProfile
case itemSaved(name: String)
case itemCopied(name: String)
case parkedDomainsImported(_ domainsCount: Int)
case userLoggedOut
case communityProfileEnabled
case purchaseDomainsDiscountApplied(Int)
Expand Down Expand Up @@ -61,8 +60,6 @@ enum Toast: Hashable {
return String.Constants.nSaved.localized(name)
case .itemCopied(let name):
return String.Constants.nCopied.localized(name)
case .parkedDomainsImported(let domainsCount):
return String.Constants.pluralNParkedDomainsImported.localized(domainsCount, domainsCount)
case .userLoggedOut:
return String.Constants.userLoggedOutToastMessage.localized()
case .communityProfileEnabled:
Expand All @@ -76,7 +73,7 @@ enum Toast: Hashable {

var secondaryMessage: String? {
switch self {
case .walletAddressCopied, .walletAdded, .iCloudBackupRestored, .walletRemoved, .walletDisconnected, .noInternetConnection, .changesConfirmed, .mintingSuccessful, .mintingUnavailable, .updatingRecords, .domainCopied, .failedToRefreshBadges, .itemSaved, .itemCopied, .parkedDomainsImported, .userLoggedOut, .communityProfileEnabled, .purchaseDomainsDiscountApplied, .followedProfileAs:
case .walletAddressCopied, .walletAdded, .iCloudBackupRestored, .walletRemoved, .walletDisconnected, .noInternetConnection, .changesConfirmed, .mintingSuccessful, .mintingUnavailable, .updatingRecords, .domainCopied, .failedToRefreshBadges, .itemSaved, .itemCopied, .userLoggedOut, .communityProfileEnabled, .purchaseDomainsDiscountApplied, .followedProfileAs:
return nil
case .failedToFetchDomainProfileData:
return String.Constants.refresh.localized()
Expand All @@ -87,7 +84,7 @@ enum Toast: Hashable {

var style: Style {
switch self {
case .walletAddressCopied, .walletAdded, .iCloudBackupRestored, .walletRemoved, .walletDisconnected, .changesConfirmed, .mintingSuccessful, .domainCopied, .itemSaved, .itemCopied, .parkedDomainsImported, .userLoggedOut, .communityProfileEnabled, .purchaseDomainsDiscountApplied, .followedProfileAs:
case .walletAddressCopied, .walletAdded, .iCloudBackupRestored, .walletRemoved, .walletDisconnected, .changesConfirmed, .mintingSuccessful, .domainCopied, .itemSaved, .itemCopied, .userLoggedOut, .communityProfileEnabled, .purchaseDomainsDiscountApplied, .followedProfileAs:
return .success
case .noInternetConnection, .updatingRecords, .mintingUnavailable, .failedToFetchDomainProfileData, .failedToUpdateProfile:
return .dark
Expand All @@ -98,7 +95,7 @@ enum Toast: Hashable {

var image: UIImage {
switch self {
case .walletAddressCopied, .walletAdded, .iCloudBackupRestored, .walletRemoved, .walletDisconnected, .changesConfirmed, .mintingSuccessful, .domainCopied, .itemSaved, .itemCopied, .parkedDomainsImported, .userLoggedOut, .communityProfileEnabled, .purchaseDomainsDiscountApplied, .followedProfileAs:
case .walletAddressCopied, .walletAdded, .iCloudBackupRestored, .walletRemoved, .walletDisconnected, .changesConfirmed, .mintingSuccessful, .domainCopied, .itemSaved, .itemCopied, .userLoggedOut, .communityProfileEnabled, .purchaseDomainsDiscountApplied, .followedProfileAs:
return .checkCircleWhite
case .noInternetConnection:
return .connectionOffIcon
Expand Down Expand Up @@ -147,8 +144,6 @@ enum Toast: Hashable {
return lhsName == rhsName
case (.itemCopied(let lhsName), .itemCopied(let rhsName)):
return lhsName == rhsName
case (.parkedDomainsImported(let lhsCount), .parkedDomainsImported(let rhsCount)):
return lhsCount == rhsCount
case (.userLoggedOut, .userLoggedOut):
return true
case (.communityProfileEnabled, .communityProfileEnabled):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,8 @@ extension String {
static let settingsAppearanceChooseTheme = "SETTINGS_APPEARANCE_CHOOSE_THEME"
static let youAreUnstoppable = "YOU_ARE_UNSTOPPABLE"
static let feedbackEmailSubject = "FEEDBACK_EMAIL_SUBJECT"

static let viewOrMoveVaultedDomains = "VIEW_OR_MOVE_VAULTED_DOMAINS"

// Wallets list
static let manageICloudBackups = "MANAGE_ICLOUD_BACKUPS"
static let restoreFromICloudBackup = "RESTORE_FROM_ICLOUD_BACKUP"
Expand Down Expand Up @@ -1271,7 +1272,7 @@ extension String {
static let reviewTxAgain = "REVIEW_TX_AGAIN"
static let confirmAndSend = "CONFIRM_AND_SEND"

static let parkedDomains = "PARKED_DOMAINS"
static let domainVault = "DOMAIN_VAULT"
static let backedUp = "BACKED_UP"
static let backUp = "BACK_UP"
static let setAsPrimaryDomain = "SET_AS_PRIMARY_DOMAIN"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class ParkedDomainsFoundInAppViewPresenter: ParkedDomainsFoundViewPresente
override var title: String {
String.Constants.pluralWeFoundNDomains.localized(domains.count, domains.count)
}
override var progress: Double? { 1 }
override var progress: Double? { nil }

init(view: ParkedDomainsFoundViewProtocol,
domains: [FirebaseDomainDisplayInfo],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,77 +8,37 @@
import UIKit

@MainActor
protocol ParkedDomainsFoundViewProtocol: BaseCollectionViewControllerProtocol & ViewWithDashesProgress{
func applySnapshot(_ snapshot: ParkedDomainsFoundSnapshot, animated: Bool)
protocol ParkedDomainsFoundViewProtocol: ViewWithDashesProgress{
func setWith(email: String, numberOfDomainsFound: Int)
}

typealias ParkedDomainsFoundDataSource = UICollectionViewDiffableDataSource<ParkedDomainsFoundViewController.Section, ParkedDomainsFoundViewController.Item>
typealias ParkedDomainsFoundSnapshot = NSDiffableDataSourceSnapshot<ParkedDomainsFoundViewController.Section, ParkedDomainsFoundViewController.Item>

@MainActor
final class ParkedDomainsFoundViewController: BaseViewController {

@IBOutlet weak var collectionView: UICollectionView!
@IBOutlet private weak var emailLabel: UILabel!
@IBOutlet private weak var titleLabel: UDTitleLabel!
@IBOutlet private weak var importButton: MainButton!

var cellIdentifiers: [UICollectionViewCell.Type] { [ParkedDomainCell.self] }
var presenter: ParkedDomainsFoundViewPresenterProtocol!
private var dataSource: ParkedDomainsFoundDataSource!
override var prefersLargeTitles: Bool { true }
override var largeTitleAlignment: NSTextAlignment { .center }
override var largeTitleIcon: UIImage? { .checkmark }
override var largeTitleIconTintColor: UIColor { .foregroundSuccess }
override var scrollableContentYOffset: CGFloat? { 10 }
override var adjustLargeTitleFontSizeForSmallerDevice: Bool { true }
override var analyticsName: Analytics.ViewName { .parkedDomainsList }

override func viewDidLoad() {
super.viewDidLoad()

configureCollectionView()
setup()
presenter.viewDidLoad()
}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)

// cNavigationBar?.setBackButton(hidden: true)
}
}

// MARK: - ParkedDomainsFoundViewProtocol
extension ParkedDomainsFoundViewController: ParkedDomainsFoundViewProtocol {
var progress: Double? { presenter.progress }

func applySnapshot(_ snapshot: ParkedDomainsFoundSnapshot, animated: Bool) {
dataSource.apply(snapshot, animatingDifferences: animated)
}
}

// MARK: - UICollectionViewDelegate
extension ParkedDomainsFoundViewController: UICollectionViewDelegate {
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
guard let item = dataSource.itemIdentifier(for: indexPath) else { return }
switch item {
case .parkedDomain(let domain):
logAnalytic(event: .domainPressed, parameters: [.domainName: domain.name])
}
presenter.didSelectItem(item)
}

func scrollViewDidScroll(_ scrollView: UIScrollView) {
cNavigationController?.underlyingScrollViewDidScroll(scrollView)
}

func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
if !decelerate {
cNavigationController?.underlyingScrollViewDidFinishScroll(scrollView)
}
}

func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
cNavigationController?.underlyingScrollViewDidFinishScroll(scrollView)
func setWith(email: String, numberOfDomainsFound: Int) {
emailLabel.setAttributedTextWith(text: email,
font: .currentFont(withSize: 16, weight: .medium),
textColor: .foregroundSuccess)
titleLabel.setTitle(String.Constants.pluralNParkedDomainsImported.localized(numberOfDomainsFound, numberOfDomainsFound))
}
}

Expand All @@ -94,93 +54,23 @@ private extension ParkedDomainsFoundViewController {
private extension ParkedDomainsFoundViewController {
func setup() {
addProgressDashesView()
setupCollectionView()
title = presenter.title
importButton.setTitle(String.Constants.viewVaultedDomains.localized(), image: nil)
}

func setupCollectionView() {
collectionView.delegate = self
collectionView.collectionViewLayout = buildLayout()
collectionView.contentInset.top = 177
collectionView.register(CollectionTextHeaderReusableView.self,
forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader,
withReuseIdentifier: CollectionTextHeaderReusableView.reuseIdentifier)

configureDataSource()
}

func configureDataSource() {
dataSource = ParkedDomainsFoundDataSource.init(collectionView: collectionView, cellProvider: { collectionView, indexPath, item in
switch item {
case .parkedDomain(let domain):
let cell = collectionView.dequeueCellOfType(ParkedDomainCell.self, forIndexPath: indexPath)

cell.setWith(domain: domain)
return cell
}
})

dataSource.supplementaryViewProvider = { collectionView, elementKind, indexPath in
let view = collectionView.dequeueReusableSupplementaryView(ofKind: elementKind,
withReuseIdentifier: CollectionTextHeaderReusableView.reuseIdentifier,
for: indexPath) as! CollectionTextHeaderReusableView

view.setHeader(String.Constants.parkedDomainsFound.localized())

return view
}
}

func buildLayout() -> UICollectionViewLayout {
let spacing: CGFloat = UICollectionView.SideOffset

let config = UICollectionViewCompositionalLayoutConfiguration()
config.interSectionSpacing = spacing

let layout = UICollectionViewCompositionalLayout(sectionProvider: {
(sectionIndex: Int, layoutEnvironment: NSCollectionLayoutEnvironment) -> NSCollectionLayoutSection? in

let layoutSection: NSCollectionLayoutSection
let sectionHeaderHeight = CollectionTextHeaderReusableView.Height

layoutSection = .flexibleListItemSection()
layoutSection.contentInsets = NSDirectionalEdgeInsets(top: 1,
leading: spacing + 1,
bottom: 1,
trailing: spacing + 1)
let background = NSCollectionLayoutDecorationItem.background(elementKind: CollectionReusableRoundedBackground.reuseIdentifier)
background.contentInsets.top = sectionHeaderHeight
layoutSection.decorationItems = [background]


let headerSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1),
heightDimension: .absolute(sectionHeaderHeight))
let header = NSCollectionLayoutBoundarySupplementaryItem(layoutSize: headerSize,
elementKind: UICollectionView.elementKindSectionHeader,
alignment: .top)
layoutSection.boundarySupplementaryItems = [header]




return layoutSection

}, configuration: config)
layout.register(CollectionReusableRoundedBackground.self, forDecorationViewOfKind: CollectionReusableRoundedBackground.reuseIdentifier)

return layout
}
}

// MARK: - Collection elements
extension ParkedDomainsFoundViewController {
enum Section: Int, Hashable {
case main
}

enum Item: Hashable {
case parkedDomain(_ domain: FirebaseDomainDisplayInfo)
}
@available(iOS 17.0, *)
#Preview {
let vc = ParkedDomainsFoundViewController.nibInstance()
let manager = PreviewLoginManager()
let presenter = ParkedDomainsFoundInAppViewPresenter(view: vc,
domains: MockEntitiesFabric.Domains.mockFirebaseDomainsDisplayInfo(),
loginFlowManager: manager)
vc.presenter = presenter

return vc
}

private final class PreviewLoginManager: LoginFlowManager {
func handle(action: LoginFlowNavigationController.Action) async throws { }
}
Loading

0 comments on commit 6f0c160

Please sign in to comment.