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
16 changes: 4 additions & 12 deletions .github/workflows/swift.yml → .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will build a Swift project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift
# Воркфлоу для запуска unit-тестов
# Документация тут: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift

name: SwiftUI-WorkoutApp CI
name: Unit-tests

on:
push:
Expand All @@ -23,19 +23,11 @@ jobs:

- name: List Available Simulators
run: xcrun simctl list devices

- name: Build App
run: |
xcodebuild build \
-scheme "SwiftUI-WorkoutApp" \
-destination "platform=iOS Simulator,name=iPhone 16 Pro,OS=18.2" \
CODE_SIGNING_ALLOWED=NO

- name: Run Tests
run: |
xcodebuild test \
-scheme "SwiftUI-WorkoutApp" \
-testPlan "SwiftUI-WorkoutApp" \
-destination "platform=iOS Simulator,name=iPhone 16 Pro,OS=18.2" \
CODE_SIGNING_ALLOWED=NO \
-verbose
CODE_SIGNING_ALLOWED=NO
12 changes: 2 additions & 10 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 Expand Up @@ -881,7 +873,7 @@
CLANG_TIDY_MISC_REDUNDANT_EXPRESSION = YES;
CLANG_WARN_SEMICOLON_BEFORE_METHOD_BODY = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 3;
CURRENT_PROJECT_VERSION = 4;
DEVELOPMENT_ASSET_PATHS = "SwiftUI-WorkoutApp/Preview\\ Content/PreviewContent.swift SwiftUI-WorkoutApp/Preview\\ Content";
DEVELOPMENT_TEAM = CR68PP2Z3F;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -931,7 +923,7 @@
CLANG_TIDY_MISC_REDUNDANT_EXPRESSION = YES;
CLANG_WARN_SEMICOLON_BEFORE_METHOD_BODY = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 3;
CURRENT_PROJECT_VERSION = 4;
DEVELOPMENT_ASSET_PATHS = "SwiftUI-WorkoutApp/Preview\\ Content/PreviewContent.swift SwiftUI-WorkoutApp/Preview\\ Content";
DEVELOPMENT_TEAM = CR68PP2Z3F;
ENABLE_PREVIEWS = YES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,19 @@ public final class SWAlert {

/// Показывает системный алерт с заданными параметрами
/// - Parameters:
/// - title: Заголовок. Если передать `nil`, то сообщение выделится жирным. Если передать текст или пустую строку, будет без
/// заголовка, и сообщение будет со стандартным шрифтом
/// - title: Заголовок. Если передать `nil`, то сообщение выделится жирным. Если передать текст или пустую строку,
/// будет без заголовка, и сообщение будет со стандартным шрифтом
/// - message: Текст сообщения
/// - closeButtonTitle: Заголовок кнопки для закрытия алерта
/// - closeButtonStyle: Стиль кнопки для закрытия алерта
/// - closeButtonTintColor: Цвет кнопки для закрытия алерта. Если не настроить явно, то при появлении будет системный (синий) цвет, а
/// при нажатии он изменится на `AccentColor` в проекте
public func presentDefaultUIKit(
title: String? = "",
message: String,
closeButtonTitle: String = "Ok",
closeButtonStyle: UIAlertAction.Style = .default,
closeButtonTintColor: UIColor? = .systemGreen
closeButtonStyle: UIAlertAction.Style = .default
) {
guard currentAlert == nil, let topMostViewController else { return }
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
alert.view.tintColor = closeButtonTintColor
alert.addAction(
.init(
title: closeButtonTitle,
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
Loading