Skip to content

Commit

Permalink
[Chip#990] Add touchesCancelled to chip.
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-zimmermann committed Jun 7, 2024
1 parent c3c95d2 commit 3c1a3b3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 6 additions & 0 deletions core/Sources/Components/Chip/View/UIKit/ChipUIView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,12 @@ public final class ChipUIView: UIControl {
}
}

// MARK: - Control functions
public override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesCancelled(touches, with: event)
self.viewModel.isPressed = false
}

//MARK: - Private functions
/// Update all colors used
private func setChipColors(_ chipColors: ChipStateColors) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ final class ChipCell: UITableViewCell, Configurable {
self.component.isSelected = configuration.isSelected
self.component.text = configuration.title
self.component.icon = configuration.icon
self.component.action = {}
}
}
11 changes: 8 additions & 3 deletions spark/Demo/Classes/View/ListView/ListViewDatasource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,14 @@ extension ListViewDataSource {

/// Chip
func createChipConfigurations() -> [ChipConfiguration] {
[ChipConfiguration(theme: SparkTheme.shared, intent: .main, variant: .dashed, alignment: .leadingIcon, isEnabled: true, isSelected: false, title: "This is", icon: UIImage(systemName: "calendar")),
ChipConfiguration(theme: SparkTheme.shared, intent: .basic, variant: .outlined, alignment: .trailingIcon, isEnabled: false, isSelected: false, title: "A chip", icon: UIImage(systemName: "arrowshape.left") ),
ChipConfiguration(theme: SparkTheme.shared, intent: .success, variant: .tinted, alignment: .leadingIcon, isEnabled: true, isSelected: true, title: "Hello", icon: nil)]
[
ChipConfiguration(theme: SparkTheme.shared, intent: .main, variant: .dashed, alignment: .leadingIcon, isEnabled: true, isSelected: false, title: "Main", icon: UIImage(systemName: "calendar")),
ChipConfiguration(theme: SparkTheme.shared, intent: .basic, variant: .outlined, alignment: .leadingIcon, isEnabled: true, isSelected: false, title: "Basic Enabled", icon: nil),
ChipConfiguration(theme: SparkTheme.shared, intent: .basic, variant: .outlined, alignment: .leadingIcon, isEnabled: true, isSelected: true, title: "Basic Enabled Selected", icon: nil),
ChipConfiguration(theme: SparkTheme.shared, intent: .basic, variant: .outlined, alignment: .trailingIcon, isEnabled: false, isSelected: false, title: "Basic Disabled", icon: UIImage(systemName: "arrowshape.left") ),
ChipConfiguration(theme: SparkTheme.shared, intent: .success, variant: .tinted, alignment: .leadingIcon, isEnabled: true, isSelected: false, title: "Success", icon: nil),
ChipConfiguration(theme: SparkTheme.shared, intent: .success, variant: .tinted, alignment: .leadingIcon, isEnabled: true, isSelected: true, title: "Success Selected", icon: nil)
]
}

/// Icon
Expand Down

0 comments on commit 3c1a3b3

Please sign in to comment.