mirror of
https://github.com/nimbold/Firelink.git
synced 2026-07-26 20:18:37 +00:00
fix: size column fallback and table row interactions
- Fix: Size column falls back to 'bytesText' if sizeBytes is unknown - Fix: Prevent filename text from intercepting row selection taps - Fix: Use explicit window ID to ensure download properties opens reliably on double click
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
import re
|
||||
|
||||
with open("Sources/Firelink/DownloadTable.swift", "r") as f:
|
||||
content = f.read()
|
||||
|
||||
# Fix size to use bytesText if sizeBytes is nil or 0
|
||||
old_size = ''' TableColumn("Size", value: \\.sortableSize) { item in
|
||||
Text(ByteFormatter.string(item.sizeBytes))
|
||||
.monospacedDigit()
|
||||
.lineLimit(1)
|
||||
.truncationMode(.tail)
|
||||
}'''
|
||||
new_size = ''' TableColumn("Size", value: \\.sortableSize) { item in
|
||||
if let size = item.sizeBytes, size > 0 {
|
||||
Text(ByteFormatter.string(size))
|
||||
.monospacedDigit()
|
||||
.lineLimit(1)
|
||||
.truncationMode(.tail)
|
||||
} else if item.bytesText != "-" && !item.bytesText.isEmpty {
|
||||
Text(item.bytesText)
|
||||
.monospacedDigit()
|
||||
.lineLimit(1)
|
||||
.truncationMode(.tail)
|
||||
} else {
|
||||
Text("Unknown")
|
||||
.monospacedDigit()
|
||||
.lineLimit(1)
|
||||
.truncationMode(.tail)
|
||||
}
|
||||
}'''
|
||||
content = content.replace(old_size, new_size)
|
||||
|
||||
# Add allowsHitTesting(false) to text to fix single click interception
|
||||
old_text = ''' Text(item.fileName)
|
||||
.font(.headline)
|
||||
.lineLimit(1)
|
||||
.truncationMode(.tail)'''
|
||||
new_text = ''' Text(item.fileName)
|
||||
.font(.headline)
|
||||
.lineLimit(1)
|
||||
.truncationMode(.tail)
|
||||
.allowsHitTesting(false)'''
|
||||
content = content.replace(old_text, new_text)
|
||||
|
||||
# Change performPrimaryAction to use id
|
||||
old_action = 'openWindow(value: item.id)'
|
||||
new_action = 'openWindow(id: "download-properties", value: item.id)'
|
||||
content = content.replace(old_action, new_action)
|
||||
|
||||
with open("Sources/Firelink/DownloadTable.swift", "w") as f:
|
||||
f.write(content)
|
||||
|
||||
with open("Sources/Firelink/FirelinkApp.swift", "r") as f:
|
||||
app_content = f.read()
|
||||
|
||||
app_content = app_content.replace(
|
||||
'WindowGroup("Download Properties", for: UUID.self)',
|
||||
'WindowGroup("Download Properties", id: "download-properties", for: UUID.self)'
|
||||
)
|
||||
|
||||
with open("Sources/Firelink/FirelinkApp.swift", "w") as f:
|
||||
f.write(app_content)
|
||||
@@ -46,16 +46,29 @@ struct DownloadTable: View {
|
||||
.font(.headline)
|
||||
.lineLimit(1)
|
||||
.truncationMode(.tail)
|
||||
.allowsHitTesting(false)
|
||||
.draggable(item.id.uuidString)
|
||||
}
|
||||
}
|
||||
.width(min: 200, ideal: 340)
|
||||
|
||||
TableColumn("Size", value: \.sortableSize) { item in
|
||||
Text(ByteFormatter.string(item.sizeBytes))
|
||||
if let size = item.sizeBytes, size > 0 {
|
||||
Text(ByteFormatter.string(size))
|
||||
.monospacedDigit()
|
||||
.lineLimit(1)
|
||||
.truncationMode(.tail)
|
||||
} else if item.bytesText != "-" && !item.bytesText.isEmpty {
|
||||
Text(item.bytesText)
|
||||
.monospacedDigit()
|
||||
.lineLimit(1)
|
||||
.truncationMode(.tail)
|
||||
} else {
|
||||
Text("Unknown")
|
||||
.monospacedDigit()
|
||||
.lineLimit(1)
|
||||
.truncationMode(.tail)
|
||||
}
|
||||
}
|
||||
.width(min: 80, ideal: 100)
|
||||
|
||||
@@ -152,7 +165,7 @@ struct DownloadTable: View {
|
||||
if item.status == .completed {
|
||||
openFile(item)
|
||||
} else {
|
||||
openWindow(value: item.id)
|
||||
openWindow(id: "download-properties", value: item.id)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ struct FirelinkApp: App {
|
||||
}
|
||||
.windowResizability(.contentSize)
|
||||
|
||||
WindowGroup("Download Properties", for: UUID.self) { $downloadID in
|
||||
WindowGroup("Download Properties", id: "download-properties", for: UUID.self) { $downloadID in
|
||||
if let downloadID {
|
||||
DownloadPropertiesWindow(downloadID: downloadID)
|
||||
.environmentObject(controller)
|
||||
|
||||
Reference in New Issue
Block a user