Skip to content

Commit

Permalink
[Feat] 서버통신 데이터 연결 #37
Browse files Browse the repository at this point in the history
  • Loading branch information
HELLOHIDI committed Nov 25, 2023
1 parent 1fc201f commit cf7b5d1
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
self.window = UIWindow(windowScene: windowScene)
window?.overrideUserInterfaceStyle = .light

let mainViewController = GelationDetailView()
let mainViewController = TabBarController()
let navigationController = UINavigationController(rootViewController: mainViewController)

navigationController.isNavigationBarHidden = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ final class MainViewController: BaseViewController {
MoyaAPI.shared.getMainData { [weak self] result in
guard let result = self?.validateResult(result) as? MainModel else { return }
self?.mainData = result
self?.dataBind()
}
}

private func dataBind() {
DispatchQueue.main.async {
self.idCardView.dataBind(self.mainData)
self.activityCardView.activityStackView.dataBind(self.mainData)
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final class ActivityCardView: UIView {
//MARK: - set Properties

private let ringImageView = UIImageView()
private let activityStackView = ActivityStackView()
let activityStackView = ActivityStackView()
private let divisionLine = UIView()
private let showDetailButton = UIButton()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ final class ActivityStackView: UIStackView {
private func setUI() {
volunteerHourItem.do {
$0.titleLabel.text = "봉사시간"
$0.valueLabel.text = "5시간"
$0.valueLabel.text = ""
}
programCompletionNumberItem.do {
$0.titleLabel.text = "프로그램 이수"
$0.valueLabel.text = "3개"
$0.valueLabel.text = ""
}
licenseNumberItem.do {
$0.titleLabel.text = "자격증"
$0.valueLabel.text = "2개"
$0.valueLabel.text = ""
}
}

Expand All @@ -51,4 +51,11 @@ final class ActivityStackView: UIStackView {
self.axis = .vertical
self.spacing = 17.adjusted
}

func dataBind(_ data: MainModel?) {
guard let data else { return }
volunteerHourItem.valueLabel.text = "\(data.volunteerHours)시간"
programCompletionNumberItem.valueLabel.text = "\(data.completedProgramCount)"
licenseNumberItem.valueLabel.text = "\(data.certificateCount)"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,13 @@ final class IdCardView: UIView {
$0.leading.equalToSuperview().inset(289.adjusted)
}
}

func dataBind(_ data: MainModel?) {
guard let data else { return }
userName.text = data.name
ageChipView.infoLabel.text = "\(data.age)"
genderChipView.infoLabel.text = data.gender
userCrimeHistory.text = data.criminalHistory
userCrimeYearAgo.text = data.criminalHistoryDate
}
}

0 comments on commit cf7b5d1

Please sign in to comment.