-
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
[#12] HandyTabs & Main화면 #32
Open
chongin12
wants to merge
13
commits into
main
Choose a base branch
from
feature/#12-Mosu
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+596
−17
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
6bdf648
[#12] TabComponent 추가
chongin12 a2ccebf
[#12] TabComponent를 모은 HandyTabs 설계
chongin12 1a807c1
[#12] Content 부분을 ScrollView가 아닌 일반 UIView로 변경
chongin12 1fedc60
[#12] 가변 탭 길이 구현
chongin12 5431555
[#12] 디버깅용 요소 제거, 첫 화면을 Tabs로 설계
chongin12 da43766
[#12] 접근제어자 수정, 애니메이션 추가
chongin12 63523ce
[#12] 파일 분리 및 주석 추가
chongin12 1f7008e
[#12] Main 화면 테이블뷰로 재작성
chongin12 092e1bc
[#12] 디자인 디테일 수정
chongin12 cd6ba50
[#12] HandyTabComponent -> HandyTabCell 이름 변경
chongin12 8fe0d2d
[#12] TabsViewController에서 탭을 추가할 수 있도록 수정
chongin12 a1d458b
[#12] 셀 아래쪽에 실선(border) 추가
chongin12 0362c4b
[#12] MainViewController에 HandyList 요소 추가
chongin12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
// | ||
// TabsViewController.swift | ||
// Handy | ||
// | ||
// Created by chongin on 12/29/24. | ||
// | ||
|
||
import Handy | ||
import UIKit | ||
|
||
final class TabsViewController: BaseViewController { | ||
var tabs: [(title: String, viewController: UIViewController)] | ||
|
||
private let handyTabs: HandyTabs = { | ||
let tabs = HandyTabs(sizeType: .small) | ||
return tabs | ||
}() | ||
|
||
private let addingTabButton: HandyFab = { | ||
let button = HandyFab() | ||
button.iconImage = .add | ||
return button | ||
}() | ||
|
||
init(_ tabCount: Int) { | ||
self.tabs = [ | ||
{ | ||
let viewController = SnackbarViewController() | ||
return ("SnackbarViewController", viewController) | ||
}(), | ||
{ | ||
let viewController = LabelViewController() | ||
return ("LabelViewController", viewController) | ||
}(), | ||
{ | ||
let viewController = FabViewController() | ||
return ("FabViewController", viewController) | ||
}(), | ||
{ | ||
let viewController = HandyBoxButtonViewController() | ||
return ("HandyBoxButtonViewController", viewController) | ||
}(), | ||
{ | ||
let viewController = ChipViewController() | ||
return ("ChipViewController", viewController) | ||
}(), | ||
{ | ||
let viewController = DividerViewController() | ||
return ("DividerViewController", viewController) | ||
}(), | ||
{ | ||
let viewController = CheckBoxViewController() | ||
return ("CheckBoxViewController", viewController) | ||
}(), | ||
{ | ||
let viewController = RadioButtonViewController() | ||
return ("RadioButtonViewController", viewController) | ||
}(), | ||
{ | ||
let viewController = HansySwitchViewController() | ||
return ("HansySwitchViewController", viewController) | ||
}(), | ||
][..<tabCount].map { $0 } | ||
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. 주어진 정적 배열 중 인자로 받는 개수까지만 표현되도록 했습니다. |
||
super.init(nibName: nil, bundle: nil) | ||
} | ||
|
||
@MainActor required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
addingTabButton.addTarget(self, action: #selector(addingTabButtonDidTap(_:)), for: .touchUpInside) | ||
self.handyTabs.tabs = self.tabs | ||
} | ||
|
||
@objc private func addingTabButtonDidTap(_ sender: UIButton) { | ||
let randomViewController = UIViewController() | ||
randomViewController.view.backgroundColor = UIColor.init(red: .random(in: 0...1), green: .random(in: 0...1), blue: .random(in: 0...1), alpha: 1) | ||
handyTabs.tabs.append(("newTab!!", randomViewController)) | ||
} | ||
|
||
override func setViewHierarchies() { | ||
self.addChild(handyTabs) | ||
self.view.addSubview(handyTabs.view) | ||
self.view.addSubview(addingTabButton) | ||
} | ||
|
||
override func setViewLayouts() { | ||
handyTabs.view.snp.makeConstraints { | ||
$0.edges.equalTo(self.view.safeAreaLayoutGuide) | ||
} | ||
|
||
addingTabButton.snp.makeConstraints { | ||
$0.trailing.bottom.equalTo(self.view.safeAreaLayoutGuide).inset(32) | ||
$0.width.height.equalTo(100) | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// | ||
// MainViewController.swift | ||
// Handy | ||
// | ||
// Created by chongin on 12/31/24. | ||
// | ||
|
||
import UIKit | ||
|
||
class MainViewController: UITableViewController { | ||
|
||
private let components: [HandyStorybookComponent] = [ | ||
.init(("SnackbarViewController", SnackbarViewController())), | ||
.init(("LabelViewController", LabelViewController())), | ||
.init(("FabViewController", FabViewController())), | ||
.init(("HandyBoxButtonViewController", HandyBoxButtonViewController())), | ||
.init(("ChipViewController", ChipViewController())), | ||
.init(("DividerViewController", DividerViewController())), | ||
.init(("CheckBoxViewController", CheckBoxViewController())), | ||
.init(("RadioButtonViewController", RadioButtonViewController())), | ||
.init(("HansySwitchViewController", HansySwitchViewController())), | ||
.init(("TabsViewController(2개)", TabsViewController(2))), | ||
.init(("TabsViewController(3개)", TabsViewController(3))), | ||
.init(("TabsViewController(9개)", TabsViewController(9))), | ||
.init(("HandyListViewController", HandyListViewController())), | ||
] | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "Cell") | ||
} | ||
} | ||
|
||
extension MainViewController { | ||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | ||
switch section { | ||
case 0: | ||
return components.count | ||
default: | ||
return 0 | ||
} | ||
} | ||
|
||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | ||
switch indexPath.section { | ||
case 0: | ||
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) | ||
let component = components[indexPath.row] | ||
cell.textLabel?.text = component.title | ||
return cell | ||
default: | ||
fatalError() | ||
} | ||
} | ||
|
||
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | ||
switch indexPath.section { | ||
case 0: | ||
let component = components[indexPath.row] | ||
navigationController?.pushViewController(component.viewController, animated: true) | ||
default: | ||
fatalError() | ||
} | ||
} | ||
|
||
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { | ||
switch section { | ||
case 0: | ||
return "Components" | ||
default: | ||
fatalError() | ||
} | ||
} | ||
} | ||
|
||
struct HandyStorybookComponent { | ||
let title: String | ||
let viewController: UIViewController | ||
|
||
init(title: String, viewController: UIViewController) { | ||
self.title = title | ||
self.viewController = viewController | ||
} | ||
|
||
init<VC: UIViewController>(_ component: (title: String, viewController: VC)) { | ||
self.title = component.title | ||
self.viewController = component.viewController as UIViewController | ||
} | ||
} |
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
15 changes: 0 additions & 15 deletions
15
Handy/Handy.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
This file was deleted.
Oops, something went wrong.
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.
지금 HandyFab 관련된 레이아웃 경고가 엄청 많이 뜨는 것 같은데 혹시 이거 때문일까요??
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.
HandyFab 자체 경고인 것 같아요..!! ㅠ
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.
@wjdalswl 혹시 레이아웃 경고 확인 해볼 수 있을까요?