Repository: nbcamp-week3-team7/pillosk
Pull request #21: #14 버튼 상호작용 기능 추가
Author: login: YunJuHyung
Created: 2025-04-09T16:06:17Z | Merged: 2025-04-10T04:00:21Z


## 🔧 관련 이슈
<!-- 관련있는 이슈 번호(#000)을 작성
     해당 pull request merge와 함께 이슈를 닫으려면 아래처럼 작성
     closed: #Issue_number -->
closed: #14 

## ✨ 변경 사항 및 이유
<!-- 변경한 내용과 그 이유 작성 -->

-클로저 함수를 사용하여 버튼 이벤트 설정했습니다.
-버튼 클릭시 메뉴리스트 보여줍니다.
-버튼 클릭시 선택한 카테고리만 배경색 변경합니다.
-처음 VC에서 화면을 load 했을때 첫번째 카테고리 선택과 menuList 적용했습니다.
-사용하지 않는 delegate 패턴 삭제했습니다.

## 🔍 PR Point
<!-- 리뷰어 분들이 집중적으로 보셨으면 하는 내용 작성. -->

## 📌 참고 사항
<!-- 참고할 사항이 있다면 작성 -->



Diff:
diff --git a/PilloskProject/PilloskProject/Extensions/UIView+Extensions.swift b/PilloskProject/PilloskProject/Extensions/UIView+Extensions.swift
index 9390b07..e374805 100644
--- a/PilloskProject/PilloskProject/Extensions/UIView+Extensions.swift
+++ b/PilloskProject/PilloskProject/Extensions/UIView+Extensions.swift
@@ -23,12 +23,6 @@ extension UIColor {
     }
 }
 
-extension ViewController: CategoryViewDelegate {
-    func setCategoryButtons(categories: [String]) {
-        categoryView.notifyCategoryButtonsUpdate(categories: categories)
-    }
-}
-
 /// 상품 셀에서 발생하는 이벤트를 처리하기 위한 델리게이트 프로토콜
 /// - 상품 추가 버튼이 눌렸을 때 호출
 /// - product: 추가된 상품 정보
diff --git a/PilloskProject/PilloskProject/Models/Data.swift b/PilloskProject/PilloskProject/Models/Data.swift
index 628c909..0bc13b0 100644
--- a/PilloskProject/PilloskProject/Models/Data.swift
+++ b/PilloskProject/PilloskProject/Models/Data.swift
@@ -30,4 +30,3 @@ struct MenuItem {
     let price: Int
     var quantity: Int
 }
