Skip to content

Commit 513dc3c

Browse files
committed
Рефактор
- Поправил отступы - Перенес заглушки для превью в PreviewContent
1 parent 0997fce commit 513dc3c

File tree

6 files changed

+129
-131
lines changed

6 files changed

+129
-131
lines changed

SwiftUI-WorkoutApp.xcodeproj/project.pbxproj

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@
113113
679F3AFF29683EB300BB3590 /* RoundedButtonLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 679F3AFE29683EB300BB3590 /* RoundedButtonLabel.swift */; };
114114
679F3B012968401700BB3590 /* AdaptiveRoundedRectangleModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 679F3B002968401700BB3590 /* AdaptiveRoundedRectangleModifier.swift */; };
115115
679F3B03296841DD00BB3590 /* URLOpener.swift in Sources */ = {isa = PBXBuildFile; fileRef = 679F3B02296841DD00BB3590 /* URLOpener.swift */; };
116-
679F3B0529689E4400BB3590 /* PreviewContent_OldXcode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 679F3B0429689E4400BB3590 /* PreviewContent_OldXcode.swift */; };
117116
679F3B072969D4E200BB3590 /* IncognitoUserButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 679F3B062969D4E200BB3590 /* IncognitoUserButton.swift */; };
118117
679F3B0C296B0A3500BB3590 /* BlacklistOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = 679F3B0B296B0A3500BB3590 /* BlacklistOption.swift */; };
119118
67A9C90528427D06005D6A36 /* SportsGroundFilter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67A9C90428427D06005D6A36 /* SportsGroundFilter.swift */; };
@@ -264,7 +263,6 @@
264263
679F3AFE29683EB300BB3590 /* RoundedButtonLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoundedButtonLabel.swift; sourceTree = "<group>"; };
265264
679F3B002968401700BB3590 /* AdaptiveRoundedRectangleModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdaptiveRoundedRectangleModifier.swift; sourceTree = "<group>"; };
266265
679F3B02296841DD00BB3590 /* URLOpener.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLOpener.swift; sourceTree = "<group>"; };
267-
679F3B0429689E4400BB3590 /* PreviewContent_OldXcode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreviewContent_OldXcode.swift; sourceTree = "<group>"; };
268266
679F3B062969D4E200BB3590 /* IncognitoUserButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IncognitoUserButton.swift; sourceTree = "<group>"; };
269267
679F3B0B296B0A3500BB3590 /* BlacklistOption.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlacklistOption.swift; sourceTree = "<group>"; };
270268
67A9C90428427D06005D6A36 /* SportsGroundFilter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SportsGroundFilter.swift; sourceTree = "<group>"; };
@@ -443,7 +441,6 @@
443441
6705E7EB283B5DCF00DABCC8 /* View+.swift */,
444442
67C87FD228435E8600D6377D /* EnvironmentValues+.swift */,
445443
6758463A2965B0F6000BA5E0 /* UIImage+.swift */,
446-
679F3B0429689E4400BB3590 /* PreviewContent_OldXcode.swift */,
447444
);
448445
path = Extensions;
449446
sourceTree = "<group>";
@@ -1026,7 +1023,6 @@
10261023
675EC6632815AA4A00C2E229 /* MapSnapshotView.swift in Sources */,
10271024
672BE762281FD4E300579183 /* AuthData.swift in Sources */,
10281025
67D9167E2838DC3E0098D3CB /* GenericListCell.swift in Sources */,
1029-
679F3B0529689E4400BB3590 /* PreviewContent_OldXcode.swift in Sources */,
10301026
6758B92A281D8FD7001D83D8 /* SportsGroundDetailViewModel.swift in Sources */,
10311027
670CA1A0280E8F9B003914A3 /* ButtonInFormLabel.swift in Sources */,
10321028
67D916812838E2460098D3CB /* DialogListView.swift in Sources */,
@@ -1211,7 +1207,7 @@
12111207
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
12121208
CODE_SIGN_STYLE = Automatic;
12131209
CURRENT_PROJECT_VERSION = 5;
1214-
DEVELOPMENT_ASSET_PATHS = "\"SwiftUI-WorkoutApp/Preview Content\"";
1210+
DEVELOPMENT_ASSET_PATHS = "SwiftUI-WorkoutApp/Preview\\ Content/PreviewContent.swift SwiftUI-WorkoutApp/Preview\\ Content";
12151211
DEVELOPMENT_TEAM = CR68PP2Z3F;
12161212
ENABLE_PREVIEWS = YES;
12171213
GENERATE_INFOPLIST_FILE = YES;
@@ -1247,7 +1243,7 @@
12471243
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
12481244
CODE_SIGN_STYLE = Automatic;
12491245
CURRENT_PROJECT_VERSION = 5;
1250-
DEVELOPMENT_ASSET_PATHS = "\"SwiftUI-WorkoutApp/Preview Content\"";
1246+
DEVELOPMENT_ASSET_PATHS = "SwiftUI-WorkoutApp/Preview\\ Content/PreviewContent.swift SwiftUI-WorkoutApp/Preview\\ Content";
12511247
DEVELOPMENT_TEAM = CR68PP2Z3F;
12521248
ENABLE_PREVIEWS = YES;
12531249
GENERATE_INFOPLIST_FILE = YES;

