From b7508f8fb6b59055dbc4c97b0fe52a782b6d79b5 Mon Sep 17 00:00:00 2001 From: Marcus Kida Date: Tue, 28 Mar 2023 11:13:13 +0200 Subject: [PATCH] IOS-132: Server picker VQA improvements (#994) --- .../PickServerCategoryCollectionViewCell.swift | 2 +- .../MastodonPickServerViewController.swift | 14 ++++++++++++++ .../PickServer/MastodonPickServerViewModel.swift | 4 +++- .../PickServer/View/OnboardingNextView.swift | 1 + .../PickServerServerSectionTableHeaderView.swift | 2 +- 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Mastodon/Scene/Onboarding/PickServer/CollectionViewCell/PickServerCategoryCollectionViewCell.swift b/Mastodon/Scene/Onboarding/PickServer/CollectionViewCell/PickServerCategoryCollectionViewCell.swift index 533487ccb..d34f1489b 100644 --- a/Mastodon/Scene/Onboarding/PickServer/CollectionViewCell/PickServerCategoryCollectionViewCell.swift +++ b/Mastodon/Scene/Onboarding/PickServer/CollectionViewCell/PickServerCategoryCollectionViewCell.swift @@ -62,7 +62,7 @@ class PickServerCategoryCollectionViewCell: UICollectionViewCell { layer.borderColor = UIColor.black.cgColor layer.borderWidth = 1.0 - applyCornerRadius(radius: 15) + applyCornerRadius(radius: 18) contentView.addSubview(container) contentView.addSubview(menuButton) diff --git a/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewController.swift b/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewController.swift index 3f32e9672..5618f2790 100644 --- a/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewController.swift +++ b/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewController.swift @@ -141,6 +141,13 @@ extension MastodonPickServerViewController { ) } .store(in: &disposeBag) + + viewModel.scrollToTop + .receive(on: DispatchQueue.main) + .sink { [weak self] _ in + self?.tableView.scroll(to: .top, animated: false) + } + .store(in: &disposeBag) authenticationViewModel .authenticated @@ -371,6 +378,13 @@ extension MastodonPickServerViewController: UITableViewDelegate { guard case let .server(server, _) = item else { return } tableView.selectRow(at: indexPath, animated: false, scrollPosition: .none) viewModel.selectedServer.send(server) + + // Briefly highlight selected cell + guard let cell = tableView.cellForRow(at: indexPath) else { return } + cell.backgroundColor = Asset.Colors.selectionHighlight.color + UIView.animate(withDuration: 0.3, animations: { + cell.backgroundColor = .none + }) } func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) { diff --git a/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewModel.swift b/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewModel.swift index fdc57214e..19e9bab3c 100644 --- a/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewModel.swift +++ b/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewModel.swift @@ -47,6 +47,7 @@ class MastodonPickServerViewModel: NSObject { let unindexedServers = CurrentValueSubject<[Mastodon.Entity.Server]?, Never>([]) // set nil when loading let viewWillAppear = PassthroughSubject() let viewDidAppear = CurrentValueSubject(Void()) + let scrollToTop = PassthroughSubject() @Published var additionalTableViewInsets: UIEdgeInsets = .zero // output @@ -125,7 +126,7 @@ extension MastodonPickServerViewModel { (selectedLanguage, manualApprovalRequired) } ) - .map { indexedServers, selectCategoryItem, searchText, filters -> [Mastodon.Entity.Server] in + .map { [weak self] indexedServers, selectCategoryItem, searchText, filters -> [Mastodon.Entity.Server] in var indexedServers = indexedServers var _indexedServers: [Mastodon.Entity.Server] = [] @@ -151,6 +152,7 @@ extension MastodonPickServerViewModel { case .language(_), .signupSpeed(_): return MastodonPickServerViewModel.filterServers(servers: indexedServers, language: filters.selectedLanguage, manualApprovalRequired: filters.manualApprovalRequired, category: nil, searchText: searchText) case .category(let category): + self?.scrollToTop.send() return MastodonPickServerViewModel.filterServers(servers: indexedServers, language: filters.selectedLanguage, manualApprovalRequired: filters.manualApprovalRequired, category: category.category.rawValue, searchText: searchText) } } diff --git a/Mastodon/Scene/Onboarding/PickServer/View/OnboardingNextView.swift b/Mastodon/Scene/Onboarding/PickServer/View/OnboardingNextView.swift index 0bd7dfc35..1f6f05d4c 100644 --- a/Mastodon/Scene/Onboarding/PickServer/View/OnboardingNextView.swift +++ b/Mastodon/Scene/Onboarding/PickServer/View/OnboardingNextView.swift @@ -28,6 +28,7 @@ final class OnboardingNextView: UIView { button.layer.cornerRadius = 14 button.backgroundColor = Asset.Colors.Brand.blurple.color button.setTitle(L10n.Common.Controls.Actions.next, for: .normal) + button.titleLabel?.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 16, weight: .bold)) return button }() diff --git a/Mastodon/Scene/Onboarding/PickServer/View/PickServerServerSectionTableHeaderView.swift b/Mastodon/Scene/Onboarding/PickServer/View/PickServerServerSectionTableHeaderView.swift index 3d84381dd..7c686cfb2 100644 --- a/Mastodon/Scene/Onboarding/PickServer/View/PickServerServerSectionTableHeaderView.swift +++ b/Mastodon/Scene/Onboarding/PickServer/View/PickServerServerSectionTableHeaderView.swift @@ -18,7 +18,7 @@ protocol PickServerServerSectionTableHeaderViewDelegate: AnyObject { final class PickServerServerSectionTableHeaderView: UIView { - static let collectionViewHeight: CGFloat = 30 + static let collectionViewHeight: CGFloat = 36 static let spacing: CGFloat = 16 static let height: CGFloat = collectionViewHeight + spacing