Skip to content

Commit be53e86

Browse files
committed
Вынес ссылки из констант во вьюмодели
1 parent f3dd56f commit be53e86

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,13 @@ public enum Constants {
44
public static let minPasswordSize = 6
55
public static let photosLimit = 15
66
public static let minUserAge = Calendar.current.date(byAdding: .year, value: -13, to: .now) ?? .now
7-
public static let maxEventFutureDate = Calendar.current.date(byAdding: .year, value: 1, to: .now) ?? .now
87
public static let authInvitationText = "Авторизуйтесь, чтобы иметь доступ ко всем возможностям"
98
public static let registrationInfoText = "Регистрация доступна на сайте workout.su"
109
public static let appVersion = (Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String).valueOrEmpty
11-
public static let appReviewURL = URL(string: "https://apps.apple.com/app/id1035159361?action=write-review")!
12-
public static let workoutShopURL = URL(string: "https://workoutshop.ru")!
13-
public static let developerProfileButton = URL(string: "https://boosty.to/oleg991")!
14-
public static let officialSiteURL = URL(string: "https://workout.su")!
15-
public static let accountCreationURL = URL(string: "https://m.workout.su/users/register")!
1610
public static let feedbackRecipient = ["info@workout.su"]
1711

1812
public enum RulesOfService {
1913
public static let registrationForm = "Принимаю условия **[пользовательского соглашения](https://workout.su/pravila)**"
20-
public static let aboutApp = URL(string: "https://workout.su/pravila")!
2114
}
2215

2316
public enum Alert {

SwiftUI-WorkoutApp/Screens/Common/SafariVCRepresentable.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ struct SafariVCRepresentable: UIViewControllerRepresentable {
1515
#if DEBUG
1616
struct SafariVCRepresentable_Previews: PreviewProvider {
1717
static var previews: some View {
18-
SafariVCRepresentable(url: Constants.accountCreationURL)
18+
let accountCreationURL = URL(string: "https://m.workout.su/users/register")!
19+
SafariVCRepresentable(url: accountCreationURL)
1920
}
2021
}
2122
#endif

SwiftUI-WorkoutApp/Screens/Events/Form/EventFormView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private extension EventFormView {
100100
DatePicker(
101101
"Дата и время",
102102
selection: $viewModel.eventForm.date,
103-
in: .now ... Constants.maxEventFutureDate
103+
in: .now ... viewModel.maxEventFutureDate
104104
)
105105
.labelsHidden()
106106
}

SwiftUI-WorkoutApp/Screens/Events/Form/EventFormViewModel.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import UIKit.UIImage
66
final class EventFormViewModel: ObservableObject {
77
private var eventID: Int?
88
private let oldEventForm: EventForm
9+
let maxEventFutureDate = Calendar.current.date(byAdding: .year, value: 1, to: .now) ?? .now
910
@Published var eventForm: EventForm
1011
@Published private(set) var isLoading = false
1112
@Published private(set) var errorMessage = ""

SwiftUI-WorkoutApp/Screens/Profile/Settings/ProfileSettingsView.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,19 +150,19 @@ private extension ProfileSettingsView {
150150
}
151151

152152
var rateAppButton: some View {
153-
Link(destination: Constants.appReviewURL) {
153+
Link(destination: viewModel.appReviewURL) {
154154
Label("Оценить приложение", systemImage: "star.bubble.fill")
155155
}
156156
}
157157

158158
var userAgreementButton: some View {
159-
Link(destination: Constants.RulesOfService.aboutApp) {
159+
Link(destination: viewModel.rulesOfServiceURL) {
160160
Label("Пользовательское соглашение", systemImage: "doc.text.fill")
161161
}
162162
}
163163

164164
var officialSiteButton: some View {
165-
Link(destination: Constants.officialSiteURL) {
165+
Link(destination: viewModel.officialSiteURL) {
166166
Label("Официальный сайт", systemImage: "w.circle.fill")
167167
}
168168
}
@@ -173,13 +173,13 @@ private extension ProfileSettingsView {
173173
}
174174

175175
var workoutShopButton: some View {
176-
Link(destination: Constants.workoutShopURL) {
176+
Link(destination: viewModel.workoutShopURL) {
177177
Label("Магазин WORKOUT", systemImage: "bag.fill")
178178
}
179179
}
180180

181181
var developerProfileButton: some View {
182-
Link(destination: Constants.developerProfileButton) {
182+
Link(destination: viewModel.developerProfileURL) {
183183
Label("Oleg991 на boosty", systemImage: "figure.wave")
184184
}
185185
}

SwiftUI-WorkoutApp/Screens/Profile/Settings/ProfileSettingsViewModel.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ import SWModels
55
@MainActor
66
final class ProfileSettingsViewModel: ObservableObject {
77
private let feedbackSender: FeedbackSender
8+
let appReviewURL = URL(string: "https://apps.apple.com/app/id1035159361?action=write-review")!
9+
let workoutShopURL = URL(string: "https://workoutshop.ru")!
10+
let developerProfileURL = URL(string: "https://boosty.to/oleg991")!
11+
let officialSiteURL = URL(string: "https://workout.su")!
12+
let rulesOfServiceURL = URL(string: "https://workout.su/pravila")!
813
@Published private(set) var isLoading = false
914
@Published private(set) var errorMessage = ""
1015

0 commit comments

Comments
 (0)