Skip to content

Commit 510ba53

Browse files
authored
Feature/remove excess viewmodels (#130)
* Форматирование * Удалил JournalSettingsViewModel * Удалил TextEntryViewModel * Удалил MessagingViewModel * Удалил UsersListViewModel * Удалил SportsGroundListViewModel * Удалил DialogListViewModel * Удалил DialogViewModel * Удалил EventsListViewModel * Убрал SportsGroundFormViewModel * Удалил JournalEntriesListViewModel * Удалил JournalsListViewModel * Удалил EventFormViewModel и поправил комментарии * Удалил SportsGroundDetailViewModel Дополнительно поправил запрос `getSportsGround` - для авторизованного пользователя передаем токен, чтобы получать корректное свойство `trainHere` * Обновил комментарии Дополнительно поправил запрос `getEvents` - для авторизованного пользователя передаем токен, чтобы получать корректное свойство `trainHere` * Удалил EventDetailsViewModel * Добавил ворнинги для лишних вьюмоделей * Удалил EditAccountViewModel * Удалил UserDetailsViewModel * Поднял версию до 3.3.4 (1)
1 parent fa2ebbc commit 510ba53

File tree

51 files changed

+1334
-2077
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1334
-2077
lines changed

SwiftUI-WorkoutApp.xcodeproj/project.pbxproj

Lines changed: 6 additions & 86 deletions
Large diffs are not rendered by default.

SwiftUI-WorkoutApp/Resources/Localizable.xcstrings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2397,6 +2397,7 @@
23972397
}
23982398
},
23992399
"Новое сообщение" : {
2400+
"extractionState" : "stale",
24002401
"localizations" : {
24012402
"en" : {
24022403
"stringUnit" : {

SwiftUI-WorkoutApp/SWModels/Sources/SWModels/City.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public struct City: Codable, Identifiable, Hashable {
1515
self.lon = lon
1616
}
1717

18+
/// Москва
1819
public static var defaultCity: Self {
1920
.init(id: "1", name: "Москва", lat: "55.753215", lon: "37.622504")
2021
}

SwiftUI-WorkoutApp/SWModels/Sources/SWModels/Country.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ public struct Country: Codable, Identifiable, Hashable {
22
public let cities: [City]
33
public var id, name: String
44

5+
/// Россия
56
public static var defaultCountry: Self {
67
.init(cities: [], id: "17", name: "Россия")
78
}

SwiftUI-WorkoutApp/SWModels/Sources/SWModels/DialogResponse.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ public extension DialogResponse {
6060
)
6161
}
6262

63+
var hasUnreadMessages: Bool {
64+
unreadMessagesCount > 0
65+
}
66+
6367
var unreadMessagesCount: Int {
6468
get { unreadCountOptional.valueOrZero }
6569
set { unreadCountOptional = newValue }

SwiftUI-WorkoutApp/SWModels/Sources/SWModels/EventResponse.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,16 +180,22 @@ public extension EventResponse {
180180
DateFormatterService.readableDate(from: beginDate)
181181
}
182182

183+
var hasComments: Bool { !comments.isEmpty }
184+
183185
var comments: [CommentResponse] {
184186
get { commentsOptional ?? [] }
185187
set { commentsOptional = newValue }
186188
}
187189

190+
var hasPhotos: Bool { !photos.isEmpty }
191+
188192
var photos: [Photo] {
189193
get { photosOptional ?? [] }
190194
set { photosOptional = newValue }
191195
}
192196

197+
var hasParticipants: Bool { !participants.isEmpty }
198+
193199
/// Список участников мероприятия
194200
var participants: [UserResponse] {
195201
get { participantsOptional ?? [] }
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/// Результат создания/сохранения мероприятия
22
///
3-
/// Бэк присылает неправильный формат данных в ответе по полю area_id.
4-
/// Иначе заменил бы эту модель на EventResponse
3+
/// Бэк присылает неправильный формат данных в ответе по полю `area_id`.
4+
/// Иначе заменил бы эту модель на `EventResponse`
55
public struct EventResult: Codable, Equatable {
66
public let id: Int
77
}

SwiftUI-WorkoutApp/SWModels/Sources/SWModels/MainUserForm.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,13 @@ public extension MainUserForm {
7272
}
7373

7474
/// Готовность формы к сохранению обновленных данных
75-
var isReadyToSave: Bool {
76-
!userName.isEmpty
75+
func isReadyToSave(comparedTo oldForm: MainUserForm) -> Bool {
76+
let isNewFormNotEmpty = !userName.isEmpty
7777
&& !email.isEmpty
7878
&& !fullName.isEmpty
7979
&& genderCode != Gender.unspecified.code
8080
&& birthDate <= Constants.minUserAge
81+
return isNewFormNotEmpty && self != oldForm
8182
}
8283

8384
static var emptyValue: Self {
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/// Модель для отправки сообщения
2+
public struct MessagingModel {
3+
/// Получатель сообщения
4+
public var recipient: UserModel?
5+
/// Статус отправки сообщения
6+
public var isLoading: Bool
7+
/// Текст сообщения
8+
public var message: String
9+
/// Можно ли отправить сообщение
10+
public var canSendMessage: Bool { !message.isEmpty && !isLoading }
11+
12+
/// Инициализатор
13+
/// - Parameters:
14+
/// - recipient: Получатель сообщения
15+
/// - isLoading: Статус отправки сообщения
16+
/// - message: Текст сообщения
17+
public init(
18+
recipient: UserModel? = nil,
19+
isLoading: Bool = false,
20+
message: String = ""
21+
) {
22+
self.recipient = recipient
23+
self.isLoading = isLoading
24+
self.message = message
25+
}
26+
}

SwiftUI-WorkoutApp/SWModels/Sources/SWModels/SportsGround.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,16 +199,22 @@ public struct CommentResponse: Codable, Identifiable, Hashable {
199199
}
200200

201201
public extension SportsGround {
202+
var hasPhotos: Bool { !photos.isEmpty }
203+
202204
var photos: [Photo] {
203205
get { photosOptional ?? [] }
204206
set { photosOptional = newValue }
205207
}
206208

209+
var hasComments: Bool { !comments.isEmpty }
210+
207211
var comments: [CommentResponse] {
208212
get { commentsOptional ?? [] }
209213
set { commentsOptional = newValue }
210214
}
211215

216+
var hasParticipants: Bool { !participants.isEmpty }
217+
212218
/// Пользователи, которые тренируются на этой площадке
213219
var participants: [UserResponse] {
214220
get { usersTrainHere ?? [] }

0 commit comments

Comments
 (0)