Skip to content
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
8 changes: 0 additions & 8 deletions SwiftUI-WorkoutApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@
6798AA45280AEDCA00DB76F1 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6798AA44280AEDCA00DB76F1 /* Preview Assets.xcassets */; };
6798AA4C280AF1C200DB76F1 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6798AA4B280AF1C200DB76F1 /* LaunchScreen.storyboard */; };
6798AA53280AF43900DB76F1 /* EventsListScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6798AA52280AF43900DB76F1 /* EventsListScreen.swift */; };
6798AA55280AF46300DB76F1 /* DialogsScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6798AA54280AF46300DB76F1 /* DialogsScreen.swift */; };
6798AA59280AF4B100DB76F1 /* ParksMapScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6798AA58280AF4B100DB76F1 /* ParksMapScreen.swift */; };
6798AA5B280AF4C700DB76F1 /* ProfileScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6798AA5A280AF4C700DB76F1 /* ProfileScreen.swift */; };
6798AA66280B232F00DB76F1 /* IncognitoProfileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6798AA65280B232F00DB76F1 /* IncognitoProfileView.swift */; };
6798AA68280B23B700DB76F1 /* UserDetailsScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6798AA67280B23B700DB76F1 /* UserDetailsScreen.swift */; };
6798AA73280B43FE00DB76F1 /* LoginScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6798AA72280B43FE00DB76F1 /* LoginScreen.swift */; };
Expand Down Expand Up @@ -148,9 +146,7 @@
6798AA44280AEDCA00DB76F1 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
6798AA4B280AF1C200DB76F1 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; };
6798AA52280AF43900DB76F1 /* EventsListScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventsListScreen.swift; sourceTree = "<group>"; };
6798AA54280AF46300DB76F1 /* DialogsScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DialogsScreen.swift; sourceTree = "<group>"; };
6798AA58280AF4B100DB76F1 /* ParksMapScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParksMapScreen.swift; sourceTree = "<group>"; };
6798AA5A280AF4C700DB76F1 /* ProfileScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileScreen.swift; sourceTree = "<group>"; };
6798AA65280B232F00DB76F1 /* IncognitoProfileView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IncognitoProfileView.swift; sourceTree = "<group>"; };
6798AA67280B23B700DB76F1 /* UserDetailsScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDetailsScreen.swift; sourceTree = "<group>"; };
6798AA72280B43FE00DB76F1 /* LoginScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginScreen.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -242,7 +238,6 @@
67419AD5282E8E7C004F5339 /* Messages */ = {
isa = PBXGroup;
children = (
6798AA54280AF46300DB76F1 /* DialogsScreen.swift */,
67D916802838E2460098D3CB /* DialogsListScreen.swift */,
67D916852838F0DD0098D3CB /* DialogScreen.swift */,
);
Expand Down Expand Up @@ -418,7 +413,6 @@
children = (
6765B25A2D455D5C006164AB /* ProfileViews.swift */,
67419AD4282E8E6F004F5339 /* Journals */,
6798AA5A280AF4C700DB76F1 /* ProfileScreen.swift */,
6770A8352834D7B50006B672 /* EditProfile */,
6798AA67280B23B700DB76F1 /* UserDetailsScreen.swift */,
674D061A28280A63007E75C6 /* FriendRequestsView.swift */,
Expand Down Expand Up @@ -620,10 +614,8 @@
buildActionMask = 2147483647;
files = (
674023402B0BC01600A7311A /* FeedbackSender.swift in Sources */,
6798AA5B280AF4C700DB76F1 /* ProfileScreen.swift in Sources */,
674D31592D44103300A2EFE8 /* UserFlagsEnvironmentKey.swift in Sources */,
67A9C90828427DEA005D6A36 /* ParkFilterScreen.swift in Sources */,
6798AA55280AF46300DB76F1 /* DialogsScreen.swift in Sources */,
6758463F2965B7F2000BA5E0 /* PDFViewRepresentable.swift in Sources */,
67BAF3F428361BC400DB40D9 /* PhotoSectionView.swift in Sources */,
67BAF3F82836245100DB40D9 /* CommentsView.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ private extension SWNetworkService {
/// - Returns: Новая ошибка
@discardableResult
func handleUrlSession(_ error: Error, _ request: URLRequest) -> Error {
if (error as NSError).code == -999 {
assertionFailure("Запрос отменён! Код ошибки: -999")
}
logger.error(
"""
\(error.localizedDescription, privacy: .public)
Expand Down

This file was deleted.

7 changes: 7 additions & 0 deletions SwiftUI-WorkoutApp/Screens/Common/IncognitoProfileView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ struct IncognitoProfileView: View {
LoginScreen()
}
}
.navigationBarTitleDisplayMode(.large)
.transition(
.asymmetric(
insertion: .opacity,
removal: .move(edge: .bottom).combined(with: .opacity)
)
)
}
}

Expand Down
2 changes: 1 addition & 1 deletion SwiftUI-WorkoutApp/Screens/Common/TextEntryScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private extension TextEntryScreen {
}
if isSuccess { refreshClbk() }
} catch {
SWAlert.shared.presentDefaultUIKit(message: ErrorFilter.message(from: error))
SWAlert.shared.presentDefaultUIKit(message: error.localizedDescription)
}
isLoading = false
}
Expand Down
6 changes: 3 additions & 3 deletions SwiftUI-WorkoutApp/Screens/Common/UsersListScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private extension UsersListScreen {
let isSuccess = try await client.sendMessage(messagingModel.message, to: userID)
endMessaging(isSuccess: isSuccess)
} catch {
SWAlert.shared.presentDefaultUIKit(message: ErrorFilter.message(from: error))
SWAlert.shared.presentDefaultUIKit(message: error.localizedDescription)
}
messagingModel.isLoading = false
}
Expand Down Expand Up @@ -191,7 +191,7 @@ private extension UsersListScreen {
}
}
} catch {
SWAlert.shared.presentDefaultUIKit(message: ErrorFilter.message(from: error))
SWAlert.shared.presentDefaultUIKit(message: error.localizedDescription)
}
isLoading = false
}
Expand All @@ -205,7 +205,7 @@ private extension UsersListScreen {
await askForUsers(refresh: true)
}
} catch {
SWAlert.shared.presentDefaultUIKit(message: ErrorFilter.message(from: error))
SWAlert.shared.presentDefaultUIKit(message: error.localizedDescription)
}
isLoading = false
}
Expand Down
10 changes: 5 additions & 5 deletions SwiftUI-WorkoutApp/Screens/Events/EventDetailsScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private extension EventDetailsScreen {
onDeletion(event.id)
}
} catch {
SWAlert.shared.presentDefaultUIKit(message: ErrorFilter.message(from: error))
SWAlert.shared.presentDefaultUIKit(message: error.localizedDescription)
}
isLoading = false
}
Expand Down Expand Up @@ -228,7 +228,7 @@ private extension EventDetailsScreen {
event.trainHere = oldValue
}
} catch {
SWAlert.shared.presentDefaultUIKit(message: ErrorFilter.message(from: error))
SWAlert.shared.presentDefaultUIKit(message: error.localizedDescription)
event.trainHere = oldValue
}
isLoading = false
Expand Down Expand Up @@ -343,7 +343,7 @@ private extension EventDetailsScreen {
do {
event = try await SWClient(with: defaults).getEvent(by: event.id)
} catch {
SWAlert.shared.presentDefaultUIKit(message: ErrorFilter.message(from: error))
SWAlert.shared.presentDefaultUIKit(message: error.localizedDescription)
}
isLoading = false
}
Expand All @@ -356,7 +356,7 @@ private extension EventDetailsScreen {
event.comments.removeAll(where: { $0.id == id })
}
} catch {
SWAlert.shared.presentDefaultUIKit(message: ErrorFilter.message(from: error))
SWAlert.shared.presentDefaultUIKit(message: error.localizedDescription)
}
isLoading = false
}
Expand All @@ -372,7 +372,7 @@ private extension EventDetailsScreen {
event.photos = event.removePhotoById(id)
}
} catch {
SWAlert.shared.presentDefaultUIKit(message: ErrorFilter.message(from: error))
SWAlert.shared.presentDefaultUIKit(message: error.localizedDescription)
}
isLoading = false
}
Expand Down
2 changes: 1 addition & 1 deletion SwiftUI-WorkoutApp/Screens/Events/EventFormScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ private extension EventFormScreen {
dismiss()
}
} catch {
SWAlert.shared.presentDefaultUIKit(message: ErrorFilter.message(from: error))
SWAlert.shared.presentDefaultUIKit(message: error.localizedDescription)
}
isLoading = false
}
Expand Down
2 changes: 1 addition & 1 deletion SwiftUI-WorkoutApp/Screens/Events/EventsListScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ private extension EventsListScreen {
if selectedEventType == .past {
pastEventStorage.loadIfNeeded(&pastEvents)
}
SWAlert.shared.presentDefaultUIKit(message: ErrorFilter.message(from: error))
SWAlert.shared.presentDefaultUIKit(message: error.localizedDescription)
}
isLoading = false
}
Expand Down
6 changes: 3 additions & 3 deletions SwiftUI-WorkoutApp/Screens/Messages/DialogScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ private extension DialogScreen {
markedAsReadClbk(dialog)
}
} catch {
SWAlert.shared.presentDefaultUIKit(message: ErrorFilter.message(from: error))
SWAlert.shared.presentDefaultUIKit(message: error.localizedDescription)
}
}

Expand All @@ -171,7 +171,7 @@ private extension DialogScreen {
do {
messages = try await SWClient(with: defaults).getMessages(for: dialog.id).reversed()
} catch {
SWAlert.shared.presentDefaultUIKit(message: ErrorFilter.message(from: error))
SWAlert.shared.presentDefaultUIKit(message: error.localizedDescription)
}
isLoading = false
}
Expand All @@ -186,7 +186,7 @@ private extension DialogScreen {
await askForMessages(refresh: true)
}
} catch {
SWAlert.shared.presentDefaultUIKit(message: ErrorFilter.message(from: error))
SWAlert.shared.presentDefaultUIKit(message: error.localizedDescription)
}
isLoading = false
}
Expand Down
34 changes: 27 additions & 7 deletions SwiftUI-WorkoutApp/Screens/Messages/DialogsListScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,30 @@ struct DialogsListScreen: View {
@State private var showDeleteConfirmation = false
@State private var refreshTask: Task<Void, Never>?
@State private var deleteDialogTask: Task<Void, Never>?
private var client: SWClient { SWClient(with: defaults) }

var body: some View {
NavigationView {
ZStack {
if defaults.isAuthorized {
authorizedContentView
.navigationBarTitleDisplayMode(.inline)
.transition(.move(edge: .top).combined(with: .opacity))
} else {
IncognitoProfileView()
}
}
.animation(.spring, value: defaults.isAuthorized)
.background(Color.swBackground)
.navigationTitle("Сообщения")
}
.navigationViewStyle(.stack)
.task { await askForDialogs() }
}
}

private extension DialogsListScreen {
var authorizedContentView: some View {
dialogList
.overlay { emptyContentView }
.loadingOverlay(if: isLoading)
Expand All @@ -27,7 +49,6 @@ struct DialogsListScreen: View {
isPresented: $showDeleteConfirmation,
titleVisibility: .visible
) { deleteDialogButton }
.task { await askForDialogs() }
.refreshable { await askForDialogs(refresh: true) }
.toolbar {
ToolbarItem(placement: .topBarLeading) {
Expand All @@ -41,9 +62,7 @@ struct DialogsListScreen: View {
[refreshTask, deleteDialogTask].forEach { $0?.cancel() }
}
}
}

private extension DialogsListScreen {
var refreshButton: some View {
Button {
refreshTask = Task {
Expand Down Expand Up @@ -165,14 +184,15 @@ private extension DialogsListScreen {
}

func askForDialogs(refresh: Bool = false) async {
guard defaults.isAuthorized else { return }
if isLoading || (!dialogs.isEmpty && !refresh) { return }
if !refresh { isLoading = true }
do {
dialogs = try await SWClient(with: defaults).getDialogs()
dialogs = try await client.getDialogs()
let unreadMessagesCount = dialogs.map(\.unreadMessagesCount).reduce(0, +)
defaults.saveUnreadMessagesCount(unreadMessagesCount)
} catch {
SWAlert.shared.presentDefaultUIKit(message: ErrorFilter.message(from: error))
SWAlert.shared.presentDefaultUIKit(message: error.localizedDescription)
}
isLoading = false
}
Expand All @@ -188,11 +208,11 @@ private extension DialogsListScreen {
isLoading = true
do {
let dialogID = dialogs[index].id
if try await SWClient(with: defaults).deleteDialog(dialogID) {
if try await client.deleteDialog(dialogID) {
dialogs.remove(at: index)
}
} catch {
SWAlert.shared.presentDefaultUIKit(message: ErrorFilter.message(from: error))
SWAlert.shared.presentDefaultUIKit(message: error.localizedDescription)
}
isLoading = false
}
Expand Down
32 changes: 0 additions & 32 deletions SwiftUI-WorkoutApp/Screens/Messages/DialogsScreen.swift

This file was deleted.

2 changes: 1 addition & 1 deletion SwiftUI-WorkoutApp/Screens/Parks/Map/ParksMapScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ private extension ParksMapScreen {
let updatedParks = try await SWClient(with: defaults).getUpdatedParks(from: dateString)
try parksManager.updateDefaultList(with: updatedParks)
} catch {
SWAlert.shared.presentDefaultUIKit(message: ErrorFilter.message(from: error))
SWAlert.shared.presentDefaultUIKit(message: error.localizedDescription)
}
isLoading = false
}
Expand Down
2 changes: 1 addition & 1 deletion SwiftUI-WorkoutApp/Screens/Parks/ParkDetailScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ private extension ParkDetailScreen {
)
onDeletion(park.id)
} else {
SWAlert.shared.presentDefaultUIKit(message: ErrorFilter.message(from: error))
SWAlert.shared.presentDefaultUIKit(message: error.localizedDescription)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion SwiftUI-WorkoutApp/Screens/Parks/ParkFormScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ private extension ParkFormScreen {
refreshClbk()
}
} catch {
SWAlert.shared.presentDefaultUIKit(message: ErrorFilter.message(from: error))
SWAlert.shared.presentDefaultUIKit(message: error.localizedDescription)
}
isLoading = false
}
Expand Down
2 changes: 1 addition & 1 deletion SwiftUI-WorkoutApp/Screens/Parks/ParksListScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private extension ParksListScreen {
parks = list
}
} catch {
SWAlert.shared.presentDefaultUIKit(message: ErrorFilter.message(from: error))
SWAlert.shared.presentDefaultUIKit(message: error.localizedDescription)
}
isLoading = false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ private extension ChangePasswordScreen {
} catch {
SWAlert.shared.presentDefaultUIKit(
title: "Ошибка".localized,
message: ErrorFilter.message(from: error)
message: error.localizedDescription
)
}
isLoading.toggle()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ private extension EditProfileScreen {
dismiss()
} catch {
isLoading = false
SWAlert.shared.presentDefaultUIKit(message: ErrorFilter.message(from: error))
SWAlert.shared.presentDefaultUIKit(message: error.localizedDescription)
}
}
}
Expand Down
Loading