Skip to content

Commit

Permalink
Mac Catalyst support added
Browse files Browse the repository at this point in the history
  • Loading branch information
XITRIX committed Apr 9, 2024
1 parent 43d0ef2 commit f6ecc22
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 7 deletions.
2 changes: 2 additions & 0 deletions ProgressWidget/ProgressWidgetBundle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import WidgetKit
struct ProgressWidgetBundle: WidgetBundle {
var body: some Widget {
// ProgressWidget()
#if canImport(ActivityKit)
ProgressWidgetLiveActivity()
#endif
}
}
2 changes: 2 additions & 0 deletions ProgressWidget/ProgressWidgetLiveActivity.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Created by Даниил Виноградов on 06.04.2024.
//

#if canImport(ActivityKit)
import ActivityKit
import SwiftUI
import WidgetKit
Expand Down Expand Up @@ -88,3 +89,4 @@ struct ProgressWidgetLiveActivity: Widget {
// ProgressWidgetAttributes.ContentState(progress: 0.2, downSpeed: 2000, upSpeed: 1000, timeRemainig: "Осталось САСАТБ", timeStamp: .now)
// ProgressWidgetAttributes.ContentState(progress: 0.7, downSpeed: 12000000, upSpeed: 1000000, timeRemainig: "Осталось САСАТБ", timeStamp: .now)
//}
#endif
2 changes: 1 addition & 1 deletion Submodules/LibTorrent-Swift
2 changes: 1 addition & 1 deletion iTorrent/Core/SceneDelegate/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class SceneDelegate: MvvmSceneDelegate {

override func binding() {
bindLiveActivity()
bind(in: disposeBag) {
disposeBag.bind {
tintColorBind
appAppearanceBind
backgroundDownloadModeBind
Expand Down
2 changes: 2 additions & 0 deletions iTorrent/Core/iTorrent.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@
<true/>
<key>com.apple.security.network.server</key>
<true/>
<key>com.apple.security.personal-information.location</key>
<true/>
</dict>
</plist>
8 changes: 4 additions & 4 deletions iTorrent/Services/NetworkMonitoringService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import CoreTelephony

class NetworkMonitoringService {
@Published var availableInterfaces: [NWInterface] = []
#if canImport(CoreTelephony)
#if canImport(CoreTelephony) && !targetEnvironment(macCatalyst)
@Published var cellularState: CTCellularDataRestrictedState = .restrictedStateUnknown
#endif

Expand All @@ -24,7 +24,7 @@ class NetworkMonitoringService {
updateAvailableInterfaces()
}

#if canImport(CoreTelephony)
#if canImport(CoreTelephony) && !targetEnvironment(macCatalyst)
cellularData.cellularDataRestrictionDidUpdateNotifier = { [weak self] newState in
guard let self else { return }
cellularState = newState
Expand All @@ -37,14 +37,14 @@ class NetworkMonitoringService {
}

private let monitor = NWPathMonitor()
#if canImport(CoreTelephony)
#if canImport(CoreTelephony) && !targetEnvironment(macCatalyst)
private let cellularData = CTCellularData()
#endif
}

private extension NetworkMonitoringService {
func updateAvailableInterfaces() {
#if canImport(CoreTelephony)
#if canImport(CoreTelephony) && !targetEnvironment(macCatalyst)
let isCellularRestricted = cellularData.restrictedState == .restricted
#else
let isCellularRestricted = false
Expand Down
2 changes: 1 addition & 1 deletion iTorrent/Services/RssFeed/RssModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class RssModel: Hashable, Codable {
init(link: URL) async throws {
xmlLink = link

let (data, response) = try await URLSession.shared.data(from: xmlLink)
let (data, _) = try await URLSession.shared.data(from: xmlLink)
guard let contents = String(data: data, encoding: .utf8)
else { throw Error.corruptedData }

Expand Down

0 comments on commit f6ecc22

Please sign in to comment.