SwiftUI-WorkoutApp/Extensions/PreviewContent_OldXcode.swift

Lines changed: 0 additions & 108 deletions
This file was deleted.
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,123 @@
1+
#if DEBUG
2+
import Foundation
13

4+
extension Photo {
5+
static var preview: Photo {
6+
.init(id: .zero, stringURL: "avatar_default")
7+
}
8+
}
9+
10+
extension Comment {
11+
static var preview: Comment {
12+
.init(id: .zero, body: "Test comment", date: "2013-01-16T03:35:54+04:00", user: .preview)
13+
}
14+
}
15+
16+
extension SportsGround {
17+
static var preview: SportsGround {
18+
try! Bundle.main.decodeJson([SportsGround].self, fileName: "oldSportsGrounds.json").first!
19+
}
20+
}
21+
22+
extension UserResponse {
23+
static var preview: UserResponse {
24+
.init(
25+
userName: "TestUserName",
26+
fullName: "TestFullName",
27+
28+
imageStringURL: "avatar_default",
29+
birthDateIsoString: "1990-11-25",
30+
createdIsoDateTimeSec: nil,
31+
userID: .zero,
32+
cityID: 1,
33+
countryID: 17,
34+
genderCode: 1,
35+
friendsCount: 5,
36+
journalsCount: 2,
37+
friendRequestsCountString: "3",
38+
sportsGroundsCountString: "4",
39+
addedSportsGrounds: nil
40+
)
41+
}
42+
}
43+
44+
extension UserModel {
45+
static var preview: UserModel { .init(.preview) }
46+
}
47+
48+
extension EventResponse {
49+
static var preview: EventResponse {
50+
try! Bundle.main.decodeJson([EventResponse].self, fileName: "oldEvents.json").first!
51+
}
52+
}
53+
54+
extension DialogResponse {
55+
static var preview: DialogResponse {
56+
.init(
57+
id: 88777,
58+
anotherUserImageStringURL: "https://workout.su/uploads/avatars/2019/03/2019-03-21-23-03-49-rjk.jpg",
59+
anotherUserName: "WasD",
60+
lastMessageText: "Ошибка 500 это про пустые ответы? Я написал серверным.",
61+
lastMessageDate: "2022-05-14T17:35:45+00:00",
62+
anotherUserID: 30,
63+
unreadCountOptional: 5,
64+
createdDate: "2022-04-25T18:47:46+00:00"
65+
)
66+
}
67+
}
68+
69+
extension JournalResponse {
70+
static var preview: JournalResponse {
71+
.init(
72+
id: 21758,
73+
titleOptional: "Test title",
74+
lastMessageImage: "avatar_default",
75+
createDate: "2022-05-21T10:48:17+03:00",
76+
modifyDate: "2022-05-22T09:48:17+03:00",
77+
lastMessageDate: "2022-05-22T09:48:29+03:00",
78+
lastMessageText: "Test last message",
79+
ownerName: "ninenineone",
80+
itemsCount: 2,
81+
ownerID: 10367,
82+
viewAccess: 2,
83+
commentAccess: 2
84+
)
85+
}
86+
}
87+
88+
extension JournalEntryResponse {
89+
static var preview: JournalEntryResponse {
90+
.init(
91+
id: .zero,
92+
journalID: .zero,
93+
authorID: 10367,
94+
authorName: "ninenineone",
95+
message: "Test text",
96+
createDate: "2011-03-16T12:55:29+03:00",
97+
modifyDate: "2022-05-21T10:48:17+03:00",
98+
authorImage: "avatar_default"
99+
)
100+
}
101+
}
102+
103+
extension Int {
104+
static var previewUserID: Self { 30 }
105+
}
106+
107+
extension TextFieldInForm.Mode: CaseIterable, Hashable {
108+
func hash(into hasher: inout Hasher) {
109+
switch self {
110+
case let .regular(systemImageName):
111+
hasher.combine(systemImageName)
112+
case .secure:
113+
break
114+
}
115+
}
116+
117+
static func == (lhs: TextFieldInForm.Mode, rhs: TextFieldInForm.Mode) -> Bool {
118+
lhs.hashValue == rhs.hashValue
119+
}
120+
121+
static var allCases: [TextFieldInForm.Mode] { [.regular(systemImageName: "person"), .secure] }
122+
}
123+
#endif

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ final class ProfileSettingsViewModel: ObservableObject {
77
@Published private(set) var isLoading = false
88
@Published private(set) var errorMessage = ""
99

10-
init() {
11-
feedbackSender = FeedbackSenderImp()
12-
}
10+
init() { feedbackSender = FeedbackSenderImp() }
1311

1412
func feedbackAction() {
1513
feedbackSender.sendFeedback(

SwiftUI-WorkoutApp/Screens/SportsGrounds/Map/MapViewUI.swift

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,7 @@ struct MapViewUI: UIViewRepresentable {
5858
mapView.setRegion(region, animated: false)
5959
needUpdateRegion.toggle()
6060
}
61-
if ignoreUserLocation {
62-
setTrackingButtonHidden(true, on: mapView)
63-
} else {
64-
setTrackingButtonHidden(false, on: mapView)
65-
}
61+
setTrackingButtonHidden(ignoreUserLocation, on: mapView)
6662
}
6763

6864
func makeCoordinator() -> MapCoordinator { .init(self) }
@@ -98,9 +94,7 @@ final class MapCoordinator: NSObject, MKMapViewDelegate {
9894
private let clusterIdentifier = "Cluster"
9995
private let parent: MapViewUI
10096

101-
init(_ parent: MapViewUI) {
102-
self.parent = parent
103-
}
97+
init(_ parent: MapViewUI) { self.parent = parent }
10498

10599
func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
106100
if view.annotation is SportsGround {
@@ -110,9 +104,7 @@ final class MapCoordinator: NSObject, MKMapViewDelegate {
110104
}
111105

112106
func mapView(_ mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {
113-
if let place = view.annotation as? SportsGround {
114-
parent.openSelected(place)
115-
}
107+
if let place = view.annotation as? SportsGround { parent.openSelected(place) }
116108
}
117109

118110
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {

SwiftUI-WorkoutApp/Screens/SportsGrounds/Map/SportsGroundsMapView.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ struct SportsGroundsMapView: View {
5858
.disabled(isLeftToolbarPartDisabled)
5959
}
6060
ToolbarItem(placement: .navigationBarTrailing) {
61-
if defaults.isAuthorized {
62-
createGroundButton
63-
}
61+
if defaults.isAuthorized { createGroundButton }
6462
}
6563
}
6664
.navigationTitle("Площадки")

0 commit comments

Comments
 (0)