Skip to content

Commit

Permalink
feat: 🗄️ Show file type names for known files (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbmorley authored Jul 8, 2024
1 parent 5ab5179 commit 03039c9
Show file tree
Hide file tree
Showing 6 changed files with 162 additions and 25 deletions.
8 changes: 8 additions & 0 deletions Reconnect.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
D83658B92C298C4F00B45693 /* NavigationStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = D83658B82C298C4F00B45693 /* NavigationStack.swift */; };
D83658BB2C29A09300B45693 /* HistoryItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D83658BA2C29A09300B45693 /* HistoryItemView.swift */; };
D83A786A2C3C80C9000E8192 /* FileTypePopover.swift in Sources */ = {isa = PBXBuildFile; fileRef = D83A78692C3C80C9000E8192 /* FileTypePopover.swift */; };
D83A786C2C3C85FE000E8192 /* DirectoryEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = D83A786B2C3C85FE000E8192 /* DirectoryEntry.swift */; };
D83A786E2C3C87F5000E8192 /* FileType.swift in Sources */ = {isa = PBXBuildFile; fileRef = D83A786D2C3C87F5000E8192 /* FileType.swift */; };
D83B4DDF2C2F9995003C3DC1 /* CheckForUpdatesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D83B4DDE2C2F9995003C3DC1 /* CheckForUpdatesView.swift */; };
D83B4DE12C2F99C3003C3DC1 /* CheckForUpdatesViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D83B4DE02C2F99C3003C3DC1 /* CheckForUpdatesViewModel.swift */; };
D84351502C2B636C009055C1 /* DriveInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = D843514F2C2B636C009055C1 /* DriveInfo.swift */; };
Expand Down Expand Up @@ -79,6 +81,8 @@
D83658B82C298C4F00B45693 /* NavigationStack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationStack.swift; sourceTree = "<group>"; };
D83658BA2C29A09300B45693 /* HistoryItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoryItemView.swift; sourceTree = "<group>"; };
D83A78692C3C80C9000E8192 /* FileTypePopover.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileTypePopover.swift; sourceTree = "<group>"; };
D83A786B2C3C85FE000E8192 /* DirectoryEntry.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DirectoryEntry.swift; sourceTree = "<group>"; };
D83A786D2C3C87F5000E8192 /* FileType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileType.swift; sourceTree = "<group>"; };
D83B4DDE2C2F9995003C3DC1 /* CheckForUpdatesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckForUpdatesView.swift; sourceTree = "<group>"; };
D83B4DE02C2F99C3003C3DC1 /* CheckForUpdatesViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckForUpdatesViewModel.swift; sourceTree = "<group>"; };
D843514F2C2B636C009055C1 /* DriveInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DriveInfo.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -157,6 +161,7 @@
D8184C462C253C59008FA79B /* ApplicationModel.swift */,
D886DA752C29343900E84BDA /* BrowserModel.swift */,
D83B4DE02C2F99C3003C3DC1 /* CheckForUpdatesViewModel.swift */,
D83A786D2C3C87F5000E8192 /* FileType.swift */,
D8C080792C1D7D8D003128AB /* ReconnectError.swift */,
D8631DB02C374B0A00344DC3 /* Transfer.swift */,
D8631DB22C374B4400344DC3 /* TransfersModel.swift */,
Expand Down Expand Up @@ -271,6 +276,7 @@
isa = PBXGroup;
children = (
D8631DBA2C37657100344DC3 /* Array.swift */,
D83A786B2C3C85FE000E8192 /* DirectoryEntry.swift */,
D843514F2C2B636C009055C1 /* DriveInfo.swift */,
D8E31EB42C26E10900350082 /* Licensable.swift */,
D8631DB62C37573200344DC3 /* rfsv.errs.swift */,
Expand Down Expand Up @@ -458,6 +464,7 @@
D8E31EB52C26E10900350082 /* Licensable.swift in Sources */,
D886DA742C28CDAD00E84BDA /* BrowserView.swift in Sources */,
D88FA1502C2CE29900805DBD /* ContentView.swift in Sources */,
D83A786E2C3C87F5000E8192 /* FileType.swift in Sources */,
D8631DBB2C37657100344DC3 /* Array.swift in Sources */,
D83B4DE12C2F99C3003C3DC1 /* CheckForUpdatesViewModel.swift in Sources */,
D83658B92C298C4F00B45693 /* NavigationStack.swift in Sources */,
Expand All @@ -475,6 +482,7 @@
D8631DAD2C3739E600344DC3 /* TransfersPopoverButton.swift in Sources */,
D8631DB12C374B0A00344DC3 /* Transfer.swift in Sources */,
D84964DA2C1BFCB600405656 /* ReconnectApp.swift in Sources */,
D83A786C2C3C85FE000E8192 /* DirectoryEntry.swift in Sources */,
D8631DB72C37573200344DC3 /* rfsv.errs.swift in Sources */,
D8631DB52C374F8700344DC3 /* TransfersView.swift in Sources */,
);
Expand Down
78 changes: 78 additions & 0 deletions Reconnect/Extensions/DirectoryEntry.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// Reconnect -- Psion connectivity for macOS
//
// Copyright (C) 2024 Jason Morley
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

