Skip to content

Commit bde6cf0

Browse files
committed
WIP: Remote trackers list
1 parent 1ad5c18 commit bde6cf0

File tree

14 files changed

+421
-34
lines changed

14 files changed

+421
-34
lines changed

ProgressWidget/ProgressWidgetLiveActivity.swift

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,9 @@ struct ProgressWidgetLiveActivity: Widget {
3838
// Lock screen/banner UI goes here
3939

4040
if #available(iOS 18, *) {
41-
#if XCODE16
4241
ProgressWidgetLiveActivityWatchSupportContent(context: context)
4342
.tint(Color(uiColor: context.tintColor))
4443
.padding()
45-
#else
46-
ProgressWidgetLiveActivityContent(context: context)
47-
.tint(Color(uiColor: context.tintColor))
48-
.padding()
49-
#endif
50-
5144
} else {
5245
ProgressWidgetLiveActivityContent(context: context)
5346
.tint(Color(uiColor: context.tintColor))
@@ -105,18 +98,13 @@ struct ProgressWidgetLiveActivity: Widget {
10598
}
10699

107100
if #available(iOS 18.0, *) {
108-
#if XCODE16
109101
return config.supplementalActivityFamilies([.small])
110-
#else
111-
return config
112-
#endif
113102
} else {
114103
return config
115104
}
116105
}
117106
}
118107

119-
#if XCODE16
120108
@available(iOS 18.0, *)
121109
struct ProgressWidgetLiveActivityWatchSupportContent: View {
122110
@Environment(\.activityFamily) var activityFamily
@@ -180,7 +168,6 @@ struct ProgressWidgetLiveActivityWatchSupportContent: View {
180168
}
181169
}
182170
}
183-
#endif
184171

