diff --git a/ApplicationLibrary/LubyTransform/LubyTransformEncoder.swift b/ApplicationLibrary/LubyTransform/LubyTransformEncoder.swift index 0eeecdb..14eb14f 100644 --- a/ApplicationLibrary/LubyTransform/LubyTransformEncoder.swift +++ b/ApplicationLibrary/LubyTransform/LubyTransformEncoder.swift @@ -94,6 +94,7 @@ final class LubyTransformEncoder { // Ideal Soliton Distribution for degree selection private func getRandomDegree() -> Int { + guard k > 1 else { return k } var probabilities = [Double](repeating: 0, count: k) probabilities[0] = 1.0 / Double(k) for d in 2 ... k { diff --git a/ApplicationLibrary/Views/Dashboard/Cards/ProfileCard.swift b/ApplicationLibrary/Views/Dashboard/Cards/ProfileCard.swift index 7bb6c21..44bc59a 100644 --- a/ApplicationLibrary/Views/Dashboard/Cards/ProfileCard.swift +++ b/ApplicationLibrary/Views/Dashboard/Cards/ProfileCard.swift @@ -78,11 +78,6 @@ public struct ProfileCard: View { QRCodeSheet(profileName: profile.name, remoteURL: remoteURL) } } - .sheet(isPresented: $viewModel.showQRSShare) { - if let profile = selectedProfile, let data = try? profile.origin.toContent().encode() { - QRSSheet(profileName: profile.name, profileData: data) - } - } #else .sheet(isPresented: $viewModel.showNewProfile, onDismiss: { environments.profileUpdate.send() @@ -269,10 +264,12 @@ public struct ProfileCard: View { } } - Button { - viewModel.showQRSShare = true - } label: { - Label("Share as QRS Code", systemImage: "barcode") + if let data = try? profile.origin.toContent().encode() { + FormNavigationLink { + QRSSheet(profileName: profile.name, profileData: data) + } label: { + Label("Share as QRS Code", systemImage: "qrcode") + } } } label: { Image(systemName: "square.and.arrow.up") @@ -317,7 +314,7 @@ public struct ProfileCard: View { Button { viewModel.showQRSShare = true } label: { - Label("Share as QRS Code", systemImage: "barcode") + Label("Share as QRS Code", systemImage: "qrcode") } } label: { Image(systemName: "square.and.arrow.up") @@ -497,10 +494,12 @@ extension ProfileCard { @Published var alert: AlertState? @Published var profileToEdit: Profile? @Published var shareItemType: ShareItemType? + #if !os(tvOS) @Published var profileExportDocument: ProfileExportDocument? @Published var showProfileExporter = false @Published var profileJSONExportDocument: ProfileJSONExportDocument? @Published var showJSONExporter = false + #endif #if os(macOS) var shareButtonView: NSView? #endif diff --git a/ApplicationLibrary/Views/Dashboard/Cards/ProfilePickerSheet.swift b/ApplicationLibrary/Views/Dashboard/Cards/ProfilePickerSheet.swift index 34d6eae..e70a0d4 100644 --- a/ApplicationLibrary/Views/Dashboard/Cards/ProfilePickerSheet.swift +++ b/ApplicationLibrary/Views/Dashboard/Cards/ProfilePickerSheet.swift @@ -570,11 +570,6 @@ private struct ProfilePickerRow: View { QRCodeSheet(profileName: profile.name, remoteURL: remoteURL) } } - .sheet(isPresented: $showQRSShare) { - if let data = try? profile.origin.toContent().encode() { - QRSSheet(profileName: profile.name, profileData: data) - } - } } private var tvOSNormalBody: some View { @@ -632,10 +627,12 @@ private struct ProfilePickerRow: View { } } - Button { - showQRSShare = true - } label: { - Label("Share as QRS Code", systemImage: "barcode") + if let data = try? profile.origin.toContent().encode() { + FormNavigationLink { + QRSSheet(profileName: profile.name, profileData: data) + } label: { + Label("Share as QRS Code", systemImage: "barcode") + } } } label: { Label("Share", systemImage: "square.and.arrow.up") diff --git a/ApplicationLibrary/Views/Log/LogView.swift b/ApplicationLibrary/Views/Log/LogView.swift index d6c90ee..df5eeb0 100644 --- a/ApplicationLibrary/Views/Log/LogView.swift +++ b/ApplicationLibrary/Views/Log/LogView.swift @@ -271,13 +271,16 @@ private struct LogContentInnerView: View { @ViewBuilder private var emptyContent: some View { - if dataModel.isConnected { - Text("Empty logs") - } else { - Text("Service not started").onAppear { - environments.connect() + Group { + if dataModel.isConnected { + Text("Empty logs") + } else { + Text("Service not started").onAppear { + environments.connect() + } } } + .frame(maxWidth: .infinity, maxHeight: .infinity) } private var logScrollView: some View { diff --git a/ApplicationLibrary/Views/Profile/QRSDisplayView.swift b/ApplicationLibrary/Views/Profile/QRSDisplayView.swift index f25615f..3202feb 100644 --- a/ApplicationLibrary/Views/Profile/QRSDisplayView.swift +++ b/ApplicationLibrary/Views/Profile/QRSDisplayView.swift @@ -47,20 +47,56 @@ public struct QRSDisplayView: View { HStack { Text(String(localized: "FPS")) Spacer() + #if os(tvOS) + Button { + fps = max(1, fps - 1) + } label: { + Image(systemName: "minus") + } Text(verbatim: "\(Int(fps))") .foregroundStyle(.secondary) + .frame(minWidth: 50) + Button { + fps = min(60, fps + 1) + } label: { + Image(systemName: "plus") + } + #else + Text(verbatim: "\(Int(fps))") + .foregroundStyle(.secondary) + #endif } + #if !os(tvOS) Slider(value: $fps, in: 1 ... 60, step: 1) + #endif HStack { Text(String(localized: "Slice Size")) Spacer() + #if os(tvOS) + Button { + sliceSize = max(100, sliceSize - 100) + } label: { + Image(systemName: "minus") + } Text("\(Int(sliceSize))") .foregroundStyle(.secondary) + .frame(minWidth: 50) + Button { + sliceSize = min(1500, sliceSize + 100) + } label: { + Image(systemName: "plus") + } + #else + Text("\(Int(sliceSize))") + .foregroundStyle(.secondary) + #endif } + #if !os(tvOS) Slider(value: $sliceSize, in: 100 ... 1500, step: 100) + #endif } .padding(.horizontal) diff --git a/ApplicationLibrary/Views/Setting/SettingView.swift b/ApplicationLibrary/Views/Setting/SettingView.swift index 4fcea91..dffa4ac 100644 --- a/ApplicationLibrary/Views/Setting/SettingView.swift +++ b/ApplicationLibrary/Views/Setting/SettingView.swift @@ -96,10 +96,10 @@ public struct SettingView: View { public init() {} public var body: some View { FormView { - #if os(macOS) - Tabs.app.navigationLink - #endif Section { + #if os(macOS) + Tabs.app.navigationLink + #endif ForEach([Tabs.core, Tabs.packetTunnel, Tabs.onDemandRules, Tabs.profileOverride]) { it in it.navigationLink } diff --git a/Library/Database/Profile+Transferable.swift b/Library/Database/Profile+Transferable.swift index 367b9fe..621f4b7 100644 --- a/Library/Database/Profile+Transferable.swift +++ b/Library/Database/Profile+Transferable.swift @@ -118,6 +118,7 @@ public extension UTType { static var profile: UTType { .init(exportedAs: "io.nekohasekai.sfavt.profile") } } +#if !os(tvOS) // MARK: - FileDocument for Export public struct ProfileExportDocument: FileDocument { @@ -175,3 +176,4 @@ public struct ProfileJSONExportDocument: FileDocument { return FileWrapper(regularFileWithContents: data) } } +#endif