-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 버튼 컴포넌트 개발 #68
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
Merged
Merged
feat: 버튼 컴포넌트 개발 #68
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
2826693
[BOOK-114] feat: SetNeeds propertyWrapper 추가
doyeonk429 df63b16
[BOOK-114] feat: add BKButtonProtocol
doyeonk429 fc471b2
[BOOK-114] feat: add ButtonStyle
doyeonk429 024bd4a
[BOOK-114] feat: ButtonState enum 추가 및 컬러셋과 연결
doyeonk429 f815beb
[BOOK-114] feat: ButtonSize 정의
doyeonk429 6cf6150
[BOOK-114] feat: BKButtonConfiguration 정의
doyeonk429 4b6f333
[BOOK-114] feat: UIImage extension for Icon resizing
doyeonk429 70f8e28
[BOOK-114] feat: BKDesignTestApp 추가
doyeonk429 90f0c65
[BOOK-114] feat: Button Foldering 수정
doyeonk429 0296e98
[BOOK-114] feat: BKButton class 구현
doyeonk429 6840b3b
[BOOK-114] test: 기본 버튼 테스트 뷰컨트롤러 개발
doyeonk429 ea6a195
[BOOK-114] feat: BKButtonGroup 개발
doyeonk429 37e9980
[BOOK-114] test: Button Group 테스트 코드 작성
doyeonk429 881a61a
[BOOK-114] fix: 커스텀 버튼 컬러셋 추가할 수 있도록 수정
doyeonk429 f4d6d4e
[BOOK-114] fix: equtable 조건 만족하게 수정
doyeonk429 732db67
[BOOK-114] fix: icon spacing 추가
doyeonk429 72b44fe
[BOOK-114] fix: 토끼 수정제안 일부 적용
doyeonk429 d828e9f
[BOOK-114] fix: convention 수정
doyeonk429 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 hidden or 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,68 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
| <plist version="1.0"> | ||
| <dict> | ||
| <key>CFBundleDevelopmentRegion</key> | ||
| <string>en</string> | ||
| <key>CFBundleExecutable</key> | ||
| <string>$(EXECUTABLE_NAME)</string> | ||
| <key>CFBundleIdentifier</key> | ||
| <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
| <key>CFBundleInfoDictionaryVersion</key> | ||
| <string>6.0</string> | ||
| <key>CFBundleName</key> | ||
| <string>$(PRODUCT_NAME)</string> | ||
| <key>CFBundlePackageType</key> | ||
| <string>APPL</string> | ||
| <key>CFBundleShortVersionString</key> | ||
| <string>1.0</string> | ||
| <key>CFBundleVersion</key> | ||
| <string>1</string> | ||
|
|
||
| <!-- 🖼 LaunchScreen --> | ||
| <key>UILaunchStoryboardName</key> | ||
| <string>LaunchScreen</string> | ||
|
|
||
| <!-- 📱 iPhone만 지원 --> | ||
| <key>UIDeviceFamily</key> | ||
| <array> | ||
| <integer>1</integer> | ||
| </array> | ||
|
|
||
| <!-- 🎬 SceneDelegate 연결 --> | ||
| <key>UIApplicationSceneManifest</key> | ||
| <dict> | ||
| <key>UIApplicationSupportsMultipleScenes</key> | ||
| <false/> | ||
| <key>UISceneConfigurations</key> | ||
| <dict> | ||
| <key>UIWindowSceneSessionRoleApplication</key> | ||
| <array> | ||
| <dict> | ||
| <key>UISceneClassName</key> | ||
| <string>UIWindowScene</string> | ||
| <key>UISceneConfigurationName</key> | ||
| <string>Default Configuration</string> | ||
| <key>UISceneDelegateClassName</key> | ||
| <string>BKDesignPreviewApp.SceneDelegate</string> | ||
| </dict> | ||
| </array> | ||
| </dict> | ||
| </dict> | ||
|
|
||
| <!-- 👟 인터페이스 방향 --> | ||
| <key>UISupportedInterfaceOrientations</key> | ||
| <array> | ||
| <string>UIInterfaceOrientationPortrait</string> | ||
| </array> | ||
|
|
||
| <!-- 🔠 폰트 등록 --> | ||
| <key>UIAppFonts</key> | ||
| <array> | ||
| <string>Pretendard-Regular.otf</string> | ||
| <string>Pretendard-Medium.otf</string> | ||
| <string>Pretendard-SemiBold.otf</string> | ||
| <string>Pretendard-Bold.otf</string> | ||
| </array> | ||
| </dict> | ||
| </plist> |
30 changes: 30 additions & 0 deletions
30
src/Projects/BKDesign/PreviewApp/Resources/LaunchScreen.storyboard
This file contains hidden or 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,30 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17150" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES"> | ||
| <dependencies> | ||
| <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17122"/> | ||
| <capability name="Safe area layout guides" minToolsVersion="9.0"/> | ||
| <capability name="System colors in document resources" minToolsVersion="11.0"/> | ||
| <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> | ||
| </dependencies> | ||
| <scenes> | ||
| <!--View Controller--> | ||
| <scene sceneID="s0d-6b-0kx"> | ||
| <objects> | ||
| <viewController id="Y6W-OH-hqX" sceneMemberID="viewController"> | ||
| <view key="view" contentMode="scaleToFill" id="5EZ-qb-Rvc"> | ||
| <rect key="frame" x="0.0" y="0.0" width="414" height="896"/> | ||
| <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | ||
| <viewLayoutGuide key="safeArea" id="vDu-zF-Fre"/> | ||
| <color key="backgroundColor" systemColor="systemBackgroundColor"/> | ||
| </view> | ||
| </viewController> | ||
| <placeholder placeholderIdentifier="IBFirstResponder" id="Ief-a0-LHa" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/> | ||
| </objects> | ||
| </scene> | ||
| </scenes> | ||
| <resources> | ||
| <systemColor name="systemBackgroundColor"> | ||
| <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> | ||
| </systemColor> | ||
| </resources> | ||
| </document> |
23 changes: 23 additions & 0 deletions
23
src/Projects/BKDesign/PreviewApp/Sources/AppDelegate.swift
This file contains hidden or 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,23 @@ | ||
| // Copyright © 2025 Booket. All rights reserved | ||
|
|
||
| import UIKit | ||
|
|
||
| @main | ||
| class AppDelegate: UIResponder, UIApplicationDelegate { | ||
| func application( | ||
| _ application: UIApplication, | ||
| didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? | ||
| ) -> Bool { | ||
| return true | ||
| } | ||
|
|
||
| // MARK: UISceneSession Lifecycle | ||
|
|
||
| func application( | ||
| _ application: UIApplication, | ||
| configurationForConnecting connectingSceneSession: UISceneSession, | ||
| options: UIScene.ConnectionOptions | ||
| ) -> UISceneConfiguration { | ||
| return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) | ||
| } | ||
| } | ||
24 changes: 24 additions & 0 deletions
24
src/Projects/BKDesign/PreviewApp/Sources/SceneDelegate.swift
This file contains hidden or 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,24 @@ | ||
| // Copyright © 2025 Booket. All rights reserved | ||
|
|
||
| import BKDesign | ||
| import UIKit | ||
|
|
||
| class SceneDelegate: UIResponder, UIWindowSceneDelegate { | ||
| var window: UIWindow? | ||
|
|
||
| func scene( | ||
| _ scene: UIScene, | ||
| willConnectTo session: UISceneSession, | ||
| options connectionOptions: UIScene.ConnectionOptions | ||
| ) { | ||
| guard let windowScene = scene as? UIWindowScene else { return } | ||
|
|
||
| let window = UIWindow(windowScene: windowScene) | ||
| let viewController = BKButtonTestViewController() | ||
| // let viewController = BKButtonGroupDemoViewController() | ||
| window.rootViewController = UINavigationController(rootViewController: viewController) | ||
| window.makeKeyAndVisible() | ||
|
|
||
| self.window = window | ||
| } | ||
| } |
105 changes: 105 additions & 0 deletions
105
src/Projects/BKDesign/PreviewApp/Sources/View/BKButtonGroupDemoViewController.swift
This file contains hidden or 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,105 @@ | ||
| // Copyright © 2025 Booket. All rights reserved | ||
|
|
||
| import BKDesign | ||
| import SnapKit | ||
| import UIKit | ||
|
|
||
| public final class BKButtonGroupDemoViewController: UIViewController { | ||
|
|
||
| private let scrollView = UIScrollView() | ||
| private let containerView = UIStackView() | ||
|
|
||
| public override func viewDidLoad() { | ||
| super.viewDidLoad() | ||
| view.backgroundColor = .white | ||
| setupScrollView() | ||
| setupDemoGroups() | ||
| } | ||
|
|
||
| private func setupScrollView() { | ||
| view.addSubview(scrollView) | ||
| scrollView.snp.makeConstraints { $0.edges.equalToSuperview() } | ||
|
|
||
| scrollView.addSubview(containerView) | ||
| containerView.axis = .vertical | ||
| containerView.spacing = 16 | ||
| containerView.alignment = .fill | ||
| containerView.distribution = .fill | ||
| containerView.snp.makeConstraints { | ||
| $0.edges.equalToSuperview().inset(20) | ||
| $0.width.equalToSuperview().inset(20) | ||
| } | ||
| } | ||
|
|
||
| private func setupDemoGroups() { | ||
| addSection(title: "Custom 구성 (직접 만든 그룹)") | ||
| containerView.addArrangedSubview(BKButtonGroup( | ||
| buttons: [ | ||
| makeButton(title: "[Custom] S", size: .small), | ||
| makeButton(title: "[Custom] M", size: .medium), | ||
| makeButton(title: "[Custom] L", size: .large) | ||
| ], | ||
| layout: .horizontal | ||
| )) | ||
|
|
||
| addDivider() | ||
|
|
||
| addSection(title: "TwoButtonGroup") | ||
| containerView.addArrangedSubview(BKButtonGroup.twoButtonGroup( | ||
| leftTitle: "취소", rightTitle: "확인", | ||
| leftAction: { print("취소 tapped") }, | ||
| rightAction: { print("확인 tapped") } | ||
| )) | ||
|
|
||
| addDivider() | ||
|
|
||
| addSection(title: "ThreeButtonGroup") | ||
| containerView.addArrangedSubview(BKButtonGroup.threeButtonGroup( | ||
| leftTitle: "이전", centerTitle: "중간", rightTitle: "다음", | ||
| leftAction: { print("이전 tapped") }, | ||
| centerAction: { print("중간 tapped") }, | ||
| rightAction: { print("다음 tapped") } | ||
| )) | ||
|
|
||
| addDivider() | ||
|
|
||
| addSection(title: "SingleFullButton") | ||
| containerView.addArrangedSubview(BKButtonGroup.singleFullButton( | ||
| title: "계속하기", | ||
| action: { print("계속하기 tapped") } | ||
| )) | ||
|
|
||
| addDivider() | ||
|
|
||
| addSection(title: "VerticalGroup (Rounded 버튼)") | ||
| containerView.addArrangedSubview(BKButtonGroup.verticalButtonGroup(buttons: [ | ||
| makeButton(title: "둥글1", size: .rounded), | ||
| makeButton(title: "둥글2", size: .rounded) | ||
| ])) | ||
| } | ||
|
|
||
| private func makeButton(title: String, size: BKButtonSize) -> BKButton { | ||
| let button = BKButton.primary(title: title, size: size) | ||
| button.addAction(UIAction { _ in | ||
| print("Tapped: \(title)") | ||
| }, for: .touchUpInside) | ||
| return button | ||
| } | ||
|
|
||
| private func addSection(title: String) { | ||
| let label = UILabel() | ||
| label.text = title | ||
| label.font = UIFont.systemFont(ofSize: 14, weight: .bold) | ||
| label.textColor = .darkGray | ||
| containerView.addArrangedSubview(label) | ||
| } | ||
|
|
||
| private func addDivider() { | ||
| let divider = UIView() | ||
| divider.backgroundColor = UIColor.lightGray.withAlphaComponent(0.4) | ||
| divider.snp.makeConstraints { make in | ||
| make.height.equalTo(1) | ||
| } | ||
| containerView.addArrangedSubview(divider) | ||
| } | ||
| } |
133 changes: 133 additions & 0 deletions
133
src/Projects/BKDesign/PreviewApp/Sources/View/BKButtonTestViewController.swift
This file contains hidden or 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,133 @@ | ||
| // Copyright © 2025 Booket. All rights reserved | ||
|
|
||
| import BKDesign | ||
| import SnapKit | ||
| import UIKit | ||
|
|
||
| public final class BKButtonTestViewController: UIViewController { | ||
|
|
||
| // MARK: - UI Components | ||
| private let scrollView = UIScrollView() | ||
| private let containerView = UIStackView() | ||
|
|
||
| // MARK: - Lifecycle | ||
|
|
||
| public override func viewDidLoad() { | ||
| super.viewDidLoad() | ||
| view.backgroundColor = .white | ||
| setupScrollView() | ||
| // setupIndependentButtons() | ||
| setupStackView() | ||
| } | ||
|
|
||
| public override func viewWillAppear(_ animated: Bool) { | ||
| super.viewWillAppear(animated) | ||
| setupAllTestButtons() | ||
| } | ||
|
|
||
| // MARK: - Setup Scroll & Stack | ||
|
|
||
| private func setupScrollView() { | ||
| view.addSubview(scrollView) | ||
| scrollView.snp.makeConstraints { $0.edges.equalToSuperview() } | ||
|
|
||
| scrollView.addSubview(containerView) | ||
| containerView.snp.makeConstraints { | ||
| $0.edges.equalToSuperview().inset(20) | ||
| $0.width.equalToSuperview().inset(20) | ||
| } | ||
| } | ||
|
|
||
| private func setupStackView() { | ||
| containerView.axis = .vertical | ||
| containerView.spacing = 16 | ||
| containerView.alignment = .fill | ||
| containerView.distribution = .equalSpacing | ||
| } | ||
|
|
||
| // MARK: - Setup Buttons by Size | ||
|
|
||
| private func setupAllTestButtons() { | ||
| setupButtons(for: .large) | ||
| setupButtons(for: .medium) | ||
| setupButtons(for: .small) | ||
| setupButtons(for: .rounded) | ||
| } | ||
|
|
||
| private func setupButtons(for size: BKButtonSize) { | ||
| addButton("Primary", style: .primary, size: size) | ||
| addButton("Secondary", style: .secondary, size: size) | ||
| addButton("Tertiary", style: .tertiary, size: size) | ||
|
|
||
| addIconButton("Apple 로그인", style: .primary, size: size, left: .appleLogo) | ||
| addIconButton("카카오 로그인", style: .primary, size: size, right: .kakaoLogo) | ||
| addIconButton("양쪽 아이콘", style: .primary, size: size, left: .appleLogo, right: .kakaoLogo) | ||
| } | ||
|
|
||
| // MARK: - Button Builders | ||
|
|
||
| private func addButton(_ title: String, style: BKButtonStyle, size: BKButtonSize) { | ||
| let button = BKButton(style: style, size: size) | ||
| button.title = "[\(size.label)] \(title)" | ||
| containerView.addArrangedSubview(button) | ||
| } | ||
|
|
||
| private func addIconButton( | ||
| _ title: String, | ||
| style: BKButtonStyle, | ||
| size: BKButtonSize, | ||
| left: BKIcon? = nil, | ||
| right: BKIcon? = nil | ||
| ) { | ||
| let button = BKButton(style: style, size: size) | ||
| button.title = "[\(size.label)] \(title)" | ||
| button.leftIcon = left?.image | ||
| button.rightIcon = right?.image | ||
| containerView.addArrangedSubview(button) | ||
| } | ||
|
|
||
| private func setupIndependentButtons() { | ||
| let sampleView = UIView() | ||
| scrollView.addSubview(sampleView) | ||
| sampleView.snp.makeConstraints { | ||
| $0.top.equalTo(containerView.snp.bottom).offset(40) | ||
| $0.centerX.equalToSuperview() | ||
| $0.bottom.lessThanOrEqualToSuperview() | ||
| } | ||
|
|
||
| let buttons: [BKButton] = [ | ||
| .primary(title: "[Free] Apple 로그인", size: .large), | ||
| .secondary(title: "[Free] Secondary", size: .large), | ||
| .tertiary(title: "[Free] Tertiary", size: .large), | ||
| .primary(title: "[Free] Apple 로그인", size: .medium), | ||
| .secondary(title: "[Free] Secondary", size: .small), | ||
| .tertiary(title: "[Free] Tertiary", size: .rounded) | ||
| ] | ||
|
|
||
| buttons[0].leftIcon = BKIcon.appleLogo.image | ||
| buttons[2].rightIcon = BKIcon.kakaoLogo.image | ||
|
|
||
| var last: UIView? | ||
| for button in buttons { | ||
| sampleView.addSubview(button) | ||
| button.snp.makeConstraints { | ||
| $0.centerX.equalToSuperview() | ||
| $0.top.equalTo(last?.snp.bottom ?? sampleView.snp.top).offset(16) | ||
| } | ||
| last = button | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
|
|
||
| public extension BKButtonSize { | ||
| var label: String { | ||
| switch self { | ||
| case .large: return "Large" | ||
| case .medium: return "Medium" | ||
| case .small: return "Small" | ||
| case .rounded: return "Rounded" | ||
| } | ||
| } | ||
| } | ||
|
doyeonk429 marked this conversation as resolved.
|
||
Oops, something went wrong.
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.
PreviewApp은 머지하기 전에 지우실거죠 ?
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.
엇 아뇨! 디자인시스템 테스트하는 용도로 남겨두려고 했습니다. 원래 모듈화했을 때, 각 모듈에 테스트앱 달아서 화면 테스트 빨리 해볼 수 있는 것도 장점이어서 이를 활용하면 좋을 것 같아요.
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.
확인했습니다 ~