Skip to content

Commit af19c2c

Browse files
authored
Доработки (#272)
* Рефактор сообщений и профиля (#270) - Пересобрал экраны сообщений и профиля, чтобы не отравлялись лишние запросы при авторизации/логауте - Удалил фильтр ошибок отмены запроса, т.к. основная причина его создания устранена * Поправил tintColor для всех алертов (#271) Исправил баг с `accentColor` у алертов, [обсуждение](https://developer.apple.com/forums/thread/673147). Без этой настройки у всех алертов при первом появлении стандартный `tintColor` (синий), а при нажатии он меняется на `AccentColor` в проекте
1 parent 153625c commit af19c2c

30 files changed

+114
-161
lines changed

.github/workflows/swift.yml renamed to .github/workflows/unit-tests.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# This workflow will build a Swift project
2-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift
1+
# Воркфлоу для запуска unit-тестов
2+
# Документация тут: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift
33

4-
name: SwiftUI-WorkoutApp CI
4+
name: Unit-tests
55

66
on:
77
push:
@@ -23,19 +23,11 @@ jobs:
2323
2424
- name: List Available Simulators
2525
run: xcrun simctl list devices
26-
27-
- name: Build App
28-
run: |
29-
xcodebuild build \
30-
-scheme "SwiftUI-WorkoutApp" \
31-
-destination "platform=iOS Simulator,name=iPhone 16 Pro,OS=18.2" \
32-
CODE_SIGNING_ALLOWED=NO
3326

3427
- name: Run Tests
3528
run: |
3629
xcodebuild test \
3730
-scheme "SwiftUI-WorkoutApp" \
3831
-testPlan "SwiftUI-WorkoutApp" \
3932
-destination "platform=iOS Simulator,name=iPhone 16 Pro,OS=18.2" \
40-
CODE_SIGNING_ALLOWED=NO \
41-
-verbose
33+
CODE_SIGNING_ALLOWED=NO

SwiftUI-WorkoutApp.xcodeproj/project.pbxproj

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@
5454
6798AA45280AEDCA00DB76F1 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6798AA44280AEDCA00DB76F1 /* Preview Assets.xcassets */; };
5555
6798AA4C280AF1C200DB76F1 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6798AA4B280AF1C200DB76F1 /* LaunchScreen.storyboard */; };
5656
6798AA53280AF43900DB76F1 /* EventsListScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6798AA52280AF43900DB76F1 /* EventsListScreen.swift */; };
57-
6798AA55280AF46300DB76F1 /* DialogsScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6798AA54280AF46300DB76F1 /* DialogsScreen.swift */; };
5857
6798AA59280AF4B100DB76F1 /* ParksMapScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6798AA58280AF4B100DB76F1 /* ParksMapScreen.swift */; };
59-
6798AA5B280AF4C700DB76F1 /* ProfileScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6798AA5A280AF4C700DB76F1 /* ProfileScreen.swift */; };
6058
6798AA66280B232F00DB76F1 /* IncognitoProfileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6798AA65280B232F00DB76F1 /* IncognitoProfileView.swift */; };
6159
6798AA68280B23B700DB76F1 /* UserDetailsScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6798AA67280B23B700DB76F1 /* UserDetailsScreen.swift */; };
6260
6798AA73280B43FE00DB76F1 /* LoginScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6798AA72280B43FE00DB76F1 /* LoginScreen.swift */; };
@@ -148,9 +146,7 @@
148146
6798AA44280AEDCA00DB76F1 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
149147
6798AA4B280AF1C200DB76F1 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; };
150148
6798AA52280AF43900DB76F1 /* EventsListScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventsListScreen.swift; sourceTree = "<group>"; };
151-
6798AA54280AF46300DB76F1 /* DialogsScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DialogsScreen.swift; sourceTree = "<group>"; };
152149
6798AA58280AF4B100DB76F1 /* ParksMapScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParksMapScreen.swift; sourceTree = "<group>"; };
153-
6798AA5A280AF4C700DB76F1 /* ProfileScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileScreen.swift; sourceTree = "<group>"; };
154150
6798AA65280B232F00DB76F1 /* IncognitoProfileView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IncognitoProfileView.swift; sourceTree = "<group>"; };
155151
6798AA67280B23B700DB76F1 /* UserDetailsScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDetailsScreen.swift; sourceTree = "<group>"; };
156152
6798AA72280B43FE00DB76F1 /* LoginScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginScreen.swift; sourceTree = "<group>"; };
@@ -242,7 +238,6 @@
242238
67419AD5282E8E7C004F5339 /* Messages */ = {
243239
isa = PBXGroup;
244240
children = (
245-
6798AA54280AF46300DB76F1 /* DialogsScreen.swift */,
246241
67D916802838E2460098D3CB /* DialogsListScreen.swift */,
247242
67D916852838F0DD0098D3CB /* DialogScreen.swift */,
248243
);
@@ -418,7 +413,6 @@
418413
children = (
419414
6765B25A2D455D5C006164AB /* ProfileViews.swift */,
420415
67419AD4282E8E6F004F5339 /* Journals */,
421-
6798AA5A280AF4C700DB76F1 /* ProfileScreen.swift */,
422416
6770A8352834D7B50006B672 /* EditProfile */,
423417
6798AA67280B23B700DB76F1 /* UserDetailsScreen.swift */,
424418
674D061A28280A63007E75C6 /* FriendRequestsView.swift */,
@@ -620,10 +614,8 @@
620614
buildActionMask = 2147483647;
621615
files = (
622616
674023402B0BC01600A7311A /* FeedbackSender.swift in Sources */,
623-
6798AA5B280AF4C700DB76F1 /* ProfileScreen.swift in Sources */,
624617
674D31592D44103300A2EFE8 /* UserFlagsEnvironmentKey.swift in Sources */,
625618
67A9C90828427DEA005D6A36 /* ParkFilterScreen.swift in Sources */,
626-
6798AA55280AF46300DB76F1 /* DialogsScreen.swift in Sources */,
627619
6758463F2965B7F2000BA5E0 /* PDFViewRepresentable.swift in Sources */,
628620
67BAF3F428361BC400DB40D9 /* PhotoSectionView.swift in Sources */,
629621
67BAF3F82836245100DB40D9 /* CommentsView.swift in Sources */,
@@ -881,7 +873,7 @@
881873
CLANG_TIDY_MISC_REDUNDANT_EXPRESSION = YES;
882874
CLANG_WARN_SEMICOLON_BEFORE_METHOD_BODY = YES;
883875
CODE_SIGN_STYLE = Automatic;
884-
CURRENT_PROJECT_VERSION = 3;
876+
CURRENT_PROJECT_VERSION = 4;
885877
DEVELOPMENT_ASSET_PATHS = "SwiftUI-WorkoutApp/Preview\\ Content/PreviewContent.swift SwiftUI-WorkoutApp/Preview\\ Content";
886878
DEVELOPMENT_TEAM = CR68PP2Z3F;
887879
ENABLE_PREVIEWS = YES;
@@ -931,7 +923,7 @@
931923
CLANG_TIDY_MISC_REDUNDANT_EXPRESSION = YES;
932924
CLANG_WARN_SEMICOLON_BEFORE_METHOD_BODY = YES;
933925
CODE_SIGN_STYLE = Automatic;
934-
CURRENT_PROJECT_VERSION = 3;
926+
CURRENT_PROJECT_VERSION = 4;
935927
DEVELOPMENT_ASSET_PATHS = "SwiftUI-WorkoutApp/Preview\\ Content/PreviewContent.swift SwiftUI-WorkoutApp/Preview\\ Content";
936928
DEVELOPMENT_TEAM = CR68PP2Z3F;
937929
ENABLE_PREVIEWS = YES;

SwiftUI-WorkoutApp/Libraries/SWAlert/Sources/SWAlert/SWAlert.swift

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,19 @@ public final class SWAlert {
88

99
/// Показывает системный алерт с заданными параметрами
1010
/// - Parameters:
11-
/// - title: Заголовок. Если передать `nil`, то сообщение выделится жирным. Если передать текст или пустую строку, будет без
12-
/// заголовка, и сообщение будет со стандартным шрифтом
11+
/// - title: Заголовок. Если передать `nil`, то сообщение выделится жирным. Если передать текст или пустую строку,
12+
/// будет без заголовка, и сообщение будет со стандартным шрифтом
1313
/// - message: Текст сообщения
1414
/// - closeButtonTitle: Заголовок кнопки для закрытия алерта
1515
/// - closeButtonStyle: Стиль кнопки для закрытия алерта
16-
/// - closeButtonTintColor: Цвет кнопки для закрытия алерта. Если не настроить явно, то при появлении будет системный (синий) цвет, а
17-
/// при нажатии он изменится на `AccentColor` в проекте
1816
public func presentDefaultUIKit(
1917
title: String? = "",
2018
message: String,
2119
closeButtonTitle: String = "Ok",
22-
closeButtonStyle: UIAlertAction.Style = .default,
23-
closeButtonTintColor: UIColor? = .systemGreen
20+
closeButtonStyle: UIAlertAction.Style = .default
2421
) {
2522
guard currentAlert == nil, let topMostViewController else { return }
2623
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
27-
alert.view.tintColor = closeButtonTintColor
2824
alert.addAction(
2925
.init(
3026
title: closeButtonTitle,

SwiftUI-WorkoutApp/Libraries/SWNetwork/Sources/SWNetwork/SWNetwork.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ private extension SWNetworkService {
163163
/// - Returns: Новая ошибка
164164
@discardableResult
165165
func handleUrlSession(_ error: Error, _ request: URLRequest) -> Error {
166+
if (error as NSError).code == -999 {
167+
assertionFailure("Запрос отменён! Код ошибки: -999")
168+
}
166169
logger.error(
167170
"""
168171
\(error.localizedDescription, privacy: .public)

SwiftUI-WorkoutApp/Libraries/SWNetworkClient/Sources/SWNetworkClient/ErrorFilter.swift

Lines changed: 0 additions & 19 deletions
This file was deleted.

SwiftUI-WorkoutApp/Screens/Common/IncognitoProfileView.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ struct IncognitoProfileView: View {
2020
LoginScreen()
2121
}
2222
}
23+
.navigationBarTitleDisplayMode(.large)
24+
.transition(
25+
.asymmetric(
26+
insertion: .opacity,
27+
removal: .move(edge: .bottom).combined(with: .opacity)
28+
)
29+
)
2330
}
2431
}
2532

SwiftUI-WorkoutApp/Screens/Common/TextEntryScreen.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ private extension TextEntryScreen {
124124
}
125125
if isSuccess { refreshClbk() }
126126
} catch {
127-
SWAlert.shared.presentDefaultUIKit(message: ErrorFilter.message(from: error))
127+
SWAlert.shared.presentDefaultUIKit(message: error.localizedDescription)
128128
}
129129
isLoading = false
130130
}

SwiftUI-WorkoutApp/Screens/Common/UsersListScreen.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ private extension UsersListScreen {
146146
let isSuccess = try await client.sendMessage(messagingModel.message, to: userID)
147147
endMessaging(isSuccess: isSuccess)
148148
} catch {
149-
SWAlert.shared.presentDefaultUIKit(message: ErrorFilter.message(from: error))
149+
SWAlert.shared.presentDefaultUIKit(message: error.localizedDescription)
150150
}
151151
messagingModel.isLoading = false
152152
}
@@ -191,7 +191,7 @@ private extension UsersListScreen {
191191
}
192192
}
193193
} catch {
194-
SWAlert.shared.presentDefaultUIKit(message: ErrorFilter.message(from: error))
194+
SWAlert.shared.presentDefaultUIKit(message: error.localizedDescription)
195195
}
196196
isLoading = false
197197
}
@@ -205,7 +205,7 @@ private extension UsersListScreen {
205205
await askForUsers(refresh: true)
206206
}
207207
} catch {
208-
SWAlert.shared.presentDefaultUIKit(message: ErrorFilter.message(from: error))
208+
SWAlert.shared.presentDefaultUIKit(message: error.localizedDescription)
209209
}
210210
isLoading = false
211211
}

SwiftUI-WorkoutApp/Screens/Events/EventDetailsScreen.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ private extension EventDetailsScreen {
117117
onDeletion(event.id)
118118
}
119119
} catch {
120-
SWAlert.shared.presentDefaultUIKit(message: ErrorFilter.message(from: error))
120+
SWAlert.shared.presentDefaultUIKit(message: error.localizedDescription)
121121
}
122122
isLoading = false
123123
}
@@ -228,7 +228,7 @@ private extension EventDetailsScreen {
228228
event.trainHere = oldValue
229229
}
230230
} catch {
231-
SWAlert.shared.presentDefaultUIKit(message: ErrorFilter.message(from: error))
231+
SWAlert.shared.presentDefaultUIKit(message: error.localizedDescription)
232232
event.trainHere = oldValue
233233
}
234234
isLoading = false
@@ -343,7 +343,7 @@ private extension EventDetailsScreen {
343343
do {
344344
event = try await SWClient(with: defaults).getEvent(by: event.id)
345345
} catch {
346-
SWAlert.shared.presentDefaultUIKit(message: ErrorFilter.message(from: error))
346+
SWAlert.shared.presentDefaultUIKit(message: error.localizedDescription)
347347
}
348348
isLoading = false
349349
}
@@ -356,7 +356,7 @@ private extension EventDetailsScreen {
356356
event.comments.removeAll(where: { $0.id == id })
357357
}
358358
} catch {
359-
SWAlert.shared.presentDefaultUIKit(message: ErrorFilter.message(from: error))
359+
SWAlert.shared.presentDefaultUIKit(message: error.localizedDescription)
360360
}
361361
isLoading = false
362362
}
@@ -372,7 +372,7 @@ private extension EventDetailsScreen {
372372
event.photos = event.removePhotoById(id)
373373
}
374374
} catch {
375-
SWAlert.shared.presentDefaultUIKit(message: ErrorFilter.message(from: error))
375+
SWAlert.shared.presentDefaultUIKit(message: error.localizedDescription)
376376
}
377377
isLoading = false
378378
}

SwiftUI-WorkoutApp/Screens/Events/EventFormScreen.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ private extension EventFormScreen {
189189
dismiss()
190190
}
191191
} catch {
192-
SWAlert.shared.presentDefaultUIKit(message: ErrorFilter.message(from: error))
192+
SWAlert.shared.presentDefaultUIKit(message: error.localizedDescription)
193193
}
194194
isLoading = false
195195
}

0 commit comments

Comments
 (0)