Skip to content
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

[Fix] #207- 출석조회 레이아웃 수정 #208

Merged
4 changes: 3 additions & 1 deletion SOPT-iOS/Projects/Core/Sources/Literals/StringLiterals.swift
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public struct I18N {
public static let today = "오늘은 "
public static let dayIs = " 날이에요"
public static let unscheduledDay = "일정이 없는"
public static let notCheckedDay = "출석점수를 체크하지 않습니다"
public static let noAttendanceSession = "출석 점수가 반영되지 않아요."
public static let currentAttendanceScore = "현재 출석점수는 "
public static let scoreIs = " 입니다!"
public static let myAttendance = "나의 출결 현황"
Expand All @@ -230,6 +230,8 @@ public struct I18N {
public static let inputCodeDescription = "출석 코드 다섯 자리를 입력해 주세요."
public static let codeMismatch = "코드가 일치하지 않아요!"
public static let takeAttendance = "출석하기"

public static let infoButtonToastMessage = "제2장 제10조(출석)를 확인해주세요"
}

public struct MyPage {
Expand Down
2 changes: 2 additions & 0 deletions SOPT-iOS/Projects/Domain/Sources/UseCase/MainUseCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ extension DefaultMainUseCase: MainUseCase {
repository.getUserMainInfo()
.sink { event in
print("MainUseCase: \(event)")
self.userMainInfo.send(completion: .finished)
} receiveValue: { [weak self] userMainInfoModel in
self?.setUserType(with: userMainInfoModel?.userType)
self?.userMainInfo.send(userMainInfoModel)
Expand All @@ -45,6 +46,7 @@ extension DefaultMainUseCase: MainUseCase {
repository.getServiceState()
.sink { event in
print("MainUseCase: \(event)")
self.serviceState.send(completion: .finished)
} receiveValue: { [weak self] serviceStateModel in
self?.serviceState.send(serviceStateModel)
}.store(in: self.cancelBag)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import DSKit

import SnapKit
import AttendanceFeatureInterface
import SafariServices

public final class ShowAttendanceVC: UIViewController, ShowAttendanceViewControllable {

Expand All @@ -26,11 +27,7 @@ public final class ShowAttendanceVC: UIViewController, ShowAttendanceViewControl
private var cancelBag = CancelBag()

public var sceneType: AttendanceScheduleType {
get {
return self.viewModel.sceneType ?? .scheduledDay
} set(type) {
self.viewModel.sceneType = type
}
return self.viewModel.sceneType ?? .unscheduledDay
}

private var viewWillAppear = PassthroughSubject<Void, Never>()
Expand Down Expand Up @@ -172,7 +169,7 @@ extension ShowAttendanceVC {

private func bindViewModels() {

let viewWillAppear = viewWillAppear.asDriver()
let viewWillAppear = Driver.just(())
let refreshStarted = refresher.publisher(for: .valueChanged)
.mapVoid()
.asDriver()
Expand All @@ -191,59 +188,59 @@ extension ShowAttendanceVC {
refreshStarted: refreshStarted)
let output = self.viewModel.transform(from: input, cancelBag: self.cancelBag)

output.isLoading
output.$todayAttendances
.withUnretained(self)
.sink { owner, isLoading in
if isLoading {
owner.showLoading()
owner.containerScrollView.isHidden = true
} else {
owner.stopLoading()
owner.containerScrollView.isHidden = false
}
.sink { owner, model in
guard let model else { return }
owner.headerScheduleView.setAttendanceInfo(model, true)
}
.store(in: self.cancelBag)

output.$scheduleModel
.sink(receiveValue: { [weak self] model in
guard let self, let model else { return }

if self.viewModel.sceneType == .scheduledDay {
self.sceneType = .scheduledDay
self.headerScheduleView.layoutIfNeeded()

if self.sceneType == .scheduledDay {
self.headerScheduleView.scheduleType = .scheduledDay
self.setScheduledData(model)
self.headerScheduleView.updateLayout(.scheduledDay)
self.attendanceButton.isHidden = false
} else {
self.sceneType = .unscheduledDay
self.headerScheduleView.updateLayout(.unscheduledDay)
self.headerScheduleView.scheduleType = .unscheduledDay
self.attendanceButton.isHidden = true
}
self.endRefresh()
})
.store(in: self.cancelBag)

output.$scoreModel
.sink { model in
guard let model else { return }
.sink { [weak self] model in
guard let self, let model else { return }
self.infoButton.setImage(DSKitAsset.Assets.opInfo.image, for: .normal)
self.setScoreData(model)
self.endRefresh()
}.store(in: self.cancelBag)

output.$todayAttendances
.withUnretained(self)
.sink { owner, model in
guard let model else { return }
owner.headerScheduleView.setAttendanceInfo(model, true)
}
.store(in: self.cancelBag)


output.attendanceButtonInfo
.withUnretained(self)
.sink { owner, info in
owner.setAttendanceButton(title: info.title, isEnabled: info.isEnalbed)
}
.store(in: self.cancelBag)

// output.isLoading
// .withUnretained(self)
// .sink { owner, isLoading in
// if isLoading {
// owner.showLoading()
// owner.containerScrollView.isHidden = true
// } else {
// owner.stopLoading()
// owner.containerScrollView.isHidden = false
// }
// }
// .store(in: self.cancelBag)
}

private func endRefresh() {
Expand All @@ -253,20 +250,24 @@ extension ShowAttendanceVC {
private func setScheduledData(_ model: AttendanceScheduleModel) {

if self.sceneType == .scheduledDay {
guard let date = viewModel.formatTimeInterval(startDate: model.startDate, endDate: model.endDate) else { return }
guard let date = viewModel.formatTimeInterval(startDate: model.startDate,
endDate: model.endDate) else { return }
headerScheduleView.setData(date: date,
place: model.location,
todaySchedule: model.name,
description: model.message)
}

self.headerScheduleView.layoutIfNeeded()
}

private func setScoreData(_ model: AttendanceScoreModel) {
attendanceScoreView.setMyInfoData(name: model.name, part: model.part, generation: model.generation,
attendanceScoreView.setMyInfoData(name: model.name,
part: model.part,
generation: model.generation,
count: model.score)
attendanceScoreView.setMyTotalScoreData(attendance: model.total.attendance, tardy: model.total.tardy, absent: model.total.absent, participate: model.total.participate)
attendanceScoreView.setMyTotalScoreData(attendance: model.total.attendance,
tardy: model.total.tardy,
absent: model.total.absent,
participate: model.total.participate)
attendanceScoreView.setMyAttendanceTableData(model.attendances)
}

Expand All @@ -277,8 +278,13 @@ extension ShowAttendanceVC {

@objc
private func infoButtonDidTap() {
if let url = URL(string: "https://sopt.org/rules") {
UIApplication.shared.open(url)

showToast(message: I18N.Attendance.infoButtonToastMessage)

DispatchQueue.main.asyncAfter(deadline: .now() + 1) { [weak self] in
let safariViewController = SFSafariViewController(url: URL(string: "https://sopt.org/rules")!)
safariViewController.playgroundStyle()
self?.present(safariViewController, animated: true)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// MyAttendanceStateExtension.swift
// AttendanceFeature
//
// Created by devxsby on 2023/04/25.
// Copyright © 2023 SOPT-iOS. All rights reserved.
//

import UIKit

import Core
import DSKit

extension AttendanceStateType {

public var image: UIImage {
switch self {
case .attendance: return DSKitAsset.Assets.opStateAttendance.image
case .absent: return DSKitAsset.Assets.opStateAbsent.image
case .tardy: return DSKitAsset.Assets.opStateTardy.image
case .participate: return DSKitAsset.Assets.opStateParticipate.image
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,7 @@ extension MyAttendanceStateTVC {
func setData(model: AttendanceModel) {
guard let status = AttendanceStateType(rawValue: model.status.lowercased()) else { return }

switch status {
case .attendance:
stateImageView.image = DSKitAsset.Assets.opStateAttendance.image
case .absent:
stateImageView.image = DSKitAsset.Assets.opStateAbsent.image
case .tardy:
stateImageView.image = DSKitAsset.Assets.opStateTardy.image
case .participate:
stateImageView.image = DSKitAsset.Assets.opStateParticipate.image
}

stateImageView.image = status.image
titleLabel.text = model.name
dateLabel.text = model.date
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,12 @@ extension TodayAttendanceView {
}

func setTodayAttendances(_ attendances: [AttendanceStepModel]) {

todayAttendanceStackView.arrangedSubviews.forEach { $0.removeFromSuperview() }

for attendance in attendances {
let attendanceStepView = OPAttendanceStepView(step: attendance)
todayAttendanceStackView.addArrangedSubviews(attendanceStepView)
todayAttendanceStackView.addArrangedSubview(attendanceStepView)
attendanceStepView.snp.makeConstraints {
$0.height.equalTo(Metric.attendanceStepHeight)
$0.width.equalTo(Metric.attendanceStepWidth)
Expand Down
Loading