Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Correctly preview non-text files#1707

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
66 commits
Select commitHold shift + click to select a range
6f30d92
Package.resolved changed
plbstlMay 7, 2024
7113389
progress
plbstlMay 7, 2024
9a85005
minor doc change in CodeEditUI EffectView
plbstlMay 7, 2024
6749915
add WorkspacePdfFileView
plbstlMay 7, 2024
3d3893e
allow WorkspacePdfFileView to be able to send data to SwiftUI
plbstlMay 7, 2024
bd3fe37
properly name `WorkspacePdfFileView` to `WorkspacePDFView`
plbstlMay 8, 2024
a12e51c
improve WorkspacePDFView docs
plbstlMay 8, 2024
2b59534
add guards to WorkspacePDFView (makeNSView, updateNSView)
plbstlMay 8, 2024
6797552
wip
plbstlMay 8, 2024
15291c0
wip 2
plbstlMay 8, 2024
2fd13b4
correct padding
plbstlMay 8, 2024
7ae71a0
progress? not
plbstlMay 8, 2024
ff47ae8
add attachPDFDocumentToView helper in WorkspacePDFView
plbstlMay 9, 2024
d820eb9
update WorkspacePDFView docs
plbstlMay 9, 2024
b5f1614
remove WorkspaceNonTextFileView
plbstlMay 9, 2024
7ef3116
fix SwiftLint violations in WorkspacePDFView, WorkspaceCodeFileView
plbstlMay 9, 2024
6d7f7d8
add magic numbers comment to WorkspaceCodeFileView
plbstlMay 9, 2024
2192c70
update WorkspacePDFView docs
plbstlMay 9, 2024
74cd22b
before i forget
plbstlMay 9, 2024
8ef8461
progressss
plbstlMay 9, 2024
a643b43
too slow
plbstlMay 9, 2024
f583df0
wip: the best work yet
plbstlMay 9, 2024
410f62d
it really works!!
plbstlMay 9, 2024
b80dc31
add WorkspaceImageView
plbstlMay 9, 2024
a9ed5ad
add WorkspaceCannotPreviewFileView
plbstlMay 9, 2024
ff57cc8
its working very predictably but showing/hiding navigator pane isn't …
plbstlMay 9, 2024
1813416
remove the use of canPreview as it can cause unexpected behaviour
plbstlMay 9, 2024
6106b64
remove computeFrame helper in WorkspaceCodeFileView
plbstlMay 9, 2024
dc7bcad
update PDF preview's background color
plbstlMay 9, 2024
2e4dd02
add note for when PDF preview cannot create PDF document
plbstlMay 9, 2024
c2fcacc
improve docs for WorkspaceImageView & WorkspacePDFView
plbstlMay 9, 2024
2d448f6
use unnamed parameter for imageUrl in WorkspaceImageView
plbstlMay 9, 2024
f2ca164
implement `WorkspaceCannotPreviewFileView`
plbstlMay 9, 2024
c248a9d
change url variables in `WorkspaceImageView`, `WorkspacePDFView` & `W…
plbstlMay 9, 2024
82ef086
add `WorkspaceLoadingView`
plbstlMay 9, 2024
eb15141
spacing violation
plbstlMay 9, 2024
d32436a
change onAppear modifier in WorkspaceCannotPreviewFileView
plbstlMay 9, 2024
4238f2c
remove `WorkspaceCannotPreviewFileView` as it creates a bug that make…
plbstlMay 9, 2024
5c5c81b
improve docs in `WorkspacePDFView` & `WorkspaceImageView`
plbstlMay 9, 2024
752fe3b
use `WorkspaceAnyFileView` to preview GIF images
plbstlMay 9, 2024
40d52c6
add a note to the documentation for `CodeFileDocument.utType`
plbstlMay 9, 2024
b24b6ff
add `WorkspaceAnyFileView` to properly preview files of different fil…
plbstlMay 9, 2024
d2664bd
rearrange files in `CodeEdit/Features/Documents/Views`
plbstlMay 9, 2024
2fbc351
add `WorkspaceAnyFileView`, `WorkspaceLoadingView`, `WorkspaceImageVi…
plbstlMay 9, 2024
afc0a82
update docs in `WorkspaceAnyFileView`, `WorkspaceLoadingView`, `Works…
plbstlMay 9, 2024
ccc79b3
rename `CodeFileDocument.typeOfFile` to `CodeFileDocument.utType`
plbstlMay 9, 2024
6561d25
fix: allow GIF previews to play, and with their proper dimensions
plbstlMay 9, 2024
12aa788
do not return
plbstlMay 9, 2024
f039914
update docs for CodeFileDocument.utType
plbstlMay 9, 2024
b660ac7
change conformance from movie to audiovisualContent in CodeFileDocume…
plbstlMay 9, 2024
d0c2671
properly display CodeFileView contents by undo-ing the padding in its…
plbstlMay 10, 2024
1b8c8b3
remove text, image, PDF, video restrictions on `CodeFileDocument.utType`
plbstlMay 10, 2024
2ac22a7
update docs in WorkspaceImageView
plbstlMay 10, 2024
c3d31a6
WorkspaceCodeFileView: group non-text files, so they inherit modifier…
plbstlMay 10, 2024
12e0ba1
WorkspaceCodeFileView: add important note on document.utType
plbstlMay 10, 2024
8f04013
remove SwiftUI VideoPlayer view for now, it creates a bug that I can'…
plbstlMay 10, 2024
acb8a63
add `NonTextFileView` to clean up code
plbstlMay 10, 2024
9688746
remove QLPreviewItem subclass from CodeFileDocument
plbstlMay 10, 2024
425f806
rename `WorkspaceCodeFileView` to `EditorAreaFileView`
plbstlMay 10, 2024
151e345
rename `EditorView` to `EditorAreaView`
plbstlMay 10, 2024
fe1f7bb
rename 4 Workspace view files
plbstlMay 10, 2024
cb88ec2
move views for opening files to `CodeEdit/Features/Editor`
plbstlMay 10, 2024
096bb68
move `CodeFileDocument` to `CodeEdit/Features/Documents`
plbstlMay 10, 2024
cf17bc7
NSTableViewWrapper: minor change in comment
plbstlMay 10, 2024
950d7ed
move `WindowCodeFileView` to `CodeEdit/Features/Editor/Views`
plbstlMay 10, 2024
b373bb6
use `AnyFileView` to view all images
plbstlMay 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
rename 4 Workspace view files
- `WorkspaceAnyFileView` -> `AnyFileView`- `WorkspaceLoadingView` -> `LoadingFileView`- `WorkspaceImageView` -> `ImageFileView`- `WorkspacePDFView` -> `PDFFileView`
  • Loading branch information
@plbstl
plbstl committedMay 10, 2024
commitfe1f7bb944d674f52fd65232aa046ca23b37c7ba
32 changes: 16 additions & 16 deletionsCodeEdit.xcodeproj/project.pbxproj
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -283,10 +283,10 @@
6195E3112B640485007261CA /* WorkspaceDocument+SearchState+IndexTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6195E3102B640485007261CA /* WorkspaceDocument+SearchState+IndexTests.swift */; };
61A53A7E2B4449870093BF8A /* WorkspaceDocument+Find.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61A53A7D2B4449870093BF8A /* WorkspaceDocument+Find.swift */; };
61A53A812B4449F00093BF8A /* WorkspaceDocument+Index.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61A53A802B4449F00093BF8A /* WorkspaceDocument+Index.swift */; };
661EF7B82BEE215300C3E577 /*WorkspaceImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 661EF7B72BEE215300C3E577 /*WorkspaceImageView.swift */; };
661EF7BD2BEE215300C3E577 /*WorkspaceLoadingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 661EF7BC2BEE215300C3E577 /*WorkspaceLoadingView.swift */; };
669BC4082BED306400D1197C /*WorkspaceAnyFileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 669BC4072BED306400D1197C /*WorkspaceAnyFileView.swift */; };
66F2C8C42BEAA939004674F7 /*WorkspacePDFView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66F2C8C32BEAA939004674F7 /*WorkspacePDFView.swift */; };
661EF7B82BEE215300C3E577 /*ImageFileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 661EF7B72BEE215300C3E577 /*ImageFileView.swift */; };
661EF7BD2BEE215300C3E577 /*LoadingFileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 661EF7BC2BEE215300C3E577 /*LoadingFileView.swift */; };
669BC4082BED306400D1197C /*AnyFileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 669BC4072BED306400D1197C /*AnyFileView.swift */; };
66F2C8C42BEAA939004674F7 /*PDFFileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66F2C8C32BEAA939004674F7 /*PDFFileView.swift */; };
66F370342BEE537B00D3B823 /* NonTextFileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66F370332BEE537B00D3B823 /* NonTextFileView.swift */; };
6C049A372A49E2DB00D42923 /* DirectoryEventStream.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C049A362A49E2DB00D42923 /* DirectoryEventStream.swift */; };
6C05A8AF284D0CA3007F4EAA /* WorkspaceDocument+Listeners.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C05A8AE284D0CA3007F4EAA /* WorkspaceDocument+Listeners.swift */; };
Expand DownExpand Up@@ -848,10 +848,10 @@
6195E3102B640485007261CA /* WorkspaceDocument+SearchState+IndexTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WorkspaceDocument+SearchState+IndexTests.swift"; sourceTree = "<group>"; };
61A53A7D2B4449870093BF8A /* WorkspaceDocument+Find.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WorkspaceDocument+Find.swift"; sourceTree = "<group>"; };
61A53A802B4449F00093BF8A /* WorkspaceDocument+Index.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WorkspaceDocument+Index.swift"; sourceTree = "<group>"; };
661EF7B72BEE215300C3E577 /*WorkspaceImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path =WorkspaceImageView.swift; sourceTree = "<group>"; };
661EF7BC2BEE215300C3E577 /*WorkspaceLoadingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path =WorkspaceLoadingView.swift; sourceTree = "<group>"; };
669BC4072BED306400D1197C /*WorkspaceAnyFileView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path =WorkspaceAnyFileView.swift; sourceTree = "<group>"; };
66F2C8C32BEAA939004674F7 /*WorkspacePDFView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path =WorkspacePDFView.swift; sourceTree = "<group>"; };
661EF7B72BEE215300C3E577 /*ImageFileView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path =ImageFileView.swift; sourceTree = "<group>"; };
661EF7BC2BEE215300C3E577 /*LoadingFileView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path =LoadingFileView.swift; sourceTree = "<group>"; };
669BC4072BED306400D1197C /*AnyFileView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path =AnyFileView.swift; sourceTree = "<group>"; };
66F2C8C32BEAA939004674F7 /*PDFFileView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path =PDFFileView.swift; sourceTree = "<group>"; };
66F370332BEE537B00D3B823 /* NonTextFileView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NonTextFileView.swift; sourceTree = "<group>"; };
6C049A362A49E2DB00D42923 /* DirectoryEventStream.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DirectoryEventStream.swift; sourceTree = "<group>"; };
6C05A8AE284D0CA3007F4EAA /* WorkspaceDocument+Listeners.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WorkspaceDocument+Listeners.swift"; sourceTree = "<group>"; };
Expand DownExpand Up@@ -1504,11 +1504,11 @@
5831E3CF2933F4E000D5A6D2 /* Views */ = {
isa = PBXGroup;
children = (
669BC4072BED306400D1197C /* WorkspaceAnyFileView.swift */,
0485EB1E27E7458B00138301 /* EditorAreaFileView.swift */,
661EF7BC2BEE215300C3E577 /* WorkspaceLoadingView.swift */,
661EF7B72BEE215300C3E577 /* WorkspaceImageView.swift */,
66F2C8C32BEAA939004674F7 /* WorkspacePDFView.swift */,
669BC4072BED306400D1197C /* AnyFileView.swift */,
661EF7BC2BEE215300C3E577 /* LoadingFileView.swift */,
661EF7B72BEE215300C3E577 /* ImageFileView.swift */,
66F2C8C32BEAA939004674F7 /* PDFFileView.swift */,
);
path = Views;
sourceTree = "<group>";
Expand DownExpand Up@@ -3351,7 +3351,7 @@
B6C4F2A62B3CABD200B2B140 /* HistoryInspectorItemView.swift in Sources */,
B65B10FE2B08B07D002852CF /* SourceControlNavigatorChangesList.swift in Sources */,
58F2EB03292FB2B0004A9BDE /* Documentation.docc in Sources */,
66F2C8C42BEAA939004674F7 /*WorkspacePDFView.swift in Sources */,
66F2C8C42BEAA939004674F7 /*PDFFileView.swift in Sources */,
611192042B08CCED00D4459B /* SearchIndexer+ProgressiveSearch.swift in Sources */,
611192022B08CCDC00D4459B /* SearchIndexer+Search.swift in Sources */,
04BA7C272AE2E9F100584E1C /* GitClient+Push.swift in Sources */,
Expand DownExpand Up@@ -3399,7 +3399,7 @@
B6C4F2AC2B3CC4D000B2B140 /* CommitChangedFileListItemView.swift in Sources */,
6C82D6B329BFD88700495C54 /* NavigateCommands.swift in Sources */,
B66A4E4C29C9179B004573B4 /* CodeEditApp.swift in Sources */,
661EF7B82BEE215300C3E577 /*WorkspaceImageView.swift in Sources */,
661EF7B82BEE215300C3E577 /*ImageFileView.swift in Sources */,
4E7F066629602E7B00BB3C12 /* CodeEditSplitViewController.swift in Sources */,
587B9E8D29301D8F00AC7927 /* GitHubAccount.swift in Sources */,
201169E72837B5CA00F92B46 /* SourceControlManager.swift in Sources */,
Expand DownExpand Up@@ -3478,7 +3478,7 @@
B6E55C3B2A95368E003ECC7D /* EditorTabsOverflowShadow.swift in Sources */,
58A5DFA229339F6400D1BD5D /* KeybindingManager.swift in Sources */,
B62AEDB32A1FD95B009A9F52 /* UtilityAreaTerminalView.swift in Sources */,
661EF7BD2BEE215300C3E577 /*WorkspaceLoadingView.swift in Sources */,
661EF7BD2BEE215300C3E577 /*LoadingFileView.swift in Sources */,
58AFAA2E2933C69E00482B53 /* EditorTabRepresentable.swift in Sources */,
6C4104E6297C884F00F472BA /* AboutDetailView.swift in Sources */,
6C6BD6F129CD13FA00235D17 /* ExtensionDiscovery.swift in Sources */,
Expand All@@ -3490,7 +3490,7 @@
6CABB1A129C5593800340467 /* SearchPanelView.swift in Sources */,
D7211D4327E066CE008F2ED7 /* Localized+Ex.swift in Sources */,
581BFB692926431000D251EC /* WelcomeActionView.swift in Sources */,
669BC4082BED306400D1197C /*WorkspaceAnyFileView.swift in Sources */,
669BC4082BED306400D1197C /*AnyFileView.swift in Sources */,
20D839AE280E0CA700B27357 /* HistoryPopoverView.swift in Sources */,
B6E41C7029DD157F0088F9F4 /* AccountsSettingsView.swift in Sources */,
6CFF967A29BEBD2400182D6F /* ViewCommands.swift in Sources */,
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,16 +24,16 @@ struct NonTextFileView: View {
switch fileDocument.utType {
case .some(.gif):
// GIF conforms to image, so to differentiate, the GIF check has to come before the image check.
WorkspaceImageView(fileURL, isGif: true)
ImageFileView(fileURL, isGif: true)

case .some(.image):
WorkspaceImageView(fileURL)
ImageFileView(fileURL)

case .some(.pdf):
WorkspacePDFView(fileURL)
PDFFileView(fileURL)

default:
WorkspaceAnyFileView(fileURL)
AnyFileView(fileURL)
}

} else {
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
//
//WorkspaceAnyFileView.swift
//AnyFileView.swift
// CodeEdit
//
// Created by Paul Ebose on 2024/5/9.
Expand All@@ -11,10 +11,10 @@ import QuickLookUI
/// A view for previewing any kind of file.
///
/// ```swift
///WorkspaceAnyFileView(fileURL)
///AnyFileView(fileURL)
/// ```
/// If the file cannot be previewed, a file icon thumbnail is shown instead.
structWorkspaceAnyFileView: NSViewRepresentable {
structAnyFileView: NSViewRepresentable {

/// URL of the file to preview. You can pass in any file type.
private let fileURL: URL
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -40,7 +40,7 @@ struct EditorAreaFileView: View {
Spacer()
}
Spacer()
WorkspaceLoadingView(file.name)
LoadingFileView(file.name)
Spacer()
.onAppear {
Task.detached {
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
//
//WorkspaceImageView.swift
//ImageFileView.swift
// CodeEdit
//
// Created by Paul Ebose on 2024/5/9.
Expand All@@ -12,7 +12,7 @@ import SwiftUI
/// It receives a URL to an image file and attempts to preview it.
///
/// ```swift
///WorkspaceImageView(imageURL)
///ImageFileView(imageURL)
/// ```
/// This implementation allows for proper image scaling, especially when the image dimensions is smaller than
/// the size of the image view area.
Expand All@@ -21,7 +21,7 @@ import SwiftUI
///
/// - Note: This view wraps around SwiftUI Image. Since SwiftUI Image view do not play GIFs, you should indicate
/// when passing in a GIF file, so this view can handle the GIF file correctly.
structWorkspaceImageView: View {
structImageFileView: View {

/// URL of the image you want to preview.
private let imageURL: URL
Expand All@@ -44,7 +44,7 @@ struct WorkspaceImageView: View {
GeometryReader { proxy in
ZStack {
if isGif {
WorkspaceAnyFileView(imageURL)
AnyFileView(imageURL)
.frame(
maxWidth: min(pixelWidth, proxy.size.width, nsImage.size.width),
maxHeight: min(pixelHeight, proxy.size.height, nsImage.size.height)
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
//
//WorkspaceLoadingView.swift
//LoadingFileView.swift
// CodeEdit
//
// Created by Paul Ebose on 2024/5/9.
Expand All@@ -11,10 +11,10 @@ import SwiftUI
///
/// It optionally receives a file name.
/// ```swift
///WorkspaceLoadingView(filename)
///WorkspaceLoadingView()
///LoadingFileView(filename)
///LoadingFileView()
/// ```
structWorkspaceLoadingView: View {
structLoadingFileView: View {

/// Name of file that is about to open.
private var filename = ""
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
//
//WorkspacePDFView.swift
//PDFFileView.swift
// CodeEdit
//
// Created by Paul Ebose on 2024/5/7.
Expand All@@ -13,7 +13,7 @@ import PDFKit.PDFView
/// It takes in a file URL and attempts to preview a PDF.
///
/// ```swift
///WorkspacePDFView(fileURL)
///PDFFileView(fileURL)
/// ```
///
/// This view provides a context menu that is the same as the one in the native MacOS Preview
Expand All@@ -22,7 +22,7 @@ import PDFKit.PDFView
/// This view also allows for proper scaling of the PDF.
///
/// - Note: If the file located at the `fileURL` cannot be previewed as a PDF, nothing happens, no redraw or anything.
structWorkspacePDFView: NSViewRepresentable {
structPDFFileView: NSViewRepresentable {

/// URL of the PDF file you want to preview.
private let fileURL: URL
Expand All@@ -40,7 +40,7 @@ struct WorkspacePDFView: NSViewRepresentable {
attachPDFDocumentToView(pdfView)
}

/// Creates a PDF document using ``WorkspacePDFView`` `.fileUrl`, and attaches it to the passed in `pdfView`.
/// Creates a PDF document using ``PDFFileView`` `.fileUrl`, and attaches it to the passed in `pdfView`.
/// - Parameters:
/// - pdfView: The [`PDFView`](https://developer.apple.com/documentation/pdfkit/pdfview) you wish to modify.
/// - Returns: A modified `pdfView` if a valid PDF was created, or an unmodified `pdfView` if it could not create a
Expand Down
5 changes: 5 additions & 0 deletionsDocumentation.docc/App Window/App Window.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,8 +12,13 @@ A collection of all the views that make up the main app window.
### Main Content

- ``EditorAreaView``
- ``EditorAreaFileView``
- ``CodeFileView``
- ``NonTextFileView``
- ``AnyFileView``
- ``LoadingFileView``
- ``ImageFileView``
- ``PDFFileView``

### PathBar

Expand Down
6 changes: 0 additions & 6 deletionsDocumentation.docc/Documentation.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -41,12 +41,6 @@
- ``CEWorkspaceFileManager``
- ``CodeFileDocument``
- ``CodeEditDocumentController``
- ``EditorAreaFileView``
- ``WorkspaceAnyFileView``
- ``WorkspaceLoadingView``
- ``WorkspaceImageView``
- ``WorkspacePDFView``
- ``WorkspaceNotificationModel``

### Feedback

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp