Skip to content
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

MOB-2058 - Revise copy and move Login CTA #604

Merged
merged 3 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Updated Vaulted domains found view UI
  • Loading branch information
Oleg-Pecheneg committed Jul 9, 2024
commit d9fa4211bb04e349b180970791bfd07377cac8e3
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 @@ -1272,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 @@ -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