From 94692f7cc1f35c034278b019c090e7cac35e26b1 Mon Sep 17 00:00:00 2001 From: devxsby Date: Sat, 15 Apr 2023 16:43:45 +0900 Subject: [PATCH 01/18] =?UTF-8?q?[Chore]=20#153-=20enum=20type=20core=20la?= =?UTF-8?q?yer=20=EB=A1=9C=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/Enum/AttendanceScheduleType.swift | 14 ++++++++++++++ .../Core/Sources/Enum/AttendanceStateType.swift | 16 ++++++++++++++++ .../Sources/Model/ShowAttendanceModel.swift | 16 ---------------- 3 files changed, 30 insertions(+), 16 deletions(-) create mode 100644 SOPT-iOS/Projects/Core/Sources/Enum/AttendanceScheduleType.swift create mode 100644 SOPT-iOS/Projects/Core/Sources/Enum/AttendanceStateType.swift delete mode 100644 SOPT-iOS/Projects/Domain/Sources/Model/ShowAttendanceModel.swift diff --git a/SOPT-iOS/Projects/Core/Sources/Enum/AttendanceScheduleType.swift b/SOPT-iOS/Projects/Core/Sources/Enum/AttendanceScheduleType.swift new file mode 100644 index 000000000..654971077 --- /dev/null +++ b/SOPT-iOS/Projects/Core/Sources/Enum/AttendanceScheduleType.swift @@ -0,0 +1,14 @@ +// +// AttendanceScheduleType.swift +// Core +// +// Created by devxsby on 2023/04/15. +// Copyright © 2023 SOPT-iOS. All rights reserved. +// + +import Foundation + +public enum AttendanceScheduleType { + case unscheduledDay /// 일정 없는 날 + case scheduledDay /// 일정(세미나, 행사) 있는 날 +} diff --git a/SOPT-iOS/Projects/Core/Sources/Enum/AttendanceStateType.swift b/SOPT-iOS/Projects/Core/Sources/Enum/AttendanceStateType.swift new file mode 100644 index 000000000..b1514218b --- /dev/null +++ b/SOPT-iOS/Projects/Core/Sources/Enum/AttendanceStateType.swift @@ -0,0 +1,16 @@ +// +// AttendanceStateType.swift +// Core +// +// Created by devxsby on 2023/04/15. +// Copyright © 2023 SOPT-iOS. All rights reserved. +// + +import Foundation + +public enum AttendanceStateType: String, CaseIterable { + case all = "전체" + case attendance = "출석" + case tardy = "지각" + case absent = "결석" +} diff --git a/SOPT-iOS/Projects/Domain/Sources/Model/ShowAttendanceModel.swift b/SOPT-iOS/Projects/Domain/Sources/Model/ShowAttendanceModel.swift deleted file mode 100644 index 4f4548354..000000000 --- a/SOPT-iOS/Projects/Domain/Sources/Model/ShowAttendanceModel.swift +++ /dev/null @@ -1,16 +0,0 @@ -// -// ShowAttendanceModel.swift -// Domain -// -// Created by devxsby on 2023/04/11. -// Copyright © 2023 SOPT-iOS. All rights reserved. -// - -import Foundation - -public struct ShowAttendanceModel { - - public init() { - - } -} From 21ee32dc9635f2712d3f57d6c1be6a1d748aa4f9 Mon Sep 17 00:00:00 2001 From: devxsby Date: Sat, 15 Apr 2023 17:57:42 +0900 Subject: [PATCH 02/18] =?UTF-8?q?[Feat]=20#153-=20entitiy=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entity/AttendanceScheduleEntity.swift | 21 +++++++++++++++ .../Entity/AttendanceScoreEntity.swift | 26 +++++++++++++++++++ .../Sources/Entity/ShowAttendanceEntity.swift | 13 ---------- 3 files changed, 47 insertions(+), 13 deletions(-) create mode 100644 SOPT-iOS/Projects/Modules/Network/Sources/Entity/AttendanceScheduleEntity.swift create mode 100644 SOPT-iOS/Projects/Modules/Network/Sources/Entity/AttendanceScoreEntity.swift delete mode 100644 SOPT-iOS/Projects/Modules/Network/Sources/Entity/ShowAttendanceEntity.swift diff --git a/SOPT-iOS/Projects/Modules/Network/Sources/Entity/AttendanceScheduleEntity.swift b/SOPT-iOS/Projects/Modules/Network/Sources/Entity/AttendanceScheduleEntity.swift new file mode 100644 index 000000000..ac985674a --- /dev/null +++ b/SOPT-iOS/Projects/Modules/Network/Sources/Entity/AttendanceScheduleEntity.swift @@ -0,0 +1,21 @@ +// +// AttendanceScheduleEntity.swift +// Network +// +// Created by devxsby on 2023/04/11. +// Copyright © 2023 SOPT-iOS. All rights reserved. +// + +import Foundation + +public struct AttendanceScheduleEntity: Codable { + public let type: String + public let id: Int + public let location, name, startDate, endDate: String + public let message: String + public let attendances: [TodayAttendance] +} + +public struct TodayAttendance: Codable { + public let status, attendedAt: String +} diff --git a/SOPT-iOS/Projects/Modules/Network/Sources/Entity/AttendanceScoreEntity.swift b/SOPT-iOS/Projects/Modules/Network/Sources/Entity/AttendanceScoreEntity.swift new file mode 100644 index 000000000..a0815d27a --- /dev/null +++ b/SOPT-iOS/Projects/Modules/Network/Sources/Entity/AttendanceScoreEntity.swift @@ -0,0 +1,26 @@ +// +// AttendanceScoreEntity.swift +// Network +// +// Created by devxsby on 2023/04/15. +// Copyright © 2023 SOPT-iOS. All rights reserved. +// + +import Foundation + +public struct AttendanceScoreEntity: Codable { + public let part: String + public let generation: Int + public let name: String + public let score: Double + public let total: TotalScore + public let attendances: [Attendance] +} + +public struct Attendance: Codable { + public let attribute, name, status, date: String +} + +public struct TotalScore: Codable { + public let attendance, absent, tardy, participate: Int +} diff --git a/SOPT-iOS/Projects/Modules/Network/Sources/Entity/ShowAttendanceEntity.swift b/SOPT-iOS/Projects/Modules/Network/Sources/Entity/ShowAttendanceEntity.swift deleted file mode 100644 index d25c61a8b..000000000 --- a/SOPT-iOS/Projects/Modules/Network/Sources/Entity/ShowAttendanceEntity.swift +++ /dev/null @@ -1,13 +0,0 @@ -// -// ShowAttendanceEntity.swift -// Network -// -// Created by devxsby on 2023/04/11. -// Copyright © 2023 SOPT-iOS. All rights reserved. -// - -import Foundation - -public struct ShowAttendanceEntity { - -} From 52907eec4ebcee152137a9128a28e73e63c08010 Mon Sep 17 00:00:00 2001 From: devxsby Date: Sat, 15 Apr 2023 17:58:22 +0900 Subject: [PATCH 03/18] =?UTF-8?q?[Chore]=20#153-=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=9C=84=EC=B9=98=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Views/AttendanceScoreComponents/SingleScoreView.swift | 7 ------- .../ShowAttendanceScene/Views/TodayScheduleView.swift | 5 ----- 2 files changed, 12 deletions(-) diff --git a/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/AttendanceScoreComponents/SingleScoreView.swift b/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/AttendanceScoreComponents/SingleScoreView.swift index 48ca249fe..3610eaa7a 100644 --- a/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/AttendanceScoreComponents/SingleScoreView.swift +++ b/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/AttendanceScoreComponents/SingleScoreView.swift @@ -11,13 +11,6 @@ import UIKit import Core import DSKit -public enum AttendanceStateType: String, CaseIterable { - case all = "전체" - case attendance = "출석" - case tardy = "지각" - case absent = "결석" -} - /* (전체: 00회)를 표현하는 단일 영역 뷰입니다. */ diff --git a/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/TodayScheduleView.swift b/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/TodayScheduleView.swift index 4a0087be5..2889ef382 100644 --- a/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/TodayScheduleView.swift +++ b/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/TodayScheduleView.swift @@ -11,11 +11,6 @@ import UIKit import Core import DSKit -public enum TodayScheduleType { - case unscheduledDay /// 일정 없는 날 - case scheduledDay /// 일정(세미나, 행사) 있는 날 -} - /* 출석 조회하기 뷰의 상단 오늘의 일정을 보여주는 뷰 입니다. */ From a8f8866bc8afc8fc5afee539a0a4e17501f97791 Mon Sep 17 00:00:00 2001 From: devxsby Date: Sat, 15 Apr 2023 17:59:16 +0900 Subject: [PATCH 04/18] =?UTF-8?q?[Chore]=20#153-=20=ED=8C=8C=EC=9D=BC?= =?UTF-8?q?=EB=AA=85=20=EB=B3=80=EA=B2=BD=EC=9C=BC=EB=A1=9C=20=EC=9D=B8?= =?UTF-8?q?=ED=95=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/ShowAttendanceScene/Views/TodayScheduleView.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/TodayScheduleView.swift b/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/TodayScheduleView.swift index 2889ef382..37821b2de 100644 --- a/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/TodayScheduleView.swift +++ b/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/TodayScheduleView.swift @@ -105,7 +105,7 @@ final class TodayScheduleView: UIView { // MARK: - Initialization - init(type: TodayScheduleType) { + init(type: AttendanceScheduleType) { super.init(frame: .zero) confiureContentView() setLayout(type) @@ -126,7 +126,7 @@ extension TodayScheduleView { self.layer.cornerRadius = 16 } - private func setLayout(_ type: TodayScheduleType) { + private func setLayout(_ type: AttendanceScheduleType) { addSubview(containerStackView) containerStackView.snp.makeConstraints { From 8ef46f37af392ab1f87d2e53a8fafda03b0a5ec1 Mon Sep 17 00:00:00 2001 From: devxsby Date: Sat, 15 Apr 2023 17:59:48 +0900 Subject: [PATCH 05/18] =?UTF-8?q?[Feat]=20#153-=20AttendanceService=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Network/Sources/Service/AttendanceService.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/SOPT-iOS/Projects/Modules/Network/Sources/Service/AttendanceService.swift b/SOPT-iOS/Projects/Modules/Network/Sources/Service/AttendanceService.swift index 515516df3..5d3e6dc68 100644 --- a/SOPT-iOS/Projects/Modules/Network/Sources/Service/AttendanceService.swift +++ b/SOPT-iOS/Projects/Modules/Network/Sources/Service/AttendanceService.swift @@ -15,9 +15,17 @@ import Moya public typealias DefaultAttendanceService = BaseService public protocol AttendanceService { - + func fetchAttendanceSchedule() -> AnyPublisher + func fetchAttendanceScore() -> AnyPublisher } extension DefaultAttendanceService: AttendanceService { + public func fetchAttendanceSchedule() -> AnyPublisher { + requestObjectInCombine(AttendanceAPI.score) + } + + public func fetchAttendanceScore() -> AnyPublisher { + requestObjectInCombine(AttendanceAPI.lecture) + } } From 7d3ad6e876e98e36303b7ce3077a9755322f2b17 Mon Sep 17 00:00:00 2001 From: devxsby Date: Sat, 15 Apr 2023 18:01:09 +0900 Subject: [PATCH 06/18] =?UTF-8?q?[Feat]=20#153-=20=EB=8F=84=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=EB=A0=88=EC=9D=B4=EC=96=B4=20=EB=AA=A8=EB=8D=B8=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Model/AttendanceScheduleModel.swift | 35 +++++++++++++ .../Sources/Model/AttendanceScoreModel.swift | 50 +++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 SOPT-iOS/Projects/Domain/Sources/Model/AttendanceScheduleModel.swift create mode 100644 SOPT-iOS/Projects/Domain/Sources/Model/AttendanceScoreModel.swift diff --git a/SOPT-iOS/Projects/Domain/Sources/Model/AttendanceScheduleModel.swift b/SOPT-iOS/Projects/Domain/Sources/Model/AttendanceScheduleModel.swift new file mode 100644 index 000000000..02b7b4775 --- /dev/null +++ b/SOPT-iOS/Projects/Domain/Sources/Model/AttendanceScheduleModel.swift @@ -0,0 +1,35 @@ +// +// AttendanceScheduleModel.swift +// Domain +// +// Created by devxsby on 2023/04/11. +// Copyright © 2023 SOPT-iOS. All rights reserved. +// + +import Foundation + +public struct AttendanceScheduleModel: Codable, Hashable { + public let type: String + public let location, name, startDate, endDate: String + public let message: String + public let attendances: [TodayAttendanceModel] + + public init(type: String, location: String, name: String, startDate: String, endDate: String, message: String, attendances: [TodayAttendanceModel]) { + self.type = type + self.location = location + self.name = name + self.startDate = startDate + self.endDate = endDate + self.message = message + self.attendances = attendances + } +} + +public struct TodayAttendanceModel: Codable, Hashable { + public let status, attendedAt: String + + public init(status: String, attendedAt: String) { + self.status = status + self.attendedAt = attendedAt + } +} diff --git a/SOPT-iOS/Projects/Domain/Sources/Model/AttendanceScoreModel.swift b/SOPT-iOS/Projects/Domain/Sources/Model/AttendanceScoreModel.swift new file mode 100644 index 000000000..ece7ca56a --- /dev/null +++ b/SOPT-iOS/Projects/Domain/Sources/Model/AttendanceScoreModel.swift @@ -0,0 +1,50 @@ +// +// AttendanceScoreModel.swift +// Domain +// +// Created by devxsby on 2023/04/15. +// Copyright © 2023 SOPT-iOS. All rights reserved. +// + +import Foundation + +public struct AttendanceScoreModel: Codable, Hashable { + public let part: String + public let generation: Int + public let name: String + public let score: Double + public let total: TotalScoreModel + public let attendances: [AttendanceModel] + + public init(part: String, generation: Int, name: String, score: Double, total: TotalScoreModel, attendances: [AttendanceModel]) { + self.part = part + self.generation = generation + self.name = name + self.score = score + self.total = total + self.attendances = attendances + } + +} + +public struct TotalScoreModel: Codable, Hashable { + public let attendance, absent, tardy, participate: Int + + public init(attendance: Int, absent: Int, tardy: Int, participate: Int) { + self.attendance = attendance + self.absent = absent + self.tardy = tardy + self.participate = participate + } +} + +public struct AttendanceModel: Codable, Hashable { + public let attribute, name, status, date: String + + public init(attribute: String, name: String, status: String, date: String) { + self.attribute = attribute + self.name = name + self.status = status + self.date = date + } +} From b4f8e49841fd030f4fc568fd40e556e95952a6ef Mon Sep 17 00:00:00 2001 From: devxsby Date: Sat, 15 Apr 2023 18:02:05 +0900 Subject: [PATCH 07/18] =?UTF-8?q?[Feat]=20#153-=20entity=EC=97=90=EC=84=9C?= =?UTF-8?q?=20model=EB=A1=9C=20=EB=B3=80=ED=99=98=ED=95=98=EB=8A=94=20Tran?= =?UTF-8?q?sform=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AttendanceScheduleTransform.swift | 33 +++++++++++++++ .../Transform/AttendanceScoreTransform.swift | 42 +++++++++++++++++++ .../Transform/ShowAttendanceTransform.swift | 19 --------- 3 files changed, 75 insertions(+), 19 deletions(-) create mode 100644 SOPT-iOS/Projects/Data/Sources/Transform/AttendanceScheduleTransform.swift create mode 100644 SOPT-iOS/Projects/Data/Sources/Transform/AttendanceScoreTransform.swift delete mode 100644 SOPT-iOS/Projects/Data/Sources/Transform/ShowAttendanceTransform.swift diff --git a/SOPT-iOS/Projects/Data/Sources/Transform/AttendanceScheduleTransform.swift b/SOPT-iOS/Projects/Data/Sources/Transform/AttendanceScheduleTransform.swift new file mode 100644 index 000000000..ceccc6955 --- /dev/null +++ b/SOPT-iOS/Projects/Data/Sources/Transform/AttendanceScheduleTransform.swift @@ -0,0 +1,33 @@ +// +// AttendanceScheduleTransform.swift +// Data +// +// Created by devxsby on 2023/04/11. +// Copyright © 2023 SOPT-iOS. All rights reserved. +// + +import Foundation + +import Domain +import Network + +extension AttendanceScheduleEntity { + + public func toDomain() -> AttendanceScheduleModel { + return .init(type: self.type, + location: self.location, + name: self.name, + startDate: self.startDate, + endDate: self.endDate, + message: self.message, + attendances: self.attendances.map { $0.toDomain() }) + } +} + +extension TodayAttendance { + + public func toDomain() -> TodayAttendanceModel { + return .init(status: self.status, + attendedAt: self.attendedAt) + } +} diff --git a/SOPT-iOS/Projects/Data/Sources/Transform/AttendanceScoreTransform.swift b/SOPT-iOS/Projects/Data/Sources/Transform/AttendanceScoreTransform.swift new file mode 100644 index 000000000..0d18da248 --- /dev/null +++ b/SOPT-iOS/Projects/Data/Sources/Transform/AttendanceScoreTransform.swift @@ -0,0 +1,42 @@ +// +// AttendanceScoreTransform.swift +// Data +// +// Created by devxsby on 2023/04/15. +// Copyright © 2023 SOPT-iOS. All rights reserved. +// + +import Foundation + +import Domain +import Network + +extension AttendanceScoreEntity { + + public func toDomain() -> AttendanceScoreModel { + .init(part: self.part, + generation: self.generation, + name: self.name, + score: self.score, + total: self.total.toDomain(), + attendances: self.attendances.map { $0.toDomain() } ) + } +} + +extension TotalScore { + public func toDomain() -> TotalScoreModel { + .init(attendance: self.attendance, + absent: self.absent, + tardy: self.tardy, + participate: self.participate) + } +} + +extension Attendance { + public func toDomain() -> AttendanceModel { + .init(attribute: self.attribute, + name: self.name, + status: self.status, + date: self.date) + } +} diff --git a/SOPT-iOS/Projects/Data/Sources/Transform/ShowAttendanceTransform.swift b/SOPT-iOS/Projects/Data/Sources/Transform/ShowAttendanceTransform.swift deleted file mode 100644 index 9dd73e6a8..000000000 --- a/SOPT-iOS/Projects/Data/Sources/Transform/ShowAttendanceTransform.swift +++ /dev/null @@ -1,19 +0,0 @@ -// -// ShowAttendanceTransform.swift -// Data -// -// Created by devxsby on 2023/04/11. -// Copyright © 2023 SOPT-iOS. All rights reserved. -// - -import Foundation - -import Domain -import Network - -extension ShowAttendanceEntity { - - public func toDomain() -> ShowAttendanceModel { - return ShowAttendanceModel.init() - } -} From 21ff201cfc9e0fe88a9add0966de037c3573dd35 Mon Sep 17 00:00:00 2001 From: devxsby Date: Sat, 15 Apr 2023 18:04:03 +0900 Subject: [PATCH 08/18] =?UTF-8?q?[Feat]=20#153-=20Repository,=20Repository?= =?UTF-8?q?=20Interface=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Repository/ShowAttendanceRepository.swift | 14 ++++++++++++-- .../ShowAttendanceRepositoryInterface.swift | 3 ++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/SOPT-iOS/Projects/Data/Sources/Repository/ShowAttendanceRepository.swift b/SOPT-iOS/Projects/Data/Sources/Repository/ShowAttendanceRepository.swift index 9da7b8d0d..a145b013d 100644 --- a/SOPT-iOS/Projects/Data/Sources/Repository/ShowAttendanceRepository.swift +++ b/SOPT-iOS/Projects/Data/Sources/Repository/ShowAttendanceRepository.swift @@ -15,14 +15,24 @@ import Network public class ShowAttendanceRepository { - private let networkService: AttendanceService + private let attendanceService: AttendanceService private let cancelBag = CancelBag() public init(service: AttendanceService) { - self.networkService = service + self.attendanceService = service } } extension ShowAttendanceRepository: ShowAttendanceRepositoryInterface { + public func fetchAttendanceScheduleModel() -> AnyPublisher { + return self.attendanceService.fetchAttendanceSchedule() + .map { $0.toDomain() } + .eraseToAnyPublisher() + } + public func fetchAttendanceScoreModel() -> AnyPublisher { + return self.attendanceService.fetchAttendanceScore() + .map { $0.toDomain() } + .eraseToAnyPublisher() + } } diff --git a/SOPT-iOS/Projects/Domain/Sources/RepositoryInterface/ShowAttendanceRepositoryInterface.swift b/SOPT-iOS/Projects/Domain/Sources/RepositoryInterface/ShowAttendanceRepositoryInterface.swift index a68dd6693..af101635f 100644 --- a/SOPT-iOS/Projects/Domain/Sources/RepositoryInterface/ShowAttendanceRepositoryInterface.swift +++ b/SOPT-iOS/Projects/Domain/Sources/RepositoryInterface/ShowAttendanceRepositoryInterface.swift @@ -9,5 +9,6 @@ import Combine public protocol ShowAttendanceRepositoryInterface { - + func fetchAttendanceScheduleModel() -> AnyPublisher + func fetchAttendanceScoreModel() -> AnyPublisher } From 1e7e1098480bddda0315cdc0f296024921de06fd Mon Sep 17 00:00:00 2001 From: devxsby Date: Sat, 15 Apr 2023 18:05:57 +0900 Subject: [PATCH 09/18] =?UTF-8?q?[Chore]=20#153-=20=EB=8D=94=EB=AF=B8=20?= =?UTF-8?q?=EB=AA=A8=EB=8D=B8=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Repository/ShowAttendanceRepository.swift | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/SOPT-iOS/Projects/Data/Sources/Repository/ShowAttendanceRepository.swift b/SOPT-iOS/Projects/Data/Sources/Repository/ShowAttendanceRepository.swift index a145b013d..7a3a359b8 100644 --- a/SOPT-iOS/Projects/Data/Sources/Repository/ShowAttendanceRepository.swift +++ b/SOPT-iOS/Projects/Data/Sources/Repository/ShowAttendanceRepository.swift @@ -25,14 +25,34 @@ public class ShowAttendanceRepository { extension ShowAttendanceRepository: ShowAttendanceRepositoryInterface { public func fetchAttendanceScheduleModel() -> AnyPublisher { - return self.attendanceService.fetchAttendanceSchedule() - .map { $0.toDomain() } - .eraseToAnyPublisher() + return Future { promise in + promise(.success(AttendanceScheduleModel(type: "HAS_ATTENDANCE", + location: "단국대학교 혜당관", + name: "3차 세미나", + startDate: "2023-04-06T14:13:51", endDate: "2023-04-06T18:13:51", message: "", + attendances: [TodayAttendanceModel(status: "ATTENDANCE", attendedAt: "2023-04-13T14:12:09"), + TodayAttendanceModel(status: "ABSENT", attendedAt: "2023-04-13T14:10:04")]))) + } + .eraseToAnyPublisher() +// return self.attendanceService.fetchAttendanceSchedule() +// .map { $0.toDomain() } +// .eraseToAnyPublisher() } public func fetchAttendanceScoreModel() -> AnyPublisher { - return self.attendanceService.fetchAttendanceScore() - .map { $0.toDomain() } - .eraseToAnyPublisher() + return Future { promise in + promise(.success(AttendanceScoreModel.init(part: "iOS", + generation: 31, + name: "윤수빈", + score: 2.0, + total: TotalScoreModel(attendance: 2, absent: 0, tardy: 1, participate: 1), + attendances: [AttendanceModel(attribute: "ETC", name: "솝커톤", status: "TARDY", date: "4월 22일"), + AttendanceModel(attribute: "SEMINAR", name: "iOS 2차 세미나", status: "ATTENDANCE", date: "4월 15일"), + AttendanceModel(attribute: "SEMINAR", name: "iOS 1차 세미나", status: "ATTENDANCE", date: "4월 8일"), + AttendanceModel(attribute: "ETC", name: "OT", status: "PARTICIPATE", date: "4월 1일")]))) + }.eraseToAnyPublisher() +// return self.attendanceService.fetchAttendanceScore() +// .map { $0.toDomain() } +// .eraseToAnyPublisher() } } From 5a9e905727f952d955f5ac5d978bd793b6d4c15b Mon Sep 17 00:00:00 2001 From: devxsby Date: Sat, 15 Apr 2023 18:06:18 +0900 Subject: [PATCH 10/18] =?UTF-8?q?[Feat]=20#153-=20Usecase=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UseCase/ShowAttendanceUseCase.swift | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/SOPT-iOS/Projects/Domain/Sources/UseCase/ShowAttendanceUseCase.swift b/SOPT-iOS/Projects/Domain/Sources/UseCase/ShowAttendanceUseCase.swift index 85f03f4d1..21e85981f 100644 --- a/SOPT-iOS/Projects/Domain/Sources/UseCase/ShowAttendanceUseCase.swift +++ b/SOPT-iOS/Projects/Domain/Sources/UseCase/ShowAttendanceUseCase.swift @@ -10,13 +10,19 @@ import Combine import Core public protocol ShowAttendanceUseCase { - + func fetchAttendanceSchedule() + func fetchAttendanceScore() + var attendanceScheduleFetched: PassthroughSubject { get set } + var attendanceScoreFetched: PassthroughSubject { get set } } public class DefaultShowAttendanceUseCase { private let repository: ShowAttendanceRepositoryInterface private var cancelBag = CancelBag() + + public var attendanceScheduleFetched = PassthroughSubject() + public var attendanceScoreFetched = PassthroughSubject() public init(repository: ShowAttendanceRepositoryInterface) { self.repository = repository @@ -24,5 +30,23 @@ public class DefaultShowAttendanceUseCase { } extension DefaultShowAttendanceUseCase: ShowAttendanceUseCase { - + public func fetchAttendanceSchedule() { + self.repository.fetchAttendanceScheduleModel() + .sink(receiveCompletion: { event in + print("completion: \(event)") + }, receiveValue: { model in + self.attendanceScheduleFetched.send(model) + }) + .store(in: cancelBag) + } + + public func fetchAttendanceScore() { + self.repository.fetchAttendanceScoreModel() + .sink(receiveCompletion: { event in + print("completion: \(event)") + }, receiveValue: { model in + self.attendanceScoreFetched.send(model) + }) + .store(in: cancelBag) + } } From 8d5475a1e4d2738aa0eab41d93fafe6f341fbf78 Mon Sep 17 00:00:00 2001 From: devxsby Date: Sat, 15 Apr 2023 18:06:48 +0900 Subject: [PATCH 11/18] =?UTF-8?q?[Chore]=20#153-=20Presentation=20layer=20?= =?UTF-8?q?=EC=97=B0=EA=B2=B0=20=ED=99=95=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewModel/ShowAttendanceViewModel.swift | 39 ++++++++++++++--- .../Views/ShowAttendanceVC.swift | 43 +++++++++++++++++-- .../OperationComponents/OPNavigationBar.swift | 5 +++ 3 files changed, 79 insertions(+), 8 deletions(-) diff --git a/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/ViewModel/ShowAttendanceViewModel.swift b/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/ViewModel/ShowAttendanceViewModel.swift index afc48e2b1..cae38e886 100644 --- a/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/ViewModel/ShowAttendanceViewModel.swift +++ b/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/ViewModel/ShowAttendanceViewModel.swift @@ -17,17 +17,21 @@ public final class ShowAttendanceViewModel: ViewModelType { private let useCase: ShowAttendanceUseCase private var cancelBag = CancelBag() + public var sceneType: AttendanceScheduleType? // MARK: - Inputs public struct Input { - + let viewDidLoad: Driver + let refreshButtonTapped: Driver } // MARK: - Outputs - public struct Output { - + public class Output { + @Published var scheduleModel: AttendanceScheduleModel? + @Published var scoreModel: AttendanceScoreModel? + } // MARK: - init @@ -41,13 +45,38 @@ extension ShowAttendanceViewModel { public func transform(from input: Input, cancelBag: CancelBag) -> Output { let output = Output() + self.bindOutput(output: output, cancelBag: cancelBag) - // input,output 상관관계 작성 + + input.viewDidLoad.merge(with: input.refreshButtonTapped) + .withUnretained(self) + .sink { owner, _ in +// if owner.sceneType == .unscheduledDay { +// owner.useCase. +// } else { +// +// } + owner.useCase.fetchAttendanceSchedule() + owner.useCase.fetchAttendanceScore() + }.store(in: cancelBag) return output } private func bindOutput(output: Output, cancelBag: CancelBag) { - + let fetchedSchedule = self.useCase.attendanceScheduleFetched + let fetchedScore = self.useCase.attendanceScoreFetched + + fetchedSchedule.asDriver() + .sink(receiveValue: { model in + output.scheduleModel = model + }) + .store(in: cancelBag) + + fetchedScore.asDriver() + .sink(receiveValue: { model in + output.scoreModel = model + }) + .store(in: cancelBag) } } diff --git a/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/ShowAttendanceVC.swift b/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/ShowAttendanceVC.swift index b360f81a0..b1ad65087 100644 --- a/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/ShowAttendanceVC.swift +++ b/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/ShowAttendanceVC.swift @@ -23,6 +23,11 @@ public final class ShowAttendanceVC: UIViewController, ShowAttendanceViewControl public var viewModel: ShowAttendanceViewModel public var factory: AttendanceFeatureViewBuildable private var cancelBag = CancelBag() + + public var sceneType: AttendanceScheduleType { + return self.viewModel.sceneType ?? .unscheduledDay + } + private var viewdidload = PassthroughSubject() // MARK: - UI Components @@ -35,7 +40,15 @@ public final class ShowAttendanceVC: UIViewController, ShowAttendanceViewControl self.refreshButtonDidTap() } - private let headerScheduleView = TodayScheduleView(type: .scheduledDay) + private lazy var headerScheduleView: TodayScheduleView = { + switch sceneType { + case .unscheduledDay: + return TodayScheduleView(type: .unscheduledDay) + case .scheduledDay: + return TodayScheduleView(type: .scheduledDay) + } + }() + private let attendanceScoreView = AttendanceScoreView() // MARK: - Initialization @@ -56,9 +69,11 @@ public final class ShowAttendanceVC: UIViewController, ShowAttendanceViewControl public override func viewDidLoad() { super.viewDidLoad() self.bindViewModels() + self.bindViews() self.setUI() self.setLayout() - self.dummy() + self.viewdidload.send(()) +// self.dummy() } } @@ -113,10 +128,32 @@ extension ShowAttendanceVC { // MARK: - Methods extension ShowAttendanceVC { + + private func bindViews() { + + navibar.rightButtonTapped + .asDriver() + .withUnretained(self) + .sink { owner, _ in + owner.refreshButtonDidTap() + }.store(in: self.cancelBag) + } private func bindViewModels() { - let input = ShowAttendanceViewModel.Input() + + let input = ShowAttendanceViewModel.Input(viewDidLoad: viewdidload.asDriver(), + refreshButtonTapped: navibar.rightButtonTapped) let output = self.viewModel.transform(from: input, cancelBag: self.cancelBag) + + output.$scheduleModel + .sink { model in + print("스케쥴 데이터가 잘 넘어왓을까요?", model) + }.store(in: self.cancelBag) + + output.$scoreModel + .sink { model in + print("스코어 데이터가 잘 넘어왔을까여?]", model) + }.store(in: self.cancelBag) } @objc diff --git a/SOPT-iOS/Projects/Modules/DSKit/Sources/Components/OperationComponents/OPNavigationBar.swift b/SOPT-iOS/Projects/Modules/DSKit/Sources/Components/OperationComponents/OPNavigationBar.swift index 9df29cdba..89ab633b3 100644 --- a/SOPT-iOS/Projects/Modules/DSKit/Sources/Components/OperationComponents/OPNavigationBar.swift +++ b/SOPT-iOS/Projects/Modules/DSKit/Sources/Components/OperationComponents/OPNavigationBar.swift @@ -25,6 +25,11 @@ public final class OPNavigationBar: UIView { private var vc: UIViewController? private var rightButtonClosure: (() -> Void)? + public var rightButtonTapped: Driver { + rightButton.publisher(for: .touchUpInside) + .map { _ in () } + .asDriver() + } // MARK: - UI Components From 9ce42852df9d93ab402c8dad1c84e4731f84a12d Mon Sep 17 00:00:00 2001 From: devxsby Date: Sat, 15 Apr 2023 18:07:14 +0900 Subject: [PATCH 12/18] =?UTF-8?q?[Chore]=20#153-=20=EB=A3=A8=ED=8A=B8=20?= =?UTF-8?q?=EB=B7=B0=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Projects/SOPT-iOS/Sources/Application/SceneDelegate.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SOPT-iOS/Projects/SOPT-iOS/Sources/Application/SceneDelegate.swift b/SOPT-iOS/Projects/SOPT-iOS/Sources/Application/SceneDelegate.swift index 556124eba..b1ee44c22 100644 --- a/SOPT-iOS/Projects/SOPT-iOS/Sources/Application/SceneDelegate.swift +++ b/SOPT-iOS/Projects/SOPT-iOS/Sources/Application/SceneDelegate.swift @@ -23,8 +23,8 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { window = UIWindow(frame: scene.coordinateSpace.bounds) window?.windowScene = scene -// let rootVC = container.makeShowAttendanceVC().viewController - let rootVC = container.makeMainVC(userType: .active).viewController + let rootVC = container.makeShowAttendanceVC().viewController +// let rootVC = container.makeMainVC(userType: .active).viewController window?.rootViewController = UINavigationController(rootViewController: rootVC) window?.makeKeyAndVisible() } From e748f2eabe24b904322135f42a325b61a030ed78 Mon Sep 17 00:00:00 2001 From: devxsby Date: Sat, 15 Apr 2023 19:14:49 +0900 Subject: [PATCH 13/18] =?UTF-8?q?[Feat]=20#153-=20=EC=98=A4=EB=8A=98?= =?UTF-8?q?=EC=9D=98=20=EC=9D=BC=EC=A0=95=20=EB=B6=80=EB=B6=84=20=EB=B7=B0?= =?UTF-8?q?=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewModel/ShowAttendanceViewModel.swift | 45 ++++++++++++++++--- .../Views/ShowAttendanceVC.swift | 40 ++++++++++++----- .../Views/TodayScheduleView.swift | 2 +- 3 files changed, 68 insertions(+), 19 deletions(-) diff --git a/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/ViewModel/ShowAttendanceViewModel.swift b/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/ViewModel/ShowAttendanceViewModel.swift index cae38e886..0244e62e8 100644 --- a/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/ViewModel/ShowAttendanceViewModel.swift +++ b/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/ViewModel/ShowAttendanceViewModel.swift @@ -10,6 +10,7 @@ import Combine import Core import Domain +import Foundation public final class ShowAttendanceViewModel: ViewModelType { @@ -31,7 +32,6 @@ public final class ShowAttendanceViewModel: ViewModelType { public class Output { @Published var scheduleModel: AttendanceScheduleModel? @Published var scoreModel: AttendanceScoreModel? - } // MARK: - init @@ -51,11 +51,6 @@ extension ShowAttendanceViewModel { input.viewDidLoad.merge(with: input.refreshButtonTapped) .withUnretained(self) .sink { owner, _ in -// if owner.sceneType == .unscheduledDay { -// owner.useCase. -// } else { -// -// } owner.useCase.fetchAttendanceSchedule() owner.useCase.fetchAttendanceScore() }.store(in: cancelBag) @@ -69,7 +64,17 @@ extension ShowAttendanceViewModel { fetchedSchedule.asDriver() .sink(receiveValue: { model in - output.scheduleModel = model + guard let convertedStartDate = self.convertDateString(model.startDate), + let convertedEndDate = self.convertDateString(model.endDate) else { return } + + let newModel = AttendanceScheduleModel(type: model.type, + location: model.location, + name: model.name, + startDate: convertedStartDate, + endDate: convertedEndDate, + message: model.message, + attendances: model.attendances) + output.scheduleModel = newModel }) .store(in: cancelBag) @@ -79,4 +84,30 @@ extension ShowAttendanceViewModel { }) .store(in: cancelBag) } + + private func convertDateString(_ dateString: String) -> String? { + let dateFormatter = DateFormatter() + dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss" + guard let date = dateFormatter.date(from: dateString) else { return nil } + + dateFormatter.dateFormat = "M월 d일 EEEE H:mm" + dateFormatter.locale = Locale(identifier: "ko_KR") + dateFormatter.timeZone = TimeZone(identifier: "Asia/Seoul") + return dateFormatter.string(from: date) + } + + func formatTimeInterval(startDate: String, endDate: String) -> String? { + let dateFormatter = DateFormatter() + dateFormatter.dateFormat = "M월 d일 EEEE HH:mm" + + guard let startDateObject = dateFormatter.date(from: startDate), + let endDateObject = dateFormatter.date(from: endDate) else { return nil } + + let formattedStartDate = dateFormatter.string(from: startDateObject) + + dateFormatter.dateFormat = "HH:mm" + let formattedEndDate = dateFormatter.string(from: endDateObject) + + return "\(formattedStartDate) ~ \(formattedEndDate)" + } } diff --git a/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/ShowAttendanceVC.swift b/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/ShowAttendanceVC.swift index b1ad65087..826a9e3c3 100644 --- a/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/ShowAttendanceVC.swift +++ b/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/ShowAttendanceVC.swift @@ -11,11 +11,18 @@ import UIKit import Combine import Core +import Domain import DSKit import SnapKit import AttendanceFeatureInterface +private enum SessionType: String, CaseIterable { + case noSession = "NO_SESSION" + case hasAttendance = "HAS_ATTENDANCE" + case noAttendance = "NO_ATTENDANCE" +} + public final class ShowAttendanceVC: UIViewController, ShowAttendanceViewControllable { // MARK: - Properties @@ -25,7 +32,7 @@ public final class ShowAttendanceVC: UIViewController, ShowAttendanceViewControl private var cancelBag = CancelBag() public var sceneType: AttendanceScheduleType { - return self.viewModel.sceneType ?? .unscheduledDay + return self.viewModel.sceneType ?? .scheduledDay } private var viewdidload = PassthroughSubject() @@ -73,7 +80,6 @@ public final class ShowAttendanceVC: UIViewController, ShowAttendanceViewControl self.setUI() self.setLayout() self.viewdidload.send(()) -// self.dummy() } } @@ -116,13 +122,6 @@ extension ShowAttendanceVC { $0.bottom.equalToSuperview() } } - - private func dummy() { - headerScheduleView.setData(date: "3월 23일 토요일 14:00 - 18:00", - place: "건국대학교 꽥꽥오리관", - todaySchedule: "1차 행사", - description: "행사도 참여하고, 출석점수도 받고, 일석이조!") - } } // MARK: - Methods @@ -146,13 +145,20 @@ extension ShowAttendanceVC { let output = self.viewModel.transform(from: input, cancelBag: self.cancelBag) output.$scheduleModel + .compactMap { $0 } .sink { model in - print("스케쥴 데이터가 잘 넘어왓을까요?", model) + if model.type == "NO_SESSION" { + self.viewModel.sceneType = .unscheduledDay + } else { + self.viewModel.sceneType = .scheduledDay + self.setData(model) + } +// print("스케쥴 데이터가 잘 넘어왓을까요?", model) }.store(in: self.cancelBag) output.$scoreModel .sink { model in - print("스코어 데이터가 잘 넘어왔을까여?]", model) +// print("스코어 데이터가 잘 넘어왔을까여?]", model) }.store(in: self.cancelBag) } @@ -160,4 +166,16 @@ extension ShowAttendanceVC { private func refreshButtonDidTap() { print("refresh button did tap") } + + private func setData(_ model: AttendanceScheduleModel) { + if self.sceneType == .scheduledDay { + 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) + } + } + + } diff --git a/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/TodayScheduleView.swift b/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/TodayScheduleView.swift index 37821b2de..15c42ca52 100644 --- a/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/TodayScheduleView.swift +++ b/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/TodayScheduleView.swift @@ -154,6 +154,6 @@ extension TodayScheduleView { titleLabel.partFontChange(targetString: todaySchedule, font: DSKitFontFamily.Suit.bold.font(size: 18)) subtitleLabel.text = description - subtitleLabel.isHidden = ((description?.isEmpty) == nil) + subtitleLabel.isHidden = ((description?.isEmpty) == nil || description == "") } } From 8a84423fd4257c2bd2d6a5b04319bc17deca292b Mon Sep 17 00:00:00 2001 From: devxsby Date: Sat, 15 Apr 2023 20:26:34 +0900 Subject: [PATCH 14/18] =?UTF-8?q?[Chore]=20#153-=20=EB=A0=88=EC=9D=B4?= =?UTF-8?q?=EC=95=84=EC=9B=83=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Repository/ShowAttendanceRepository.swift | 22 +++++++++-- .../ViewModel/ShowAttendanceViewModel.swift | 32 ++++++++++----- .../Views/ShowAttendanceVC.swift | 39 ++++++++++--------- .../Views/TodayScheduleView.swift | 12 ++++++ 4 files changed, 73 insertions(+), 32 deletions(-) diff --git a/SOPT-iOS/Projects/Data/Sources/Repository/ShowAttendanceRepository.swift b/SOPT-iOS/Projects/Data/Sources/Repository/ShowAttendanceRepository.swift index 7a3a359b8..c0d1e1d80 100644 --- a/SOPT-iOS/Projects/Data/Sources/Repository/ShowAttendanceRepository.swift +++ b/SOPT-iOS/Projects/Data/Sources/Repository/ShowAttendanceRepository.swift @@ -26,12 +26,28 @@ public class ShowAttendanceRepository { extension ShowAttendanceRepository: ShowAttendanceRepositoryInterface { public func fetchAttendanceScheduleModel() -> AnyPublisher { return Future { promise in +// promise(.success(AttendanceScheduleModel(type: "HAS_ATTENDANCE", +// location: "단국대학교 혜당관", +// name: "3차 세미나", +// startDate: "2023-04-06T14:14:00", endDate: "2023-04-06T18:00:00", message: "", +// attendances: [TodayAttendanceModel(status: "ATTENDANCE", attendedAt: "2023-04-13T14:12:09"), +// TodayAttendanceModel(status: "ABSENT", attendedAt: +// "2023-04-13T14:10:04")]))) + promise(.success(AttendanceScheduleModel(type: "HAS_ATTENDANCE", - location: "단국대학교 혜당관", - name: "3차 세미나", - startDate: "2023-04-06T14:13:51", endDate: "2023-04-06T18:13:51", message: "", + location: "한국대학교 혜당관", + name: "2차 행사", + startDate: "2023-04-06T14:14:00", endDate: "2023-04-06T18:00:00", + message: "행사도 참여하고, 출석점수도 받고, 일석이조!", attendances: [TodayAttendanceModel(status: "ATTENDANCE", attendedAt: "2023-04-13T14:12:09"), TodayAttendanceModel(status: "ABSENT", attendedAt: "2023-04-13T14:10:04")]))) + +// promise(.success(AttendanceScheduleModel(type: "NO_SESSION", +// location: "", +// name: "", +// startDate: "", endDate: "", message: "", +// attendances: [TodayAttendanceModel(status: "", attendedAt: ""), +// TodayAttendanceModel(status: "", attendedAt: "")]))) } .eraseToAnyPublisher() // return self.attendanceService.fetchAttendanceSchedule() diff --git a/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/ViewModel/ShowAttendanceViewModel.swift b/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/ViewModel/ShowAttendanceViewModel.swift index 0244e62e8..39467caae 100644 --- a/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/ViewModel/ShowAttendanceViewModel.swift +++ b/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/ViewModel/ShowAttendanceViewModel.swift @@ -12,6 +12,12 @@ import Core import Domain import Foundation +public enum SessionType: String, CaseIterable { + case noSession = "NO_SESSION" + case hasAttendance = "HAS_ATTENDANCE" + case noAttendance = "NO_ATTENDANCE" +} + public final class ShowAttendanceViewModel: ViewModelType { // MARK: - Properties @@ -64,17 +70,23 @@ extension ShowAttendanceViewModel { fetchedSchedule.asDriver() .sink(receiveValue: { model in - guard let convertedStartDate = self.convertDateString(model.startDate), - let convertedEndDate = self.convertDateString(model.endDate) else { return } + if model.type != SessionType.noSession.rawValue { + self.sceneType = .scheduledDay + guard let convertedStartDate = self.convertDateString(model.startDate), + let convertedEndDate = self.convertDateString(model.endDate) else { return } - let newModel = AttendanceScheduleModel(type: model.type, - location: model.location, - name: model.name, - startDate: convertedStartDate, - endDate: convertedEndDate, - message: model.message, - attendances: model.attendances) - output.scheduleModel = newModel + let newModel = AttendanceScheduleModel(type: model.type, + location: model.location, + name: model.name, + startDate: convertedStartDate, + endDate: convertedEndDate, + message: model.message, + attendances: model.attendances) + output.scheduleModel = newModel + } else { + self.sceneType = .unscheduledDay + output.scheduleModel = model + } }) .store(in: cancelBag) diff --git a/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/ShowAttendanceVC.swift b/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/ShowAttendanceVC.swift index 826a9e3c3..b231b4381 100644 --- a/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/ShowAttendanceVC.swift +++ b/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/ShowAttendanceVC.swift @@ -17,12 +17,6 @@ import DSKit import SnapKit import AttendanceFeatureInterface -private enum SessionType: String, CaseIterable { - case noSession = "NO_SESSION" - case hasAttendance = "HAS_ATTENDANCE" - case noAttendance = "NO_ATTENDANCE" -} - public final class ShowAttendanceVC: UIViewController, ShowAttendanceViewControllable { // MARK: - Properties @@ -32,8 +26,13 @@ public final class ShowAttendanceVC: UIViewController, ShowAttendanceViewControl private var cancelBag = CancelBag() public var sceneType: AttendanceScheduleType { - return self.viewModel.sceneType ?? .scheduledDay + get { + return self.viewModel.sceneType ?? .scheduledDay + } set(type) { + self.viewModel.sceneType = type + } } + private var viewdidload = PassthroughSubject() // MARK: - UI Components @@ -137,7 +136,7 @@ extension ShowAttendanceVC { owner.refreshButtonDidTap() }.store(in: self.cancelBag) } - + private func bindViewModels() { let input = ShowAttendanceViewModel.Input(viewDidLoad: viewdidload.asDriver(), @@ -145,16 +144,19 @@ extension ShowAttendanceVC { let output = self.viewModel.transform(from: input, cancelBag: self.cancelBag) output.$scheduleModel - .compactMap { $0 } - .sink { model in - if model.type == "NO_SESSION" { - self.viewModel.sceneType = .unscheduledDay + .sink(receiveValue: { [weak self] model in + guard let self, let model else { return } + + if self.viewModel.sceneType == .scheduledDay { + self.sceneType = .scheduledDay + self.setScheduledData(model) + headerScheduleView.updateLayout(.scheduledDay) } else { - self.viewModel.sceneType = .scheduledDay - self.setData(model) + self.sceneType = .unscheduledDay + headerScheduleView.updateLayout(.unscheduledDay) } -// print("스케쥴 데이터가 잘 넘어왓을까요?", model) - }.store(in: self.cancelBag) + }) + .store(in: self.cancelBag) output.$scoreModel .sink { model in @@ -167,7 +169,8 @@ extension ShowAttendanceVC { print("refresh button did tap") } - private func setData(_ model: AttendanceScheduleModel) { + private func setScheduledData(_ model: AttendanceScheduleModel) { + if self.sceneType == .scheduledDay { guard let date = viewModel.formatTimeInterval(startDate: model.startDate, endDate: model.endDate) else { return } headerScheduleView.setData(date: date, @@ -176,6 +179,4 @@ extension ShowAttendanceVC { description: model.message) } } - - } diff --git a/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/TodayScheduleView.swift b/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/TodayScheduleView.swift index 15c42ca52..4c1aaa5dd 100644 --- a/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/TodayScheduleView.swift +++ b/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/TodayScheduleView.swift @@ -143,6 +143,18 @@ extension TodayScheduleView { } } } + + func updateLayout(_ type: AttendanceScheduleType) { + if case .unscheduledDay = type { + todayInfoStackView.isHidden = true + + addSubview(titleLabel) + titleLabel.snp.makeConstraints { + $0.top.bottom.equalToSuperview().inset(32) + $0.leading.equalToSuperview().offset(32) + } + } + } } extension TodayScheduleView { From cd5d3eee84887f4c624caa3910b13e3ef428cc2d Mon Sep 17 00:00:00 2001 From: devxsby Date: Sat, 15 Apr 2023 21:44:38 +0900 Subject: [PATCH 15/18] =?UTF-8?q?[Feat]=20#153-=20=EC=A0=90=EC=88=98=20?= =?UTF-8?q?=EC=98=81=EC=97=AD=20=EB=B7=B0=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Repository/ShowAttendanceRepository.swift | 32 ++++++------ .../MyAttendanceStateTVC.swift | 19 +++++-- .../MyInformationWithScoreView.swift | 52 +++++++++++-------- .../Views/AttendanceScoreView.swift | 36 +++++++++---- .../Views/ShowAttendanceVC.swift | 14 +++-- 5 files changed, 96 insertions(+), 57 deletions(-) diff --git a/SOPT-iOS/Projects/Data/Sources/Repository/ShowAttendanceRepository.swift b/SOPT-iOS/Projects/Data/Sources/Repository/ShowAttendanceRepository.swift index c0d1e1d80..3787201c7 100644 --- a/SOPT-iOS/Projects/Data/Sources/Repository/ShowAttendanceRepository.swift +++ b/SOPT-iOS/Projects/Data/Sources/Repository/ShowAttendanceRepository.swift @@ -34,13 +34,13 @@ extension ShowAttendanceRepository: ShowAttendanceRepositoryInterface { // TodayAttendanceModel(status: "ABSENT", attendedAt: // "2023-04-13T14:10:04")]))) - promise(.success(AttendanceScheduleModel(type: "HAS_ATTENDANCE", - location: "한국대학교 혜당관", - name: "2차 행사", - startDate: "2023-04-06T14:14:00", endDate: "2023-04-06T18:00:00", - message: "행사도 참여하고, 출석점수도 받고, 일석이조!", - attendances: [TodayAttendanceModel(status: "ATTENDANCE", attendedAt: "2023-04-13T14:12:09"), - TodayAttendanceModel(status: "ABSENT", attendedAt: "2023-04-13T14:10:04")]))) +// promise(.success(AttendanceScheduleModel(type: "HAS_ATTENDANCE", +// location: "한국대학교 혜당관", +// name: "2차 행사", +// startDate: "2023-04-06T14:14:00", endDate: "2023-04-06T18:00:00", +// message: "행사도 참여하고, 출석점수도 받고, 일석이조!", +// attendances: [TodayAttendanceModel(status: "ATTENDANCE", attendedAt: "2023-04-13T14:12:09"), +// TodayAttendanceModel(status: "ABSENT", attendedAt: "2023-04-13T14:10:04")]))) // promise(.success(AttendanceScheduleModel(type: "NO_SESSION", // location: "", @@ -57,15 +57,15 @@ extension ShowAttendanceRepository: ShowAttendanceRepositoryInterface { public func fetchAttendanceScoreModel() -> AnyPublisher { return Future { promise in - promise(.success(AttendanceScoreModel.init(part: "iOS", - generation: 31, - name: "윤수빈", - score: 2.0, - total: TotalScoreModel(attendance: 2, absent: 0, tardy: 1, participate: 1), - attendances: [AttendanceModel(attribute: "ETC", name: "솝커톤", status: "TARDY", date: "4월 22일"), - AttendanceModel(attribute: "SEMINAR", name: "iOS 2차 세미나", status: "ATTENDANCE", date: "4월 15일"), - AttendanceModel(attribute: "SEMINAR", name: "iOS 1차 세미나", status: "ATTENDANCE", date: "4월 8일"), - AttendanceModel(attribute: "ETC", name: "OT", status: "PARTICIPATE", date: "4월 1일")]))) +// promise(.success(AttendanceScoreModel.init(part: "iOS", +// generation: 31, +// name: "윤수빈", +// score: 2.0, +// total: TotalScoreModel(attendance: 2, absent: 0, tardy: 1, participate: 1), +// attendances: [AttendanceModel(attribute: "ETC", name: "솝커톤", status: "TARDY", date: "4월 22일"), +// AttendanceModel(attribute: "SEMINAR", name: "iOS 2차 세미나", status: "ATTENDANCE", date: "4월 15일"), +// AttendanceModel(attribute: "SEMINAR", name: "iOS 1차 세미나", status: "ATTENDANCE", date: "4월 8일"), +// AttendanceModel(attribute: "ETC", name: "OT", status: "PARTICIPATE", date: "4월 1일")]))) }.eraseToAnyPublisher() // return self.attendanceService.fetchAttendanceScore() // .map { $0.toDomain() } diff --git a/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/AttendanceScoreComponents/MyAttendanceStateTVC.swift b/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/AttendanceScoreComponents/MyAttendanceStateTVC.swift index 9ed26f4bc..429aadb7c 100644 --- a/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/AttendanceScoreComponents/MyAttendanceStateTVC.swift +++ b/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/AttendanceScoreComponents/MyAttendanceStateTVC.swift @@ -10,6 +10,7 @@ import UIKit import Core import DSKit +import Domain /* 나의 출결 현황 스택뷰에 1줄짜리 상태(출석, 1차 세미나, 00월 00일)를 나타내는 테이블뷰 셀입니다. @@ -80,9 +81,19 @@ extension MyAttendanceStateTVC { extension MyAttendanceStateTVC { - func setData(title: String, image: UIImage, date: String) { - stateImageView.image = image - titleLabel.text = title - dateLabel.text = date + func setData(model: AttendanceModel) { + + if model.status == "ATTENDANCE" { + stateImageView.image = DSKitAsset.Assets.opStateAttendance.image + } else if model.status == "ABSENT" { + stateImageView.image = DSKitAsset.Assets.opStateAbsent.image + } else if model.status == "TARDY" { + stateImageView.image = DSKitAsset.Assets.opStateTardy.image + } else { + stateImageView.image = DSKitAsset.Assets.opStateParticipate.image + } + + titleLabel.text = model.name + dateLabel.text = model.date } } diff --git a/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/AttendanceScoreComponents/MyInformationWithScoreView.swift b/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/AttendanceScoreComponents/MyInformationWithScoreView.swift index fa575ac78..7fe8659af 100644 --- a/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/AttendanceScoreComponents/MyInformationWithScoreView.swift +++ b/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/AttendanceScoreComponents/MyInformationWithScoreView.swift @@ -21,32 +21,12 @@ final class MyInformationWithScoreView: UIView { private let nameLabel: UILabel = { let label = UILabel() - label.text = "32기 디자인파트 김솝트" label.font = .Main.body2 label.textColor = DSKitAsset.Colors.gray60.color return label }() - private let currentScoreLabel: UILabel = { - let label = UILabel() - let mainText = I18N.Attendance.currentAttendanceScore - let pointText = "1.5점" - let subText = I18N.Attendance.scoreIs - let attributedString = NSMutableAttributedString(string: mainText + pointText + subText) - - attributedString.addAttributes([NSAttributedString.Key.font: UIFont.Main.body0, - NSAttributedString.Key.foregroundColor: UIColor.white], - range: NSRange(location: 0, length: mainText.count)) - attributedString.addAttributes([NSAttributedString.Key.font: UIFont.Main.headline1, - NSAttributedString.Key.foregroundColor: DSKitAsset.Colors.purple40.color], - range: NSRange(location: mainText.count, length: pointText.count)) - attributedString.addAttributes([NSAttributedString.Key.font: UIFont.Main.body0, - NSAttributedString.Key.foregroundColor: UIColor.white], - range: NSRange(location: mainText.count + pointText.count, length: subText.count)) - - label.attributedText = attributedString - return label - }() + private let currentScoreLabel = UILabel() private lazy var infoButton: UIButton = { let button = UIButton(type: .system) @@ -56,12 +36,12 @@ final class MyInformationWithScoreView: UIView { }() // MARK: - Initialization - + override init(frame: CGRect) { super.init(frame: frame) setLayout() } - + required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } @@ -101,4 +81,30 @@ extension MyInformationWithScoreView { UIApplication.shared.open(url) } } + + func setData(name: String, part: String, generation: Int, count: Double) { + nameLabel.text = "\(generation)기 \(part)파트 \(name)" + chageFontAndColor(with: "\(String(count))점") + } + + private func chageFontAndColor(with pointedText: String) { + let mainText = I18N.Attendance.currentAttendanceScore + let subText = I18N.Attendance.scoreIs + + let attributedString = NSMutableAttributedString(string: mainText + pointedText + subText) + + attributedString.addAttributes([NSAttributedString.Key.font: UIFont.Main.body0, + NSAttributedString.Key.foregroundColor: UIColor.white], + range: NSRange(location: 0, length: mainText.count)) + + attributedString.addAttributes([NSAttributedString.Key.font: UIFont.Main.headline1, + NSAttributedString.Key.foregroundColor: DSKitAsset.Colors.purple40.color], + range: NSRange(location: mainText.count, length: pointedText.count)) + + attributedString.addAttributes([NSAttributedString.Key.font: UIFont.Main.body0, + NSAttributedString.Key.foregroundColor: UIColor.white], + range: NSRange(location: mainText.count + pointedText.count, length: subText.count)) + + currentScoreLabel.attributedText = attributedString + } } diff --git a/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/AttendanceScoreView.swift b/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/AttendanceScoreView.swift index 5074b7a0d..c57ff8eff 100644 --- a/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/AttendanceScoreView.swift +++ b/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/AttendanceScoreView.swift @@ -10,6 +10,7 @@ import UIKit import Core import DSKit +import Domain /* 출석 조회하기 뷰의 하단 출석 점수 현황을 보여주는 뷰 입니다. @@ -19,8 +20,7 @@ final class AttendanceScoreView: UIView { // MARK: - Properties - private let tableViewHeight: CGFloat = 40 - private var tableViewDataSourceCount: Int = 5 + private var attendanceModelList = [AttendanceModel]() // MARK: - UI Components @@ -30,8 +30,8 @@ final class AttendanceScoreView: UIView { /// 2. 전체 출결 점수 영역 - private let allScoreView = SingleScoreView(type: .all, count: 5) - private let attendanceScoreView = SingleScoreView(type: .attendance, count: 5) + private let allScoreView = SingleScoreView(type: .all) + private let attendanceScoreView = SingleScoreView(type: .attendance) private let tardyScoreView = SingleScoreView(type: .tardy) private let absentScoreView = SingleScoreView(type: .absent) @@ -138,10 +138,27 @@ extension AttendanceScoreView { func updateTableviewHeight() { attendanceTableView.snp.updateConstraints { - $0.height.equalTo(tableViewDataSourceCount * Int(tableViewHeight)) + $0.height.equalTo(attendanceModelList.count * 40) } } + func setMyInfoData(name: String, part: String, generation: Int, count: Double) { + myInfoContainerView.setData(name: name, part: part, generation: generation, count: count) + } + + func setMyTotalScoreData(attendance: Int, tardy: Int, absent: Int) { + allScoreView.setData(attendance + tardy + absent) + attendanceScoreView.setData(attendance) + tardyScoreView.setData(tardy) + absentScoreView.setData(absent) + } + + func setMyAttendanceTableData(_ model: [AttendanceModel]) { + attendanceModelList = model + updateTableviewHeight() + attendanceTableView.reloadData() + } + } // MARK: - UITableViewDelegate, UITableViewDataSource @@ -149,20 +166,17 @@ extension AttendanceScoreView { extension AttendanceScoreView: UITableViewDelegate, UITableViewDataSource { func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { - tableViewHeight + return 40 } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - tableViewDataSourceCount + attendanceModelList.count } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { guard let cell = tableView.dequeueReusableCell(withIdentifier: MyAttendanceStateTVC.className, for: indexPath) as? MyAttendanceStateTVC else { return UITableViewCell() } cell.selectionStyle = .none - cell.setData(title: "\(indexPath.row+1)차 세미나", - image: DSKitAsset.Assets.opStateAttendance.image, - date: "4월 \(indexPath.row*7+1)일") - updateTableviewHeight() + cell.setData(model: attendanceModelList[safe: indexPath.row]!) return cell } } diff --git a/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/ShowAttendanceVC.swift b/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/ShowAttendanceVC.swift index b231b4381..82746b561 100644 --- a/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/ShowAttendanceVC.swift +++ b/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/ShowAttendanceVC.swift @@ -150,17 +150,18 @@ extension ShowAttendanceVC { if self.viewModel.sceneType == .scheduledDay { self.sceneType = .scheduledDay self.setScheduledData(model) - headerScheduleView.updateLayout(.scheduledDay) + self.headerScheduleView.updateLayout(.scheduledDay) } else { self.sceneType = .unscheduledDay - headerScheduleView.updateLayout(.unscheduledDay) + self.headerScheduleView.updateLayout(.unscheduledDay) } }) .store(in: self.cancelBag) output.$scoreModel .sink { model in -// print("스코어 데이터가 잘 넘어왔을까여?]", model) + guard let model else { return } + self.setScoreData(model) }.store(in: self.cancelBag) } @@ -179,4 +180,11 @@ extension ShowAttendanceVC { description: model.message) } } + + private func setScoreData(_ model: AttendanceScoreModel) { + 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) + attendanceScoreView.setMyAttendanceTableData(model.attendances) + } } From 511d139c164923c13526f617cd0a98c8aa398ea8 Mon Sep 17 00:00:00 2001 From: devxsby Date: Sat, 15 Apr 2023 21:52:44 +0900 Subject: [PATCH 16/18] =?UTF-8?q?[Feat]=20#153-=20doubleToString=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Repository/ShowAttendanceRepository.swift | 32 +++++++++---------- .../MyInformationWithScoreView.swift | 10 +++++- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/SOPT-iOS/Projects/Data/Sources/Repository/ShowAttendanceRepository.swift b/SOPT-iOS/Projects/Data/Sources/Repository/ShowAttendanceRepository.swift index 3787201c7..c0d1e1d80 100644 --- a/SOPT-iOS/Projects/Data/Sources/Repository/ShowAttendanceRepository.swift +++ b/SOPT-iOS/Projects/Data/Sources/Repository/ShowAttendanceRepository.swift @@ -34,13 +34,13 @@ extension ShowAttendanceRepository: ShowAttendanceRepositoryInterface { // TodayAttendanceModel(status: "ABSENT", attendedAt: // "2023-04-13T14:10:04")]))) -// promise(.success(AttendanceScheduleModel(type: "HAS_ATTENDANCE", -// location: "한국대학교 혜당관", -// name: "2차 행사", -// startDate: "2023-04-06T14:14:00", endDate: "2023-04-06T18:00:00", -// message: "행사도 참여하고, 출석점수도 받고, 일석이조!", -// attendances: [TodayAttendanceModel(status: "ATTENDANCE", attendedAt: "2023-04-13T14:12:09"), -// TodayAttendanceModel(status: "ABSENT", attendedAt: "2023-04-13T14:10:04")]))) + promise(.success(AttendanceScheduleModel(type: "HAS_ATTENDANCE", + location: "한국대학교 혜당관", + name: "2차 행사", + startDate: "2023-04-06T14:14:00", endDate: "2023-04-06T18:00:00", + message: "행사도 참여하고, 출석점수도 받고, 일석이조!", + attendances: [TodayAttendanceModel(status: "ATTENDANCE", attendedAt: "2023-04-13T14:12:09"), + TodayAttendanceModel(status: "ABSENT", attendedAt: "2023-04-13T14:10:04")]))) // promise(.success(AttendanceScheduleModel(type: "NO_SESSION", // location: "", @@ -57,15 +57,15 @@ extension ShowAttendanceRepository: ShowAttendanceRepositoryInterface { public func fetchAttendanceScoreModel() -> AnyPublisher { return Future { promise in -// promise(.success(AttendanceScoreModel.init(part: "iOS", -// generation: 31, -// name: "윤수빈", -// score: 2.0, -// total: TotalScoreModel(attendance: 2, absent: 0, tardy: 1, participate: 1), -// attendances: [AttendanceModel(attribute: "ETC", name: "솝커톤", status: "TARDY", date: "4월 22일"), -// AttendanceModel(attribute: "SEMINAR", name: "iOS 2차 세미나", status: "ATTENDANCE", date: "4월 15일"), -// AttendanceModel(attribute: "SEMINAR", name: "iOS 1차 세미나", status: "ATTENDANCE", date: "4월 8일"), -// AttendanceModel(attribute: "ETC", name: "OT", status: "PARTICIPATE", date: "4월 1일")]))) + promise(.success(AttendanceScoreModel.init(part: "iOS", + generation: 31, + name: "윤수빈", + score: 2.0, + total: TotalScoreModel(attendance: 2, absent: 0, tardy: 1, participate: 1), + attendances: [AttendanceModel(attribute: "ETC", name: "솝커톤", status: "TARDY", date: "4월 22일"), + AttendanceModel(attribute: "SEMINAR", name: "iOS 2차 세미나", status: "ATTENDANCE", date: "4월 15일"), + AttendanceModel(attribute: "SEMINAR", name: "iOS 1차 세미나", status: "ATTENDANCE", date: "4월 8일"), + AttendanceModel(attribute: "ETC", name: "OT", status: "PARTICIPATE", date: "4월 1일")]))) }.eraseToAnyPublisher() // return self.attendanceService.fetchAttendanceScore() // .map { $0.toDomain() } diff --git a/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/AttendanceScoreComponents/MyInformationWithScoreView.swift b/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/AttendanceScoreComponents/MyInformationWithScoreView.swift index 7fe8659af..c8bd6fd9a 100644 --- a/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/AttendanceScoreComponents/MyInformationWithScoreView.swift +++ b/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/AttendanceScoreComponents/MyInformationWithScoreView.swift @@ -84,7 +84,7 @@ extension MyInformationWithScoreView { func setData(name: String, part: String, generation: Int, count: Double) { nameLabel.text = "\(generation)기 \(part)파트 \(name)" - chageFontAndColor(with: "\(String(count))점") + chageFontAndColor(with: "\(countFormatter(count))점") } private func chageFontAndColor(with pointedText: String) { @@ -107,4 +107,12 @@ extension MyInformationWithScoreView { currentScoreLabel.attributedText = attributedString } + + private func countFormatter(_ number: Double) -> String { + if number.truncatingRemainder(dividingBy: 1) == 0 { + return(String(format: "%.0f", number)) + } else { + return(String(format: "%.1f", number)) + } + } } From 0be35536a0b6da99428530bab22c7146fb175497 Mon Sep 17 00:00:00 2001 From: devxsby Date: Sat, 15 Apr 2023 21:58:48 +0900 Subject: [PATCH 17/18] =?UTF-8?q?[Chore]=20#153-=20doubleToString=EB=A1=9C?= =?UTF-8?q?=20=EC=9D=B4=EB=A6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyInformationWithScoreView.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/AttendanceScoreComponents/MyInformationWithScoreView.swift b/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/AttendanceScoreComponents/MyInformationWithScoreView.swift index c8bd6fd9a..c8abddc64 100644 --- a/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/AttendanceScoreComponents/MyInformationWithScoreView.swift +++ b/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/AttendanceScoreComponents/MyInformationWithScoreView.swift @@ -84,7 +84,7 @@ extension MyInformationWithScoreView { func setData(name: String, part: String, generation: Int, count: Double) { nameLabel.text = "\(generation)기 \(part)파트 \(name)" - chageFontAndColor(with: "\(countFormatter(count))점") + chageFontAndColor(with: "\(doubleToString(count))점") } private func chageFontAndColor(with pointedText: String) { @@ -108,7 +108,7 @@ extension MyInformationWithScoreView { currentScoreLabel.attributedText = attributedString } - private func countFormatter(_ number: Double) -> String { + private func doubleToString(_ number: Double) -> String { if number.truncatingRemainder(dividingBy: 1) == 0 { return(String(format: "%.0f", number)) } else { From 9d2c1ff57708f2abe65c4c1e8eaa674fed04888c Mon Sep 17 00:00:00 2001 From: devxsby Date: Sat, 15 Apr 2023 21:59:18 +0900 Subject: [PATCH 18/18] =?UTF-8?q?[Chore]=20#153-=20=ED=8F=B0=ED=8A=B8=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/ShowAttendanceScene/Views/TodayScheduleView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/TodayScheduleView.swift b/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/TodayScheduleView.swift index 4c1aaa5dd..677423f45 100644 --- a/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/TodayScheduleView.swift +++ b/SOPT-iOS/Projects/Features/AttendanceFeature/Sources/ShowAttendanceScene/Views/TodayScheduleView.swift @@ -164,7 +164,7 @@ extension TodayScheduleView { placeLabel.text = place titleLabel.text = I18N.Attendance.today + todaySchedule + I18N.Attendance.dayIs titleLabel.partFontChange(targetString: todaySchedule, - font: DSKitFontFamily.Suit.bold.font(size: 18)) + font: DSKitFontFamily.Suit.bold.font(size: 17)) subtitleLabel.text = description subtitleLabel.isHidden = ((description?.isEmpty) == nil || description == "") }