Skip to content

Commit 4718aa3

Browse files
committed
Сделал отдельный пакет для NetworkStatus
- Обновил нейминг: CheckNetworkService -> NetworkStatus - Вынес NetworkStatus в отдельный пакет - Поднял версию билда до 13
1 parent 370e8a8 commit 4718aa3

File tree

29 files changed

+132
-53
lines changed

29 files changed

+132
-53
lines changed

SwiftUI-WorkoutApp.xcodeproj/project.pbxproj

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134
67BAF3FB28362AD100DB40D9 /* AddCommentButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67BAF3FA28362AD100DB40D9 /* AddCommentButton.swift */; };
135135
67C87FD62843892D00D6377D /* PhotoSectionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67C87FD52843892D00D6377D /* PhotoSectionCell.swift */; };
136136
67C87FD828438F1600D6377D /* PhotoContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67C87FD728438F1600D6377D /* PhotoContainer.swift */; };
137+
67CB32CE297BBEB3009380DF /* NetworkStatus in Frameworks */ = {isa = PBXBuildFile; productRef = 67CB32CD297BBEB3009380DF /* NetworkStatus */; };
137138
67D9167C2838D6610098D3CB /* DialogResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67D9167B2838D6610098D3CB /* DialogResponse.swift */; };
138139
67D9167E2838DC3E0098D3CB /* GenericListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67D9167D2838DC3E0098D3CB /* GenericListCell.swift */; };
139140
67D916812838E2460098D3CB /* DialogListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67D916802838E2460098D3CB /* DialogListView.swift */; };
@@ -142,7 +143,6 @@
142143
67D916882838F4C40098D3CB /* DialogViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67D916872838F4C40098D3CB /* DialogViewModel.swift */; };
143144
67D9168A2838F79D0098D3CB /* MessageResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67D916892838F79D0098D3CB /* MessageResponse.swift */; };
144145
67D9169628396C1E0098D3CB /* SendMessageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67D9169528396C1E0098D3CB /* SendMessageView.swift */; };
145-
67D91698283A22840098D3CB /* CheckNetworkService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67D91697283A22840098D3CB /* CheckNetworkService.swift */; };
146146
67DD1120282C3CE400E3917C /* TextEntryViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67DD111F282C3CE400E3917C /* TextEntryViewModel.swift */; };
147147
67E4266D2821429500DF82A7 /* UserModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67E4266C2821429500DF82A7 /* UserModel.swift */; };
148148
67E4266F28218B6E00DF82A7 /* ShortAddressService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67E4266E28218B6E00DF82A7 /* ShortAddressService.swift */; };
@@ -293,6 +293,7 @@
293293
67BAF3FA28362AD100DB40D9 /* AddCommentButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddCommentButton.swift; sourceTree = "<group>"; };
294294
67C87FD52843892D00D6377D /* PhotoSectionCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhotoSectionCell.swift; sourceTree = "<group>"; };
295295
67C87FD728438F1600D6377D /* PhotoContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhotoContainer.swift; sourceTree = "<group>"; };
296+
67CB32CC297BBE03009380DF /* NetworkStatus */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = NetworkStatus; path = "SwiftUI-WorkoutApp/NetworkStatus"; sourceTree = "<group>"; };
296297
67D9167B2838D6610098D3CB /* DialogResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DialogResponse.swift; sourceTree = "<group>"; };
297298
67D9167D2838DC3E0098D3CB /* GenericListCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GenericListCell.swift; sourceTree = "<group>"; };
298299
67D916802838E2460098D3CB /* DialogListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DialogListView.swift; sourceTree = "<group>"; };
@@ -301,7 +302,6 @@
301302
67D916872838F4C40098D3CB /* DialogViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DialogViewModel.swift; sourceTree = "<group>"; };
302303
67D916892838F79D0098D3CB /* MessageResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageResponse.swift; sourceTree = "<group>"; };
303304
67D9169528396C1E0098D3CB /* SendMessageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SendMessageView.swift; sourceTree = "<group>"; };
304-
67D91697283A22840098D3CB /* CheckNetworkService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckNetworkService.swift; sourceTree = "<group>"; };
305305
67DD111F282C3CE400E3917C /* TextEntryViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextEntryViewModel.swift; sourceTree = "<group>"; };
306306
67E4266C2821429500DF82A7 /* UserModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserModel.swift; sourceTree = "<group>"; };
307307
67E4266E28218B6E00DF82A7 /* ShortAddressService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShortAddressService.swift; sourceTree = "<group>"; };
@@ -326,6 +326,7 @@
326326
672609522977256900042226 /* CachedAcyncImage in Frameworks */,
327327
67F9534F2964A5700077DFDC /* ImagePicker in Frameworks */,
328328
675A370A2854810B00DAE071 /* Utils in Frameworks */,
329+
67CB32CE297BBEB3009380DF /* NetworkStatus in Frameworks */,
329330
);
330331
runOnlyForDeploymentPostprocessing = 0;
331332
};
@@ -576,6 +577,7 @@
576577
6798AA31280AEDC900DB76F1 = {
577578
isa = PBXGroup;
578579
children = (
580+
67CB32CC297BBE03009380DF /* NetworkStatus */,
579581
672609502977250B00042226 /* CachedAcyncImage */,
580582
675A3707285480E600DAE071 /* Utils */,
581583
6798AA3C280AEDC900DB76F1 /* SwiftUI-WorkoutApp */,
@@ -693,7 +695,6 @@
693695
67B78711281D654C008B104F /* DefaultsService.swift */,
694696
67E4266E28218B6E00DF82A7 /* ShortAddressService.swift */,
695697
674B37AB282B9332001A5B66 /* FormatterService.swift */,
696-
67D91697283A22840098D3CB /* CheckNetworkService.swift */,
697698
67B65DAC289E860E00FBAFCB /* ErrorFilterService.swift */,
698699
679F3B02296841DD00BB3590 /* URLOpener.swift */,
699700
);
@@ -897,6 +898,7 @@
897898
670431502964544D0090CAC3 /* FeedbackSender */,
898899
67F9534E2964A5700077DFDC /* ImagePicker */,
899900
672609512977256900042226 /* CachedAcyncImage */,
901+
67CB32CD297BBEB3009380DF /* NetworkStatus */,
900902
);
901903
productName = "SwiftUI-WorkoutApp";
902904
productReference = 6798AA3A280AEDC900DB76F1 /* WorkoutApp.app */;
@@ -1108,7 +1110,6 @@
11081110
67D9169628396C1E0098D3CB /* SendMessageView.swift in Sources */,
11091111
6758B936281E5EA9001D83D8 /* APIService.swift in Sources */,
11101112
6747575928128603002F0A24 /* SportsGroundDetailView.swift in Sources */,
1111-
67D91698283A22840098D3CB /* CheckNetworkService.swift in Sources */,
11121113
675EC6572815433600C2E229 /* UsersListView.swift in Sources */,
11131114
67B78710281D6110008B104F /* LoginViewModel.swift in Sources */,
11141115
675EC65F2815532800C2E229 /* EventFormView.swift in Sources */,
@@ -1316,7 +1317,7 @@
13161317
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
13171318
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
13181319
CODE_SIGN_STYLE = Automatic;
1319-
CURRENT_PROJECT_VERSION = 12;
1320+
CURRENT_PROJECT_VERSION = 13;
13201321
DEVELOPMENT_ASSET_PATHS = "SwiftUI-WorkoutApp/Preview\\ Content/PreviewContent.swift SwiftUI-WorkoutApp/Preview\\ Content";
13211322
DEVELOPMENT_TEAM = CR68PP2Z3F;
13221323
ENABLE_PREVIEWS = YES;
@@ -1352,7 +1353,7 @@
13521353
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
13531354
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
13541355
CODE_SIGN_STYLE = Automatic;
1355-
CURRENT_PROJECT_VERSION = 12;
1356+
CURRENT_PROJECT_VERSION = 13;
13561357
DEVELOPMENT_ASSET_PATHS = "SwiftUI-WorkoutApp/Preview\\ Content/PreviewContent.swift SwiftUI-WorkoutApp/Preview\\ Content";
13571358
DEVELOPMENT_TEAM = CR68PP2Z3F;
13581359
ENABLE_PREVIEWS = YES;
@@ -1447,6 +1448,10 @@
14471448
isa = XCSwiftPackageProductDependency;
14481449
productName = Utils;
14491450
};
1451+
67CB32CD297BBEB3009380DF /* NetworkStatus */ = {
1452+
isa = XCSwiftPackageProductDependency;
1453+
productName = NetworkStatus;
1454+
};
14501455
67F9534E2964A5700077DFDC /* ImagePicker */ = {
14511456
isa = XCSwiftPackageProductDependency;
14521457
package = 67F9534D2964A5700077DFDC /* XCRemoteSwiftPackageReference "ImagePicker" */;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.DS_Store
2+
/.build
3+
/Packages
4+
/*.xcodeproj
5+
xcuserdata/
6+
DerivedData/
7+
.swiftpm/config/registries.json
8+
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
9+
.netrc
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// swift-tools-version: 5.6
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "NetworkStatus",
8+
platforms: [.iOS(.v15)],
9+
products: [
10+
// Products define the executables and libraries a package produces, and make them visible to other packages.
11+
.library(
12+
name: "NetworkStatus",
13+
targets: ["NetworkStatus"]),
14+
],
15+
dependencies: [
16+
// Dependencies declare other packages that this package depends on.
17+
// .package(url: /* package url */, from: "1.0.0"),
18+
],
19+
targets: [
20+
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
21+
// Targets can depend on other targets in this package, and on products in packages this package depends on.
22+
.target(
23+
name: "NetworkStatus",
24+
dependencies: []),
25+
.testTarget(
26+
name: "NetworkStatusTests",
27+
dependencies: ["NetworkStatus"]),
28+
]
29+
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# NetworkStatus
2+
3+
Показывает статус подключения к сети

