-
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
merge :: 디자인 시스템 - RadioButton #31
Merged
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6a6696f
feat :: 디자인 시스템 RadioButton
sian7563 ff9434f
feat :: RadioButton 수정
sian7563 4dc636a
feat :: RadioButton 수정
sian7563 34a6032
feat :: DMSRadioButton 수정
sian7563 b890306
feat :: RadioButtonExtension 수정
sian7563 dfad4ea
feat :: DMSRadioButton 수정
sian7563 2efadd0
feat :: extension 파일 이름 수정
sian7563 be93166
Merge branch 'develop' of https://github.com/team-aliens/DMS-iOS into…
sian7563 e7d98f9
feat :: DMSRadioButton 수정
sian7563 f6e1abb
feat :: DMSRadioButton 수정
sian7563 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
55 changes: 55 additions & 0 deletions
55
Projects/UsertInterfaces/DesignSystem/Sources/RadioButton/DMSRadioButton.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,55 @@ | ||
import SwiftUI | ||
|
||
public struct DMSRadioButton: View { | ||
|
||
@Binding var isOn: Bool | ||
@Binding var isDisabeld: Bool | ||
|
||
let id: String | ||
let size: CGFloat | ||
let callback: (String) -> Void | ||
baekteun marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
public init( | ||
isOn: Binding<Bool> = .constant(false), | ||
isDisabled: Binding<Bool> = .constant(false), | ||
id: String, | ||
size: CGFloat = 20, | ||
callback: @escaping (String) -> Void | ||
) { | ||
self._isOn = isOn | ||
self._isDisabeld = isDisabled | ||
self.id = id | ||
self.size = size | ||
baekteun marked this conversation as resolved.
Show resolved
Hide resolved
|
||
self.callback = callback | ||
} | ||
|
||
public var body: some View { | ||
Button { | ||
self.isOn.toggle() | ||
self.callback(self.id) | ||
} label: { | ||
HStack(alignment: .center) { | ||
if self.isDisabeld { | ||
Image(systemName: self.isOn ? "largecircle.fill.circle" : "circle") | ||
.clipShape(Circle()) | ||
.foregroundColor(self.isOn ? Color.PrimaryVariant.lighten1 : Color.GrayScale.gray3) | ||
.disabled(isDisabeld) | ||
baekteun marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} else { | ||
Image(systemName: self.isOn ? "largecircle.fill.circle" : "circle") | ||
.clipShape(Circle()) | ||
.foregroundColor(self.isOn ? Color.PrimaryVariant.primary : Color.GrayScale.gray5) | ||
.disabled(isDisabeld) | ||
baekteun marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
baekteun marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
} | ||
} | ||
|
||
struct DMSRadioButton_Previews: PreviewProvider { | ||
static var previews: some View { | ||
DMSRadioButton( | ||
id: "asdf", | ||
callback: { _ in } | ||
) | ||
} | ||
} |
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.
disabled를 binding으로 받는 특별한 이유가 있을까요?
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.
@Environment(.isEnabled)로 isEnabled상태를 받을 수 있으니 이거 쓰시는게 어떤가요