Skip to content

Commit

Permalink
Merge branch 'peng-u-0807/add-notice-view' of https://github.com/waff…
Browse files Browse the repository at this point in the history
…lestudio/snutt-ios into peng-u-0807/add-notice-view
  • Loading branch information
peng-u-0807 committed Sep 29, 2024
2 parents 3bdb8df + 493c60e commit 6ac0a5f
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion SNUTT-2022/SNUTT/AppState/AppEnvironment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ extension EnvironmentValues {

#if DEBUG
extension AppEnvironment.Services {
@MainActor static func preview(appState: AppState) -> Self {
@MainActor static func preview(appState _: AppState) -> Self {
.init(timetableService: FakeTimetableService(),
userService: FakeUserService(),
lectureService: FakeLectureService(),
Expand Down
2 changes: 1 addition & 1 deletion SNUTT-2022/SNUTT/AppState/States/SystemState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class SystemState {
@Published var preferredColorScheme: ColorScheme? = nil

@Published var selectedTab: TabType = .timetable

@Published var noticeViewInfo: ConfigsDto.NoticeViewInfoDto?

var isMapViewExpanded: Bool?
Expand Down
2 changes: 1 addition & 1 deletion SNUTT-2022/SNUTT/Repositories/Dto/ConfigDto.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ extension ConfigsDto {
src["ios"]
}
}

struct NoticeViewInfoDto: Codable {
let title: String
let content: String
Expand Down
39 changes: 20 additions & 19 deletions SNUTT-2022/SNUTT/Services/GlobalUIService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protocol GlobalUIServiceProtocol: Sendable {

func setRoutingState<V>(_ key: WritableKeyPath<ViewRoutingState, V>, value: V)
func hasNewBadge(settingName: String) -> Bool

func showNoticeViewIfNeeded() async throws
}

Expand Down Expand Up @@ -164,8 +164,9 @@ struct GlobalUIService: GlobalUIServiceProtocol, UserAuthHandler, ConfigsProvida
appState.menu.lectureTimeSheetAction = action
appState.menu.isLectureTimeSheetOpen = value
}

// MARK: Show Notice View

func showNoticeViewIfNeeded() async throws {
let configs = try await configRepository?.fetchConfigs()
appState.system.noticeViewInfo = configs?.notice
Expand Down Expand Up @@ -205,14 +206,14 @@ extension GlobalUIService {
}

class FakeGlobalUIService: GlobalUIServiceProtocol {
func setColorScheme(_ colorScheme: ColorScheme?) {}
func setColorScheme(_: ColorScheme?) {}
func loadColorSchemeDuringBootstrap() {}

func setSelectedTab(_ tab: TabType) {}
func setIsErrorAlertPresented(_ value: Bool) {}
func setIsMenuOpen(_ value: Bool) {}
func setSelectedTab(_: TabType) {}
func setIsErrorAlertPresented(_: Bool) {}
func setIsMenuOpen(_: Bool) {}

func openEllipsis(for timetable: TimetableMetadata) {}
func openEllipsis(for _: TimetableMetadata) {}
func closeEllipsis() {}

func openThemeSheet() {}
Expand All @@ -221,25 +222,25 @@ class FakeGlobalUIService: GlobalUIServiceProtocol {
func openRenameSheet() {}
func closeRenameSheet() {}

func openCreateSheet(withPicker: Bool) {}
func openCreateSheet(withPicker _: Bool) {}
func closeCreateSheet() {}

func setRenameTitle(_ value: String) {}
func setCreateTitle(_ value: String) {}
func setCreateQuarter(_ value: Quarter?) {}
func setRenameTitle(_: String) {}
func setCreateTitle(_: String) {}
func setCreateQuarter(_: Quarter?) {}

func setIsLectureTimeSheetOpen(_ value: Bool, modifying timePlace: TimePlace?, action: ((TimePlace) -> Void)?) {}
func setIsLectureTimeSheetOpen(_: Bool, modifying _: TimePlace?, action _: ((TimePlace) -> Void)?) {}

func presentErrorAlert(error: STError?) {}
func presentErrorAlert(error: ErrorCode) {}
func presentErrorAlert(error: Error) {}
func presentErrorAlert(error _: STError?) {}
func presentErrorAlert(error _: ErrorCode) {}
func presentErrorAlert(error _: Error) {}

func preloadWebViews() {}
func sendMainWebViewReloadSignal() {}
func sendDetailWebViewReloadSignal(url: URL) {}
func sendDetailWebViewReloadSignal(url _: URL) {}

func setRoutingState<V>(_: WritableKeyPath<ViewRoutingState, V>, value _: V) {}
func hasNewBadge(settingName _: String) -> Bool { return true }

func setRoutingState<V>(_ key: WritableKeyPath<ViewRoutingState, V>, value: V) {}
func hasNewBadge(settingName: String) -> Bool { return true }

func showNoticeViewIfNeeded() async throws {}
}
4 changes: 2 additions & 2 deletions SNUTT-2022/SNUTT/Views/Components/NoticeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ struct NoticeView: View {
let title: String?
let content: String?
let sendFeedback: (String, String) async -> Bool

@State private var pushToFeedBackView = false

var body: some View {
VStack(spacing: 32) {
Image("warning.cat")
Expand Down
7 changes: 3 additions & 4 deletions SNUTT-2022/SNUTT/Views/SNUTTView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct SNUTTView: View, Sendable {
ZStack {
if let noticeViewInfo = viewModel.noticeViewInfo, noticeViewInfo.visible {
NavigationView {
NoticeView(title: noticeViewInfo.title,
NoticeView(title: noticeViewInfo.title,
content: noticeViewInfo.content,
sendFeedback: viewModel.sendFeedback)
}
Expand Down Expand Up @@ -147,7 +147,6 @@ extension SNUTTView {
@Published var preferredColorScheme: ColorScheme? = nil
@Published private var error: STError? = nil
@Published var noticeViewInfo: ConfigsDto.NoticeViewInfoDto?


@Published private var _isErrorAlertPresented = false
var isErrorAlertPresented: Bool {
Expand Down Expand Up @@ -223,7 +222,7 @@ extension SNUTTView {
services.globalUIService.presentErrorAlert(error: error)
}
}

func showNoticeViewIfNeeded() async {
do {
try await services.globalUIService.showNoticeViewIfNeeded()
Expand Down Expand Up @@ -275,7 +274,7 @@ extension SNUTTView {
services.globalUIService.presentErrorAlert(error: error)
}
}

func sendFeedback(email: String, message: String) async -> Bool {
if !Validation.check(email: email) {
services.globalUIService.presentErrorAlert(error: .INVALID_EMAIL)
Expand Down

0 comments on commit 6ac0a5f

Please sign in to comment.