-
Notifications
You must be signed in to change notification settings - Fork 0
chore: 디버그 모드 기능 추가 #233
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
chore: 디버그 모드 기능 추가 #233
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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
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 |
|---|---|---|
|
|
@@ -4,4 +4,5 @@ import Foundation | |
|
|
||
| public protocol MarkOnboardingSeenUseCase { | ||
| func execute() | ||
| func reset() | ||
| } | ||
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
138 changes: 138 additions & 0 deletions
138
src/Projects/Booket/Sources/DebugOptionViewController.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,138 @@ | ||
| // Copyright © 2025 Booket. All rights reserved | ||
|
|
||
| import BKCore | ||
| import BKData | ||
| import BKDesign | ||
| import BKDomain | ||
| import BKNetwork | ||
| import BKPresentation | ||
| import BKStorage | ||
| import KakaoSDKAuth | ||
| #if DEBUG | ||
| import Pulse | ||
| import PulseUI | ||
| #endif | ||
| import SwiftUI | ||
| import UIKit | ||
|
|
||
| public final class DebugOptionViewController: UIViewController { | ||
|
|
||
| private struct DebugSection { | ||
| let title: String | ||
| let options: [DebugOption] | ||
| } | ||
|
|
||
| private enum DebugOption: String, CaseIterable { | ||
| case showNetworkLog = "네트워크 로그 확인" | ||
| case resetOnboardingSeen = "온보딩 화면 보기" | ||
|
|
||
| // 각 옵션에 따라 실행할 함수를 연결 | ||
| func performAction(on viewController: UIViewController) { | ||
| guard let vc = viewController as? DebugOptionViewController else { return } | ||
| switch self { | ||
| case .showNetworkLog: | ||
| vc.openPulseLog() | ||
| case .resetOnboardingSeen: | ||
| vc.resetOnboardingSeen() | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private let tableView = UITableView(frame: .zero, style: .insetGrouped) | ||
| private var sections: [DebugSection] = [] | ||
|
|
||
| @Autowired var markOnboardingSeenUseCase: MarkOnboardingSeenUseCase | ||
|
|
||
| override public func viewDidLoad() { | ||
| super.viewDidLoad() | ||
| setupData() | ||
| setupUI() | ||
| setupTableView() | ||
| } | ||
|
|
||
| private func setupData() { | ||
| self.sections = [ | ||
| DebugSection(title: "Log", options: [ | ||
| .showNetworkLog | ||
| ]), | ||
| DebugSection(title: "플래그 초기화", options: [ | ||
| .resetOnboardingSeen | ||
| ]) | ||
| ] | ||
| } | ||
|
|
||
| // UI 설정은 동일 | ||
| private func setupUI() { | ||
| self.title = "디버그 메뉴" | ||
| view.backgroundColor = .systemGroupedBackground | ||
| view.addSubview(tableView) | ||
|
|
||
| tableView.translatesAutoresizingMaskIntoConstraints = false | ||
| NSLayoutConstraint.activate([ | ||
| tableView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor), | ||
| tableView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor), | ||
| tableView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor), | ||
| tableView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor) | ||
| ]) | ||
| } | ||
|
|
||
| // 테이블뷰 설정은 동일 | ||
| private func setupTableView() { | ||
| tableView.delegate = self | ||
| tableView.dataSource = self | ||
| tableView.register(UITableViewCell.self, forCellReuseIdentifier: "DebugCell") | ||
| } | ||
|
|
||
| // 각 셀 선택 시 호출될 함수들 | ||
| private func openPulseLog() { | ||
| DispatchQueue.main.async { [weak self] in | ||
| let viewController = MainViewController() | ||
| self?.navigationController?.present(viewController, animated: true) | ||
| } | ||
| } | ||
|
|
||
| private func resetOnboardingSeen() { | ||
| markOnboardingSeenUseCase.reset() | ||
| forceQuitApplication() | ||
| } | ||
|
|
||
| private func forceQuitApplication() { | ||
| UIApplication.shared.perform(#selector(NSXPCConnection.suspend)) | ||
| DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { | ||
| exit(0) | ||
| } | ||
| } | ||
doyeonk429 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| extension DebugOptionViewController: UITableViewDelegate, UITableViewDataSource { | ||
|
|
||
| public func numberOfSections(in tableView: UITableView) -> Int { | ||
| return sections.count | ||
| } | ||
|
|
||
| public func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { | ||
| return sections[section].title | ||
| } | ||
|
|
||
| public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | ||
| return sections[section].options.count | ||
| } | ||
|
|
||
| public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | ||
| let cell = tableView.dequeueReusableCell(withIdentifier: "DebugCell", for: indexPath) | ||
| let option = sections[indexPath.section].options[indexPath.row] | ||
|
|
||
| var content = cell.defaultContentConfiguration() | ||
| content.text = option.rawValue | ||
| cell.contentConfiguration = content | ||
| cell.accessoryType = .none | ||
|
|
||
| return cell | ||
| } | ||
|
|
||
| public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | ||
| tableView.deselectRow(at: indexPath, animated: true) | ||
| let selectedOption = sections[indexPath.section].options[indexPath.row] | ||
| selectedOption.performAction(on: self) | ||
| } | ||
| } | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.