Skip to content

Commit 78ddfd8

Browse files
committed
[design] #157 PokitBookmark 추가
1 parent 43b0e25 commit 78ddfd8

File tree

2 files changed

+72
-1
lines changed

2 files changed

+72
-1
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
//
2+
// PokitBookmark.swift
3+
// DSKit
4+
//
5+
// Created by 김도형 on 11/28/24.
6+
//
7+
8+
import SwiftUI
9+
10+
public struct PokitBookmark: View {
11+
private let state: PokitBookmark.State
12+
private let action: () -> Void
13+
14+
public init(
15+
state: PokitBookmark.State,
16+
action: @escaping () -> Void
17+
) {
18+
self.state = state
19+
self.action = action
20+
}
21+
22+
public var body: some View {
23+
Button(action: action) {
24+
Image(.icon(.starFill))
25+
.resizable()
26+
.frame(width: 24, height: 24)
27+
.foregroundStyle(starColor)
28+
.padding(4)
29+
.background {
30+
RoundedRectangle(
31+
cornerRadius: 9999,
32+
style: .continuous
33+
)
34+
.fill(backgroundColor)
35+
}
36+
}
37+
.disabled(state == .disable)
38+
}
39+
40+
private var starColor: Color {
41+
switch state {
42+
case .default, .disable:
43+
return .pokit(.icon(.disable))
44+
case .active:
45+
return .pokit(.icon(.brand))
46+
}
47+
}
48+
49+
private var backgroundColor: Color {
50+
switch state {
51+
case .default, .active:
52+
return .pokit(.bg(.baseIcon))
53+
case .disable:
54+
return .pokit(.bg(.disable))
55+
}
56+
}
57+
}
58+
59+
extension PokitBookmark {
60+
public enum State {
61+
case `default`
62+
case active
63+
case disable
64+
}
65+
}
66+
67+
#Preview {
68+
PokitBookmark(state: .active) {
69+
70+
}
71+
}

Projects/DSKit/Sources/Extensions/Color+Extension.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public extension Color {
144144
case .bg(let bg):
145145
switch bg {
146146
case .base: return .pokitColor(.grayScale(.white))
147-
case .baseIcon: return Color(hue: 0, saturation: 0, brightness: 85, opacity: 0.6)
147+
case .baseIcon: return Color(red: 0.85, green: 0.85, blue: 0.85).opacity(0.6)
148148
case .brand: return .pokitColor(.orange(._700))
149149
case .disable: return .pokitColor(.grayScale(._200))
150150
case .error: return .pokitColor(.red(._500))

0 commit comments

Comments
 (0)