generated from GSM-MSG/MSG-Repository-Generator
-
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
Showing
2 changed files
with
53 additions
and
9 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
56 changes: 49 additions & 7 deletions
56
Projects/Core/DesignSystem/Sources/Chip/SMSChipButtonStyle.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 |
---|---|---|
@@ -1,12 +1,54 @@ | ||
import SwiftUI | ||
|
||
public enum ChipStyle { | ||
case outline | ||
case `default` | ||
} | ||
|
||
struct SMSChipButtonStyle: ButtonStyle { | ||
func makeBody(configuration: Configuration) -> some View { | ||
configuration.label | ||
.padding(8) | ||
.background { | ||
configuration.isPressed ? Color.sms(.neutral(.n10)) : .sms(.system(.white)) | ||
} | ||
.cornerRadius(8) | ||
var style: ChipStyle | ||
|
||
public func makeBody(configuration: Configuration) -> some View { | ||
switch style { | ||
case .outline: | ||
OutlineChip(configuration: configuration) | ||
|
||
case .`default`: | ||
DefaultChip(configuration: configuration) | ||
} | ||
} | ||
} | ||
|
||
extension SMSChipButtonStyle { | ||
struct DefaultChip: View { | ||
let configuration: ButtonStyle.Configuration | ||
|
||
var body: some View { | ||
configuration.label | ||
.smsFont(.body1, color: .neutral(.n30)) | ||
.padding(8) | ||
.background { | ||
configuration.isPressed ? Color.sms(.neutral(.n10)) : .sms(.system(.white)) | ||
} | ||
.cornerRadius(8) | ||
} | ||
} | ||
} | ||
|
||
extension SMSChipButtonStyle { | ||
struct OutlineChip: View { | ||
let configuration: ButtonStyle.Configuration | ||
var body: some View { | ||
configuration.label | ||
.padding(8) | ||
.smsFont(.body1, color: .system(.black)) | ||
.background { | ||
configuration.isPressed ? Color.sms(.neutral(.n10)) : .sms(.system(.white)) | ||
} | ||
.overlay { | ||
RoundedRectangle(cornerRadius: 8).stroke(Color.sms(.system(.black)), lineWidth: 1) | ||
} | ||
.cornerRadius(8) | ||
} | ||
} | ||
} |