Skip to content

Instantly share code, notes, and snippets.

@b-onc
Created March 10, 2020 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save b-onc/4416132a0ec4ebe1c1791b451500f36e to your computer and use it in GitHub Desktop.
Save b-onc/4416132a0ec4ebe1c1791b451500f36e to your computer and use it in GitHub Desktop.
private func setupUI() {
view.addSubview(cameraButton)
cameraButton.translatesAutoresizingMaskIntoConstraints = false
cameraButton.setImage(UIImage(systemName: "camera.fill",
withConfiguration: UIImage.SymbolConfiguration(font: .systemFont(ofSize: 24))),
for: .normal)
cameraButton.tintColor = UIColor.gray.withAlphaComponent(0.7)
view.addSubview(soundRecordButton)
soundRecordButton.translatesAutoresizingMaskIntoConstraints = false
soundRecordButton.setImage(UIImage(systemName: "waveform.circle.fill",
withConfiguration: UIImage.SymbolConfiguration(font: .systemFont(ofSize: 30, weight: .bold))),
for: .normal)
soundRecordButton.tintColor = UIColor.gray.withAlphaComponent(0.7)
NSLayoutConstraint.activate([
cameraButton.centerYAnchor.constraint(equalTo: composerView.centerYAnchor),
cameraButton.leftAnchor.constraint(equalTo: view.leftAnchor, constant: 16),
cameraButton.heightAnchor.constraint(equalToConstant: 40),
soundRecordButton.centerYAnchor.constraint(equalTo: composerView.centerYAnchor),
soundRecordButton.rightAnchor.constraint(equalTo: composerView.rightAnchor, constant: -2),
])
composerView
.sendButtonVisibility
.asDriver(onErrorJustReturn: (isHidden: false, isEnabled: false))
.drive(onNext: { [weak self] state in
self?.soundRecordButton.isHidden = !state.isHidden
}).disposed(by: disposeBag)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment