Skip to content

Commit

Permalink
[Gardening] Rename semicircular to capsule, handle narrow capsule case
Browse files Browse the repository at this point in the history
  • Loading branch information
nononoah committed Sep 14, 2020
1 parent 5b59899 commit e2772d1
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
6 changes: 3 additions & 3 deletions BlueprintUICommonControls/Sources/Box.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ extension Box {

public enum CornerStyle {
case square
case semicircular
case capsule
case rounded(radius: CGFloat)
}

Expand Down Expand Up @@ -145,8 +145,8 @@ extension Box.CornerStyle {
switch self {
case .square:
return 0
case .semicircular:
return bounds.height / 2.0
case .capsule:
return min(bounds.height, bounds.width) / 2.0
case let .rounded(radius: radius):
return radius
}
Expand Down
9 changes: 7 additions & 2 deletions BlueprintUICommonControls/Tests/Sources/BoxTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,16 @@ class BoxTests: XCTestCase {
do {
var box = Box()
box.backgroundColor = .blue
box.cornerStyle = .semicircular
box.cornerStyle = .capsule
compareSnapshot(
of: box,
size: CGSize(width: 200, height: 100),
identifier: "semicircular")
identifier: "wideCapsule")

compareSnapshot(
of: box,
size: CGSize(width: 100, height: 200),
identifier: "longCapsule")
}

do {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Add `addFixed(child:)` and `addFlexible(child:)` methods to `StackElement` for adding children with a grow & shrink priority of 0.0 and 1.0 respectively.

- Add `semicircular` case to `Box.CornerStyle` ([#145]). This addition sugars the following pattern
- Add `capsule` case to `Box.CornerStyle` ([#145]). This addition sugars the following pattern

```
GeometryReader { geometry in
Expand All @@ -24,7 +24,7 @@ GeometryReader { geometry in
into

```
Box(cornerStyle: .semicircular)
Box(cornerStyle: .capsule)
```

### Removed
Expand Down

0 comments on commit e2772d1

Please sign in to comment.