Skip to content

Commit

Permalink
Merge pull request #94 from TeamHY2/Fix/#92-Study_TimeExtension
Browse files Browse the repository at this point in the history
[Fix] 열람실 이용시간 연장시 다건처리
  • Loading branch information
Seokki-Kwon authored Nov 13, 2024
2 parents 2bbb0b1 + 4082820 commit 35bde07
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 28 deletions.
4 changes: 2 additions & 2 deletions HongikYeolgong2.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1463,7 +1463,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_ASSET_PATHS = "\"HongikYeolgong2/Resources/Preview Content\"";
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = P4D4ZQC4YF;
Expand Down Expand Up @@ -1510,7 +1510,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_ASSET_PATHS = "\"HongikYeolgong2/Resources/Preview Content\"";
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = P4D4ZQC4YF;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"originHash" : "37f87f153a7df0e69f7682478910cd31cbff8c536dc79a044414e38ba896c24f",
"pins" : [
{
"identity" : "abseil-cpp-binary",
Expand Down Expand Up @@ -50,8 +51,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/firebase-ios-sdk.git",
"state" : {
"revision" : "8328630971a8fdd8072b36bb22bef732eb15e1f0",
"version" : "11.4.0"
"revision" : "dbdfdc44bee8b8e4eaa5ec27eb12b9338f3f2bc1",
"version" : "11.5.0"
}
},
{
Expand Down Expand Up @@ -181,5 +182,5 @@
}
}
],
"version" : 2
"version" : 3
}
32 changes: 25 additions & 7 deletions HongikYeolgong2/Domain/Interactors/StudySessionInteractor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ protocol StudySessionInteractor {
func pauseStudy()
func resumeStudy()
func addTime()
func uploadStudySession(startTime: Date, endTime: Date)
func setStartTime(_ startTime: Date)
}

Expand Down Expand Up @@ -73,12 +74,7 @@ final class StudySessionInteractorImpl: StudySessionInteractor {
let startTime: Date = appState.value.studySession.startTime
let endTime: Date = .now

studySessionRepository
.uploadStudyRecord(startTime: startTime, endTime: endTime)
.sink { _ in
} receiveValue: { _ in
}
.store(in: cancleBag)
uploadStudySession(startTime: startTime, endTime: endTime)
}