-
diff --git a/PilloskProject/PilloskProject/ViewControllers/ViewController.swift b/PilloskProject/PilloskProject/ViewControllers/ViewController.swift
index 37ebf9f..114e5b5 100644
--- a/PilloskProject/PilloskProject/ViewControllers/ViewController.swift
+++ b/PilloskProject/PilloskProject/ViewControllers/ViewController.swift
@@ -19,10 +19,10 @@ final class ViewController: UIViewController {
     let categoryView = CategoryView()
     private let dataService = DataService()
     private var productData: [ProductData] = []
-    
+
     /// 상품 리스트 뷰 (UICollectionView + PageControl 포함)
     private let menuListView = MenuListView()
-    
+
     /// 상품 데이터 배열 (현재는 더미 데이터)
     private var products: [Product] = []
     /// 한 페이지에 표시할 상품 수 (2x2 = 4개)
@@ -31,59 +31,74 @@ final class ViewController: UIViewController {
     private var numberOfPages: Int {
         return Int(ceil(Double(products.count) / Double(itemsPerPage)))
     }
-    
+
     override func viewDidLoad() {
         super.viewDidLoad()
         view.backgroundColor = .white
-        view.addSubview(categoryView)
-        categoryView.delegate = self
+
         loadData()
         configureUI()
-        setupViews()
         setupCollectionView()
-        loadDummyData()
     }
 
     private func setCollectionView() {
         menuListView.collectionView.dataSource = self
         menuListView.collectionView.register(ProductCell.self, forCellWithReuseIdentifier: CellIdentifier.productCell)
     }
+
     func loadData() {
         dataService.loadData { [weak self] result in
             guard let self = self else { return }
-            
+
             DispatchQueue.main.async {
                 switch result {
                 case .success(let productData):
                     self.productData = [productData]
-                    
-                    // 임시로 첫 번째 카테고리 상품을 사용
-                    if let firstCategory = productData.categories.first {
-                        self.products = firstCategory.products
-                        
-                        // 페이지 컨트롤 업데이트
-                        self.menuListView.pageControl.numberOfPages = Int(ceil(Double(self.products.count) / Double(self.itemsPerPage)))
-                        
-                        // 컬렉션 뷰 리로드
-                        self.menuListView.collectionView.reloadData()
-                    }                    
-                    
-                    let categoryNames = productData.categories.map { $0.name }
+
+                    let categoryNames = productData.categories.map { $0 }
                     self.categoryView.notifyCategoryButtonsUpdate(categories: categoryNames)
+                    // 앱실행시 첫번째 선택 결과를 받겠다고 클로저 호출 및 동작
+                    self.setCollectionViewProducts()
+                    // 강제로 버튼을 눌러서 menulist 보여줌
+                    if let firstCategorySet = categoryNames.first {
+                        self.categoryView.selectedFirstCategory(name: firstCategorySet.name)
+                    }
                 case .failure(let error):
                     print(error)
                 }
             }
         }
     }
-    
+
+    // CategoryView 클로저 함수
+    private func setCollectionViewProducts() {
+        categoryView.categorySelected = { [weak self] products in
+            guard let self = self else { return }
+            print(#fileID, #function, #line, "print product = \(products)")
+            self.products = products
+            self.menuListView.pageControl.numberOfPages = Int(
+                ceil(Double(products.count) / Double(self.itemsPerPage))
+            )
+            self.menuListView.collectionView.reloadData()
+        }
+    }
+    // 메인 view 오토레이아웃 함수
     func configureUI() {
         view.addSubview(categoryView)
         categoryView.snp.makeConstraints {
             $0.top.leading.trailing.equalTo(view.safeAreaLayoutGuide)
             $0.height.equalTo(120)
         }
-        
+
+        view.addSubview(menuListView)
+        // MARK: - -오토 레이아웃 우측이 안맞아서 trailing 수정 했습니다.
+        menuListView.snp.makeConstraints {
+            $0.top.equalTo(categoryView.snp.bottom).offset(20)
+            $0.leading.equalToSuperview().inset(16)
+            $0.trailing.equalToSuperview().inset(-16)
+            $0.height.equalTo(400)
+        }
+
         view.addSubview(orderSummaryView)
         orderSummaryView.snp.makeConstraints { make in
             make.height.equalTo(300)
@@ -92,25 +107,13 @@ final class ViewController: UIViewController {
         }
 
     }
-    
-    /// 메인 뷰에 menuListView 추가 및 레이아웃 설정
-    private func setupViews() {
-        view.addSubview(menuListView)
-        
-        menuListView.snp.makeConstraints {
-            $0.top.equalTo(categoryView.snp.bottom).offset(20)
-            $0.leading.trailing.equalToSuperview().inset(16)
-            $0.height.equalTo(400)
-        }
-    }
-    
     /// 컬렉션 뷰의 데이터 소스 연결 및 셀 등록
     private func setupCollectionView() {
         menuListView.collectionView.dataSource = self
         // ProductCell 셀 등록 (재사용을 위한 identifier 설정)
         menuListView.collectionView.register(ProductCell.self, forCellWithReuseIdentifier: CellIdentifier.productCell)
     }
-    
+
     /// 상품 목록 더미 데이터 로드
     private func loadDummyData() {
         // 임시데이터, 추후 수정
@@ -122,7 +125,7 @@ final class ViewController: UIViewController {
             Product(name: "소화제", price: 3300, image: "VitaminC.jpg"),
             Product(name: "유산균", price: 8500, image: "Acetaminophen.jpg")
         ]
-        
+
         // 페이지 컨트롤의 전체 페이지 수 업데이트
         menuListView.pageControl.numberOfPages = numberOfPages
         // 컬렉션 뷰 데이터 리로드 (화면 갱신)
@@ -138,7 +141,7 @@ extension ViewController: UICollectionViewDataSource {
     func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
         return products.count
     }
-    
+
     /// 각 셀을 구성하는 메서드
     /// 셀이 화면에 표시될 때마다 호출
     /// - Parameters:
@@ -155,7 +158,6 @@ extension ViewController: UICollectionViewDataSource {
         cell.delegate = self
         // 셀 구성 (상품명, 가격, 이미지)
         cell.configure(with: product)
-        
         return cell
     }
 }
diff --git a/PilloskProject/PilloskProject/Views/CategoryView.swift b/PilloskProject/PilloskProject/Views/CategoryView.swift
index 2617b7d..64afad3 100644
--- a/PilloskProject/PilloskProject/Views/CategoryView.swift
+++ b/PilloskProject/PilloskProject/Views/CategoryView.swift
@@ -7,54 +7,78 @@
 
 import UIKit
 import SnapKit
-
-protocol CategoryViewDelegate: AnyObject {
-    func setCategoryButtons(categories: [String])
-}
+import Combine
 
 class CategoryView: UIView {
-
+    @Published var selectedProducts: [Product] = []
+    private var categories: [Category] = []
     private var buttons: [UIButton] = []
 
-    weak var delegate: CategoryViewDelegate?
+    // 데이터 보내주는 클로저
+    var categorySelected: (([Product]) -> Void)?
 
-    private func setUpCategoryButton(categories: [String]) {
+    // 버튼 셋업 메서드
+    private func configureCategoryButtons(categories: [Category]) {
         categoryContentsStackView.arrangedSubviews.forEach { $0.removeFromSuperview() }
         buttons.removeAll()
 
         for items in categories {
             var configuration = UIButton.Configuration.filled()
-            configuration.title = items
+            configuration.title = items.name
             configuration.attributedTitle?.font = UIFont.systemFont(ofSize: 16, weight: .regular)
-            configuration.baseBackgroundColor = .systemBlue
             configuration.baseForegroundColor = .white
-            //configuration.background.strokeColor = .cyan
+            // configuration.background.strokeColor = .cyan
             configuration.cornerStyle = .capsule
             configuration.buttonSize = .medium
             configuration.contentInsets = NSDirectionalEdgeInsets(top: 5, leading: 5, bottom: 5, trailing: 5)
 
             let button = UIButton(configuration: configuration, primaryAction: nil)
+            // 버튼 선택했을시 색상 변경 핸들러
             button.configurationUpdateHandler = { button in
-                if button.isSelected {
-                    button.configuration?.baseBackgroundColor = .darkGray
-                } else {
-                    button.configuration?.baseBackgroundColor = .systemBlue
+                var config = button.configuration
+                switch button.state {
+                case .selected:
+                    config?.baseBackgroundColor = .darkGray
+                default:
+                    config?.baseBackgroundColor = UIColor(hex: "1B8DFF")
                 }
+                button.configuration = config
+            }
+            button.snp.makeConstraints {
+                $0.width.equalTo(100)
             }
             button.addTarget(self, action: #selector(buttonTapped(_:)), for: .touchUpInside)
+            buttons.append(button)
             categoryContentsStackView.addArrangedSubview(button)
         }
-
     }
 
-    func notifyCategoryButtonsUpdate(categories: [String]) {
-        setUpCategoryButton(categories: categories)
+    // VC에서 호출되는 메서드
+    func notifyCategoryButtonsUpdate(categories: [Category]) {
+        self.categories = categories
+        configureCategoryButtons(categories: categories)
+
+    }
+    // 첫번째
+    func selectedFirstCategory(name: String) {
+        guard let button = buttons.first(where: { $0.configuration?.title == name }) else { return }
+        buttonTapped(button)
     }
 
     @objc private func buttonTapped(_ sender: UIButton) {
-
-        sender.isSelected.toggle()
-
+        // 버튼 상태 확인
+        for button in buttons {
+            button.isSelected = (button == sender)
+        }
+        guard let selectedButton = sender.configuration else {
+            print("occured error")
+            return
+        }
+        guard let title = selectedButton.title,
+              let selectedCategory = categories.first(where: { $0.name == title }) else {
+            return
+        }
+        categorySelected?(selectedCategory.products)
     }
 
     override init(frame: CGRect) {
@@ -70,8 +94,7 @@ class CategoryView: UIView {
     }
 
     let categoryViewTitleLabel = UILabel()
-    let categoryItems: [Category] = []
-    //    let categoryStackView =
+    let categoryItems: [String] = []
     let categoryScrollView = UIScrollView()
     let categoryContentsStackView = UIStackView()
 
@@ -106,14 +129,16 @@ class CategoryView: UIView {
         categoryScrollView.snp.makeConstraints {
             $0.top.equalTo(categoryViewTitleLabel.snp.bottom)
             $0.leading.trailing.bottom.equalToSuperview()
+            $0.height.equalTo(50)
         }
 
         categoryContentsStackView.snp.makeConstraints {
-            $0.top.bottom.equalTo(categoryScrollView.contentLayoutGuide)
-            $0.height.equalTo(categoryScrollView.frameLayoutGuide)
-            $0.leading.equalTo(categoryScrollView.snp.leading).inset(20)
-            $0.trailing.equalTo(categoryScrollView.snp.trailing).offset(-20)
+            $0.top.bottom.equalToSuperview()
+            $0.leading.equalToSuperview().offset(20)
+            $0.trailing.equalToSuperview()
+            $0.height.equalToSuperview()
         }
+
     }
 
 }
diff --git a/PilloskProject/PilloskProject/Views/MenuListView.swift b/PilloskProject/PilloskProject/Views/MenuListView.swift
index 79f0fb9..874a249 100644
--- a/PilloskProject/PilloskProject/Views/MenuListView.swift
+++ b/PilloskProject/PilloskProject/Views/MenuListView.swift
@@ -11,7 +11,7 @@ import SnapKit
 final class MenuListView: UIView {
     /// 상품 리스트를 표시할 컬렉션 뷰
     let collectionView: UICollectionView
-    
+
     /// 페이지 컨트롤
     let pageControl: UIPageControl = {
         let pageControl = UIPageControl()
@@ -21,18 +21,18 @@ final class MenuListView: UIView {
         pageControl.currentPageIndicatorTintColor = .systemBlue
         return pageControl
     }()
-    
+
     /// MenuListView 가 코드로 생성될 때 호출
     override init(frame: CGRect) {
         // 컬렉션 뷰 레이아웃 설정
-        let layout = UICollectionViewCompositionalLayout { [weak pageControl = pageControl] sectionIndex, environment in
+        let layout = UICollectionViewCompositionalLayout { [weak pageControl = pageControl] _, environment in
             // 아이템 (셀) 사이즈 지정
             let itemSize = NSCollectionLayoutSize(
                 widthDimension: .fractionalWidth(0.45), // 그룹 너비의 45% 차지
                 heightDimension: .fractionalHeight(1.0) // 그룹 높이의 100% 차지
             )
             let item = NSCollectionLayoutItem(layoutSize: itemSize)
-            
+
             // 수평 그룹: 셀 2개를 가로로 배치
             let horizontalGroupSize = NSCollectionLayoutSize(
                 widthDimension: .fractionalWidth(1.0), // 컬렉션 뷰 width 에 맞춤
@@ -42,11 +42,11 @@ final class MenuListView: UIView {
                 layoutSize: horizontalGroupSize,
                 subitems: [item, item]
             )
-            
+
             horizontalGroup.interItemSpacing = .fixed(16)
-            
+
             horizontalGroup.contentInsets = NSDirectionalEdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0)
-            
+
             // 수직 그룹: 수평 그룹 2개를 세로로 배치
             let verticalGroupSize = NSCollectionLayoutSize(
                 widthDimension: .fractionalWidth(1.0),
@@ -56,47 +56,47 @@ final class MenuListView: UIView {
                 layoutSize: verticalGroupSize,
                 subitems: [horizontalGroup, horizontalGroup]
             )
-            
+
             verticalGroup.interItemSpacing = .fixed(16)
-            
+
             // 섹션 생성
             let section = NSCollectionLayoutSection(group: verticalGroup)
             section.orthogonalScrollingBehavior = .paging
-            
+
             // 스크롤 이동 시 현재 페이지 업데이트
-            section.visibleItemsInvalidationHandler = { visibleItems, offset, environment in
+            section.visibleItemsInvalidationHandler = { _, offset, environment in
                 let page = round(offset.x / environment.container.contentSize.width)
                 DispatchQueue.main.async {
                     pageControl?.currentPage = Int(page)
                 }
             }
-            
+
             return section
         }
-        
+
         collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
         collectionView.isPagingEnabled = false
         collectionView.showsHorizontalScrollIndicator = false
         collectionView.backgroundColor = .clear
-        
+
         super.init(frame: frame)
         setupViews()
     }
-    
+
     required init?(coder: NSCoder) {
         fatalError("init(coder:) has not been implemented")
     }
-    
+
     /// MenuListView 내의 서브뷰 배치 및 제약 설정
     private func setupViews() {
         addSubview(collectionView)
         addSubview(pageControl)
-        
+
         collectionView.snp.makeConstraints {
             $0.top.leading.trailing.equalToSuperview()
             $0.height.equalToSuperview().multipliedBy(0.8)
         }
-        
+
         pageControl.snp.makeConstraints {
             $0.top.equalTo(collectionView.snp.bottom).offset(8)
             $0.centerX.equalToSuperview()
diff --git a/PilloskProject/PilloskProject/Views/OrderSummaryView.swift b/PilloskProject/PilloskProject/Views/OrderSummaryView.swift
index ab2e6d8..528245e 100644
--- a/PilloskProject/PilloskProject/Views/OrderSummaryView.swift
+++ b/PilloskProject/PilloskProject/Views/OrderSummaryView.swift
@@ -12,66 +12,66 @@ import SnapKit
 /// 주문 요약 화면 클래스
 /// 테이블뷰, 버튼, 레이블 등 UI 요소를 포함하며 오토레이아웃을 설정
 final class OrderSummaryView: UIView, UITableViewDataSource, UITableViewDelegate, StackTableViewCellDelegate {
-    
+
     private var orderItems: [MenuItem] = []
-    
+
     let orderTableView = UITableView()
     let summaryCountLabel = UILabel()
     let resetButton = UIButton()
     let paymentButton = UIButton()
     let lineView = UIView()
-    
+
     override init(frame: CGRect) {
         super.init(frame: frame)
         backgroundColor = .white
         setupUI()
     }
-    
+
     /// UI 초기 설정 및 레이아웃 배치 함수 호출
     private func setupUI() {
         [orderTableView, summaryCountLabel, resetButton, paymentButton, lineView].forEach { self.addSubview($0) }
-        
+
         setLineView()
         setTableView()
         summaryCountLabelSetting()
         resetOrderButton()
         processPayment()
     }
-    
+
     /// 구분선 설정
     func setLineView() {
         lineView.backgroundColor = .systemGray4
         self.addSubview(lineView)
-        
+
         lineView.snp.makeConstraints { make in
             make.height.equalTo(1)
             make.leading.trailing.equalToSuperview()
             make.top.equalTo(summaryCountLabel.snp.bottom)
         }
     }
-    
+
     /// 테이블뷰 초기 설정
     /// 데이터소스와 델리게이트 연결 및 레이아웃 배치
     func setTableView() {
         orderTableView.register(StackTableViewCell.self, forCellReuseIdentifier: "stackCell")
-        
+
         orderTableView.dataSource = self
         orderTableView.delegate = self
-        
+
         orderTableView.snp.makeConstraints { make in
             make.top.equalTo(lineView.snp.bottom).offset(0)
             make.trailing.leading.equalToSuperview().inset(5)
             make.bottom.equalTo(paymentButton.snp.top)
         }
     }
-    
+
     /// 결제 버튼 텍스트 업데이트
     /// - 주문 항목의 총 가격을 계산하여 버튼 텍스트를 업데이트
     func updatePaymentButtonTitle() {
         let totalPrice = calculateTotalPrice()
         paymentButton.setTitle("\(totalPrice.formattedWithComma())원 결제하기", for: .normal)
     }
-    
+
     /// 주문 상품 추가
     /// - 같은 이름의 상품이 있으면 수량만 증가, 없으면 새로 추가
     /// - UI 업데이트: 테이블뷰 갱신, 레이블 및 버튼 상태 변경
@@ -82,28 +82,28 @@ final class OrderSummaryView: UIView, UITableViewDataSource, UITableViewDelegate
             let menuItem = MenuItem(name: product.name, price: product.price, quantity: 1)
             orderItems.append(menuItem)
         }
-        
+
         /// 테이블뷰 갱신 및 UI 업데이트
         orderTableView.reloadData()
         updateSummaryCountLabel()
         updateButtons(isEnabled: !orderItems.isEmpty)
         updatePaymentButtonTitle()
     }
-    
+
     /// 테이블뷰의 섹션별 셀 개수 반환
     func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
         return orderItems.count
     }
-    
+
     /// 테이블뷰 셀 높이 설정
     func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
         return 80
     }
-    
+
     /// 테이블뷰 셀 생성 및 데이터 설정
     func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
         let cell = tableView.dequeueReusableCell(withIdentifier: "stackCell", for: indexPath) as! StackTableViewCell
-        
+
         let menuItem = orderItems[indexPath.row]
         cell.configure(name: menuItem.name,
                        price: menuItem.price,
@@ -111,30 +111,30 @@ final class OrderSummaryView: UIView, UITableViewDataSource, UITableViewDelegate
         cell.delegate = self
         return cell
     }
-    
+
     /// 테이블뷰 셀 삭제 요청 처리
     /// - 특정 셀 삭제 후 UI 업데이트
     func didTapDeleteButton(cell: StackTableViewCell) {
         guard let indexPath = orderTableView.indexPath(for: cell) else { return }
-        
+
         orderItems.remove(at: indexPath.row)
         orderTableView.deleteRows(at: [indexPath], with: .automatic)
         updateSummaryCountLabel()
         updateButtons(isEnabled: !orderItems.isEmpty)
         updatePaymentButtonTitle()
     }
-    
+
     /// 테이블뷰 셀 수량 변경 요청 처리
     /// - 특정 셀의 수량 변경 후 UI 업데이트
     func didUpdateQuantity(cell: StackTableViewCell, quantity: Int) {
         guard let indexPath = orderTableView.indexPath(for: cell) else { return }
-        
+
         if indexPath.row < orderItems.count {
             if quantity <= 0 {
                 print("1개 이하 구매 불가")
                 return
             }
-            
+
             orderItems[indexPath.row].quantity = quantity
             updatePaymentButtonTitle()
             updateSummaryCountLabel()
@@ -142,7 +142,7 @@ final class OrderSummaryView: UIView, UITableViewDataSource, UITableViewDelegate
             print("IndexPath.row가 배열 범위 초과")
         }
     }
-    
+
     /// 총 가격 계산
     /// - 주문 목록의 가격과 수량을 곱하여 총합 계산
     private func calculateTotalPrice() -> Int {
@@ -151,27 +151,27 @@ final class OrderSummaryView: UIView, UITableViewDataSource, UITableViewDelegate
         }
         return orderItems.reduce(0) { $0 + ($1.price * $1.quantity) }
     }
-    
+
     /// 요약 레이블 초기 설정
     /// 텍스트, 폰트, 배경색 및 레이아웃 배치
     func summaryCountLabelSetting() {
         summaryCountLabel.font = UIFont.boldSystemFont(ofSize: 16)
         updateSummaryCountLabel()
         summaryCountLabel.textAlignment = .left
-        
+
         summaryCountLabel.snp.makeConstraints { make in
             make.height.equalTo(40)
             make.top.equalToSuperview()
             make.leading.trailing.equalToSuperview().inset(10)
         }
     }
-    
+
     /// 총 수량 레이블 업데이트
     func updateSummaryCountLabel() {
         let totalQuantity = orderItems.reduce(0) { $0 + $1.quantity }
         summaryCountLabel.text = " 총 \(totalQuantity)개"
     }
-    
+
     /// 버튼 활성화 상태 업데이트
     /// - 주문 항목이 없으면 버튼 비활성화
     func updateButtons(isEnabled: Bool) {
@@ -182,7 +182,7 @@ final class OrderSummaryView: UIView, UITableViewDataSource, UITableViewDelegate
         paymentButton.backgroundColor = buttonColor
         paymentButton.setTitleColor(buttonTextColor, for: .normal)
     }
-    
+
     /// 초기화 버튼 설정
     /// - 버튼 클릭 시 모든 주문 항목 초기화
     func resetOrderButton() {
@@ -191,19 +191,19 @@ final class OrderSummaryView: UIView, UITableViewDataSource, UITableViewDelegate
         resetButton.backgroundColor = .white
         resetButton.titleLabel?.textAlignment = .center
         resetButton.titleLabel?.font = UIFont.systemFont(ofSize: 15)
-        
+
         resetButton.snp.makeConstraints { make in
             make.height.equalTo(60)
             make.width.equalTo(150)
             make.leading.equalToSuperview()
             make.bottom.equalToSuperview()
         }
-        
+
         resetButton.addTarget(self,
                               action: #selector(resetButtonTapped),
                               for: .touchUpInside)
     }
-    
+
     /// 결제 버튼 설정
     /// - 버튼 클릭 시 결제 로직 실행 가능
     func processPayment() {
@@ -211,7 +211,7 @@ final class OrderSummaryView: UIView, UITableViewDataSource, UITableViewDelegate
         paymentButton.setTitleColor(.white, for: .normal)
         paymentButton.backgroundColor = .lightGray
         paymentButton.titleLabel?.font = UIFont.boldSystemFont(ofSize: 15)
-        
+
         paymentButton.snp.makeConstraints { make in
             make.height.equalTo(50)
             make.leading.equalTo(resetButton.snp.trailing)
@@ -222,23 +222,23 @@ final class OrderSummaryView: UIView, UITableViewDataSource, UITableViewDelegate
                                 action: #selector(paymentButtonTapped),
                                 for: .touchUpInside)
     }
-    
+
     /// 초기화 버튼 클릭 이벤트
     @objc private func resetButtonTapped() {
         showAlert(title: "확인", message: "전체 목록을 삭제하시겠습니까?", isReset: true)
     }
-    
+
     /// 결제 버튼 클릭 이벤트
     @objc private func paymentButtonTapped() {
         showAlert(title: "확인", message: "결제를 진행하시겠습니까?", isReset: false)
     }
-    
+
     /// 알럿 표시 함수
     /// - 초기화 또는 결제 확인을 위한 알럿 표시
     private func showAlert(title: String, message: String, isReset: Bool) {
         let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
-        
-        let confirmAction = UIAlertAction(title: "확인", style: .default){ _ in
+
+        let confirmAction = UIAlertAction(title: "확인", style: .default) { _ in
             self.orderItems.removeAll()
             self.orderTableView.reloadData()
             self.updateSummaryCountLabel()
@@ -246,27 +246,27 @@ final class OrderSummaryView: UIView, UITableViewDataSource, UITableViewDelegate
             self.updatePaymentButtonTitle()
             if !isReset {
                 print("결제 진행 중")
-                ///추후 추가 결제 로직 기능 작성 가능
+                /// 추후 추가 결제 로직 기능 작성 가능
             }
         }
         let cancelAction = UIAlertAction(title: "취소", style: .cancel, handler: nil)
-        
+
         alert.addAction(confirmAction)
         alert.addAction(cancelAction)
-        
+
         /// 현재 뷰 컨트롤러에서 알럿 표시
         if let viewController = self.parentViewController {
             viewController.present(alert, animated: true, completion: nil)
         }
     }
-    
+
     /// 코너 라운드 적용
     override func layoutSubviews() {
         super.layoutSubviews()
         resetButton.applyRoundedCorners(corners: [.topLeft, .topRight], radius: CGSize(width: 10, height: 10))
         paymentButton.applyRoundedCorners(corners: [.topLeft, .topRight], radius: CGSize(width: 10, height: 10))
     }
-    
+
     required init?(coder: NSCoder) {
         fatalError("init(coder:) has not been implemented")
     }
@@ -299,32 +299,32 @@ extension Int {
 /// 스택뷰 및 다양한 UI 요소를 포함
 class StackTableViewCell: UITableViewCell {
     weak var delegate: StackTableViewCellDelegate?
-    
+
     let countContainerView = UIView()
     let verticalStackView = UIStackView()
     let horizontalStackView = UIStackView()
-    
+
     let nameLabel = UILabel()
     let priceLabel = UILabel()
     let minusButton = UIButton()
     let plusButton = UIButton()
     let countLabel = UILabel()
     let deleteButton = UIButton()
-    
+
     private var unitPrice: Int = 0
-    
+
     /// 이름 레이블 설정
     private func nameLabelSettings() {
         nameLabel.font = UIFont.boldSystemFont(ofSize: 15)
         nameLabel.textColor = .black
     }
-    
+
     /// 가격 레이블 설정
     private func priceLabelSettings() {
         priceLabel.font = UIFont.systemFont(ofSize: 15)
         priceLabel.textColor = .black
     }
-    
+
     /// 마이너스 버튼 설정
     private func minusButtonSettings() {
         minusButton.setTitle("-", for: .normal)
@@ -332,7 +332,7 @@ class StackTableViewCell: UITableViewCell {
         minusButton.setTitleColor(.white, for: .normal)
         minusButton.backgroundColor = .clear
     }
-    
+
     /// 플러스 버튼 설정
     private func plusButtonSettings() {
         plusButton.setTitle("+", for: .normal)
@@ -340,7 +340,7 @@ class StackTableViewCell: UITableViewCell {
         plusButton.setTitleColor(.white, for: .normal)
         plusButton.backgroundColor = .clear
     }
-    
+
     /// 카운트 레이블 설정
     private func countLabelSettings() {
         countLabel.text = "1"
@@ -349,16 +349,16 @@ class StackTableViewCell: UITableViewCell {
         countLabel.backgroundColor = .clear
         countLabel.textColor = .white
     }
-    
+
     /// 카운트 컨테이너 설정
     private func countContainerViewSettings() {
         countContainerView.backgroundColor = .systemBlue
         countContainerView.layer.cornerRadius = 15
         countContainerView.clipsToBounds = true
-        
+
         [minusButton, countLabel, plusButton].forEach { countContainerView.addSubview($0) }
     }
-    
+
     /// 삭제 버튼 설정
     private func deleteButtonSettings() {
         deleteButton.setTitle("X", for: .normal)
@@ -366,70 +366,70 @@ class StackTableViewCell: UITableViewCell {
         deleteButton.setTitleColor(.black, for: .normal)
         deleteButton.layer.cornerRadius = 15
     }
-    
+
     /// 스택뷰 설정
     private func setupStackView() {
         horizontalStackView.axis = .horizontal
         horizontalStackView.spacing = 10
         horizontalStackView.alignment = .center
         horizontalStackView.distribution = .fill
-        
+
         verticalStackView.axis = .vertical
         verticalStackView.spacing = 10
         verticalStackView.alignment = .leading
         verticalStackView.distribution = .fillEqually
     }
-    
+
     /// 스택뷰 레이아웃 설정
     private func setLayoutStackView() {
         countContainerView.snp.makeConstraints { make in
             make.height.equalTo(30)
             make.width.equalTo(90)
         }
-        
+
         minusButton.snp.makeConstraints { make in
             make.leading.top.bottom.equalToSuperview()
             make.width.equalTo(30)
         }
-        
+
         plusButton.snp.makeConstraints { make in
             make.trailing.top.bottom.equalToSuperview()
             make.width.equalTo(30)
             make.leading.equalTo(countLabel.snp.trailing)
         }
-        
+
         countLabel.snp.makeConstraints { make in
             make.width.equalTo(30)
             make.height.equalTo(30)
             make.leading.equalTo(minusButton.snp.trailing)
             make.trailing.equalTo(plusButton.snp.leading)
         }
-        
+
         horizontalStackView.snp.makeConstraints { make in
             make.top.bottom.equalToSuperview().inset(5)
             make.leading.equalToSuperview().inset(5)
             make.trailing.equalToSuperview().offset(-10)
         }
     }
-    
+
     /// 셀 구성 메서드
     /// - name: 상품 이름
     /// - price: 상품 개별 가격
     /// - quantity: 상품 수량
     func configure(name: String, price: Int, quantity: Int) {
         nameLabel.text = name
-        unitPrice = price                       //개별 가격
+        unitPrice = price                       // 개별 가격
         updatePriceLabel(quantity: quantity)    // 초기 가격
         countLabel.text = "\(quantity)"
     }
-    
+
     /// 가격 레이블 업데이트
     /// - quantity: 상품 수량
     private func updatePriceLabel(quantity: Int) {
         let totalPrice = unitPrice * quantity
         priceLabel.text = "\(totalPrice.formattedWithComma())원"
     }
-    
+
     /// 셀 초기화 메서드
     override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
         super.init(style: style, reuseIdentifier: reuseIdentifier)
@@ -441,14 +441,14 @@ class StackTableViewCell: UITableViewCell {
         deleteButtonSettings()
         countContainerViewSettings()
         setupStackView()
-        
-        [nameLabel, priceLabel].forEach() { verticalStackView.addArrangedSubview($0) }
+
+        [nameLabel, priceLabel].forEach { verticalStackView.addArrangedSubview($0) }
         [verticalStackView, countContainerView, deleteButton].forEach { horizontalStackView.addArrangedSubview($0) }
-        
+
         contentView.addSubview(horizontalStackView)
         setLayoutStackView()
-        
-        ///버튼에 액션 추가
+
+        /// 버튼에 액션 추가
         deleteButton.addTarget(self,
                                action: #selector(deleteButtonTapped),
                                for: .touchUpInside)
@@ -459,13 +459,13 @@ class StackTableViewCell: UITableViewCell {
                              action: #selector(plusButtonTapped),
                              for: .touchUpInside)
     }
-    
+
     /// 삭제 버튼 클릭 이벤트
     /// 셀 삭제 요청을 delegate에 전달
     @objc private func deleteButtonTapped() {
         delegate?.didTapDeleteButton(cell: self)
     }
-    
+
     /// 마이너스 버튼 클릭 이벤트
     /// 상품 수량 감소 및 UI 업데이트
     @objc private func minusButtonTapped() {
@@ -478,30 +478,30 @@ class StackTableViewCell: UITableViewCell {
         updatePriceLabel(quantity: updatedCount)
         delegate?.didUpdateQuantity(cell: self, quantity: updatedCount)
     }
-    
+
     /// 플러스 버튼 클릭 이벤트
     /// 상품 수량 증가 및 UI 업데이트
     @objc private func plusButtonTapped() {
         guard let currentCount = Int(countLabel.text ?? "0") else { return }
-        
+
         let updateCount = currentCount + 1
         countLabel.text = "\(updateCount)"
         updatePriceLabel(quantity: updateCount)
         delegate?.didUpdateQuantity(cell: self, quantity: updateCount)
-        
+
     }
-    
+
     required init?(coder: NSCoder) {
         fatalError("init(coder:) has not been implemented")
     }
-    
+
     /// countLabel 값 업데이트 함수
     /// - increment: true면 수량 증가, false면 감소
     func updateCountLabel(increment: Bool) {
         guard let currentCount = Int(countLabel.text ?? "0") else { return }
-        
+
         let updatedCount = increment ? currentCount + 1 : currentCount - 1
-        
+
         if updatedCount < 0 {
             print("0 이하 조작 불가")
             return
@@ -517,11 +517,11 @@ class StackTableViewCell: UITableViewCell {
 extension UIView {
     var parentViewController: UIViewController? {
         var responder: UIResponder? = self
-        while let r = responder {
-            if let viewController = r as? UIViewController {
+        while let response = responder {
+            if let viewController = response as? UIViewController {
                 return viewController
             }
-            responder = r.next
+            responder = response.next
         }
         return nil
     }
diff --git a/PilloskProject/PilloskProject/Views/ProductCell.swift b/PilloskProject/PilloskProject/Views/ProductCell.swift
index e1ef4b4..7a06e5f 100644
--- a/PilloskProject/PilloskProject/Views/ProductCell.swift
+++ b/PilloskProject/PilloskProject/Views/ProductCell.swift
@@ -13,14 +13,14 @@ import SnapKit
 final class ProductCell: UICollectionViewCell {
     /// BY: 델리게이트 연결
     weak var delegate: ProductCellDelegate?
-    
+
     /// 상품 이미지 뷰
     private let imageView: UIImageView = {
         let imageView = UIImageView()
         imageView.contentMode = .scaleAspectFit
         return imageView
     }()
-    
+
     /// 상품명과 가격을 수직으로 나열하는 스택뷰
     private let productInfoStackView: UIStackView = {
         let sv = UIStackView()
@@ -29,21 +29,21 @@ final class ProductCell: UICollectionViewCell {
         sv.alignment = .leading
         return sv
     }()
-    
+
     /// 상품명
     private let nameLabel: UILabel = {
         let label = UILabel()
         label.font = UIFont.systemFont(ofSize: 14)
         return label
     }()
-    
+
     /// 상품 가격
     private let priceLabel: UILabel = {
         let label = UILabel()
         label.font = UIFont.systemFont(ofSize: 12)
         return label
     }()
-    
+
     /// 상품 정보 + 플러스 버튼을 수평으로 나열하는 스택뷰
     private let horizontalStackView: UIStackView = {
         let sv = UIStackView()
@@ -54,7 +54,7 @@ final class ProductCell: UICollectionViewCell {
         sv.layoutMargins = UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 16)
         return sv
     }()
-    
+
     /// 상품을 장바구니에 추가하는 플러스 버튼
     private let addButton: UIButton = {
         let button = UIButton(type: .system)
@@ -62,63 +62,63 @@ final class ProductCell: UICollectionViewCell {
         button.titleLabel?.font = UIFont.systemFont(ofSize: 14)
         return button
     }()
-    
+
     private var product: Product?
-    
+
     override init(frame: CGRect) {
         super.init(frame: frame)
         setupViews()
-        addButton.addTarget(self, action: #selector(addButtonTapped), for: .touchUpInside) //BY: Delegate Button Action
+        addButton.addTarget(self, action: #selector(addButtonTapped), for: .touchUpInside) // BY: Delegate Button Action
     }
-    
+
     /// BY: 버튼 누르면 델리게이트 동작
     @objc private func addButtonTapped() {
             if let product = product {
                 delegate?.didTapAddButton(product: product)
             }
         }
-    
+
     required init?(coder: NSCoder) {
         fatalError("init(coder:) has not been implemented")
     }
-    
+
     /// 셀 내부 뷰들을 추가하고 레이아웃 제약을 설정
     private func setupViews() {
         // 뷰 계층 추가
         contentView.addSubview(imageView)
         contentView.addSubview(horizontalStackView)
-        
+
         // horizontalStackView 에 상품 정보 스택뷰와 플러스 버튼 추가
         [productInfoStackView, addButton].forEach {
             horizontalStackView.addArrangedSubview($0)
         }
-        
+
         // 상품 정보 스택뷰에 상품명과 가격 라벨 추가
         [nameLabel, priceLabel].forEach {
             productInfoStackView.addArrangedSubview($0)
         }
-        
+
         contentView.layer.cornerRadius = 8
         contentView.layer.borderWidth = 1
         contentView.layer.borderColor = UIColor.lightGray.cgColor
         contentView.clipsToBounds = true
-        
+
         imageView.snp.makeConstraints {
             $0.top.equalToSuperview().offset(8)
             $0.centerX.equalToSuperview()
             $0.height.equalTo(80)
         }
-        
+
         horizontalStackView.snp.makeConstraints {
             $0.top.equalTo(imageView.snp.bottom).offset(8)
             $0.leading.trailing.bottom.equalToSuperview()
         }
-        
+
         addButton.snp.makeConstraints {
             $0.width.height.equalTo(30)
         }
     }
-    
+
     /// 셀에 상품 데이터를 주입하는 메서드
     /// - 호출 시점: 컬렉션 뷰의 cellForItemAt 메서드에서 호출
     /// - Parameter product: 상품 데이터


Reviews:
user: login: ksyq12
body: 고생하셨습니다 👍
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-04-10T00:30:50Z
user: login: LEEBUYONG
body: 선택 상태에 따라 스타일 변경하는 로직 잘 작성된 것 같습니다. categoryContentsStackView의 기존 뷰를 제거하고 다시 추가하는 방식도 좋은 것 같습니다. 주석만 추가적으로 신경 써주시면 될 것 같습니다!
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-04-10T01:23:21Z

Review comments:
diff_hunk: @@ -7,54 +7,77 @@
 
 import UIKit
 import SnapKit
-
-protocol CategoryViewDelegate: AnyObject {
-    func setCategoryButtons(categories: [String])
-}
+import Combine
 
 class CategoryView: UIView {
-
+    @Published var selectedProducts: [Product] = []
+    private var categories: [Category] = []
     private var buttons: [UIButton] = []
 
-    weak var delegate: CategoryViewDelegate?
+    // 데이터 보내주는 클로저
+    var categorySelected: (([Product]) -> Void)?
 
-    private func setUpCategoryButton(categories: [String]) {
+    // 버튼 셋업 메서드
+    private func configureCategoryButtons(categories: [Category]) {
         categoryContentsStackView.arrangedSubviews.forEach { $0.removeFromSuperview() }
         buttons.removeAll()
 
         for items in categories {
path: PilloskProject/PilloskProject/Views/CategoryView.swift
user: login: LEEBUYONG
body: UIButton.Configuration 설정이 반복적으로 작성되는데 이 부분 함수로 분리해도 좋을 것 같습니다
created_at: 2025-04-10T01:15:39Z
author_association: CONTRIBUTOR
diff_hunk: @@ -7,54 +7,77 @@
 
 import UIKit
 import SnapKit
-
-protocol CategoryViewDelegate: AnyObject {
-    func setCategoryButtons(categories: [String])
-}
+import Combine
 
 class CategoryView: UIView {
-
+    @Published var selectedProducts: [Product] = []
+    private var categories: [Category] = []
     private var buttons: [UIButton] = []
 
-    weak var delegate: CategoryViewDelegate?
+    // 데이터 보내주는 클로저
+    var categorySelected: (([Product]) -> Void)?
 
-    private func setUpCategoryButton(categories: [String]) {
+    // 버튼 셋업 메서드
+    private func configureCategoryButtons(categories: [Category]) {
         categoryContentsStackView.arrangedSubviews.forEach { $0.removeFromSuperview() }
         buttons.removeAll()
 
         for items in categories {
             var configuration = UIButton.Configuration.filled()
-            configuration.title = items
+            configuration.title = items.name
             configuration.attributedTitle?.font = UIFont.systemFont(ofSize: 16, weight: .regular)
-            configuration.baseBackgroundColor = .systemBlue
             configuration.baseForegroundColor = .white
-            configuration.background.strokeColor = .cyan
             configuration.cornerStyle = .capsule
             configuration.buttonSize = .medium
             configuration.contentInsets = NSDirectionalEdgeInsets(top: 5, leading: 5, bottom: 5, trailing: 5)
 
             let button = UIButton(configuration: configuration, primaryAction: nil)
+            // 버튼 선택했을시 색상 변경 핸들러
             button.configurationUpdateHandler = { button in
path: PilloskProject/PilloskProject/Views/CategoryView.swift
user: login: LEEBUYONG
body: 클로저 내부에서 botton을 직접 참조하는 코드 같습니다. 다만, 메모리 순환 참조 문제에 대대한 고려가 안되어 있는 것 같아서`button.configurationUpdateHandler = { [weak button] button in`으로 수정하시면 좋을 것 같습니다.
created_at: 2025-04-10T01:17:52Z
author_association: CONTRIBUTOR
diff_hunk: @@ -7,54 +7,77 @@
 
 import UIKit
 import SnapKit
-
-protocol CategoryViewDelegate: AnyObject {
-    func setCategoryButtons(categories: [String])
-}
+import Combine
 
 class CategoryView: UIView {
-
+    @Published var selectedProducts: [Product] = []
+    private var categories: [Category] = []
     private var buttons: [UIButton] = []
 
-    weak var delegate: CategoryViewDelegate?
+    // 데이터 보내주는 클로저
+    var categorySelected: (([Product]) -> Void)?
 
-    private func setUpCategoryButton(categories: [String]) {
+    // 버튼 셋업 메서드
+    private func configureCategoryButtons(categories: [Category]) {
         categoryContentsStackView.arrangedSubviews.forEach { $0.removeFromSuperview() }
         buttons.removeAll()
 
         for items in categories {
             var configuration = UIButton.Configuration.filled()
-            configuration.title = items
+            configuration.title = items.name
             configuration.attributedTitle?.font = UIFont.systemFont(ofSize: 16, weight: .regular)
-            configuration.baseBackgroundColor = .systemBlue
             configuration.baseForegroundColor = .white
-            configuration.background.strokeColor = .cyan
             configuration.cornerStyle = .capsule
             configuration.buttonSize = .medium
             configuration.contentInsets = NSDirectionalEdgeInsets(top: 5, leading: 5, bottom: 5, trailing: 5)
 
             let button = UIButton(configuration: configuration, primaryAction: nil)
+            // 버튼 선택했을시 색상 변경 핸들러
             button.configurationUpdateHandler = { button in
-                if button.isSelected {
-                    button.configuration?.baseBackgroundColor = .darkGray
-                } else {
-                    button.configuration?.baseBackgroundColor = .systemBlue
+                var config = button.configuration
+                switch button.state {
+                case .selected:
+                    config?.baseBackgroundColor = .darkGray
+                default:
+                    config?.baseBackgroundColor = UIColor(hex: "1B8DFF")
                 }
+                button.configuration = config
+            }
+            button.snp.makeConstraints {
+                $0.width.equalTo(100)
             }
             button.addTarget(self, action: #selector(buttonTapped(_:)), for: .touchUpInside)
+            buttons.append(button)
             categoryContentsStackView.addArrangedSubview(button)
         }
-
     }
 
-    func notifyCategoryButtonsUpdate(categories: [String]) {
-        setUpCategoryButton(categories: categories)
+    // VC에서 호출되는 메서드
+    func notifyCategoryButtonsUpdate(categories: [Category]) {
+        self.categories = categories
+        configureCategoryButtons(categories: categories)
+
+    }
+    // 첫번째
+    func selectedFirstCategory(name: String) {
+        guard let button = buttons.first(where: { $0.configuration?.title == name }) else { return }
+        buttonTapped(button)
     }
 
     @objc private func buttonTapped(_ sender: UIButton) {
-
-        sender.isSelected.toggle()
-
+        // 버튼 상태 확인
+        for button in buttons {
+            button.isSelected = (button == sender)
+        }
+        guard let selectedButton = sender.configuration else {
+            print("occured error")
+            return
+        }
+        guard let title = selectedButton.title,
path: PilloskProject/PilloskProject/Views/CategoryView.swift
user: login: LEEBUYONG
body: forEach 사용하시면 코드 더 간결해질 것 같습니다 `buttons.forEach { $0.isSelected = ($0 == sender) }`
created_at: 2025-04-10T01:19:47Z
author_association: CONTRIBUTOR
diff_hunk: @@ -7,54 +7,77 @@
 
 import UIKit
 import SnapKit
-
-protocol CategoryViewDelegate: AnyObject {
-    func setCategoryButtons(categories: [String])
-}
+import Combine
 
 class CategoryView: UIView {
-
+    @Published var selectedProducts: [Product] = []
+    private var categories: [Category] = []
     private var buttons: [UIButton] = []
 
-    weak var delegate: CategoryViewDelegate?
+    // 데이터 보내주는 클로저
+    var categorySelected: (([Product]) -> Void)?
 
-    private func setUpCategoryButton(categories: [String]) {
+    // 버튼 셋업 메서드
+    private func configureCategoryButtons(categories: [Category]) {
         categoryContentsStackView.arrangedSubviews.forEach { $0.removeFromSuperview() }
         buttons.removeAll()
 
         for items in categories {
             var configuration = UIButton.Configuration.filled()
-            configuration.title = items
+            configuration.title = items.name
             configuration.attributedTitle?.font = UIFont.systemFont(ofSize: 16, weight: .regular)
-            configuration.baseBackgroundColor = .systemBlue
             configuration.baseForegroundColor = .white
-            configuration.background.strokeColor = .cyan
             configuration.cornerStyle = .capsule
             configuration.buttonSize = .medium
             configuration.contentInsets = NSDirectionalEdgeInsets(top: 5, leading: 5, bottom: 5, trailing: 5)
 
             let button = UIButton(configuration: configuration, primaryAction: nil)
+            // 버튼 선택했을시 색상 변경 핸들러
             button.configurationUpdateHandler = { button in
-                if button.isSelected {
-                    button.configuration?.baseBackgroundColor = .darkGray
-                } else {
-                    button.configuration?.baseBackgroundColor = .systemBlue
+                var config = button.configuration
+                switch button.state {
+                case .selected:
+                    config?.baseBackgroundColor = .darkGray
+                default:
+                    config?.baseBackgroundColor = UIColor(hex: "1B8DFF")
                 }
+                button.configuration = config
+            }
+            button.snp.makeConstraints {
+                $0.width.equalTo(100)
             }
             button.addTarget(self, action: #selector(buttonTapped(_:)), for: .touchUpInside)
+            buttons.append(button)
             categoryContentsStackView.addArrangedSubview(button)
         }
-
     }
 
-    func notifyCategoryButtonsUpdate(categories: [String]) {
-        setUpCategoryButton(categories: categories)
+    // VC에서 호출되는 메서드
+    func notifyCategoryButtonsUpdate(categories: [Category]) {
+        self.categories = categories
+        configureCategoryButtons(categories: categories)
+
+    }
+    // 첫번째
+    func selectedFirstCategory(name: String) {
+        guard let button = buttons.first(where: { $0.configuration?.title == name }) else { return }
path: PilloskProject/PilloskProject/Views/CategoryView.swift
user: login: LEEBUYONG
body: return 대신 버튼이 없을 경우 로그를 추가하거나 에러 처리를 해주는 게 좋을 것 같습니다
created_at: 2025-04-10T01:21:47Z
author_association: CONTRIBUTOR

PR comments:
user: login: ksyq12
created_at: 2025-04-10T00:33:42Z
body: 연동해주신 이슈 번호가 맞는지 한번더 확인 부탁드립니다!
author_association: CONTRIBUTOR
user: login: YunJuHyung
created_at: 2025-04-10T01:10:50Z
body: > 연동해주신 이슈 번호가 맞는지 한번더 확인 부탁드립니다!
해당PR에서 BUG에 관련된 내용도 포함돼서 이슈를 연동시켜놨습니다. 혹시 신경써야 할 부분이 있었을까요?

author_association: MEMBER
user: login: LEEBUYONG
created_at: 2025-04-10T01:14:23Z
body: 제목에 해시태그 안 적혀져 있고, 제 pr에서 실수로 #14를 달아서 그렇게 말씀하신 것 같습니다. 제목 잘못 작성하셨는데 그건 제가 그냥 수정했습니다..
author_association: CONTRIBUTOR