diff --git a/Budi/Budi/Source/MyBudi/Edit/Cells/LocationReplaceTableViewCell.swift b/Budi/Budi/Source/MyBudi/Edit/Cells/LocationReplaceTableViewCell.swift index 0e947eb5..0a9b5f81 100644 --- a/Budi/Budi/Source/MyBudi/Edit/Cells/LocationReplaceTableViewCell.swift +++ b/Budi/Budi/Source/MyBudi/Edit/Cells/LocationReplaceTableViewCell.swift @@ -23,5 +23,9 @@ class LocationReplaceTableViewCell: UITableViewCell { // Configure the view for the selected state } - + + func configureLocation(location: String) { + locationTextField.text = location + } + } diff --git a/Budi/Budi/Source/MyBudi/Edit/Cells/NormalTextFieldTableViewCell.swift b/Budi/Budi/Source/MyBudi/Edit/Cells/NormalTextFieldTableViewCell.swift index cb25161a..d0a7eec6 100644 --- a/Budi/Budi/Source/MyBudi/Edit/Cells/NormalTextFieldTableViewCell.swift +++ b/Budi/Budi/Source/MyBudi/Edit/Cells/NormalTextFieldTableViewCell.swift @@ -11,6 +11,7 @@ class NormalTextFieldTableViewCell: UITableViewCell { static let cellId = "NormalTextFieldTableViewCell" + @IBOutlet weak var normalTextField: UITextField! @IBOutlet weak var normalTitleLabel: UILabel! override func awakeFromNib() { super.awakeFromNib() @@ -23,6 +24,10 @@ class NormalTextFieldTableViewCell: UITableViewCell { // Configure the view for the selected state } + func configureText(text: String) { + normalTextField.text = text + } + func configureLabel(text: String) { normalTitleLabel.text = text } diff --git a/Budi/Budi/Source/MyBudi/Edit/Cells/NormalTextFieldTableViewCell.xib b/Budi/Budi/Source/MyBudi/Edit/Cells/NormalTextFieldTableViewCell.xib index 35bea6e7..3304bb7a 100644 --- a/Budi/Budi/Source/MyBudi/Edit/Cells/NormalTextFieldTableViewCell.xib +++ b/Budi/Budi/Source/MyBudi/Edit/Cells/NormalTextFieldTableViewCell.xib @@ -55,6 +55,7 @@ + diff --git a/Budi/Budi/Source/MyBudi/Edit/Cells/PositionTableViewCell.swift b/Budi/Budi/Source/MyBudi/Edit/Cells/PositionTableViewCell.swift index 1809495d..e07baec7 100644 --- a/Budi/Budi/Source/MyBudi/Edit/Cells/PositionTableViewCell.swift +++ b/Budi/Budi/Source/MyBudi/Edit/Cells/PositionTableViewCell.swift @@ -11,6 +11,7 @@ class PositionTableViewCell: UITableViewCell { static let cellId = "PositionTableViewCell" + @IBOutlet weak var positionTextField: UITextField! override func awakeFromNib() { super.awakeFromNib() // Initialization code @@ -21,5 +22,14 @@ class PositionTableViewCell: UITableViewCell { // Configure the view for the selected state } - + + + func configurePosition(position: [String]) { + var positionText = "" + for position in position { + positionText += "#\(position) " + } + positionTextField.text = positionText + } } + diff --git a/Budi/Budi/Source/MyBudi/Edit/Cells/PositionTableViewCell.xib b/Budi/Budi/Source/MyBudi/Edit/Cells/PositionTableViewCell.xib index 72fc4514..8a14918f 100644 --- a/Budi/Budi/Source/MyBudi/Edit/Cells/PositionTableViewCell.xib +++ b/Budi/Budi/Source/MyBudi/Edit/Cells/PositionTableViewCell.xib @@ -50,6 +50,9 @@ + + + diff --git a/Budi/Budi/Source/MyBudi/Edit/MyBudiEditViewController.swift b/Budi/Budi/Source/MyBudi/Edit/MyBudiEditViewController.swift index 546ad405..0ab758e5 100644 --- a/Budi/Budi/Source/MyBudi/Edit/MyBudiEditViewController.swift +++ b/Budi/Budi/Source/MyBudi/Edit/MyBudiEditViewController.swift @@ -31,6 +31,8 @@ final class MyBudiEditViewController: UIViewController { configureTableView() print(viewModel.state.mySectionData.value) print(viewModel.state.mySectionData.value[1].items.count) + print("유저 정보", viewModel.state.loginUserData.value) + print(UserDefaults.standard.string(forKey: "accessToken")) } override func viewWillAppear(_ animated: Bool) { @@ -133,16 +135,19 @@ extension MyBudiEditViewController: UITableViewDelegate, UITableViewDataSource { if indexPath.row == 0 { cell.configureLabel(text: "닉네임") + cell.configureText(text: self.viewModel.state.loginUserData.value?.nickName ?? "") } else { cell.configureLabel(text: "한줄소개") + cell.configureText(text: self.viewModel.state.loginUserData.value?.description ?? "") } return cell } else if indexPath.row == 1 { guard let cell = tableView.dequeueReusableCell(withIdentifier: LocationReplaceTableViewCell.cellId, for: indexPath) as? LocationReplaceTableViewCell else { return UITableViewCell() } - + cell.configureLocation(location: "충남 당진시") return cell } else { guard let cell = tableView.dequeueReusableCell(withIdentifier: PositionTableViewCell.cellId, for: indexPath) as? PositionTableViewCell else { return UITableViewCell() } + cell.configurePosition(position: viewModel.state.loginUserData.value?.positions ?? []) return cell } } else if indexPath.section == 1 { @@ -152,7 +157,7 @@ extension MyBudiEditViewController: UITableViewDelegate, UITableViewDataSource { } else { guard let cell = tableView.dequeueReusableCell(withIdentifier: PortfolioURLTableViewCell.cellId, for: indexPath) as? PortfolioURLTableViewCell else { return UITableViewCell() } - cell.configureButtonLable(text: viewModel.state.mySectionData.value[indexPath.section-1].items[indexPath.row].itemInfo.buttonTitle) + cell.configureButtonLabel(text: viewModel.state.mySectionData.value[indexPath.section-1].items[indexPath.row].itemInfo.buttonTitle) return cell } diff --git a/Budi/Budi/Source/MyBudi/Edit/MyBudiEditViewModel.swift b/Budi/Budi/Source/MyBudi/Edit/MyBudiEditViewModel.swift index b6c7202c..cb8c1404 100644 --- a/Budi/Budi/Source/MyBudi/Edit/MyBudiEditViewModel.swift +++ b/Budi/Budi/Source/MyBudi/Edit/MyBudiEditViewModel.swift @@ -17,6 +17,7 @@ class MyBudiEditViewModel: ViewModel { } struct State { + let loginUserData = CurrentValueSubject(nil) let mySectionData = CurrentValueSubject<[HistorySectionModel], Never>( [ HistorySectionModel.init( diff --git a/Budi/Budi/Source/MyBudi/Main/MyBudiMainViewController.swift b/Budi/Budi/Source/MyBudi/Main/MyBudiMainViewController.swift index cccc11f0..bb700a9f 100644 --- a/Budi/Budi/Source/MyBudi/Main/MyBudiMainViewController.swift +++ b/Budi/Budi/Source/MyBudi/Main/MyBudiMainViewController.swift @@ -138,7 +138,7 @@ extension MyBudiMainViewController: UICollectionViewDataSource, UICollectionView .receive(on: DispatchQueue.main) .sink { [weak self] _ in guard let self = self else { return } - self.coordinator?.showEditViewController() + self.coordinator?.showEditViewController(userData: self.viewModel.state.loginStatusData.value ?? nil) }.store(in: &cell.cancellables) return cell diff --git a/Budi/Budi/Source/MyBudi/MyBudiCoordinator.swift b/Budi/Budi/Source/MyBudi/MyBudiCoordinator.swift index 8b657140..ef65a54c 100644 --- a/Budi/Budi/Source/MyBudi/MyBudiCoordinator.swift +++ b/Budi/Budi/Source/MyBudi/MyBudiCoordinator.swift @@ -26,8 +26,10 @@ final class MyBudiCoordinator: NavigationCoordinator { } extension MyBudiCoordinator { - func showEditViewController() { - let viewController: MyBudiEditViewController = MyBudiEditViewController(nibName: MyBudiEditViewController.identifier, bundle: nil, viewModel: MyBudiEditViewModel()) + func showEditViewController(userData: LoginUserDetail?) { + let viewModel = MyBudiEditViewModel() + viewModel.state.loginUserData.value = userData + let viewController: MyBudiEditViewController = MyBudiEditViewController(nibName: MyBudiEditViewController.identifier, bundle: nil, viewModel: viewModel) viewController.coordinator = self navigationController?.pushViewController(viewController, animated: true) } diff --git a/Budi/Budi/Source/ReuseViews/PortfolioURLTableViewCell.swift b/Budi/Budi/Source/ReuseViews/PortfolioURLTableViewCell.swift index 0c53d968..148f3a09 100644 --- a/Budi/Budi/Source/ReuseViews/PortfolioURLTableViewCell.swift +++ b/Budi/Budi/Source/ReuseViews/PortfolioURLTableViewCell.swift @@ -50,7 +50,7 @@ class PortfolioURLTableViewCell: UITableViewCell { portfolioUrlLabel.text = url } - func configureButtonLable(text: String) { + func configureButtonLabel(text: String) { addButton.setTitle(text, for: .normal) } }