/// 스터디 일시중지
Expand All @@ -102,7 +98,13 @@ final class StudySessionInteractorImpl: StudySessionInteractor {

/// 열람실 이용시간을 연장합니다.
func addTime() {
let startTime: Date = appState.value.studySession.startTime
let endTime: Date = .now

uploadStudySession(startTime: startTime, endTime: endTime)

appState.bulkUpdate { appState in
appState.studySession.startTime = .now
appState.studySession.endTime += addedTime
appState.studySession.remainingTime += addedTime
}
Expand All @@ -113,11 +115,27 @@ final class StudySessionInteractorImpl: StudySessionInteractor {
registerNotification(for: .extensionAvailable, endTimeInMinute: remainingTime)
registerNotification(for: .urgent, endTimeInMinute: remainingTime)
}

/// 서버에 스터디세션을 업로드 합니다.
/// - Parameters:
/// - startTime: 시작시간
/// - endTime: 종료시간
func uploadStudySession(startTime: Date, endTime: Date) {
studySessionRepository
.uploadStudyRecord(startTime: startTime, endTime: endTime)
.sink { _ in
} receiveValue: { _ in
}
.store(in: cancleBag)
}

/// 열람실 이용 시작시간을 설정합니다.
/// - Parameter startTime: 시작시간
func setStartTime(_ startTime: Date) {
appState[\.studySession.startTime] = startTime
appState.bulkUpdate { appState in
appState.studySession.startTime = startTime
appState.studySession.firstStartTime = startTime
}
}

/// 열람실 이용종료 Notification을 등록합니다.
Expand Down
1 change: 1 addition & 0 deletions HongikYeolgong2/Injected/AppState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ extension AppState {
/// 열람실 이용상태를 관리하는 구조체 입니다.
struct StudySession: Equatable {
var isStudying = false
var firstStartTime: Date = .now
var startTime: Date = .now
var endTime: Date = .now
var remainingTime: TimeInterval = 0
Expand Down
15 changes: 8 additions & 7 deletions HongikYeolgong2/Presentation/Home/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,7 @@ struct HomeView: View {
@State private var shouldShowWebView = false

var body: some View {
VStack {
NavigationLink("",
destination: WebViewWithNavigation(url: SecretKeys.roomStatusUrl, title: "좌석")
.edgesIgnoringSafeArea(.bottom),
isActive: $shouldShowWebView)

VStack(spacing: 0) {
WeeklyStudyView(studyRecords: studyRecords)

StudyContentControllerView(
Expand All @@ -48,6 +43,12 @@ struct HomeView: View {
addButtonTapped: { shouldShowAddTimeModal.toggle() }
)
)

NavigationLink("",
destination: WebViewWithNavigation(url: SecretKeys.roomStatusUrl, title: "좌석")
.edgesIgnoringSafeArea(.bottom),
isActive: $shouldShowWebView)
.frame(width: 0, height: 0)
}
.systemOverlay(isPresented: $shouldShowTimePicker) {
TimePickerView(
Expand Down Expand Up @@ -137,7 +138,7 @@ struct StudyContentControllerView: View {
if studySession.isStudying {
VStack(spacing: 32.adjustToScreenHeight) {
StudyPeriodView(
startTime: studySession.startTime,
startTime: studySession.firstStartTime,
endTime: studySession.endTime
)
StudyTimerView(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ struct WeeklyStudyView: View {
)
}
}
.padding(.top, 33.adjustToScreenHeight)
.padding(.top, 32.adjustToScreenHeight)
}
}
4 changes: 2 additions & 2 deletions HongikYeolgong2/Presentation/Ranking/RankingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ struct RankingView: View {
})
.frame(width: 36.adjustToScreenWidth, height: 36.adjustToScreenHeight)
}
}
.padding(EdgeInsets(top: 33.adjustToScreenHeight,
}
.padding(EdgeInsets(top: 32.adjustToScreenHeight,
leading: 32.adjustToScreenWidth,
bottom: 17.adjustToScreenHeight,
trailing: 32.adjustToScreenWidth))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ struct CaledarView: View {
.font(.suite(size: 24, weight: .bold))
.foregroundStyle(Color.gray100)


Spacer().frame(width: 8.adjustToScreenWidth)

Text(seletedDate.getYearString())
Expand All @@ -68,6 +67,7 @@ struct CaledarView: View {
}
}


Spacer().frame(height: 12.adjustToScreenHeight)

// weakday
Expand Down
2 changes: 1 addition & 1 deletion HongikYeolgong2/Presentation/Record/RecordView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct RecordView: View {
var body: some View {
VStack(spacing: 13.adjustToScreenHeight) {

CaledarView()
CaledarView()

Spacer()
// 기록 정보 출력부분
Expand Down
13 changes: 9 additions & 4 deletions HongikYeolgong2/Presentation/Setting/SettingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,34 @@ struct SettingView: View {
@Environment(\.injected) var injected: DIContainer
@Environment(\.injected.interactors.userDataInteractor) var userDataInteractor
@State private var userProfile = UserProfile()


@State private var shouldShowWithdrawModal = false
@State private var shouldShowLogoutModal = false
@State private var shouldShowNotice = false
@State private var shouldShowQna = false

var body: some View {
VStack(alignment:.leading, spacing: 0){
NavigationLink("",
destination: WebViewWithNavigation(url: SecretKeys.noticeUrl, title: "공지사항")
.edgesIgnoringSafeArea(.bottom),
.edgesIgnoringSafeArea(.bottom),
isActive: $shouldShowNotice)
.frame(width: 0, height: 0)

NavigationLink("",
destination: WebViewWithNavigation(url: SecretKeys.qnaUrl, title: "문의사항")
.edgesIgnoringSafeArea(.bottom),
.edgesIgnoringSafeArea(.bottom),
isActive: $shouldShowQna)
.frame(width: 0, height: 0)

VStack(alignment: .leading, spacing: 0) {
HStack(spacing: 0) {
Image(.settingIcon)
.resizable()
.frame(width: 55.adjustToScreenWidth, height: 55.adjustToScreenHeight)
.padding(.trailing, 19)

Text(userProfile.nickname)
.font(.pretendard(size: 16, weight: .regular), lineHeight: 26.adjustToScreenHeight)
.padding(.trailing, 8)
Expand All @@ -41,6 +46,7 @@ struct SettingView: View {
.font(.pretendard(size: 16, weight: .regular), lineHeight: 26.adjustToScreenHeight)
.foregroundStyle(.gray200)
}
.padding(.top, 32.adjustToScreenHeight)
.padding(.bottom, 20.adjustToScreenHeight)

Button(action: {
Expand Down Expand Up @@ -117,7 +123,6 @@ struct SettingView: View {
HStack(alignment: .center, spacing: 0) {
Spacer()
Button(action: {
// injected.interactors.userDataInteractor.logout()
shouldShowLogoutModal.toggle()
}, label: {
Text("로그아웃")
Expand Down

0 comments on commit 35bde07

Please sign in to comment.