Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] HomeScreen 열람실 이용시 이전시간을 차감합니다. #126

Merged
merged 4 commits into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions HongikYeolgong2.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1582,7 +1582,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.1.3;
MARKETING_VERSION = 1.1.4;
PRODUCT_BUNDLE_IDENTIFIER = com.teamHY2.HongikYeolgong2;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -1629,7 +1629,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.1.3;
MARKETING_VERSION = 1.1.4;
PRODUCT_BUNDLE_IDENTIFIER = com.teamHY2.HongikYeolgong2;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/amplitude/analytics-connector-ios.git",
"state" : {
"revision" : "decb203b5ce0e06091bbc5040acbf24fa85ebdce",
"version" : "1.3.0"
"revision" : "4adbfe85486e6dcdcdca5fa9362097ffe5ec712b",
"version" : "1.3.1"
}
},
{
Expand Down Expand Up @@ -60,17 +60,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/Kitura/BlueRSA.git",
"state" : {
"revision" : "440f78db26d8bb073f29590f1c7bd31004da09ae",
"version" : "1.0.201"
"revision" : "4c9464b4a21dd558a9b1f4a4ed603bb67dcbc773",
"version" : "1.0.202"
}
},
{
"identity" : "firebase-ios-sdk",
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/firebase-ios-sdk.git",
"state" : {
"revision" : "dbdfdc44bee8b8e4eaa5ec27eb12b9338f3f2bc1",
"version" : "11.5.0"
"revision" : "2e02253fd1ce99145bcbf1bb367ccf61bd0ca46b",
"version" : "11.6.0"
}
},
{
Expand Down Expand Up @@ -177,17 +177,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/Kitura/Swift-JWT.git",
"state" : {
"revision" : "f68ec28fbd90a651597e9e825ea7f315f8d52a1f",
"version" : "4.0.1"
"revision" : "2cf7ef3eeb0df84318c75662c257651285f8289f",
"version" : "4.0.2"
}
},
{
"identity" : "swift-log",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-log.git",
"state" : {
"revision" : "9cb486020ebf03bfa5b5df985387a14a98744537",
"version" : "1.6.1"
"revision" : "96a2f8a0fa41e9e09af4585e2724c4e825410b91",
"version" : "1.6.2"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ final class StudySessionInteractorImpl: StudySessionInteractor {
/// 스터디세션을 시작합니다.
func startStudy() {
let startTime = appState.value.studySession.startTime
let timeDiff = Date().timeIntervalSince(startTime)
let timeDiffMinutes = TimeInterval(minutes: Int(timeDiff / 60))
let endTime = startTime + addedTime
let remainingTime = endTime.timeIntervalSince(startTime)
let remainingTime = endTime.timeIntervalSince(startTime) - timeDiffMinutes

appState.bulkUpdate { appState in
appState.studySession.isStudying = true
Expand Down Expand Up @@ -164,8 +166,8 @@ final class StudySessionInteractorImpl: StudySessionInteractor {
func configuredNotificationTrigger(for type: LocalNotification, endTime: TimeInterval) -> UNTimeIntervalNotificationTrigger? {
let triggerTime = endTime - type.timeOffset

assert(endTime - triggerTime == type.timeOffset, "잘못된 시간이 등록되었습니다.")
assert(triggerTime > 0, "잔여 시간이 부족합니다. (필요: \(Int(type.timeOffset/60))분, 현재: \(Int(endTime/60))분)")
// assert(endTime - triggerTime == type.timeOffset, "잘못된 시간이 등록되었습니다.")
// assert(triggerTime > 0, "잔여 시간이 부족합니다. (필요: \(Int(type.timeOffset/60))분, 현재: \(Int(endTime/60))분)")

guard triggerTime > 0 else {
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
// Created by 권석기 on 10/28/24.
//

import Combine
import SwiftUI

protocol WeeklyStudyInteractor {
protocol WeeklyStudyInteractor {
func getWeekyStudy(studyRecords: LoadableSubject<[WeeklyStudyRecord]>)
func getWiseSaying(wiseSaying: LoadableSubject<WiseSaying>)
func addStarCount(studyRecords: LoadableSubject<[WeeklyStudyRecord]>)
Expand Down Expand Up @@ -52,6 +53,7 @@ final class WeeklyStudyInteractorImpl: WeeklyStudyInteractor {
}
return $0.element
}

studyRecords.wrappedValue.setSuccess(value: newStudyRecords)
}
}
2 changes: 1 addition & 1 deletion HongikYeolgong2/Injected/AppState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ extension AppState {
}

var totalTime: TimeInterval {
endTime.timeIntervalSince(startTime)
endTime.timeIntervalSince(firstStartTime)
}
}
}
Expand Down
38 changes: 21 additions & 17 deletions HongikYeolgong2/Presentation/Home/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ struct HomeView: View {
@State private var studySession = AppState.StudySession()
@State private var studyRecords: Loadable<[WeeklyStudyRecord]> = .notRequest
@State private var wiseSaying: Loadable<WiseSaying> = .notRequest
@State private var shouldShowTimePicker = false
@State private var shouldShowAddTimeModal = false
@State private var shouldShowEndUseModal = false
@State private var shouldShowWebView = false
@State private var isShowTimePicker = false
@State private var isShowAddTimeModal = false
@State private var isShowEndUseModal = false
@State private var isShowWebView = false
@State private var isViewOnAppeared = false

var body: some View {
NetworkStateView(
Expand Down Expand Up @@ -61,10 +62,10 @@ struct HomeView: View {
NavigationLink("",
destination: WebViewWithNavigation(url: SecretKeys.roomStatusUrl, title: "좌석")
.edgesIgnoringSafeArea(.bottom),
isActive: $shouldShowWebView)
isActive: $isShowWebView)
.frame(width: 0, height: 0)
}
.systemOverlay(isPresented: $shouldShowTimePicker) {
.systemOverlay(isPresented: $isShowTimePicker) {
TimePickerView(
selectedTime: Binding(
get: { appState.value.studySession.startTime },
Expand All @@ -73,15 +74,15 @@ struct HomeView: View {
onTimeSelected: startStudy
)
}
.systemOverlay(isPresented: $shouldShowAddTimeModal) {
ModalView(isPresented: $shouldShowAddTimeModal,
.systemOverlay(isPresented: $isShowAddTimeModal) {
ModalView(isPresented: $isShowAddTimeModal,
title: "열람실 이용 시간을 연장할까요?",
confirmButtonText: "연장하기",
cancleButtonText: "아니오",
confirmAction: { studySessionInteractor.addTime() })
}
.systemOverlay(isPresented: $shouldShowEndUseModal) {
ModalView(isPresented: $shouldShowEndUseModal,
.systemOverlay(isPresented: $isShowEndUseModal) {
ModalView(isPresented: $isShowEndUseModal,
title: "열람실을 다 이용하셨나요?",
confirmButtonText: "네",
cancleButtonText: "더 이용하기",
Expand All @@ -90,8 +91,11 @@ struct HomeView: View {
.padding(.horizontal, 32.adjustToScreenWidth)
.modifier(IOSBackground())
.onAppear {
weeklyStudyInteractor.getWeekyStudy(studyRecords: $studyRecords)
weeklyStudyInteractor.getWiseSaying(wiseSaying: $wiseSaying)
if !isViewOnAppeared {
isViewOnAppeared = true
Seokki-Kwon marked this conversation as resolved.
Show resolved Hide resolved
weeklyStudyInteractor.getWeekyStudy(studyRecords: $studyRecords)
weeklyStudyInteractor.getWiseSaying(wiseSaying: $wiseSaying)
}
}
.onReceive(studySessionUpdated) {
studySession = $0
Expand All @@ -113,19 +117,19 @@ struct HomeView: View {
// MARK: - Helpers
extension HomeView {
func endButtonTapped() {
shouldShowEndUseModal.toggle()
isShowEndUseModal.toggle()
}

func startButtonTapped() {
shouldShowTimePicker.toggle()
isShowTimePicker.toggle()
}

func seatButtonTapped() {
shouldShowWebView.toggle()
isShowWebView.toggle()
}

func addButtonTapped() {
shouldShowAddTimeModal.toggle()
isShowAddTimeModal.toggle()
Amplitude.instance.track(eventType: "StudyExtendButton")
}

Expand Down Expand Up @@ -175,7 +179,7 @@ extension HomeView {
.delay(for: 1, scheduler: RunLoop.main)
.map { _ in }
.eraseToAnyPublisher()
}
}
}

// MARK: - StudyContentControllerView
Expand Down
6 changes: 3 additions & 3 deletions HongikYeolgong2/Presentation/Root/RootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ private extension RootView {

private extension RootView {
func appVersionCheck() {
Task {
Task {
guard let currentVersionString = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String,
let currentVersion = Int(currentVersionString.split(separator: ".").joined()),
let minimumVersion = await RemoteConfigManager.shared.getMinimumAppVersion() else {
let minimumVersion = await RemoteConfigManager.shared.getMinimumAppVersion() else {
return
}

guard currentVersion >= minimumVersion else {
guard currentVersion >= minimumVersion else {
showAppUpdateModal.toggle()
return
}
Expand Down
4 changes: 2 additions & 2 deletions HongikYeolgong2/Util/Services/RemoteConfigManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation

import FirebaseRemoteConfig

struct RemoteConfigManager {
class RemoteConfigManager {
static let shared = RemoteConfigManager()

let remoteConfig = RemoteConfig.remoteConfig()
Expand All @@ -25,7 +25,7 @@ struct RemoteConfigManager {
try await remoteConfig.fetch()
try await remoteConfig.activate()
return remoteConfig["appVersion"].numberValue.intValue
} catch {
} catch {
return nil
}
}
Expand Down