Skip to content

Commit

Permalink
[Feature] 베지어 버튼, Boxing 관련 기능 추가 (#5)
Browse files Browse the repository at this point in the history
* [Feature] 베지어 버튼, Boxing 관련 기능 추가

* [Etc] 리뷰적용
  • Loading branch information
jam0128 authored Feb 13, 2023
1 parent d1a45f2 commit 8fbf47b
Show file tree
Hide file tree
Showing 4 changed files with 844 additions and 0 deletions.
68 changes: 68 additions & 0 deletions Sources/BezierSwift/Foundation/Boxing/BezierCornerRadius.swift
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 Sources/BezierSwift/Foundation/Boxing/BezierElevation.swift
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
)
}
}
3 changes: 3 additions & 0 deletions Sources/BezierSwift/Foundation/Color/SemanticColor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import SwiftUI

public enum SemanticColor {
case bgTransparent

// MARK: - Background
case bgWhiteHigh
case bgWhiteLow
Expand Down Expand Up @@ -155,6 +157,7 @@ extension SemanticColor {

private var paletteSet: PaletteSet {
switch self {
case .bgTransparent: return (Palette.white_0, Palette.white_0)
// MARK: - Background
case .bgWhiteHigh: return (Palette.white, Palette.grey700)
case .bgWhiteLow: return (Palette.white, Palette.grey800)
Expand Down
Loading

0 comments on commit 8fbf47b

Please sign in to comment.