Skip to content

Commit

Permalink
YAPP-19th#61 - 수정 뷰 유저 정보 가져와 표시 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
ITlearning committed Jan 10, 2022
1 parent 334acb1 commit 7af6de4
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,9 @@ class LocationReplaceTableViewCell: UITableViewCell {

// Configure the view for the selected state
}


func configureLocation(location: String) {
locationTextField.text = location
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
</tableViewCellContentView>
<viewLayoutGuide key="safeArea" id="njF-e1-oar"/>
<connections>
<outlet property="normalTextField" destination="sOm-rs-puA" id="OMS-VP-Fdz"/>
<outlet property="normalTitleLabel" destination="6Kl-4G-e9g" id="rHW-Lc-tts"/>
</connections>
<point key="canvasLocation" x="132.60869565217394" y="83.370535714285708"/>
Expand Down
12 changes: 11 additions & 1 deletion Budi/Budi/Source/MyBudi/Edit/Cells/PositionTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class PositionTableViewCell: UITableViewCell {

static let cellId = "PositionTableViewCell"

@IBOutlet weak var positionTextField: UITextField!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
Expand All @@ -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
}
}

3 changes: 3 additions & 0 deletions Budi/Budi/Source/MyBudi/Edit/Cells/PositionTableViewCell.xib
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
</constraints>
</tableViewCellContentView>
<viewLayoutGuide key="safeArea" id="njF-e1-oar"/>
<connections>
<outlet property="positionTextField" destination="QZj-ka-GdP" id="8TT-w4-iE1"/>
</connections>
<point key="canvasLocation" x="141.30434782608697" y="82.03125"/>
</tableViewCell>
</objects>
Expand Down
9 changes: 7 additions & 2 deletions Budi/Budi/Source/MyBudi/Edit/MyBudiEditViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand All @@ -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
}

Expand Down
1 change: 1 addition & 0 deletions Budi/Budi/Source/MyBudi/Edit/MyBudiEditViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class MyBudiEditViewModel: ViewModel {
}

struct State {
let loginUserData = CurrentValueSubject<LoginUserDetail?, Never>(nil)
let mySectionData = CurrentValueSubject<[HistorySectionModel], Never>(
[
HistorySectionModel.init(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 4 additions & 2 deletions Budi/Budi/Source/MyBudi/MyBudiCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class PortfolioURLTableViewCell: UITableViewCell {
portfolioUrlLabel.text = url
}

func configureButtonLable(text: String) {
func configureButtonLabel(text: String) {
addButton.setTitle(text, for: .normal)
}
}

0 comments on commit 7af6de4

Please sign in to comment.