-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d38a8b6
commit 77be5c0
Showing
8 changed files
with
138 additions
and
23 deletions.
There are no files selected for viewing
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
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
3 changes: 3 additions & 0 deletions
3
...em/Resources/Image.xcassets/16/16_minus_tertiary.imageset/16_minus_tertiary.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions
12
.../Shared/DesignSystem/Resources/Image.xcassets/16/16_minus_tertiary.imageset/Contents.json
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,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "16_minus_tertiary.svg", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
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
3 changes: 3 additions & 0 deletions
3
...stem/Resources/Image.xcassets/16/16_plus_tertiary.imageset/16_plus_tertiary.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions
12
...s/Shared/DesignSystem/Resources/Image.xcassets/16/16_plus_tertiary.imageset/Contents.json
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,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "16_plus_tertiary.svg", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
Projects/Shared/DesignSystem/Sources/Component/Button/Select/SelectChipButtonStyle.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,79 @@ | ||
// | ||
// SelectChipButtonStyle.swift | ||
// DesignSystem | ||
// | ||
// Created by devMinseok on 8/24/24. | ||
// Copyright © 2024 PomoNyang. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
public struct SelectChipButtonStyle: ButtonStyle { | ||
let isSelected: Bool | ||
let isDisabled: Bool | ||
|
||
public init( | ||
isSelected: Bool, | ||
isDisabled: Bool | ||
) { | ||
self.isSelected = isSelected | ||
self.isDisabled = isDisabled | ||
} | ||
|
||
public func makeBody(configuration: Configuration) -> some View { | ||
configuration.label | ||
.selectButtonDetailStyle( | ||
SelectChipButtonStyleImpl( | ||
isSelected: isSelected, | ||
isDisabled: isDisabled | ||
) | ||
) | ||
} | ||
} | ||
|
||
extension ButtonStyle where Self == SelectChipButtonStyle { | ||
public static func selectChip( | ||
isSelected: Bool, | ||
isDisabled: Bool | ||
) -> Self { | ||
return SelectChipButtonStyle(isSelected: isSelected, isDisabled: isDisabled) | ||
} | ||
} | ||
|
||
struct SelectChipButtonStyleImpl: SelectButtonDetailStyle { | ||
let isSelected: Bool | ||
let isDisabled: Bool | ||
|
||
func makeBody(configuration: Configuration) -> some View { | ||
HStack(spacing: Alias.Spacing.xSmall) { | ||
configuration.leftIcon | ||
configuration.subtitle | ||
.font(Typography.bodySB) | ||
.foregroundStyle(getSubtitleForegourndColor()) | ||
configuration.rightIcon | ||
} | ||
.padding(.horizontal, Alias.Spacing.medium) | ||
.padding(.vertical, Alias.Spacing.small) | ||
.background( | ||
RoundedRectangle(cornerRadius: Alias.BorderRadius.xSmall) | ||
.fill(getBackgroundColor()) | ||
.strokeBorder(isSelected ? Alias.Color.Background.accent1 : .clear, lineWidth: 1) | ||
) | ||
} | ||
|
||
func getSubtitleForegourndColor() -> Color { | ||
if isDisabled { | ||
return Alias.Color.Text.disabled | ||
} else { | ||
return Alias.Color.Text.tertiary | ||
} | ||
} | ||
|
||
func getBackgroundColor() -> Color { | ||
if isSelected { | ||
return Alias.Color.Background.accent2 | ||
} else { | ||
return Alias.Color.Background.secondary | ||
} | ||
} | ||
} |