IOS-132: Server picker VQA improvements (#994)

This commit is contained in:
Marcus Kida 2023-03-28 11:13:13 +02:00 committed by GitHub
parent 245543ea60
commit b7508f8fb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 3 deletions

View File

@ -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)

View File

@ -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) {

View File

@ -47,6 +47,7 @@ class MastodonPickServerViewModel: NSObject {
let unindexedServers = CurrentValueSubject<[Mastodon.Entity.Server]?, Never>([]) // set nil when loading
let viewWillAppear = PassthroughSubject<Void, Never>()
let viewDidAppear = CurrentValueSubject<Void, Never>(Void())
let scrollToTop = PassthroughSubject<Void, Never>()
@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)
}
}

View File

@ -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
}()

View File

@ -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