Minor fixes

This commit is contained in:
世界
2026-01-03 00:55:17 +08:00
parent 52db9bbb39
commit 64e2ece819
7 changed files with 65 additions and 27 deletions
@@ -94,6 +94,7 @@ final class LubyTransformEncoder {
// Ideal Soliton Distribution for degree selection // Ideal Soliton Distribution for degree selection
private func getRandomDegree() -> Int { private func getRandomDegree() -> Int {
guard k > 1 else { return k }
var probabilities = [Double](repeating: 0, count: k) var probabilities = [Double](repeating: 0, count: k)
probabilities[0] = 1.0 / Double(k) probabilities[0] = 1.0 / Double(k)
for d in 2 ... k { for d in 2 ... k {
@@ -78,11 +78,6 @@ public struct ProfileCard: View {
QRCodeSheet(profileName: profile.name, remoteURL: remoteURL) 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 #else
.sheet(isPresented: $viewModel.showNewProfile, onDismiss: { .sheet(isPresented: $viewModel.showNewProfile, onDismiss: {
environments.profileUpdate.send() environments.profileUpdate.send()
@@ -269,10 +264,12 @@ public struct ProfileCard: View {
} }
} }
Button { if let data = try? profile.origin.toContent().encode() {
viewModel.showQRSShare = true FormNavigationLink {
QRSSheet(profileName: profile.name, profileData: data)
} label: { } label: {
Label("Share as QRS Code", systemImage: "barcode") Label("Share as QRS Code", systemImage: "qrcode")
}
} }
} label: { } label: {
Image(systemName: "square.and.arrow.up") Image(systemName: "square.and.arrow.up")
@@ -317,7 +314,7 @@ public struct ProfileCard: View {
Button { Button {
viewModel.showQRSShare = true viewModel.showQRSShare = true
} label: { } label: {
Label("Share as QRS Code", systemImage: "barcode") Label("Share as QRS Code", systemImage: "qrcode")
} }
} label: { } label: {
Image(systemName: "square.and.arrow.up") Image(systemName: "square.and.arrow.up")
@@ -497,10 +494,12 @@ extension ProfileCard {
@Published var alert: AlertState? @Published var alert: AlertState?
@Published var profileToEdit: Profile? @Published var profileToEdit: Profile?
@Published var shareItemType: ShareItemType? @Published var shareItemType: ShareItemType?
#if !os(tvOS)
@Published var profileExportDocument: ProfileExportDocument? @Published var profileExportDocument: ProfileExportDocument?
@Published var showProfileExporter = false @Published var showProfileExporter = false
@Published var profileJSONExportDocument: ProfileJSONExportDocument? @Published var profileJSONExportDocument: ProfileJSONExportDocument?
@Published var showJSONExporter = false @Published var showJSONExporter = false
#endif
#if os(macOS) #if os(macOS)
var shareButtonView: NSView? var shareButtonView: NSView?
#endif #endif
@@ -570,11 +570,6 @@ private struct ProfilePickerRow: View {
QRCodeSheet(profileName: profile.name, remoteURL: remoteURL) 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 { private var tvOSNormalBody: some View {
@@ -632,11 +627,13 @@ private struct ProfilePickerRow: View {
} }
} }
Button { if let data = try? profile.origin.toContent().encode() {
showQRSShare = true FormNavigationLink {
QRSSheet(profileName: profile.name, profileData: data)
} label: { } label: {
Label("Share as QRS Code", systemImage: "barcode") Label("Share as QRS Code", systemImage: "barcode")
} }
}
} label: { } label: {
Label("Share", systemImage: "square.and.arrow.up") Label("Share", systemImage: "square.and.arrow.up")
} }
@@ -271,6 +271,7 @@ private struct LogContentInnerView: View {
@ViewBuilder @ViewBuilder
private var emptyContent: some View { private var emptyContent: some View {
Group {
if dataModel.isConnected { if dataModel.isConnected {
Text("Empty logs") Text("Empty logs")
} else { } else {
@@ -279,6 +280,8 @@ private struct LogContentInnerView: View {
} }
} }
} }
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
private var logScrollView: some View { private var logScrollView: some View {
#if os(tvOS) #if os(tvOS)
@@ -47,20 +47,56 @@ public struct QRSDisplayView: View {
HStack { HStack {
Text(String(localized: "FPS")) Text(String(localized: "FPS"))
Spacer() Spacer()
#if os(tvOS)
Button {
fps = max(1, fps - 1)
} label: {
Image(systemName: "minus")
}
Text(verbatim: "\(Int(fps))") Text(verbatim: "\(Int(fps))")
.foregroundStyle(.secondary) .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) Slider(value: $fps, in: 1 ... 60, step: 1)
#endif
HStack { HStack {
Text(String(localized: "Slice Size")) Text(String(localized: "Slice Size"))
Spacer() Spacer()
#if os(tvOS)
Button {
sliceSize = max(100, sliceSize - 100)
} label: {
Image(systemName: "minus")
}
Text("\(Int(sliceSize))") Text("\(Int(sliceSize))")
.foregroundStyle(.secondary) .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) Slider(value: $sliceSize, in: 100 ... 1500, step: 100)
#endif
} }
.padding(.horizontal) .padding(.horizontal)
@@ -96,10 +96,10 @@ public struct SettingView: View {
public init() {} public init() {}
public var body: some View { public var body: some View {
FormView { FormView {
Section {
#if os(macOS) #if os(macOS)
Tabs.app.navigationLink Tabs.app.navigationLink
#endif #endif
Section {
ForEach([Tabs.core, Tabs.packetTunnel, Tabs.onDemandRules, Tabs.profileOverride]) { it in ForEach([Tabs.core, Tabs.packetTunnel, Tabs.onDemandRules, Tabs.profileOverride]) { it in
it.navigationLink it.navigationLink
} }
@@ -118,6 +118,7 @@ public extension UTType {
static var profile: UTType { .init(exportedAs: "io.nekohasekai.sfavt.profile") } static var profile: UTType { .init(exportedAs: "io.nekohasekai.sfavt.profile") }
} }
#if !os(tvOS)
// MARK: - FileDocument for Export // MARK: - FileDocument for Export
public struct ProfileExportDocument: FileDocument { public struct ProfileExportDocument: FileDocument {
@@ -175,3 +176,4 @@ public struct ProfileJSONExportDocument: FileDocument {
return FileWrapper(regularFileWithContents: data) return FileWrapper(regularFileWithContents: data)
} }
} }
#endif