import Foundation

extension FileServer.DirectoryEntry {

var fileType: FileType {
if isDirectory {
return .directory
} else {
switch uid3 {
case .word:
return .word
case .sheet:
return .sheet
case .record:
return .record
case .opl:
return .opl
case .data:
return .data
case .agenda:
return .agenda
case .sketch:
return .sketch
case .jotter:
return .jotter
default:
return .unknown
}
}
}

var image: String {
if isDirectory {
return "Folder16"
} else {
switch uid3 {
case .word:
return "Word16"
case .sheet:
return "Sheet16"
case .record:
return "Record16"
case .opl:
return "OPL16"
case .data:
return "Data16"
case .agenda:
return "Agenda16"
case .sketch:
return "Sketch16"
case .jotter:
return "Jotter16"
default:
return "FileUnknown16"
}
}

}

}
7 changes: 7 additions & 0 deletions Reconnect/Extensions/UInt32.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ import SwiftUI

extension UInt32 {

// UID1
static let directFileStore: Self = 0x10000037

// UID2
static let mbm: Self = 0x10000042

// UID3
static let word: Self = 0x1000007F
static let sheet: Self = 0x10000088
static let record: Self = 0x1000007E
Expand Down
66 changes: 66 additions & 0 deletions Reconnect/Model/FileType.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Reconnect -- Psion connectivity for macOS
//
// Copyright (C) 2024 Jason Morley
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

import Foundation

enum FileType {

case unknown
case directory
case word
case sheet
case record
case opl
case data
case agenda
case sketch
case jotter
case mbm

}

extension FileType {

var name: String {
switch self {
case .unknown:
return "Unknown"
case .directory:
return "Folder"
case .word:
return "Word"
case .sheet:
return "Sheet"
case .record:
return "Record"
case .opl:
return "OPL"
case .data:
return "Data"
case .agenda:
return "Agenda"
case .sketch:
return "Sketch"
case .jotter:
return "Jotter"
case .mbm:
return "Bitmap"
}
}

}
26 changes: 2 additions & 24 deletions Reconnect/Views/BrowserDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,7 @@ struct BrowserDetailView: View {
ZStack {
Table(browserModel.files, selection: $browserModel.fileSelection) {
TableColumn("") { file in
if file.isDirectory {
Image("Folder16")
} else {
switch file.uid3 {
case .word:
Image("Word16")
case .sheet:
Image("Sheet16")
case .record:
Image("Record16")
case .opl:
Image("OPL16")
case .data:
Image("Data16")
case .agenda:
Image("Agenda16")
case .sketch:
Image("Sketch16")
case .jotter:
Image("Jotter16")
default:
Image("FileUnknown16")
}
}
Image(file.image)
}
.width(16.0)
TableColumn("Name", value: \.name)
Expand All @@ -72,6 +49,7 @@ struct BrowserDetailView: View {

TableColumn("Type") { file in
FileTypePopover(file: file)
.foregroundStyle(.secondary)
}
}
.contextMenu(forSelectionType: FileServer.DirectoryEntry.ID.self) { items in
Expand Down
2 changes: 1 addition & 1 deletion Reconnect/Views/FileTypePopover.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct FileTypePopover: View {
Button {
isPresented = true
} label: {
Image(systemName: "info.circle")
Text(file.fileType.name)
}
.popover(isPresented: $isPresented) {
Grid {
Expand Down

0 comments on commit 03039c9

Please sign in to comment.