-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] 베지어 버튼, Boxing 관련 기능 추가 (#5)
* [Feature] 베지어 버튼, Boxing 관련 기능 추가 * [Etc] 리뷰적용
- Loading branch information
Showing
4 changed files
with
844 additions
and
0 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
Sources/BezierSwift/Foundation/Boxing/BezierCornerRadius.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// | ||
// BezierCornerRadius.swift | ||
// | ||
// | ||
// Created by Jam on 2023/02/09. | ||
// | ||
|
||
import SwiftUI | ||
|
||
enum BezierCornerRadius { | ||
case round2 | ||
case round3 | ||
case round4 | ||
case round6 | ||
case round8 | ||
case round12 | ||
case round16 | ||
case round20 | ||
case round22 | ||
case round32 | ||
case round44 | ||
case roundHalf(length: CGFloat) | ||
case roundAvatar(length: CGFloat) | ||
|
||
var rawValue: CGFloat { | ||
switch self { | ||
case .round2: | ||
return CGFloat(2) | ||
case .round3: | ||
return CGFloat(3) | ||
case .round4: | ||
return CGFloat(4) | ||
case .round6: | ||
return CGFloat(6) | ||
case .round8: | ||
return CGFloat(8) | ||
case .round12: | ||
return CGFloat(12) | ||
case .round16: | ||
return CGFloat(16) | ||
case .round20: | ||
return CGFloat(20) | ||
case .round22: | ||
return CGFloat(22) | ||
case .round32: | ||
return CGFloat(32) | ||
case .round44: | ||
return CGFloat(44) | ||
case .roundHalf(let length): | ||
return length / CGFloat(2) | ||
case .roundAvatar(let length): | ||
return length * CGFloat(0.42) | ||
} | ||
} | ||
} | ||
|
||
|
||
extension View { | ||
func applyBezierCornerRadius(type: BezierCornerRadius, correction: CGFloat = 0) -> some View { | ||
return self | ||
.clipShape( | ||
RoundedRectangle( | ||
cornerRadius: type.rawValue + correction, | ||
style: .continuous | ||
) | ||
) | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
Sources/BezierSwift/Foundation/Boxing/BezierElevation.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// BezierElevation.swift | ||
// | ||
// | ||
// Created by Jam on 2023/02/09. | ||
// | ||
|
||
import SwiftUI | ||
|
||
enum BezierElevation { | ||
case mEv1 | ||
case mEv2 | ||
case mEv3 | ||
case mEv4 | ||
case mEv5 | ||
case mEv6 | ||
|
||
func rawValue( | ||
_ themeable: Themeable | ||
) -> (color: Color, x: CGFloat, y: CGFloat, blur: CGFloat) { | ||
switch self { | ||
case .mEv1: return (themeable.palette(.shdwMedium), 0, 1, 4) | ||
case .mEv2: return (themeable.palette(.shdwMedium), 0, 2, 6) | ||
case .mEv3: return (themeable.palette(.shdwLarge), 0, 4, 20) | ||
case .mEv4: return (themeable.palette(.shdwXlarge), 0, 4, 24) | ||
case .mEv5: return (themeable.palette(.shdwXlarge), 0, 6, 40) | ||
case .mEv6: return (themeable.palette(.shdwXlarge), 0, 12, 60) | ||
} | ||
} | ||
} | ||
|
||
extension View { | ||
func applyBezierElevation(_ themeable: Themeable, type: BezierElevation) -> some View { | ||
let rawVaue = type.rawValue(themeable) | ||
return self | ||
.shadow( | ||
color: rawVaue.color, | ||
radius: rawVaue.blur, | ||
x: rawVaue.x, | ||
y: rawVaue.y | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.