SwiftUI-WorkoutApp/Services/CheckNetworkService.swift renamed to SwiftUI-WorkoutApp/NetworkStatus/Sources/NetworkStatus/NetworkStatus.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import Foundation
22
import Network
33

4-
final class CheckNetworkService: ObservableObject {
4+
public final class NetworkStatus: ObservableObject {
55
private let monitor = NWPathMonitor()
66
private let queue = DispatchQueue.global(qos: .background)
77

8-
@Published var isConnected = false
8+
@Published public private(set) var isConnected = false
99

10-
init() {
10+
public init() {
1111
monitor.pathUpdateHandler = { [weak self] path in
1212
OperationQueue.main.addOperation {
1313
self?.isConnected = path.status == .satisfied ? true : false
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import XCTest
2+
@testable import NetworkStatus
3+
4+
final class NetworkStatusTests: XCTestCase {
5+
func testExample() throws {
6+
// This is an example of a functional test case.
7+
// Use XCTAssert and related functions to verify your tests produce the correct
8+
// results.
9+
}
10+
}

SwiftUI-WorkoutApp/Screens/Common/Comments/CommentViewCell.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import SwiftUI
2+
import NetworkStatus
23

34
struct CommentViewCell: View {
4-
@EnvironmentObject private var network: CheckNetworkService
5+
@EnvironmentObject private var network: NetworkStatus
56
@EnvironmentObject private var defaults: DefaultsService
67
let model: Comment
78
let reportClbk: (Comment) -> Void
@@ -86,7 +87,7 @@ struct SportsGroundCommentView_Previews: PreviewProvider {
8687
deleteClbk: { _ in },
8788
editClbk: { _ in }
8889
)
89-
.environmentObject(CheckNetworkService())
90+
.environmentObject(NetworkStatus())
9091
.environmentObject(DefaultsService())
9192
.previewLayout(.sizeThatFits)
9293
}

SwiftUI-WorkoutApp/Screens/Common/Comments/Comments.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import SwiftUI
2+
import NetworkStatus
23

34
/// Список комментариев
45
struct Comments: View {
@@ -33,7 +34,7 @@ struct Comments_Previews: PreviewProvider {
3334
)
3435
}
3536
.environmentObject(DefaultsService())
36-
.environmentObject(CheckNetworkService())
37+
.environmentObject(NetworkStatus())
3738
}
3839
}
3940
#endif

SwiftUI-WorkoutApp/Screens/Common/EmptyContentView.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import SwiftUI
2+
import NetworkStatus
23

34
/// Заглушка на случай, когда нет контента
45
struct EmptyContentView: View {
5-
@EnvironmentObject private var network: CheckNetworkService
6+
@EnvironmentObject private var network: NetworkStatus
67
@EnvironmentObject private var defaults: DefaultsService
78
let mode: Mode
89
let action: () -> Void
@@ -86,7 +87,7 @@ struct EmptyContentView_Previews: PreviewProvider {
8687
ForEach(EmptyContentView.Mode.allCases, id: \.self) { mode in
8788
EmptyContentView(mode: mode, action: {})
8889
}
89-
.environmentObject(CheckNetworkService())
90+
.environmentObject(NetworkStatus())
9091
.environmentObject(DefaultsService())
9192
.previewLayout(.sizeThatFits)
9293
}

SwiftUI-WorkoutApp/Screens/Common/GenericListCell.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import SwiftUI
2+
import NetworkStatus
23

34
/// Ячейка для экранов с дневниками и диалогами
45
struct GenericListCell: View {
5-
@EnvironmentObject private var network: CheckNetworkService
6+
@EnvironmentObject private var network: NetworkStatus
67
@EnvironmentObject private var defaults: DefaultsService
78
private let mode: Mode
89

@@ -123,7 +124,7 @@ private extension GenericListCell {
123124
struct GenericListCell_Previews: PreviewProvider {
124125
static var previews: some View {
125126
GenericListCell(for: .dialog(.preview))
126-
.environmentObject(CheckNetworkService())
127+
.environmentObject(NetworkStatus())
127128
.previewLayout(.sizeThatFits)
128129
}
129130
}

0 commit comments

Comments
 (0)