Skip to content

Commit

Permalink
[Snackbar][Demo][UIKit] Replaced tap action by a checkbox for full width
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisBorleeAdevinta committed Oct 4, 2024
1 parent 4c210ba commit 25ac101
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions .Demo/Classes/View/NewComponents/Snackbar/SnackbarDemoUIView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ final class SnackbarDemoUIView: UIViewController {

private var cancellables = Set<AnyCancellable>()

deinit {
print("Deinit \(self)")
}

override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = .systemBackground
Expand All @@ -111,6 +107,7 @@ final class SnackbarDemoUIView: UIViewController {
self.setupLeftPaddingConfiguration()
self.setupRightPaddingConfiguration()
self.setupLabelLineNumberConfiguration()
self.setupFullWithConfiguration()
self.setupLabelTextFieldConfiguration()
self.setupButtonTextFieldConfiguration()
}
Expand Down Expand Up @@ -222,10 +219,6 @@ extension SnackbarDemoUIView {
private func addButton() {
let button = self.snackbar.addButton()
button.setTitle(self.buttonTextField.text, for: .normal)
button.addAction(.init(handler: { [weak self] _ in
guard let self else { return }
self.snackbarWidthConstraint.isActive.toggle()
}), for: .touchUpInside)
}
}

Expand Down Expand Up @@ -376,6 +369,22 @@ extension SnackbarDemoUIView {
self.verticalStackView.addArrangedSubview(checkbox)
}

private func setupFullWithConfiguration() {
let checkbox = CheckboxUIView(
theme: self.theme,
intent: .basic,
text: "Is full width",
checkedImage: .init(systemName: "checkmark")?.withRenderingMode(.alwaysTemplate) ?? UIImage(),
selectionState: .unselected,
alignment: .left
)
checkbox.publisher.subscribe(in: &self.cancellables) { [weak self] state in
guard let self else { return }
self.snackbarWidthConstraint.isActive.toggle()
}
self.verticalStackView.addArrangedSubview(checkbox)
}

private func setupLabelTextFieldConfiguration() {
self.labelTextField.addAction(.init(handler: { _ in
self.snackbar.label.text = self.labelTextField.text
Expand Down

0 comments on commit 25ac101

Please sign in to comment.