185172
struct ProgressWidgetLiveActivityContent: View {
186173
@State var context: ActivityViewContext<ProgressWidgetAttributes>

iTorrent.xcodeproj/project.pbxproj

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@
186186
D1B99D932BEE631B00F51514 /* Benefit.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1B99D8F2BEE631B00F51514 /* Benefit.swift */; };
187187
D1B99D942BEE631B00F51514 /* Tier.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1B99D902BEE631B00F51514 /* Tier.swift */; };
188188
D1B99D962BEE657F00F51514 /* API.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1B99D952BEE657F00F51514 /* API.swift */; };
189+
D1BB073B2C98524B00981D5F /* TrackersListService.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1BB073A2C98524A00981D5F /* TrackersListService.swift */; };
190+
D1BB07432C985EB800981D5F /* TrackersListPreferencesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1BB07422C985EAE00981D5F /* TrackersListPreferencesView.swift */; };
191+
D1BB07452C9869C300981D5F /* TrackersListDetailsPreferencesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1BB07442C9869B900981D5F /* TrackersListDetailsPreferencesView.swift */; };
189192
D1CAB8852AF3B51E00EB6AFF /* ToggleCellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1CAB8842AF3B51E00EB6AFF /* ToggleCellView.swift */; };
190193
D1CAB8872AF3B52E00EB6AFF /* ToggleCellViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1CAB8862AF3B52E00EB6AFF /* ToggleCellViewModel.swift */; };
191194
D1D1279B2BC7CA7600C04533 /* SwiftUILayoutGuides.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1D1279A2BC7CA7600C04533 /* SwiftUILayoutGuides.swift */; };
@@ -418,6 +421,9 @@
418421
D1B99D8F2BEE631B00F51514 /* Benefit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Benefit.swift; sourceTree = "<group>"; };
419422
D1B99D902BEE631B00F51514 /* Tier.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Tier.swift; sourceTree = "<group>"; };
420423
D1B99D952BEE657F00F51514 /* API.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = API.swift; sourceTree = "<group>"; };
424+
D1BB073A2C98524A00981D5F /* TrackersListService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrackersListService.swift; sourceTree = "<group>"; };
425+
D1BB07422C985EAE00981D5F /* TrackersListPreferencesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrackersListPreferencesView.swift; sourceTree = "<group>"; };
426+
D1BB07442C9869B900981D5F /* TrackersListDetailsPreferencesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrackersListDetailsPreferencesView.swift; sourceTree = "<group>"; };
421427
D1CAB8842AF3B51E00EB6AFF /* ToggleCellView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToggleCellView.swift; sourceTree = "<group>"; };
422428
D1CAB8862AF3B52E00EB6AFF /* ToggleCellViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToggleCellViewModel.swift; sourceTree = "<group>"; };
423429
D1D1279A2BC7CA7600C04533 /* SwiftUILayoutGuides.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftUILayoutGuides.swift; sourceTree = "<group>"; };
@@ -793,6 +799,7 @@
793799
D111384C2AF9663F008907F7 /* Preferences */ = {
794800
isa = PBXGroup;
795801
children = (
802+
D1BB07412C985E9700981D5F /* TrackersList */,
796803
7C95B7A32C34B554000EC50F /* Storage */,
797804
D1DB718E2BD92206007F9267 /* Patreon */,
798805
7CB6F6CC2BD82B8A00D0813B /* FileSharing */,
@@ -1118,6 +1125,7 @@
11181125
D1A226F02AEF018500669D6D /* Services */ = {
11191126
isa = PBXGroup;
11201127
children = (
1128+
D1BB07392C98522D00981D5F /* TrackersListService */,
11211129
7C1C08AE2C31FEF700569B45 /* IntentsService */,
11221130
7C3142D42C31ED4600397E82 /* LiveActivityService */,
11231131
D1B99D842BEE5E4100F51514 /* Patreon */,
@@ -1256,6 +1264,23 @@
12561264
path = Models;
12571265
sourceTree = "<group>";
12581266
};
1267+
D1BB07392C98522D00981D5F /* TrackersListService */ = {
1268+
isa = PBXGroup;
1269+
children = (
1270+
D1BB073A2C98524A00981D5F /* TrackersListService.swift */,
1271+
);
1272+
path = TrackersListService;
1273+
sourceTree = "<group>";
1274+
};
1275+
D1BB07412C985E9700981D5F /* TrackersList */ = {
1276+
isa = PBXGroup;
1277+
children = (
1278+
D1BB07442C9869B900981D5F /* TrackersListDetailsPreferencesView.swift */,
1279+
D1BB07422C985EAE00981D5F /* TrackersListPreferencesView.swift */,
1280+
);
1281+
path = TrackersList;
1282+
sourceTree = "<group>";
1283+
};
12591284
D1CAB8832AF3B50C00EB6AFF /* ToggleCell */ = {
12601285
isa = PBXGroup;
12611286
children = (
@@ -1539,6 +1564,7 @@
15391564
D11138552AF97511008907F7 /* TorrentAddFileItemViewModel.swift in Sources */,
15401565
D11333B52AF19C4900FA017E /* TorrentHandle+Extension.swift in Sources */,
15411566
D19E00202AEFFA1B000A17A2 /* DetailCellView.swift in Sources */,
1567+
D1BB07452C9869C300981D5F /* TrackersListDetailsPreferencesView.swift in Sources */,
15421568
D1ACFDC62AF6DB9F0098FF56 /* TorrentFilesFileListCell.swift in Sources */,
15431569
D1A227072AEF0B2C00669D6D /* TorrentListItem.swift in Sources */,
15441570
D111384B2AF965F1008907F7 /* TorrentAddViewModel.swift in Sources */,
@@ -1602,6 +1628,7 @@
16021628
7CFEBE7C2BC4318E0013233F /* RssChannelViewController.swift in Sources */,
16031629
7C5FBE2C2BBDD6B40069E5A0 /* UIView+LayerColors.swift in Sources */,
16041630
7C4ED08D2BE646E40034B62C /* AdView+Meta.swift in Sources */,
1631+
D1BB07432C985EB800981D5F /* TrackersListPreferencesView.swift in Sources */,
16051632
D1B538572AF1171900694AFD /* TorrentDetailProgressCellView.swift in Sources */,
16061633
7C5FBE742BC2F0A30069E5A0 /* MvvmViewModelProtocol+Alert.swift in Sources */,
16071634
D1EFCD122AF572E400D33A7A /* TorrentFilesFileItemViewModel.swift in Sources */,
@@ -1672,6 +1699,7 @@
16721699
D1DB71802BD6773E007F9267 /* RssSearchViewModel.swift in Sources */,
16731700
D17733EE2BBC2C5F006FC81A /* ProxyPreferencesViewModel.swift in Sources */,
16741701
7CF6DA3E2C0F9DC40033D03F /* LiveActivityService.swift in Sources */,
1702+
D1BB073B2C98524B00981D5F /* TrackersListService.swift in Sources */,
16751703
7C4ED0982BEF8B8E0034B62C /* PatreonCredentials.swift in Sources */,
16761704
D173D9E12BC0286800E4F9EB /* UIMenu+Priority.swift in Sources */,
16771705
D1AA00CE2AFA8B1000B74629 /* PreferencesStorage.swift in Sources */,
@@ -1744,6 +1772,7 @@
17441772
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "iTorrent2 ProgressWidget Dev";
17451773
SKIP_INSTALL = YES;
17461774
SUPPORTS_MACCATALYST = YES;
1775+
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$inherited XCODE16";
17471776
SWIFT_EMIT_LOC_STRINGS = YES;
17481777
TARGETED_DEVICE_FAMILY = "1,2";
17491778
};
@@ -1891,6 +1920,7 @@
18911920
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "iTorrent2 ProgressWidget Dev";
18921921
SKIP_INSTALL = YES;
18931922
SUPPORTS_MACCATALYST = YES;
1923+
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$inherited XCODE16";
18941924
SWIFT_EMIT_LOC_STRINGS = YES;
18951925
TARGETED_DEVICE_FAMILY = "1,2";
18961926
};
@@ -2033,6 +2063,7 @@
20332063
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "iTorrent2 ProgressWidget Distrib";
20342064
SKIP_INSTALL = YES;
20352065
SUPPORTS_MACCATALYST = YES;
2066+
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$inherited XCODE16";
20362067
SWIFT_EMIT_LOC_STRINGS = YES;
20372068
TARGETED_DEVICE_FAMILY = "1,2";
20382069
};

iTorrent/Core/Assets/Localizable.xcstrings

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4912,6 +4912,22 @@
49124912
}
49134913
}
49144914
},
4915+
"preferences.network.trackers" : {
4916+
"localizations" : {
4917+
"en" : {
4918+
"stringUnit" : {
4919+
"state" : "translated",
4920+
"value" : "Trackers sources"
4921+
}
4922+
},
4923+
"ru" : {
4924+
"stringUnit" : {
4925+
"state" : "translated",
4926+
"value" : "Источники трекеров"
4927+
}
4928+
}
4929+
}
4930+
},
49154931
"preferences.notifications" : {
49164932
"localizations" : {
49174933
"en" : {
@@ -5780,6 +5796,76 @@
57805796
}
57815797
}
57825798
},
5799+
"preferences.trackers.add.title" : {
5800+
"localizations" : {
5801+
"en" : {
5802+
"stringUnit" : {
5803+
"state" : "translated",
5804+
"value" : "Add trackers list"
5805+
}
5806+
}
5807+
}
5808+
},
5809+
"preferences.trackers.add.titlePlaceholder" : {
5810+
"localizations" : {
5811+
"en" : {
5812+
"stringUnit" : {
5813+
"state" : "translated",
5814+
"value" : "Title"
5815+
}
5816+
}
5817+
}
5818+
},
5819+
"preferences.trackers.add.urlPlaceholder" : {
5820+
"localizations" : {
5821+
"en" : {
5822+
"stringUnit" : {
5823+
"state" : "translated",
5824+
"value" : "URL to trackers source file"
5825+
}
5826+
}
5827+
}
5828+
},
5829+
"preferences.trackers.exists.title" : {
5830+
"localizations" : {
5831+
"en" : {
5832+
"stringUnit" : {
5833+
"state" : "translated",
5834+
"value" : "This tracker list already added"
5835+
}
5836+
}
5837+
}
5838+
},
5839+
"preferences.trackers.remove.message" : {
5840+
"localizations" : {
5841+
"en" : {
5842+
"stringUnit" : {
5843+
"state" : "translated",
5844+
"value" : "Do you want to remove this trackers source?"
5845+
}
5846+
}
5847+
}
5848+
},
5849+
"preferences.trackers.remove.title" : {
5850+
"localizations" : {
5851+
"en" : {
5852+
"stringUnit" : {
5853+
"state" : "translated",
5854+
"value" : "Remove source"
5855+
}
5856+
}
5857+
}
5858+
},
5859+
"preferences.trackers.rename.title" : {
5860+
"localizations" : {
5861+
"en" : {
5862+
"stringUnit" : {
5863+
"state" : "translated",
5864+
"value" : "Rename source"
5865+
}
5866+
}
5867+
}
5868+
},
57835869
"preferences.version" : {
57845870
"localizations" : {
57855871
"en" : {

iTorrent/Core/SceneDelegate/SceneDelegate.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class SceneDelegate: MvvmSceneDelegate {
2424
container.registerSingleton(factory: { BackgroundService.shared })
2525
container.registerSingleton(factory: NetworkMonitoringService.init)
2626
container.registerSingleton(factory: ImageLoader.init)
27+
container.registerSingleton(factory: TrackersListService.init)
2728
container.registerDaemon(factory: PatreonService.init)
2829
container.registerDaemon(factory: TorrentMonitoringService.init)
2930
container.registerDaemon(factory: RssFeedProvider.init)
@@ -62,6 +63,8 @@ class SceneDelegate: MvvmSceneDelegate {
6263

6364
router.register(BasePreferencesViewController<PreferencesViewModel>.self)
6465
router.register(BasePreferencesViewController<ProxyPreferencesViewModel>.self)
66+
router.register(TrackersListPreferencesViewController.self)
67+
router.register(TrackersListDetailsPreferencesViewController.self)
6568
router.register(BasePreferencesViewController<ConnectionPreferencesViewModel>.self)
6669
router.register(BasePreferencesViewController<FileSharingPreferencesViewModel>.self)
6770
router.register(PreferencesSectionGroupingViewController.self)

iTorrent/Screens/Preferences/Root/PreferencesViewModel.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ private extension PreferencesViewModel {
143143
PRButtonViewModel(with: .init(title: %"preferences.network.proxy", accessories: [.disclosureIndicator()]) { [unowned self] in
144144
navigate(to: ProxyPreferencesViewModel.self, by: .show)
145145
})
146+
PRButtonViewModel(with: .init(title: %"preferences.network.trackers", accessories: [.disclosureIndicator()]) { [unowned self] in
147+
navigate(to: TrackersListPreferencesViewModel.self, by: .show)
148+
})
146149
PRButtonViewModel(with: .init(title: %"preferences.network.connection", accessories: [.disclosureIndicator()]) { [unowned self] in
147150
navigate(to: ConnectionPreferencesViewModel.self, by: .show)
148151
})
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//
2+
// TrackersListDetailsPreferencesView.swift
3+
// iTorrent
4+
//
5+
// Created by Daniil Vinogradov on 16/09/2024.
6+
//
7+
8+
import LibTorrent
9+
import MvvmFoundation
10+
import SwiftUI
11+
12+
class TrackersListDetailsPreferencesViewModel: BaseViewModelWith<TrackersListService.ListState>, ObservableObject {
13+
@Published var trackers: [String] = []
14+
@Published var title: String = ""
15+
16+
override func prepare(with model: TrackersListService.ListState) {
17+
trackers = model.trackers
18+
title = model.title
19+
}
20+
}
21+
22+
struct TrackersListDetailsPreferencesView<VM: TrackersListDetailsPreferencesViewModel>: MvvmSwiftUIViewProtocol {
23+
@ObservedObject var viewModel: VM
24+
var title: String
25+
26+
init(viewModel: VM) {
27+
self.viewModel = viewModel
28+
title = viewModel.title
29+
}
30+
31+
var body: some View {
32+
List {
33+
Section {
34+
ForEach(viewModel.trackers, id: \.self) { tracker in
35+
Text(tracker)
36+
}
37+
}
38+
}
39+
}
40+
}
41+
42+
class TrackersListDetailsPreferencesViewController: BaseHostingViewController<TrackersListDetailsPreferencesView<TrackersListDetailsPreferencesViewModel>> {
43+
44+
}

0 commit comments

Comments
 (0)