chore: set the photoButton highlight with some value alpha
This commit is contained in:
parent
ad8dfb25ad
commit
384fe6018e
|
@ -8,9 +8,9 @@
|
||||||
import Combine
|
import Combine
|
||||||
import MastodonSDK
|
import MastodonSDK
|
||||||
import os.log
|
import os.log
|
||||||
|
import PhotosUI
|
||||||
import UIKit
|
import UIKit
|
||||||
import UITextField_Shake
|
import UITextField_Shake
|
||||||
import PhotosUI
|
|
||||||
|
|
||||||
final class MastodonRegisterViewController: UIViewController, NeedsDependency, OnboardingViewControllerAppearance {
|
final class MastodonRegisterViewController: UIViewController, NeedsDependency, OnboardingViewControllerAppearance {
|
||||||
var disposeBag = Set<AnyCancellable>()
|
var disposeBag = Set<AnyCancellable>()
|
||||||
|
@ -216,19 +216,28 @@ final class MastodonRegisterViewController: UIViewController, NeedsDependency, O
|
||||||
}()
|
}()
|
||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function)
|
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", (#file as NSString).lastPathComponent, #line, #function)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension MastodonRegisterViewController {
|
extension MastodonRegisterViewController {
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
|
||||||
setupOnboardingAppearance()
|
setupOnboardingAppearance()
|
||||||
defer { setupNavigationBarBackgroundView() }
|
defer { setupNavigationBarBackgroundView() }
|
||||||
|
|
||||||
|
NSObject.KeyValueObservingPublisher<UIButton, Bool>(object: photoButton, keyPath: \.isHighlighted, options: NSKeyValueObservingOptions.new)
|
||||||
|
.receive(on: DispatchQueue.main)
|
||||||
|
.sink { [weak self] isHighlighted in
|
||||||
|
guard let self = self else { return }
|
||||||
|
let alpha: CGFloat = isHighlighted ? 0.8 : 1
|
||||||
|
self.plusIcon.alpha = alpha
|
||||||
|
self.plusIconBackground.alpha = alpha
|
||||||
|
self.photoButton.alpha = alpha
|
||||||
|
}
|
||||||
|
.store(in: &disposeBag)
|
||||||
|
|
||||||
domainLabel.text = "@" + viewModel.domain + " "
|
domainLabel.text = "@" + viewModel.domain + " "
|
||||||
domainLabel.sizeToFit()
|
domainLabel.sizeToFit()
|
||||||
passwordCheckLabel.attributedText = viewModel.attributeStringForPassword()
|
passwordCheckLabel.attributedText = viewModel.attributeStringForPassword()
|
||||||
|
@ -415,7 +424,7 @@ extension MastodonRegisterViewController {
|
||||||
|
|
||||||
viewModel.isUsernameTaken
|
viewModel.isUsernameTaken
|
||||||
.receive(on: DispatchQueue.main)
|
.receive(on: DispatchQueue.main)
|
||||||
.sink {[weak self] isUsernameTaken in
|
.sink { [weak self] isUsernameTaken in
|
||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
if isUsernameTaken {
|
if isUsernameTaken {
|
||||||
self.usernameIsTakenLabel.isHidden = false
|
self.usernameIsTakenLabel.isHidden = false
|
||||||
|
@ -492,10 +501,9 @@ extension MastodonRegisterViewController {
|
||||||
.store(in: &disposeBag)
|
.store(in: &disposeBag)
|
||||||
|
|
||||||
if viewModel.approvalRequired {
|
if viewModel.approvalRequired {
|
||||||
|
|
||||||
inviteTextField.delegate = self
|
inviteTextField.delegate = self
|
||||||
NSLayoutConstraint.activate([
|
NSLayoutConstraint.activate([
|
||||||
inviteTextField.heightAnchor.constraint(equalToConstant: 50).priority(.defaultHigh)
|
inviteTextField.heightAnchor.constraint(equalToConstant: 50).priority(.defaultHigh),
|
||||||
])
|
])
|
||||||
|
|
||||||
viewModel.inviteValidateState
|
viewModel.inviteValidateState
|
||||||
|
@ -503,7 +511,6 @@ extension MastodonRegisterViewController {
|
||||||
.sink { [weak self] validateState in
|
.sink { [weak self] validateState in
|
||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
self.setTextFieldValidAppearance(self.inviteTextField, validateState: validateState)
|
self.setTextFieldValidAppearance(self.inviteTextField, validateState: validateState)
|
||||||
|
|
||||||
}
|
}
|
||||||
.store(in: &disposeBag)
|
.store(in: &disposeBag)
|
||||||
NotificationCenter.default
|
NotificationCenter.default
|
||||||
|
@ -518,11 +525,9 @@ extension MastodonRegisterViewController {
|
||||||
|
|
||||||
signUpButton.addTarget(self, action: #selector(MastodonRegisterViewController.signUpButtonPressed(_:)), for: .touchUpInside)
|
signUpButton.addTarget(self, action: #selector(MastodonRegisterViewController.signUpButtonPressed(_:)), for: .touchUpInside)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension MastodonRegisterViewController: UITextFieldDelegate {
|
extension MastodonRegisterViewController: UITextFieldDelegate {
|
||||||
|
|
||||||
func textFieldDidBeginEditing(_ textField: UITextField) {
|
func textFieldDidBeginEditing(_ textField: UITextField) {
|
||||||
let text = textField.text?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
|
let text = textField.text?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
|
||||||
|
|
||||||
|
@ -564,7 +569,6 @@ extension MastodonRegisterViewController: UITextFieldDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
extension MastodonRegisterViewController {
|
extension MastodonRegisterViewController {
|
||||||
|
|
||||||
@objc private func tapGestureRecognizerHandler(_ sender: UITapGestureRecognizer) {
|
@objc private func tapGestureRecognizerHandler(_ sender: UITapGestureRecognizer) {
|
||||||
view.endEditing(true)
|
view.endEditing(true)
|
||||||
}
|
}
|
||||||
|
@ -611,6 +615,5 @@ extension MastodonRegisterViewController {
|
||||||
self.coordinator.present(scene: .mastodonConfirmEmail(viewModel: viewModel), from: self, transition: .show)
|
self.coordinator.present(scene: .mastodonConfirmEmail(viewModel: viewModel), from: self, transition: .show)
|
||||||
}
|
}
|
||||||
.store(in: &disposeBag)
|
.store(in: &disposeBag)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue