Skip to content

Commit

Permalink
Merge pull request #1010 from adevinta/1009-component-textfield-add-s…
Browse files Browse the repository at this point in the history
…cale-factor-to-corner-radius

[TextField#1009] Fixed corner radius scaling
  • Loading branch information
LouisBorleeAdevinta authored Jun 27, 2024
2 parents 84782a7 + 093dea6 commit fbb7951
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ public struct TextFieldAddons<LeftView: View, RightView: View, LeftAddon: View,
}
.frame(maxHeight: maxHeight)
.allowsHitTesting(self.viewModel.textFieldViewModel.isUserInteractionEnabled)
.border(width: self.viewModel.borderWidth * self.scaleFactor, radius: self.viewModel.borderRadius, colorToken: self.viewModel.textFieldViewModel.borderColor)
.border(
width: self.viewModel.borderWidth * self.scaleFactor,
radius: self.viewModel.borderRadius * self.scaleFactor,
colorToken: self.viewModel.textFieldViewModel.borderColor
)
.opacity(self.viewModel.dim)
.accessibilityElement(children: .contain)
.accessibilityIdentifier(TextFieldAddonsAccessibilityIdentifier.view)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public final class TextFieldAddonsUIView: UIControl {

self.viewModel.$borderRadius.removeDuplicates().subscribe(in: &self.cancellables) { [weak self] borderRadius in
guard let self else { return }
self.setCornerRadius(borderRadius)
self.setCornerRadius(borderRadius * self.scaleFactor)
}

self.viewModel.$leftSpacing.removeDuplicates().subscribe(in: &self.cancellables) { [weak self] leftSpacing in
Expand Down Expand Up @@ -221,6 +221,7 @@ public final class TextFieldAddonsUIView: UIControl {
guard previousTraitCollection?.preferredContentSizeCategory != self.traitCollection.preferredContentSizeCategory else { return }

self._scaleFactor.update(traitCollection: self.traitCollection)
self.setCornerRadius(self.viewModel.borderRadius * self.scaleFactor)
self.setBorderWidthAndRefreshAddonsXCenter(self.borderWidth)
self.setLeftSpacing(self.viewModel.leftSpacing, borderWidth: self.borderWidth)
self.setRightSpacing(self.viewModel.rightSpacing, borderWidth: self.borderWidth)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ struct TextFieldViewInternal<LeftView: View, RightView: View>: View {
}
.tint(self.viewModel.textColor.color)
.allowsHitTesting(self.viewModel.isUserInteractionEnabled)
.border(width: self.viewModel.borderWidth * self.scaleFactor, radius: self.viewModel.borderRadius, colorToken: self.viewModel.borderColor)
.border(
width: self.viewModel.borderWidth * self.scaleFactor,
radius: self.viewModel.borderRadius * self.scaleFactor,
colorToken: self.viewModel.borderColor
)
.frame(height: self.height)
.opacity(self.viewModel.dim)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public final class TextFieldUIView: UITextField {

self.viewModel.$borderRadius.removeDuplicates().subscribe(in: &self.cancellables) { [weak self] borderRadius in
guard let self else { return }
self.setCornerRadius(borderRadius)
self.setCornerRadius(borderRadius * self.scaleFactor)
}

self.viewModel.$leftSpacing.removeDuplicates().subscribe(in: &self.cancellables) { [weak self] dim in
Expand Down Expand Up @@ -272,6 +272,7 @@ public final class TextFieldUIView: UITextField {

self._height.update(traitCollection: self.traitCollection)
self._scaleFactor.update(traitCollection: self.traitCollection)
self.setCornerRadius(self.viewModel.borderRadius * self.scaleFactor)
self.setBorderWidth(self.viewModel.borderWidth * self.scaleFactor)
self.invalidateIntrinsicContentSize()
}
Expand Down

0 comments on commit fbb7951

Please sign in to comment.