From 80049856dda4ef3585fdbff52118d1d766361982 Mon Sep 17 00:00:00 2001 From: shp7724 Date: Sat, 1 Mar 2025 03:08:02 +0000 Subject: [PATCH] Apply SwiftFormat changes --- .../SNUTT/AppState/States/UserState.swift | 2 +- SNUTT-2022/SNUTT/Services/AuthService.swift | 6 ++- .../SNUTT/Services/LectureService.swift | 36 ++++++++++++--- SNUTT-2022/SNUTT/Services/SearchService.swift | 24 +++++++--- .../ViewModels/LectureDetailViewModel.swift | 20 +++++++-- .../Lecture/ExpandableLectureCell.swift | 37 ++++++++++++---- .../SNUTT/Views/Components/LectureList.swift | 11 ++++- .../MenuSheets/MenuThemeSheet.swift | 3 +- .../Views/Components/NotificationList.swift | 39 +++++++++++++--- .../Components/Timetable/LectureBlocks.swift | 27 +++++++++--- SNUTT-2022/SNUTT/Views/SNUTTView.swift | 5 ++- .../Views/Scenes/LectureDetailScene.swift | 44 ++++++++++++++----- .../SNUTT/Views/Scenes/LectureListScene.swift | 10 +++-- .../SNUTT/Views/Scenes/OnboardScene.swift | 23 +++++++--- .../Views/Scenes/Settings/SettingScene.swift | 6 ++- .../Scenes/Settings/ThemeSettingScene.swift | 24 +++++++--- .../Settings/TimetableSettingScene.swift | 10 +++-- .../SharedUIAnalytics/AnalyticsEvent.swift | 13 +++--- .../SharedUIAnalytics/AnalyticsScreen.swift | 9 ++-- .../AnalyticsScreenModifier.swift | 8 ++-- .../SnakeCaseConvertible.swift | 11 +++-- .../SNUTT/Views/Scenes/TimetableScene.swift | 19 ++++++-- 22 files changed, 292 insertions(+), 95 deletions(-) diff --git a/SNUTT-2022/SNUTT/AppState/States/UserState.swift b/SNUTT-2022/SNUTT/AppState/States/UserState.swift index c66c6b85..b8db6eeb 100644 --- a/SNUTT-2022/SNUTT/AppState/States/UserState.swift +++ b/SNUTT-2022/SNUTT/AppState/States/UserState.swift @@ -5,8 +5,8 @@ // Created by Jinsup Keum on 2022/06/25. // -import SwiftUI import FirebaseAnalytics +import SwiftUI class UserState { @Published var accessToken: String? diff --git a/SNUTT-2022/SNUTT/Services/AuthService.swift b/SNUTT-2022/SNUTT/Services/AuthService.swift index db9d4255..2a8e533c 100644 --- a/SNUTT-2022/SNUTT/Services/AuthService.swift +++ b/SNUTT-2022/SNUTT/Services/AuthService.swift @@ -72,7 +72,11 @@ struct AuthService: AuthServiceProtocol, UserAuthHandler { func registerWithLocalId(localId: String, localPassword: String, email: String) async throws { FirebaseAnalyticsLogger().logEvent(.signUp) - let dto = try await authRepository.registerWithLocalId(localId: localId, localPassword: localPassword, email: email) + let dto = try await authRepository.registerWithLocalId( + localId: localId, + localPassword: localPassword, + email: email + ) saveAccessTokenFromLoginResponse(dto: dto) try await registerFCMToken() } diff --git a/SNUTT-2022/SNUTT/Services/LectureService.swift b/SNUTT-2022/SNUTT/Services/LectureService.swift index 8a388e9b..818f31d3 100644 --- a/SNUTT-2022/SNUTT/Services/LectureService.swift +++ b/SNUTT-2022/SNUTT/Services/LectureService.swift @@ -51,7 +51,11 @@ struct LectureService: LectureServiceProtocol { func addLecture(lecture: Lecture, isForced: Bool = false) async throws { guard let currentTimetable = appState.timetable.current else { return } - let dto = try await lectureRepository.addLecture(timetableId: currentTimetable.id, lectureId: lecture.id, isForced: isForced) + let dto = try await lectureRepository.addLecture( + timetableId: currentTimetable.id, + lectureId: lecture.id, + isForced: isForced + ) let timetable = Timetable(from: dto) appState.timetable.current = timetable appState.search.selectedLecture = nil @@ -64,7 +68,11 @@ struct LectureService: LectureServiceProtocol { guard let currentTimetable = appState.timetable.current else { return } var lectureDto = LectureDto(from: lecture) lectureDto.class_time_mask = nil - let dto = try await lectureRepository.addCustomLecture(timetableId: currentTimetable.id, lecture: lectureDto, isForced: isForced) + let dto = try await lectureRepository.addCustomLecture( + timetableId: currentTimetable.id, + lecture: lectureDto, + isForced: isForced + ) let timetable = Timetable(from: dto) appState.timetable.current = timetable userDefaultsRepository.set(TimetableDto.self, key: .currentTimetable, value: dto) @@ -74,7 +82,12 @@ struct LectureService: LectureServiceProtocol { try checkIfTimeplaceOverlapped(newLecture) guard let currentTimetable = appState.timetable.current else { return } - let dto = try await lectureRepository.updateLecture(timetableId: currentTimetable.id, oldLecture: .init(from: oldLecture), newLecture: .init(from: newLecture), isForced: isForced) + let dto = try await lectureRepository.updateLecture( + timetableId: currentTimetable.id, + oldLecture: .init(from: oldLecture), + newLecture: .init(from: newLecture), + isForced: isForced + ) let timetable = Timetable(from: dto) appState.timetable.current = timetable userDefaultsRepository.set(TimetableDto.self, key: .currentTimetable, value: dto) @@ -84,7 +97,10 @@ struct LectureService: LectureServiceProtocol { guard let currentTimetable = appState.timetable.current, let timetableLecture = currentTimetable.lectures.first(where: { $0.isEquivalent(with: lecture) }) else { return } - let dto = try await lectureRepository.deleteLecture(timetableId: currentTimetable.id, lectureId: timetableLecture.id) + let dto = try await lectureRepository.deleteLecture( + timetableId: currentTimetable.id, + lectureId: timetableLecture.id + ) let timetable = Timetable(from: dto) appState.timetable.current = timetable userDefaultsRepository.set(TimetableDto.self, key: .currentTimetable, value: dto) @@ -111,7 +127,11 @@ struct LectureService: LectureServiceProtocol { } func fetchIsFirstBookmark() { - appState.timetable.isFirstBookmark = userDefaultsRepository.get(Bool.self, key: .isFirstBookmark, defaultValue: true) + appState.timetable.isFirstBookmark = userDefaultsRepository.get( + Bool.self, + key: .isFirstBookmark, + defaultValue: true + ) } func bookmarkLecture(lecture: Lecture) async throws { @@ -143,7 +163,11 @@ struct LectureService: LectureServiceProtocol { if let isMapViewExpanded = appState.system.isMapViewExpanded { return isMapViewExpanded } else { - let isMapViewExpanded = userDefaultsRepository.get(Bool.self, key: .expandLectureMapView, defaultValue: false) + let isMapViewExpanded = userDefaultsRepository.get( + Bool.self, + key: .expandLectureMapView, + defaultValue: false + ) appState.system.isMapViewExpanded = isMapViewExpanded return isMapViewExpanded } diff --git a/SNUTT-2022/SNUTT/Services/SearchService.swift b/SNUTT-2022/SNUTT/Services/SearchService.swift index e22e4fcd..bddd1078 100644 --- a/SNUTT-2022/SNUTT/Services/SearchService.swift +++ b/SNUTT-2022/SNUTT/Services/SearchService.swift @@ -63,8 +63,10 @@ struct SearchService: SearchServiceProtocol { let dto = try await searchRepository.fetchTags(quarter: quarter) let model = SearchTagList(from: dto) appState.search.searchTagList = model - guard let recentTagNames = userDefaultsRepository.get([String].self, key: .recentDepartmentTags) else { return } - appState.search.pinnedTagList = model?.tagList.filter { $0.type == .department && recentTagNames.contains($0.text) } ?? [] + guard let recentTagNames = userDefaultsRepository.get([String].self, key: .recentDepartmentTags) + else { return } + appState.search.pinnedTagList = model?.tagList + .filter { $0.type == .department && recentTagNames.contains($0.text) } ?? [] } private func _saveDepartmentTagsToUserDefaults(from tagList: [SearchTag]) { @@ -84,8 +86,12 @@ struct SearchService: SearchServiceProtocol { guard let currentTimetable = timetableState.current else { return } let tagList = searchState.selectedTagList _saveDepartmentTagsToUserDefaults(from: tagList) - let timeList = tagList.contains(where: { $0.type == .time && TimeType(rawValue: $0.text) == .range }) ? searchState.selectedTimeRange : nil - let excludedTimeList = tagList.contains(where: { $0.type == .time && TimeType(rawValue: $0.text) == .empty }) ? currentTimetable.timeMask : nil + let timeList = tagList + .contains(where: { $0.type == .time && TimeType(rawValue: $0.text) == .range }) ? searchState + .selectedTimeRange : nil + let excludedTimeList = tagList + .contains(where: { $0.type == .time && TimeType(rawValue: $0.text) == .empty }) ? currentTimetable + .timeMask : nil let offset = searchState.perPage * searchState.pageNum let dtos = try await searchRepository.fetchSearchResult(query: searchState.searchText, quarter: currentTimetable.quarter, @@ -95,7 +101,11 @@ struct SearchService: SearchServiceProtocol { offset: offset, limit: searchState.perPage) let models: [Lecture] = dtos.map { Lecture(from: $0) } - FirebaseAnalyticsLogger().logEvent(.searchLecture(.init(query: searchState.searchText, quarter: currentTimetable.quarter.longString(), page: searchState.pageNum))) + FirebaseAnalyticsLogger().logEvent(.searchLecture(.init( + query: searchState.searchText, + quarter: currentTimetable.quarter.longString(), + page: searchState.pageNum + ))) searchState.searchResult = offset == 0 ? models : (searchState.searchResult ?? []) + models } @@ -133,7 +143,9 @@ struct SearchService: SearchServiceProtocol { } func selectTimeRangeTag() { - guard let tag = searchState.searchTagList?.tagList.first(where: { $0.type == .time && $0.text == TimeType.range.rawValue }) else { + guard let tag = searchState.searchTagList?.tagList + .first(where: { $0.type == .time && $0.text == TimeType.range.rawValue }) + else { return } if searchState.selectedTagList.firstIndex(where: { $0.id == tag.id }) == nil { diff --git a/SNUTT-2022/SNUTT/ViewModels/LectureDetailViewModel.swift b/SNUTT-2022/SNUTT/ViewModels/LectureDetailViewModel.swift index 024e07a8..5879cac3 100644 --- a/SNUTT-2022/SNUTT/ViewModels/LectureDetailViewModel.swift +++ b/SNUTT-2022/SNUTT/ViewModels/LectureDetailViewModel.swift @@ -65,7 +65,11 @@ extension LectureDetailScene { } do { - try await lectureService.updateLecture(oldLecture: oldLecture, newLecture: newLecture, isForced: isForced) + try await lectureService.updateLecture( + oldLecture: oldLecture, + newLecture: newLecture, + isForced: isForced + ) return true } catch let error as STError where error.code == .LECTURE_TIME_OVERLAP { isLectureOverlapped = true @@ -172,7 +176,10 @@ extension LectureDetailScene { } func bookmarkLecture(lecture: Lecture) async { - FirebaseAnalyticsLogger().logEvent(.addToBookmark(.init(lectureID: lecture.referenceId, referrer: .lectureDetail))) + FirebaseAnalyticsLogger().logEvent(.addToBookmark(.init( + lectureID: lecture.referenceId, + referrer: .lectureDetail + ))) do { try await services.lectureService.bookmarkLecture(lecture: lecture) } catch { @@ -195,7 +202,10 @@ extension LectureDetailScene { } func addVacancyLecture(lecture: Lecture) async { - FirebaseAnalyticsLogger().logEvent(.addToVacancy(.init(lectureID: lecture.referenceId, referrer: .lectureDetail))) + FirebaseAnalyticsLogger().logEvent(.addToVacancy(.init( + lectureID: lecture.referenceId, + referrer: .lectureDetail + ))) do { try await services.vacancyService.addLecture(lecture: lecture) } catch let error as STError where error.code == .INVALID_SEMESTER_FOR_VACANCY_NOTIFICATION { @@ -221,7 +231,9 @@ extension LectureDetailScene { var theme: Theme { if let currentTimetable = appState.timetable.current { - return appState.theme.themeList.first(where: { $0.id == currentTimetable.themeId || $0.theme == currentTimetable.theme }) ?? Theme(rawValue: 0) + return appState.theme.themeList + .first(where: { $0.id == currentTimetable.themeId || $0.theme == currentTimetable.theme }) ?? + Theme(rawValue: 0) } else { return Theme(rawValue: 0) } } diff --git a/SNUTT-2022/SNUTT/Views/Components/Lecture/ExpandableLectureCell.swift b/SNUTT-2022/SNUTT/Views/Components/Lecture/ExpandableLectureCell.swift index c21efd30..4b8541a7 100644 --- a/SNUTT-2022/SNUTT/Views/Components/Lecture/ExpandableLectureCell.swift +++ b/SNUTT-2022/SNUTT/Views/Components/Lecture/ExpandableLectureCell.swift @@ -34,7 +34,10 @@ struct ExpandableLectureCell: View { if lecture.isCustom { LectureDetailRow(imageName: "tag.white", text: "") } else { - LectureDetailRow(imageName: "tag.white", text: "\(lecture.department), \(lecture.academicYear)") + LectureDetailRow( + imageName: "tag.white", + text: "\(lecture.department), \(lecture.academicYear)" + ) } HStack(spacing: 2) { Image("search.rating.star") @@ -92,7 +95,8 @@ struct ExpandableLectureCell: View { } LectureCellActionButton( - icon: .asset(name: isVacancyNotificationEnabled ? "search.vacancy.fill" : "search.vacancy"), + icon: .asset(name: isVacancyNotificationEnabled ? "search.vacancy.fill" : + "search.vacancy"), text: "빈자리알림" ) { if isVacancyNotificationEnabled { @@ -113,14 +117,18 @@ struct ExpandableLectureCell: View { } } } - /// This `sheet` modifier should be called on `HStack` to prevent animation glitch when `dismiss`ed. + /// This `sheet` modifier should be called on `HStack` to prevent animation glitch when + /// `dismiss`ed. .sheet(isPresented: $isReviewWebViewPresented) { ReviewScene( viewModel: .init(container: viewModel.container), isMainWebView: false, detailId: reviewDetailId ) - .analyticsScreen(.reviewDetail(.init(lectureID: lecture.referenceId, referrer: viewModel.detailReferrer))) + .analyticsScreen(.reviewDetail(.init( + lectureID: lecture.referenceId, + referrer: viewModel.detailReferrer + ))) .id(reviewDetailId) } .sheet(isPresented: $isDetailPagePresented) { @@ -130,7 +138,10 @@ struct ExpandableLectureCell: View { lecture: lecture, displayMode: .preview(shouldHideDismissButton: false) ) - .analyticsScreen(.lectureDetail(.init(lectureID: lecture.referenceId, referrer: viewModel.detailReferrer))) + .analyticsScreen(.lectureDetail(.init( + lectureID: lecture.referenceId, + referrer: viewModel.detailReferrer + ))) } } } @@ -210,7 +221,11 @@ extension ExpandableLectureCell { extension ExpandableLectureCell.ViewModel { func addLecture(_ lecture: Lecture) async { - FirebaseAnalyticsLogger().logEvent(.addToTimetable(.init(lectureID: lecture.referenceId, timetableID: appState.timetable.current?.id, referrer: lectureActionReferrer))) + FirebaseAnalyticsLogger().logEvent(.addToTimetable(.init( + lectureID: lecture.referenceId, + timetableID: appState.timetable.current?.id, + referrer: lectureActionReferrer + ))) do { try await services.lectureService.addLecture(lecture: lecture) } catch { @@ -246,7 +261,10 @@ extension ExpandableLectureCell.ViewModel { } func addVacancyLecture(_ lecture: Lecture) async { - FirebaseAnalyticsLogger().logEvent(.addToVacancy(.init(lectureID: lecture.referenceId, referrer: lectureActionReferrer))) + FirebaseAnalyticsLogger().logEvent(.addToVacancy(.init( + lectureID: lecture.referenceId, + referrer: lectureActionReferrer + ))) do { try await services.vacancyService.addLecture(lecture: lecture) } catch { @@ -263,7 +281,10 @@ extension ExpandableLectureCell.ViewModel { } func addBookmarkLecture(_ lecture: Lecture) async { - FirebaseAnalyticsLogger().logEvent(.addToBookmark(.init(lectureID: lecture.referenceId, referrer: lectureActionReferrer))) + FirebaseAnalyticsLogger().logEvent(.addToBookmark(.init( + lectureID: lecture.referenceId, + referrer: lectureActionReferrer + ))) isFirstBookmarkAlertPresented = appState.timetable.isFirstBookmark ?? false do { try await services.lectureService.bookmarkLecture(lecture: lecture) diff --git a/SNUTT-2022/SNUTT/Views/Components/LectureList.swift b/SNUTT-2022/SNUTT/Views/Components/LectureList.swift index 272e42a5..d57e1d4d 100644 --- a/SNUTT-2022/SNUTT/Views/Components/LectureList.swift +++ b/SNUTT-2022/SNUTT/Views/Components/LectureList.swift @@ -16,8 +16,15 @@ struct LectureList: View { LazyVStack(spacing: 0) { ForEach(lectures) { lecture in NavigationLink { - LectureDetailScene(viewModel: .init(container: viewModel.container), lecture: lecture, displayMode: .normal) - .analyticsScreen(.lectureDetail(.init(lectureID: lecture.referenceId, referrer: .lectureList))) + LectureDetailScene( + viewModel: .init(container: viewModel.container), + lecture: lecture, + displayMode: .normal + ) + .analyticsScreen(.lectureDetail(.init( + lectureID: lecture.referenceId, + referrer: .lectureList + ))) } label: { VStack(spacing: 0) { Divider() diff --git a/SNUTT-2022/SNUTT/Views/Components/MenuSheets/MenuThemeSheet.swift b/SNUTT-2022/SNUTT/Views/Components/MenuSheets/MenuThemeSheet.swift index 9d8ff6a9..982c0a2a 100644 --- a/SNUTT-2022/SNUTT/Views/Components/MenuSheets/MenuThemeSheet.swift +++ b/SNUTT-2022/SNUTT/Views/Components/MenuSheets/MenuThemeSheet.swift @@ -57,7 +57,8 @@ struct MenuThemeSheet: View { .padding(.horizontal, 10) .padding(.vertical, 5) .font(STFont.regular14.font) - .background(selectedTheme == theme ? Color(uiColor: .tertiarySystemFill) : .clear) + .background(selectedTheme == theme ? Color(uiColor: .tertiarySystemFill) : + .clear) .clipShape(Capsule()) } } diff --git a/SNUTT-2022/SNUTT/Views/Components/NotificationList.swift b/SNUTT-2022/SNUTT/Views/Components/NotificationList.swift index c326a5d1..9decb26a 100644 --- a/SNUTT-2022/SNUTT/Views/Components/NotificationList.swift +++ b/SNUTT-2022/SNUTT/Views/Components/NotificationList.swift @@ -59,8 +59,15 @@ struct NotificationList: View { return Group { if let lecture = routingInfo.lecture { ZStack { - LectureDetailScene(viewModel: .init(container: viewModel.container), lecture: lecture, displayMode: .preview(shouldHideDismissButton: true)) - .analyticsScreen(.lectureDetail(.init(lectureID: lecture.referenceId, referrer: .notification))) + LectureDetailScene( + viewModel: .init(container: viewModel.container), + lecture: lecture, + displayMode: .preview(shouldHideDismissButton: true) + ) + .analyticsScreen(.lectureDetail(.init( + lectureID: lecture.referenceId, + referrer: .notification + ))) if let timetableId = routingInfo.timetableId { VStack { Spacer() @@ -126,7 +133,9 @@ extension NotificationList { @available(iOS, deprecated: 16.0, message: "Use NaviationStack instead. This will be removed in the future.") struct NavigationUtil { static func popToRootView(animated: Bool = false) { - findNavigationController(viewController: UIApplication.shared.connectedScenes.flatMap { ($0 as? UIWindowScene)?.windows ?? [] }.first { $0.isKeyWindow }?.rootViewController)?.popToRootViewController(animated: animated) + findNavigationController(viewController: UIApplication.shared.connectedScenes + .flatMap { ($0 as? UIWindowScene)?.windows ?? [] }.first { $0.isKeyWindow }?.rootViewController)? + .popToRootViewController(animated: animated) } static func findNavigationController(viewController: UIViewController?) -> UINavigationController? { @@ -154,9 +163,27 @@ struct NavigationUtil { struct NotificationList_Previews: PreviewProvider { static var notifications: [STNotification] { return [ - .init(title: "공지", message: "공지예시 1", created_at: "2022-04-30T08:11:04.200Z", type: .normal, user_id: ""), - .init(title: "공지", message: "공지예시 2", created_at: "2022-04-30T08:11:04.201Z", type: .normal, user_id: ""), - .init(title: "공지", message: "공지예시 3", created_at: "2022-04-30T08:11:04.202Z", type: .normal, user_id: ""), + .init( + title: "공지", + message: "공지예시 1", + created_at: "2022-04-30T08:11:04.200Z", + type: .normal, + user_id: "" + ), + .init( + title: "공지", + message: "공지예시 2", + created_at: "2022-04-30T08:11:04.201Z", + type: .normal, + user_id: "" + ), + .init( + title: "공지", + message: "공지예시 3", + created_at: "2022-04-30T08:11:04.202Z", + type: .normal, + user_id: "" + ), ] } diff --git a/SNUTT-2022/SNUTT/Views/Components/Timetable/LectureBlocks.swift b/SNUTT-2022/SNUTT/Views/Components/Timetable/LectureBlocks.swift index 266da84f..29bd0fb6 100644 --- a/SNUTT-2022/SNUTT/Views/Components/Timetable/LectureBlocks.swift +++ b/SNUTT-2022/SNUTT/Views/Components/Timetable/LectureBlocks.swift @@ -27,7 +27,12 @@ struct LectureBlocks: View { config: config) { Group { - let blockHeight = Painter.getHeight(of: timePlace, in: reader.size, current: current, config: config) + let blockHeight = Painter.getHeight( + of: timePlace, + in: reader.size, + current: current, + config: config + ) #if WIDGET TimetableBlock(lecture: lecture, timePlace: timePlace, @@ -36,7 +41,14 @@ struct LectureBlocks: View { visibilityOptions: config.visibilityOptions) #else if let container = container { - NavigationLink(destination: LectureDetailScene(viewModel: .init(container: container), lecture: lecture, displayMode: .normal).analyticsScreen(.lectureDetail(.init(lectureID: lecture.referenceId, referrer: .timetable)))) { + NavigationLink(destination: LectureDetailScene( + viewModel: .init(container: container), + lecture: lecture, + displayMode: .normal + ).analyticsScreen(.lectureDetail(.init( + lectureID: lecture.referenceId, + referrer: .timetable + )))) { TimetableBlock(lecture: lecture, timePlace: timePlace, theme: theme, @@ -53,9 +65,14 @@ struct LectureBlocks: View { } #endif } - .frame(width: Painter.getWeekWidth(in: reader.size, weekCount: Painter.getWeekCount(current: current, config: config)), - height: Painter.getHeight(of: timePlace, in: reader.size, current: current, config: config), - alignment: .top) + .frame( + width: Painter.getWeekWidth( + in: reader.size, + weekCount: Painter.getWeekCount(current: current, config: config) + ), + height: Painter.getHeight(of: timePlace, in: reader.size, current: current, config: config), + alignment: .top + ) .clipped() .offset(x: offsetPoint.x, y: offsetPoint.y) .animation(.customSpring, value: config.compactMode) diff --git a/SNUTT-2022/SNUTT/Views/SNUTTView.swift b/SNUTT-2022/SNUTT/Views/SNUTTView.swift index 32412944..8f0bff19 100644 --- a/SNUTT-2022/SNUTT/Views/SNUTTView.swift +++ b/SNUTT-2022/SNUTT/Views/SNUTTView.swift @@ -104,7 +104,10 @@ struct SNUTTView: View, Sendable { PopupScene(viewModel: .init(container: viewModel.container)) } else { NavigationView { - OnboardScene(viewModel: .init(container: viewModel.container), pushToTimetableScene: $pushToTimetableScene) + OnboardScene( + viewModel: .init(container: viewModel.container), + pushToTimetableScene: $pushToTimetableScene + ) } .navigationViewStyle(StackNavigationViewStyle()) } diff --git a/SNUTT-2022/SNUTT/Views/Scenes/LectureDetailScene.swift b/SNUTT-2022/SNUTT/Views/Scenes/LectureDetailScene.swift index 860be59a..2f90c4b1 100644 --- a/SNUTT-2022/SNUTT/Views/Scenes/LectureDetailScene.swift +++ b/SNUTT-2022/SNUTT/Views/Scenes/LectureDetailScene.swift @@ -176,9 +176,14 @@ struct LectureDetailScene: View { guard let tempLecture = tempLecture else { return } // save Task { - let success = await viewModel.updateLecture(oldLecture: tempLecture, newLecture: lecture) - - if success, let updatedLecture = viewModel.findLectureInCurrentTimetable(lecture) { + let success = await viewModel.updateLecture( + oldLecture: tempLecture, + newLecture: lecture + ) + + if success, + let updatedLecture = viewModel.findLectureInCurrentTimetable(lecture) + { lecture = updatedLecture editMode = .inactive resignFirstResponder() @@ -193,7 +198,8 @@ struct LectureDetailScene: View { return } - // in case of duplicate failures, delegate the rollback operation to lecture overlap alert. + // in case of duplicate failures, delegate the rollback operation to lecture + // overlap alert. } } else { // edit @@ -232,7 +238,11 @@ struct LectureDetailScene: View { case .create: success = await viewModel.addCustomLecture(lecture: lecture, isForced: true) case .normal: - success = await viewModel.updateLecture(oldLecture: tempLecture, newLecture: lecture, isForced: true) + success = await viewModel.updateLecture( + oldLecture: tempLecture, + newLecture: lecture, + isForced: true + ) case .preview: return } @@ -278,7 +288,11 @@ struct LectureDetailScene: View { HStack { DetailLabel(text: "색") NavigationLink { - LectureColorList(theme: viewModel.theme, colorIndex: $lecture.colorIndex, customColor: $lecture.color) + LectureColorList( + theme: viewModel.theme, + colorIndex: $lecture.colorIndex, + customColor: $lecture.color + ) } label: { HStack { LectureColorPreview(lectureColor: lecture.getColor()) @@ -364,7 +378,10 @@ struct LectureDetailScene: View { } HStack { DetailLabel(text: "정원(재학생)") - EditableTextField(text: .constant("\(lecture.quota)(\(lecture.nonFreshmanQuota))"), readOnly: true) + EditableTextField( + text: .constant("\(lecture.quota)(\(lecture.nonFreshmanQuota))"), + readOnly: true + ) } HStack { DetailLabel(text: "비고") @@ -521,9 +538,16 @@ struct LectureDetailScene: View { showReviewWebView = true } .sheet(isPresented: $showReviewWebView) { - ReviewScene(viewModel: .init(container: viewModel.container), isMainWebView: false, detailId: lecture.evLecture?.evLectureId) - .analyticsScreen(.reviewDetail(.init(lectureID: lecture.referenceId, referrer: .lectureDetail))) - .id(colorScheme) + ReviewScene( + viewModel: .init(container: viewModel.container), + isMainWebView: false, + detailId: lecture.evLecture?.evLectureId + ) + .analyticsScreen(.reviewDetail(.init( + lectureID: lecture.referenceId, + referrer: .lectureDetail + ))) + .id(colorScheme) } } diff --git a/SNUTT-2022/SNUTT/Views/Scenes/LectureListScene.swift b/SNUTT-2022/SNUTT/Views/Scenes/LectureListScene.swift index 75904413..7c6d534b 100644 --- a/SNUTT-2022/SNUTT/Views/Scenes/LectureListScene.swift +++ b/SNUTT-2022/SNUTT/Views/Scenes/LectureListScene.swift @@ -1,5 +1,5 @@ // -// MyLectureListScene.swift +// LectureListScene.swift // SNUTT // // Created by 박신홍 on 2022/03/30. @@ -35,8 +35,12 @@ struct LectureListScene: View { .sheet(isPresented: $showingCreatePage, content: { ZStack { NavigationView { - LectureDetailScene(viewModel: .init(container: viewModel.container), lecture: viewModel.placeholderLecture, displayMode: .create) - .analyticsScreen(.lectureCreate) + LectureDetailScene( + viewModel: .init(container: viewModel.container), + lecture: viewModel.placeholderLecture, + displayMode: .create + ) + .analyticsScreen(.lectureCreate) } // this view is duplicated on purpose (i.e. there are 2 instances of LectureTimeSheetScene) LectureTimeSheetScene(viewModel: .init(container: viewModel.container)) diff --git a/SNUTT-2022/SNUTT/Views/Scenes/OnboardScene.swift b/SNUTT-2022/SNUTT/Views/Scenes/OnboardScene.swift index 6f3ec529..94d5f08e 100644 --- a/SNUTT-2022/SNUTT/Views/Scenes/OnboardScene.swift +++ b/SNUTT-2022/SNUTT/Views/Scenes/OnboardScene.swift @@ -128,11 +128,24 @@ struct OnboardScene: View { .navigationBarHidden(true) .background( Group { - NavigationLink(destination: SignUpView(registerLocalId: viewModel.registerWith(id:password:email:), sendVerificationCode: viewModel.sendVerificationCode(email:), checkVerificationCode: viewModel.submitVerificationCode(code:), pushToTimetableScene: $pushToTimetableScene), isActive: $pushToSignUpScene) { EmptyView() } - - NavigationLink(destination: LoginScene(viewModel: .init(container: viewModel.container), moveToTimetableScene: $pushToTimetableScene), isActive: $pushToLoginScene) { EmptyView() } - - NavigationLink(destination: UserSupportView(email: nil, sendFeedback: viewModel.sendFeedback(email:message:)), isActive: $pushToFeedbackView) { EmptyView() } + NavigationLink( + destination: SignUpView(registerLocalId: viewModel.registerWith(id:password:email:), + sendVerificationCode: viewModel.sendVerificationCode(email:), + checkVerificationCode: viewModel.submitVerificationCode(code:), + pushToTimetableScene: $pushToTimetableScene), + isActive: $pushToSignUpScene + ) { EmptyView() } + + NavigationLink( + destination: LoginScene(viewModel: .init(container: viewModel.container), + moveToTimetableScene: $pushToTimetableScene), + isActive: $pushToLoginScene + ) { EmptyView() } + + NavigationLink( + destination: UserSupportView(email: nil, sendFeedback: viewModel.sendFeedback(email:message:)), + isActive: $pushToFeedbackView + ) { EmptyView() } } ) .onLoad { diff --git a/SNUTT-2022/SNUTT/Views/Scenes/Settings/SettingScene.swift b/SNUTT-2022/SNUTT/Views/Scenes/Settings/SettingScene.swift index 9b5212ce..34d2f40e 100644 --- a/SNUTT-2022/SNUTT/Views/Scenes/Settings/SettingScene.swift +++ b/SNUTT-2022/SNUTT/Views/Scenes/Settings/SettingScene.swift @@ -18,7 +18,11 @@ struct SettingScene: View { var body: some View { List { Section { - SettingsLinkItem(title: "내 계정", leadingImage: Image("account.person"), detail: viewModel.currentUser?.nickname.fullString) { + SettingsLinkItem( + title: "내 계정", + leadingImage: Image("account.person"), + detail: viewModel.currentUser?.nickname.fullString + ) { AccountSettingScene(viewModel: .init(container: viewModel.container)) } .padding(.vertical, 12) diff --git a/SNUTT-2022/SNUTT/Views/Scenes/Settings/ThemeSettingScene.swift b/SNUTT-2022/SNUTT/Views/Scenes/Settings/ThemeSettingScene.swift index 8c5604e8..8f185d80 100644 --- a/SNUTT-2022/SNUTT/Views/Scenes/Settings/ThemeSettingScene.swift +++ b/SNUTT-2022/SNUTT/Views/Scenes/Settings/ThemeSettingScene.swift @@ -37,8 +37,12 @@ struct ThemeSettingScene: View { .sheet(isPresented: $viewModel.isNewThemeSheetOpen, content: { ZStack { NavigationView { - ThemeDetailScene(viewModel: .init(container: viewModel.container), theme: viewModel.newTheme, themeType: .new) - .analyticsScreen(.themeCustomNew) + ThemeDetailScene( + viewModel: .init(container: viewModel.container), + theme: viewModel.newTheme, + themeType: .new + ) + .analyticsScreen(.themeCustomNew) } } .accentColor(Color(UIColor.label)) @@ -46,8 +50,12 @@ struct ThemeSettingScene: View { .sheet(isPresented: $viewModel.isBasicThemeSheetOpen, content: { ZStack { NavigationView { - ThemeDetailScene(viewModel: .init(container: viewModel.container), theme: viewModel.targetTheme ?? viewModel.newTheme, themeType: .basic) - .analyticsScreen(.themeBasicDetail) + ThemeDetailScene( + viewModel: .init(container: viewModel.container), + theme: viewModel.targetTheme ?? viewModel.newTheme, + themeType: .basic + ) + .analyticsScreen(.themeBasicDetail) } } .accentColor(Color(UIColor.label)) @@ -55,8 +63,12 @@ struct ThemeSettingScene: View { .sheet(isPresented: $viewModel.isCustomThemeSheetOpen, content: { ZStack { NavigationView { - ThemeDetailScene(viewModel: .init(container: viewModel.container), theme: viewModel.targetTheme ?? viewModel.newTheme, themeType: .custom) - .analyticsScreen(.themeCustomEdit) + ThemeDetailScene( + viewModel: .init(container: viewModel.container), + theme: viewModel.targetTheme ?? viewModel.newTheme, + themeType: .custom + ) + .analyticsScreen(.themeCustomEdit) } } .accentColor(Color(UIColor.label)) diff --git a/SNUTT-2022/SNUTT/Views/Scenes/Settings/TimetableSettingScene.swift b/SNUTT-2022/SNUTT/Views/Scenes/Settings/TimetableSettingScene.swift index 740baa95..d60dae60 100644 --- a/SNUTT-2022/SNUTT/Views/Scenes/Settings/TimetableSettingScene.swift +++ b/SNUTT-2022/SNUTT/Views/Scenes/Settings/TimetableSettingScene.swift @@ -64,8 +64,11 @@ struct TimetableSettingScene: View { VStack(alignment: .leading) { Text("시간대") - TimeRangeSlider(minHour: $viewModel.timetableConfig.minHour, maxHour: $viewModel.timetableConfig.maxHour) - .frame(height: 40) + TimeRangeSlider( + minHour: $viewModel.timetableConfig.minHour, + maxHour: $viewModel.timetableConfig.maxHour + ) + .frame(height: 40) } } } @@ -81,8 +84,7 @@ struct TimetableSettingScene: View { .clipShape(RoundedRectangle(cornerRadius: 20, style: .continuous)) .overlay(RoundedRectangle(cornerRadius: 20, style: .continuous) .stroke(lineWidth: 0.5) - .foregroundColor(Color(UIColor.quaternaryLabel)) - ) + .foregroundColor(Color(UIColor.quaternaryLabel))) .shadow(color: .black.opacity(0.05), radius: 3) .padding(.vertical, 10) .environment(\.dependencyContainer, nil) diff --git a/SNUTT-2022/SNUTT/Views/Scenes/SharedUIAnalytics/AnalyticsEvent.swift b/SNUTT-2022/SNUTT/Views/Scenes/SharedUIAnalytics/AnalyticsEvent.swift index 5fa56d1e..7567130e 100644 --- a/SNUTT-2022/SNUTT/Views/Scenes/SharedUIAnalytics/AnalyticsEvent.swift +++ b/SNUTT-2022/SNUTT/Views/Scenes/SharedUIAnalytics/AnalyticsEvent.swift @@ -23,6 +23,7 @@ public struct LoginParameter: Encodable { case facebook case kakao } + let provider: Provider } @@ -55,7 +56,7 @@ enum LectureActionReferrer: Encodable { func encode(to encoder: any Encoder) throws { var container = encoder.singleValueContainer() switch self { - case .search(let query): + case let .search(query): try container.encode("search=\(query)") case .lectureDetail: try container.encode("lectureDetail") @@ -77,15 +78,15 @@ public struct SearchLectureParameter: Encodable { extension AnalyticsEvent { var extraParameters: [String: Any] { switch self { - case .login(let parameter): + case let .login(parameter): parameter.dictionary - case .addToBookmark(let parameter): + case let .addToBookmark(parameter): parameter.dictionary - case .searchLecture(let parameter): + case let .searchLecture(parameter): parameter.dictionary - case .addToTimetable(let parameter): + case let .addToTimetable(parameter): parameter.dictionary - case .addToVacancy(let parameter): + case let .addToVacancy(parameter): parameter.dictionary default: [:] diff --git a/SNUTT-2022/SNUTT/Views/Scenes/SharedUIAnalytics/AnalyticsScreen.swift b/SNUTT-2022/SNUTT/Views/Scenes/SharedUIAnalytics/AnalyticsScreen.swift index 96a211f3..699a59f6 100644 --- a/SNUTT-2022/SNUTT/Views/Scenes/SharedUIAnalytics/AnalyticsScreen.swift +++ b/SNUTT-2022/SNUTT/Views/Scenes/SharedUIAnalytics/AnalyticsScreen.swift @@ -46,7 +46,6 @@ public enum AnalyticsScreen: SnakeCaseConvertible { case onboard } - public struct LectureDetailParameter: Encodable { typealias Referrer = DetailScreenReferrer let lectureID: String @@ -74,7 +73,7 @@ enum DetailScreenReferrer: Encodable { func encode(to encoder: any Encoder) throws { var container = encoder.singleValueContainer() switch self { - case .search(let query): + case let .search(query): try container.encode("search=\(query)") case .notification: try container.encode("notification") @@ -93,11 +92,11 @@ enum DetailScreenReferrer: Encodable { extension AnalyticsScreen { var extraParameters: [String: Any] { switch self { - case .lectureDetail(let parameter): + case let .lectureDetail(parameter): parameter.dictionary - case .reviewDetail(let parameter): + case let .reviewDetail(parameter): parameter.dictionary - case .lectureSyllabus(let parameter): + case let .lectureSyllabus(parameter): parameter.dictionary default: [:] diff --git a/SNUTT-2022/SNUTT/Views/Scenes/SharedUIAnalytics/AnalyticsScreenModifier.swift b/SNUTT-2022/SNUTT/Views/Scenes/SharedUIAnalytics/AnalyticsScreenModifier.swift index 954a7996..b71c1ccf 100644 --- a/SNUTT-2022/SNUTT/Views/Scenes/SharedUIAnalytics/AnalyticsScreenModifier.swift +++ b/SNUTT-2022/SNUTT/Views/Scenes/SharedUIAnalytics/AnalyticsScreenModifier.swift @@ -6,8 +6,8 @@ // import FirebaseAnalytics -import SwiftUI import os +import SwiftUI let analyticsLocalLogger = os.Logger( subsystem: "com.wafflestudio.snutt", @@ -21,14 +21,14 @@ struct AnalyticsScreenModifier: ViewModifier { content .analyticsScreen(name: screen.snakeCase, extraParameters: screen.extraParameters) .onAppear { - analyticsLocalLogger.trace("[AnalyticsScreen] \(screen.snakeCase) recorded with \(screen.extraParameters).") + analyticsLocalLogger + .trace("[AnalyticsScreen] \(screen.snakeCase) recorded with \(screen.extraParameters).") } } } extension View { - @ViewBuilder - func analyticsScreen(_ screen: AnalyticsScreen, isVisible: Bool = true) -> some View { + @ViewBuilder func analyticsScreen(_ screen: AnalyticsScreen, isVisible: Bool = true) -> some View { if isVisible { modifier(AnalyticsScreenModifier(screen: screen)) } else { diff --git a/SNUTT-2022/SNUTT/Views/Scenes/SharedUIAnalytics/SnakeCaseConvertible.swift b/SNUTT-2022/SNUTT/Views/Scenes/SharedUIAnalytics/SnakeCaseConvertible.swift index d5173264..8f37dc0b 100644 --- a/SNUTT-2022/SNUTT/Views/Scenes/SharedUIAnalytics/SnakeCaseConvertible.swift +++ b/SNUTT-2022/SNUTT/Views/Scenes/SharedUIAnalytics/SnakeCaseConvertible.swift @@ -25,16 +25,15 @@ extension SnakeCaseConvertible { let fullWordsPattern = "([a-z])([A-Z]|[0-9])" let digitsFirstPattern = "([0-9])([A-Z])" return string.processCamelCaseRegex(pattern: acronymPattern)? - .processCamelCaseRegex(pattern: fullWordsPattern)? - .processCamelCaseRegex(pattern:digitsFirstPattern)?.lowercased() ?? string.lowercased() + .processCamelCaseRegex(pattern: fullWordsPattern)? + .processCamelCaseRegex(pattern: digitsFirstPattern)?.lowercased() ?? string.lowercased() } } - extension String { fileprivate func processCamelCaseRegex(pattern: String) -> String? { - let regex = try? NSRegularExpression(pattern: pattern, options: []) - let range = NSRange(location: 0, length: count) - return regex?.stringByReplacingMatches(in: self, options: [], range: range, withTemplate: "$1_$2") + let regex = try? NSRegularExpression(pattern: pattern, options: []) + let range = NSRange(location: 0, length: count) + return regex?.stringByReplacingMatches(in: self, options: [], range: range, withTemplate: "$1_$2") } } diff --git a/SNUTT-2022/SNUTT/Views/Scenes/TimetableScene.swift b/SNUTT-2022/SNUTT/Views/Scenes/TimetableScene.swift index d4ce71dd..9597750e 100644 --- a/SNUTT-2022/SNUTT/Views/Scenes/TimetableScene.swift +++ b/SNUTT-2022/SNUTT/Views/Scenes/TimetableScene.swift @@ -50,7 +50,10 @@ struct TimetableScene: View, Sendable { } NavBarButton(imageName: "nav.share") { - screenshot = self.timetable.takeScreenshot(size: .init(width: proxy.size.width, height: proxy.size.height - toolBarHeight), preferredColorScheme: colorScheme) + screenshot = self.timetable.takeScreenshot( + size: .init(width: proxy.size.width, height: proxy.size.height - toolBarHeight), + preferredColorScheme: colorScheme + ) isShareSheetOpened = true } @@ -87,7 +90,10 @@ struct TimetableScene: View, Sendable { // navigate programmatically, because NavigationLink inside toolbar doesn't work .background( Group { - NavigationLink(destination: LectureListScene(viewModel: .init(container: viewModel.container)), isActive: $pushToListScene) { EmptyView() } + NavigationLink( + destination: LectureListScene(viewModel: .init(container: viewModel.container)), + isActive: $pushToListScene + ) { EmptyView() } NavigationLink(destination: NotificationList(viewModel: .init(container: viewModel.container)), isActive: $viewModel.routingState.pushToNotification) { EmptyView() } @@ -106,12 +112,17 @@ struct TimetableScene: View, Sendable { private struct ActivityViewController: UIViewControllerRepresentable { var activityItems: [Any] - func makeUIViewController(context _: UIViewControllerRepresentableContext) -> UIActivityViewController { + func makeUIViewController(context _: UIViewControllerRepresentableContext) + -> UIActivityViewController + { let controller = UIActivityViewController(activityItems: activityItems, applicationActivities: nil) return controller } - func updateUIViewController(_: UIActivityViewController, context _: UIViewControllerRepresentableContext) {} + func updateUIViewController( + _: UIActivityViewController, + context _: UIViewControllerRepresentableContext + ) {} } private final class LinkMetadata: NSObject, UIActivityItemSource {