generated from GSM-MSG/MSG-Repository-Generator
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
π :: DesignSystem SMSSelectionControls μ μ #37
Merged
Merged
Changes from 13 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
e70aa84
:lipstick: SMSSelectionControls μ μ
kimsh153 715d732
:recycle: SMSSelctionControls
kimsh153 4fb864d
:recycle: Group μμ
kimsh153 abab51c
:lipstick: RadioButtonComponent
kimsh153 6eef1cf
Merge branch 'master' of https://github.com/GSM-MSG/SMS-iOS into 36-sβ¦
kimsh153 3d7d4ad
:fire: μ΄μν μ½λ μ§μ°κΈ° =
kimsh153 94053a1
Merge branch 'master' of https://github.com/GSM-MSG/SMS-iOS into 36-sβ¦
kimsh153 e25c2a4
:recycle: Comment μμ
kimsh153 1a75279
:recycle: init μμ
kimsh153 6535fe1
:recycle: Public μ ν
kimsh153 80e8c8e
:recycle: Comment μμ
kimsh153 8c29c2a
Merge branch 'master' of https://github.com/GSM-MSG/SMS-iOS into 36-sβ¦
kimsh153 1208295
:recycle: Commnet μμ
kimsh153 fdc43eb
:recycle: λ°λ‘ λ
Έλκ±° μμ
kimsh153 8a8091a
:recycle: λ°λ‘ λ
Έλκ±° μμ
kimsh153 f326a31
:boom: κ²°κ΅ ν΄κ²°μ±
μ μ°Ύμ§ λͺ»νκ³ μ²μμΌλ‘ λμμμ΅λλ€
kimsh153 97479aa
:recycle: PressedSelectionButtonStyle
kimsh153 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
32 changes: 32 additions & 0 deletions
32
Projects/Core/DesignSystem/Sources/SelectionControls/RadioComponent.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,32 @@ | ||
import SwiftUI | ||
|
||
public struct RadioComponent<T: Hashable, Content: View>: View { | ||
private let value: RadioValue<T> | ||
private let content: () -> Content | ||
|
||
public init( | ||
selection: Binding<T?>, | ||
@ViewBuilder _ content: @escaping () -> Content, | ||
onTapReceive: ((T?) -> Void)? = nil | ||
) { | ||
self.value = RadioValue(selection: selection, onTapReceive: onTapReceive) | ||
self.content = content | ||
} | ||
|
||
public var body: some View { | ||
content() | ||
.environmentObject(value) | ||
} | ||
} | ||
|
||
final class RadioValue<T: Hashable>: ObservableObject { | ||
typealias TapReceiveAction = (T?) -> Void | ||
|
||
@Binding var selection: T? | ||
var onTapReceive: (TapReceiveAction)? | ||
|
||
init(selection: Binding<T?>, onTapReceive: (TapReceiveAction)? = nil) { | ||
_selection = selection | ||
self.onTapReceive = onTapReceive | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
Projects/Core/DesignSystem/Sources/SelectionControls/RadioTag.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,26 @@ | ||
import SwiftUI | ||
|
||
public struct RadioTag<T: Hashable>: ViewModifier { | ||
@EnvironmentObject private var value: RadioValue<T> | ||
private var tag: T? | ||
|
||
init(_ tag: T?) { | ||
self.tag = tag | ||
} | ||
|
||
public func body(content: Content) -> some View { | ||
Button { | ||
value.selection = tag | ||
value.onTapReceive?(tag) | ||
} label: { | ||
content | ||
} | ||
.buttonStyle(CustomButtonStyle.init(isOn: tag == value.selection)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CustomButtonStyle μ΄κ±° μ νΌμ λ°λ‘ λμμ? |
||
} | ||
} | ||
|
||
extension View { | ||
public func radioTag<T: Hashable>(_ tag: T?) -> some View { | ||
self.modifier(RadioTag(tag)) | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
Projects/Core/DesignSystem/Sources/SelectionControls/SMSSelectionControls.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,40 @@ | ||
import SwiftUI | ||
|
||
public struct SMSSelectionControls<T: Hashable>: View { | ||
@EnvironmentObject private var value: RadioValue<T> | ||
private var tag: T? | ||
|
||
public init(tag: T?) { | ||
self.tag = tag | ||
} | ||
|
||
public var body: some View { | ||
ZStack { | ||
Circle() | ||
.stroke(tag == value.selection ? Color.sms(.primary(.p2)) : Color.sms(.neutral(.n20)), lineWidth: 2) | ||
.frame(width: 20, height: 20) | ||
|
||
Circle() | ||
.fill(tag == value.selection ? Color.sms(.primary(.p2)) : .clear) | ||
.frame(width: 12, height: 12) | ||
} | ||
} | ||
} | ||
|
||
struct CustomButtonStyle: ButtonStyle { | ||
var isOn: Bool | ||
|
||
init(isOn: Bool) { | ||
self.isOn = isOn | ||
} | ||
|
||
@ViewBuilder | ||
func makeBody(configuration: Configuration) -> some View { | ||
Circle() | ||
.fill(self.isOn && configuration.isPressed ? Color.sms(.neutral(.n20)) : Color.clear) | ||
.overlay { | ||
configuration.label | ||
} | ||
.frame(width: 32, height: 32) | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
content μ΄ μΉκ΅¬ labelμ΄ μ _ μΈκ±°μ£ ?