Skip to content

Commit

Permalink
Merge pull request #61 from TeamHY2/Feature/#59-Record_GetStudyTime
Browse files Browse the repository at this point in the history
[Feature] RecordView 데이터 연동 구현
  • Loading branch information
Seokki-Kwon authored Nov 8, 2024
2 parents 665d118 + 54147fd commit 3fd019a
Show file tree
Hide file tree
Showing 11 changed files with 191 additions and 7 deletions.
30 changes: 30 additions & 0 deletions HongikYeolgong2.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@
47F79B2E2CCCB7AA00DD0899 /* TimePickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47F79B2D2CCCB7AA00DD0899 /* TimePickerView.swift */; };
47F79B302CCCB7FC00DD0899 /* TimePicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47F79B2F2CCCB7FC00DD0899 /* TimePicker.swift */; };
98B5F00A2CDB362C007CF5FA /* Secrets-dev.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 98B5F0092CDB362C007CF5FA /* Secrets-dev.xcconfig */; };
98B5F00C2CDB6226007CF5FA /* StudyTimeResponseDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98B5F00B2CDB6226007CF5FA /* StudyTimeResponseDTO.swift */; };
98B5F00F2CDB652A007CF5FA /* StudyTime.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98B5F00E2CDB652A007CF5FA /* StudyTime.swift */; };
98B5F0112CDB9990007CF5FA /* StudyTimeInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98B5F0102CDB9990007CF5FA /* StudyTimeInteractor.swift */; };
98B5F0132CDBB905007CF5FA /* StudyTimeMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98B5F0122CDBB905007CF5FA /* StudyTimeMapper.swift */; };
98F9D8462CDA2E6D00DE12BB /* RecordCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98F9D8452CDA2E6D00DE12BB /* RecordCell.swift */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -257,6 +261,10 @@
47F79B2D2CCCB7AA00DD0899 /* TimePickerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimePickerView.swift; sourceTree = "<group>"; };
47F79B2F2CCCB7FC00DD0899 /* TimePicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimePicker.swift; sourceTree = "<group>"; };
98B5F0092CDB362C007CF5FA /* Secrets-dev.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Secrets-dev.xcconfig"; sourceTree = "<group>"; };
98B5F00B2CDB6226007CF5FA /* StudyTimeResponseDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StudyTimeResponseDTO.swift; sourceTree = "<group>"; };
98B5F00E2CDB652A007CF5FA /* StudyTime.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StudyTime.swift; sourceTree = "<group>"; };
98B5F0102CDB9990007CF5FA /* StudyTimeInteractor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StudyTimeInteractor.swift; sourceTree = "<group>"; };
98B5F0122CDBB905007CF5FA /* StudyTimeMapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StudyTimeMapper.swift; sourceTree = "<group>"; };
98F9D8452CDA2E6D00DE12BB /* RecordCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecordCell.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -409,6 +417,7 @@
isa = PBXGroup;
children = (
478004412CCA924200FFAF00 /* StudySessionMapper.swift */,
98B5F0122CDBB905007CF5FA /* StudyTimeMapper.swift */,
478F844A2CD35AF40097CAA1 /* RankingMapper.swift */,
);
path = Mapper;
Expand All @@ -428,6 +437,7 @@
473E8EB72CCEA5FB000F102C /* StudySessionRequestDTO.swift */,
473E8EB92CCEA702000F102C /* StudySessionResponseDTO.swift */,
4786A10F2CCA351A008635A4 /* WeeklyStudySessionDTO.swift */,
98B5F00B2CDB6226007CF5FA /* StudyTimeResponseDTO.swift */,
);
path = StudySession;
sourceTree = "<group>";
Expand Down Expand Up @@ -566,6 +576,7 @@
47A147382CA1380900A91F66 /* Entities */ = {
isa = PBXGroup;
children = (
98B5F00D2CDB64D4007CF5FA /* Record */,
478F84452CD358F50097CAA1 /* Ranking */,
478FBCA12CD1397600256012 /* User */,
4780043D2CCA8FF800FFAF00 /* WeeklyStudy */,
Expand Down Expand Up @@ -599,6 +610,7 @@
isa = PBXGroup;
children = (
4763FFB92CB913FF00990336 /* UserDataInteractor.swift */,
98B5F0102CDB9990007CF5FA /* StudyTimeInteractor.swift */,
4786A1042CCA3352008635A4 /* StudySessionInteractor.swift */,
4786A0EB2CC9E2BC008635A4 /* UserPermissionsInteractor.swift */,
47E250702CCF274400267897 /* WeeklyStudyInteractor.swift */,
Expand Down Expand Up @@ -842,6 +854,14 @@
path = Models;
sourceTree = "<group>";
};
98B5F00D2CDB64D4007CF5FA /* Record */ = {
isa = PBXGroup;
children = (
98B5F00E2CDB652A007CF5FA /* StudyTime.swift */,
);
path = Record;
sourceTree = "<group>";
};
98F9D8422CDA2DE100DE12BB /* Component */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1040,6 +1060,7 @@
471940CB2CAFD9B700426D30 /* RankingCell.swift in Sources */,
473671A72CB1404E00527896 /* Ratio.swift in Sources */,
478004502CCABEFF00FFAF00 /* WeeklyStudyRecord.swift in Sources */,
98B5F00C2CDB6226007CF5FA /* StudyTimeResponseDTO.swift in Sources */,
47BACCF72CA164BA00295DAC /* Font+.swift in Sources */,
4786A1102CCA351A008635A4 /* WeeklyStudySessionDTO.swift in Sources */,
470722FA2CBC0A870046469F /* Constants.swift in Sources */,
Expand Down Expand Up @@ -1075,6 +1096,7 @@
4780044E2CCAAE3200FFAF00 /* String+.swift in Sources */,
4786A1072CCA33DF008635A4 /* WeeklyEndpoint.swift in Sources */,
4763FFBA2CB913FF00990336 /* UserDataInteractor.swift in Sources */,
98B5F0112CDB9990007CF5FA /* StudyTimeInteractor.swift in Sources */,
475B86E72CA1CC20000534B2 /* HY2TextField.swift in Sources */,
47F635022CC3E98D0034EAA9 /* UserEndpoint.swift in Sources */,
478933792CADBDA500E1D89E /* SignUpView.swift in Sources */,
Expand All @@ -1092,6 +1114,7 @@
47BE30E32CC813BB0015D973 /* KeyChainManager.swift in Sources */,
4786A10C2CCA34A7008635A4 /* StudySessionRepositoryImpl.swift in Sources */,
470723132CBC1BF10046469F /* BaseResponse.swift in Sources */,
98B5F00F2CDB652A007CF5FA /* StudyTime.swift in Sources */,
471940CD2CAFDAD700426D30 /* WeeklyRanking+Mock.swift in Sources */,
47CA17252CC9336100CBB251 /* StudyPeriodView.swift in Sources */,
4763FFB82CB9134D00990336 /* Store.swift in Sources */,
Expand All @@ -1106,6 +1129,7 @@
47A147792CA158E800A91F66 /* MainTabView.swift in Sources */,
47F79B302CCCB7FC00DD0899 /* TimePicker.swift in Sources */,
478FBCA32CD13A1E00256012 /* UserInfo.swift in Sources */,
98B5F0132CDBB905007CF5FA /* StudyTimeMapper.swift in Sources */,
47D5EDCF2CCBD10300ACA469 /* ActionButton.swift in Sources */,
478F844B2CD35AF40097CAA1 /* RankingMapper.swift in Sources */,
);
Expand Down Expand Up @@ -1265,6 +1289,7 @@
};
47B1D4CD2C9CB1760071B62B /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 98B5F0092CDB362C007CF5FA /* Secrets-dev.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
Expand Down Expand Up @@ -1311,6 +1336,7 @@
};
47B1D4CE2C9CB1760071B62B /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 98B5F0092CDB362C007CF5FA /* Secrets-dev.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
Expand Down Expand Up @@ -1357,6 +1383,7 @@
};
47B1D4D02C9CB1760071B62B /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 98B5F0092CDB362C007CF5FA /* Secrets-dev.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(TEST_HOST)";
Expand All @@ -1377,6 +1404,7 @@
};
47B1D4D12C9CB1760071B62B /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 98B5F0092CDB362C007CF5FA /* Secrets-dev.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(TEST_HOST)";
Expand All @@ -1397,6 +1425,7 @@
};
47B1D4D32C9CB1760071B62B /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 98B5F0092CDB362C007CF5FA /* Secrets-dev.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic;
Expand All @@ -1415,6 +1444,7 @@
};
47B1D4D42C9CB1760071B62B /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 98B5F0092CDB362C007CF5FA /* Secrets-dev.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic;
Expand Down
3 changes: 3 additions & 0 deletions HongikYeolgong2/Core/AppEnviroment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ extension AppEnviroment {
authRepository: remoteRepository.authRepository,
authService: services.appleAuthService
),
studyTimeInteractor: StudyTimeInteractorImpl(
studySessionRepository: remoteRepository.studySessionRepository
),
studySessionInteractor: StudySessionInteractorImpl(
appState: appState,
studySessionRepository: remoteRepository.studySessionRepository
Expand Down
19 changes: 19 additions & 0 deletions HongikYeolgong2/Data/DTO/StudySession/StudyTimeResponseDTO.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// StudyDurationResponseDTO.swift
// HongikYeolgong2
//
// Created by 최주원 on 11/6/24.
//

import Foundation

struct StudyTimeResponseDTO: Decodable {
let yearHours: Int
let yearMinutes: Int
let monthHours: Int
let monthMinutes: Int
let dayHours: Int
let dayMinutes: Int
let semesterHours: Int
let semesterMinutes: Int
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,18 @@ final class StudySessionRepositoryImpl: StudySessionRepository {
}
}.eraseToAnyPublisher()
}

// 연간, 월간, 투데이, 학기 공부 시간 조회
func getStudyTime() -> AnyPublisher<StudyTime, NetworkError> {
return Future<StudyTime, NetworkError> { promise in
Task {
do {
let response: BaseResponse<StudyTimeResponseDTO> = try await NetworkService.shared.request(endpoint: WeeklyEndpoint.getStudyTime)
promise(.success(response.data.toEntity()))
} catch let error as NetworkError {
print(error.message)
}
}
}.eraseToAnyPublisher()
}
}
41 changes: 41 additions & 0 deletions HongikYeolgong2/Domain/Entities/Record/StudyTime.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// StudyTime.swift
// HongikYeolgong2
//
// Created by 최주원 on 11/6/24.
//

import Foundation

struct StudyTime {
let yearHours: Int
let yearMinutes: Int
let monthHours: Int
let monthMinutes: Int
let dayHours: Int
let dayMinutes: Int
let semesterHours: Int
let semesterMinutes: Int

init(yearHours: Int, yearMinutes: Int, monthHours: Int, monthMinutes: Int, dayHours: Int, dayMinutes: Int, semesterHours: Int, semesterMinutes: Int) {
self.yearHours = yearHours
self.yearMinutes = yearMinutes
self.monthHours = monthHours
self.monthMinutes = monthMinutes
self.dayHours = dayHours
self.dayMinutes = dayMinutes
self.semesterHours = semesterHours
self.semesterMinutes = semesterMinutes
}

init() {
self.yearHours = 0
self.yearMinutes = 0
self.monthHours = 0
self.monthMinutes = 0
self.dayHours = 0
self.dayMinutes = 0
self.semesterHours = 0
self.semesterMinutes = 0
}
}
32 changes: 32 additions & 0 deletions HongikYeolgong2/Domain/Interactors/StudyTimeInteractor.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// StudyTimeInteractor.swift
// HongikYeolgong2
//
// Created by 최주원 on 11/6/24.
//

import SwiftUI

protocol StudyTimeInteractor {
func getStudyTime(StudyTime: Binding<StudyTime>)
}

final class StudyTimeInteractorImpl: StudyTimeInteractor {
private let cancleBag = CancelBag()
private let studySessionRepository: StudySessionRepository

init(studySessionRepository: StudySessionRepository) {
self.studySessionRepository = studySessionRepository
}

func getStudyTime(StudyTime: Binding<StudyTime>) {
studySessionRepository
.getStudyTime()
.sink { _ in
} receiveValue: {
StudyTime.wrappedValue = $0
}
.store(in: cancleBag)

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ protocol StudySessionRepository {
func uploadStudyRecord(startTime: Date, endTime: Date) -> AnyPublisher<StudySessionResponseDTO, NetworkError>
func getWiseSaying() -> AnyPublisher<WiseSaying, NetworkError>
func getWeeklyRanking(yearWeek: Int) -> AnyPublisher<WeeklyRanking, NetworkError>
func getStudyTime() -> AnyPublisher<StudyTime, NetworkError>
}
21 changes: 21 additions & 0 deletions HongikYeolgong2/Domain/Mapper/StudyTimeMapper.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// StudyTimeMapper.swift
// HongikYeolgong2
//
// Created by 최주원 on 11/6/24.
//

import Foundation

extension StudyTimeResponseDTO {
func toEntity() -> StudyTime {
.init(yearHours: yearHours,
yearMinutes: yearMinutes,
monthHours: monthHours,
monthMinutes: monthMinutes,
dayHours: dayHours,
dayMinutes: dayMinutes,
semesterHours: semesterHours,
semesterMinutes: semesterMinutes)
}
}
8 changes: 6 additions & 2 deletions HongikYeolgong2/Injected/InteractorsContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,21 @@ import Foundation
extension DIContainer {
struct Interactors {
let userDataInteractor: UserDataInteractor
let studyTimeInteractor: StudyTimeInteractor
let studySessionInteractor: StudySessionInteractor
let userPermissionsInteractor: UserPermissionsInteractor
let weeklyStudyInteractor: WeeklyStudyInteractor
let rankingDataInteractor: RankingDataInteractor

init(userDataInteractor: UserDataInteractor,
studySessionInteractor: StudySessionInteractor,
userPermissionsInteractor: UserPermissionsInteractor,
studyTimeInteractor: StudyTimeInteractor,
studySessionInteractor: StudySessionInteractor,
userPermissionsInteractor: UserPermissionsInteractor,
weeklyStudyInteractor: WeeklyStudyInteractor,
rankingDataInteractor: RankingDataInteractor) {

self.userDataInteractor = userDataInteractor
self.studyTimeInteractor = studyTimeInteractor
self.studySessionInteractor = studySessionInteractor
self.userPermissionsInteractor = userPermissionsInteractor
self.weeklyStudyInteractor = weeklyStudyInteractor
Expand All @@ -34,6 +37,7 @@ extension DIContainer {
authRepository: AuthRepositoryImpl(),
authService: AuthenticationServiceImpl()
),
studyTimeInteractor: StudyTimeInteractorImpl(studySessionRepository: StudySessionRepositoryImpl()),
studySessionInteractor: StudySessionInteractorImpl(appState: Store<AppState>(AppState()), studySessionRepository: StudySessionRepositoryImpl()),
userPermissionsInteractor: RealUserPermissionsInteractor(appState: Store<AppState>(AppState()), openAppSetting: {}),
weeklyStudyInteractor: WeeklyStudyInteractorImpl(appState: Store<AppState>(AppState()), studySessionRepository: StudySessionRepositoryImpl()),
Expand Down
24 changes: 20 additions & 4 deletions HongikYeolgong2/Presentation/Record/RecordView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,37 @@
import SwiftUI

struct RecordView: View {
@Environment(\.injected.interactors.studyTimeInteractor) var studyTimeInteractor

@State var studyTime = StudyTime()

var body: some View {
VStack(spacing: 13.adjustToScreenHeight) {
Spacer()
// 기록 정보 출력부분
HStack(spacing: 13.adjustToScreenWidth) {
RecordCell(title: "연간", hours: 200, minutes: 4)
RecordCell(title: "이번학기", hours: 120, minutes: 4)
RecordCell(title: "연간",
hours: studyTime.yearHours,
minutes: studyTime.yearMinutes)
RecordCell(title: "이번학기",
hours: studyTime.semesterHours,
minutes: studyTime.semesterMinutes)
}
HStack(spacing: 13.adjustToScreenWidth) {
RecordCell(title: "월간", hours: 50, minutes: 4)
RecordCell(title: "투데이", hours: 3, minutes: 24)
RecordCell(title: "월간",
hours: studyTime.monthHours,
minutes: studyTime.monthMinutes)
RecordCell(title: "투데이",
hours: studyTime.dayHours,
minutes: studyTime.dayMinutes)
}
}
.padding(.horizontal, 32.adjustToScreenWidth)
.padding(.bottom, 36.adjustToScreenHeight)
.onAppear {
// 이용 시간 가져오기
studyTimeInteractor.getStudyTime(StudyTime: $studyTime)
}
}
}

Expand Down
Loading

0 comments on commit 3fd019a

Please sign in to comment.