Merge branch 'feature/signup' into feature/server-rule

# Conflicts:
#	Mastodon/Scene/Authentication/Register/MastodonRegisterViewController.swift
This commit is contained in:
CMK 2021-02-22 16:26:50 +08:00
commit abf2e673e1
2 changed files with 21 additions and 14 deletions

View File

@ -148,7 +148,7 @@ final class MastodonRegisterViewController: UIViewController, NeedsDependency {
let passwordCheckLabel: UILabel = { let passwordCheckLabel: UILabel = {
let label = UILabel() let label = UILabel()
label.numberOfLines = 4 label.numberOfLines = 0
return label return label
}() }()
@ -217,7 +217,7 @@ extension MastodonRegisterViewController {
stackView.axis = .vertical stackView.axis = .vertical
stackView.distribution = .fill stackView.distribution = .fill
stackView.spacing = 40 stackView.spacing = 40
stackView.layoutMargins = UIEdgeInsets(top: 20, left: 0, bottom: 0, right: 0) stackView.layoutMargins = UIEdgeInsets(top: 20, left: 0, bottom: 26, right: 0)
stackView.isLayoutMarginsRelativeArrangement = true stackView.isLayoutMarginsRelativeArrangement = true
stackView.addArrangedSubview(largeTitleLabel) stackView.addArrangedSubview(largeTitleLabel)
stackView.addArrangedSubview(photoView) stackView.addArrangedSubview(photoView)
@ -309,21 +309,19 @@ extension MastodonRegisterViewController {
signUpActivityIndicatorView.centerYAnchor.constraint(equalTo: signUpButton.centerYAnchor), signUpActivityIndicatorView.centerYAnchor.constraint(equalTo: signUpButton.centerYAnchor),
]) ])
Publishers.CombineLatest3( Publishers.CombineLatest(
KeyboardResponderService.shared.isShow.eraseToAnyPublisher(),
KeyboardResponderService.shared.state.eraseToAnyPublisher(), KeyboardResponderService.shared.state.eraseToAnyPublisher(),
KeyboardResponderService.shared.endFrame.eraseToAnyPublisher() KeyboardResponderService.shared.willEndFrame.eraseToAnyPublisher()
) )
.sink(receiveValue: { [weak self] isShow, state, endFrame in .sink(receiveValue: { [weak self] state, endFrame in
guard let self = self else { return } guard let self = self else { return }
guard isShow, state == .dock else { guard state == .dock else {
self.scrollView.contentInset.bottom = 0.0 self.scrollView.contentInset.bottom = 0.0
self.scrollView.verticalScrollIndicatorInsets.bottom = 0.0 self.scrollView.verticalScrollIndicatorInsets.bottom = 0.0
return return
} }
// isShow AND dock state
let contentFrame = self.view.convert(self.scrollView.frame, to: nil) let contentFrame = self.view.convert(self.scrollView.frame, to: nil)
let padding = contentFrame.maxY - endFrame.minY let padding = contentFrame.maxY - endFrame.minY
guard padding > 0 else { guard padding > 0 else {
@ -431,9 +429,10 @@ extension MastodonRegisterViewController: UITextFieldDelegate {
// align to password label when overlap // align to password label when overlap
if textField === passwordTextField, if textField === passwordTextField,
KeyboardResponderService.shared.isShow.value, KeyboardResponderService.shared.isShow.value,
KeyboardResponderService.shared.state.value == .dock { KeyboardResponderService.shared.state.value == .dock
let endFrame = KeyboardResponderService.shared.endFrame.value {
let contentFrame = self.scrollView.convert(self.passwordCheckLabel.frame, to: nil) let endFrame = KeyboardResponderService.shared.willEndFrame.value
let contentFrame = scrollView.convert(passwordCheckLabel.frame, to: nil)
let padding = contentFrame.maxY - endFrame.minY let padding = contentFrame.maxY - endFrame.minY
if padding > 0 { if padding > 0 {
let contentOffsetY = scrollView.contentOffset.y let contentOffsetY = scrollView.contentOffset.y

View File

@ -18,7 +18,8 @@ final class KeyboardResponderService {
// output // output
let isShow = CurrentValueSubject<Bool, Never>(false) let isShow = CurrentValueSubject<Bool, Never>(false)
let state = CurrentValueSubject<KeyboardState, Never>(.none) let state = CurrentValueSubject<KeyboardState, Never>(.none)
let endFrame = CurrentValueSubject<CGRect, Never>(.zero) let didEndFrame = CurrentValueSubject<CGRect, Never>(.zero)
let willEndFrame = CurrentValueSubject<CGRect, Never>(.zero)
private init() { private init() {
NotificationCenter.default.publisher(for: UIResponder.keyboardWillShowNotification, object: nil) NotificationCenter.default.publisher(for: UIResponder.keyboardWillShowNotification, object: nil)
@ -37,6 +38,15 @@ final class KeyboardResponderService {
NotificationCenter.default.publisher(for: UIResponder.keyboardDidChangeFrameNotification, object: nil) NotificationCenter.default.publisher(for: UIResponder.keyboardDidChangeFrameNotification, object: nil)
.sink { notification in .sink { notification in
guard let endFrame = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect else { return }
self.didEndFrame.value = endFrame
self.updateInternalStatus(notification: notification)
}
.store(in: &disposeBag)
NotificationCenter.default.publisher(for: UIResponder.keyboardWillChangeFrameNotification, object: nil)
.sink { notification in
guard let endFrame = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect else { return }
self.willEndFrame.value = endFrame
self.updateInternalStatus(notification: notification) self.updateInternalStatus(notification: notification)
} }
.store(in: &disposeBag) .store(in: &disposeBag)
@ -52,8 +62,6 @@ extension KeyboardResponderService {
return return
} }
self.endFrame.value = endFrame
guard isLocal else { guard isLocal else {
self.state.value = .notLocal self.state.value = .notLocal
return return