Release v0.2

This commit is contained in:
Akshay Kolli
2026-06-18 16:44:19 -07:00
parent c2ca546c8c
commit 09f6f9d970
10 changed files with 269 additions and 165 deletions

20
CHANGELOG.md Normal file
View File

@@ -0,0 +1,20 @@
# Changelog
## Version 0.2 - 2026-06-18
### Fixed
- Opening a PDF from Finder Open With now opens in its own window state instead of mirroring into an existing window.
- Zoom toolbar and menu commands now apply to the focused PDF window instead of another open window.
- Pressing Return in a new comment editor now saves the comment without requiring the mouse.
- Page and comments sidebar toolbar icons remain visible in narrow windows.
### Changed
- Sidebar toolbar controls are grouped together in the leading toolbar area for better visibility.
## Version 0.1
- Initial macOS SwiftUI/PDFKit release.
- Local PDF opening, reading, zoom, fit width, fit page, page navigation, and search.
- Highlight, underline, selection-bound comment, free-text annotation, comments sidebar, save, Save As, and share workflows.

View File

@@ -12,13 +12,13 @@ Supported Mac architectures: Apple Silicon and Intel, subject to the local Swift
## Latest Release ## Latest Release
Download the v0.1 macOS DMG from the GitHub release page: Download the v0.2 macOS DMG from the GitHub release page:
<https://github.com/akkolli/ihatepdfs/releases/tag/v0.1> <https://github.com/akkolli/ihatepdfs/releases/tag/v0.2>
Use `IHatePDFs-v0.1-macos.dmg` for normal app installation. Open the DMG, then drag `I Hate PDFs.app` into `/Applications`. Use `IHatePDFs-v0.2-macos.dmg` for normal app installation. Open the DMG, then drag `I Hate PDFs.app` into `/Applications`.
Signing status for v0.1: the DMG is ad-hoc signed, but it is not Developer ID signed or Apple-notarized yet. macOS Gatekeeper may require opening the app from Finder with Control-click, then Open, on first launch. Signing status for v0.2: the DMG is ad-hoc signed, but it is not Developer ID signed or Apple-notarized yet. macOS Gatekeeper may require opening the app from Finder with Control-click, then Open, on first launch.
## Features ## Features
@@ -41,7 +41,7 @@ Signing status for v0.1: the DMG is ad-hoc signed, but it is not Developer ID si
### Download Releases ### Download Releases
https://github.com/akkolli/ihatepdfs/releases/tag/v0.1 https://github.com/akkolli/ihatepdfs/releases/tag/v0.2
## Build From Source ## Build From Source
@@ -82,13 +82,13 @@ Create a downloadable `.dmg`:
scripts/make-dmg.sh scripts/make-dmg.sh
``` ```
The packaged app is written to `dist/I Hate PDFs.app`; the disk image is written to `dist/IHatePDFs.dmg`. The packaged app is written to `dist/I Hate PDFs.app`; the disk image is written to `dist/IHatePDFs-v0.2-macos.dmg`.
## Installation ## Installation
Download `IHatePDFs-v0.1-macos.dmg` from the latest GitHub release, open it, and move `I Hate PDFs.app` into `/Applications`. Download `IHatePDFs-v0.2-macos.dmg` from the latest GitHub release, open it, and move `I Hate PDFs.app` into `/Applications`.
For v0.1 and local development builds, the app is not Developer ID signed or notarized. If macOS blocks first launch, open Finder, Control-click `I Hate PDFs.app`, choose Open, then confirm. For v0.2 and local development builds, the app is not Developer ID signed or notarized. If macOS blocks first launch, open Finder, Control-click `I Hate PDFs.app`, choose Open, then confirm.
## Development ## Development

8
RELEASE_NOTES.md Normal file
View File

@@ -0,0 +1,8 @@
# Release Notes
## Version 0.2
- Fixed multi-window document state so opening a PDF with Finder Open With does not mirror it into an existing window.
- Fixed zoom commands so toolbar and menu zoom actions apply to the focused PDF window instead of another open window.
- Fixed comment entry so pressing Return saves a new comment without requiring the mouse.
- Kept the page and comments sidebar toolbar icons visible in narrow windows by grouping sidebar controls in the leading toolbar.

View File

@@ -69,6 +69,9 @@ struct CommentEditorView: View {
.onChange(of: model.author) { _ in .onChange(of: model.author) { _ in
model.updateDraft() model.updateDraft()
} }
.commitOnPlainReturn {
model.commit()
}
} }
private var header: some View { private var header: some View {

View File

@@ -3,154 +3,176 @@ import SwiftUI
@main @main
struct IHatePDFsApp: App { struct IHatePDFsApp: App {
@StateObject private var appState = AppState()
var body: some Scene { var body: some Scene {
WindowGroup { WindowGroup {
AppWindowRoot()
}
.windowStyle(.titleBar)
.commands {
AppCommands()
}
}
}
private struct AppWindowRoot: View {
@StateObject private var appState = AppState()
var body: some View {
MainView() MainView()
.environmentObject(appState) .environmentObject(appState)
.focusedObject(appState)
.onOpenURL { url in .onOpenURL { url in
appState.loadDocument(from: url) appState.loadDocument(from: url)
} }
} }
.windowStyle(.titleBar) }
.commands {
private struct AppCommands: Commands {
@FocusedObject private var appState: AppState?
private var hasDocument: Bool {
appState?.document != nil
}
var body: some Commands {
CommandGroup(replacing: .newItem) { CommandGroup(replacing: .newItem) {
Button("Open...") { Button("Open...") {
appState.openDocument() appState?.openDocument()
} }
.keyboardShortcut("o") .keyboardShortcut("o")
.disabled(appState == nil)
Button("Save") { Button("Save") {
appState.saveDocument() appState?.saveDocument()
} }
.keyboardShortcut("s") .keyboardShortcut("s")
.disabled(appState.document == nil) .disabled(!hasDocument)
Button("Save As...") { Button("Save As...") {
appState.saveDocumentAs() appState?.saveDocumentAs()
} }
.keyboardShortcut("s", modifiers: [.command, .shift]) .keyboardShortcut("s", modifiers: [.command, .shift])
.disabled(appState.document == nil) .disabled(!hasDocument)
Button("Share...") { Button("Share...") {
appState.shareDocument() appState?.shareDocument()
} }
.keyboardShortcut("e", modifiers: [.command, .shift]) .keyboardShortcut("e", modifiers: [.command, .shift])
.disabled(appState.document == nil) .disabled(!hasDocument)
Divider() Divider()
Button("Close PDF") { Button("Close PDF") {
appState.closeDocument() appState?.closeDocument()
} }
.keyboardShortcut("w") .keyboardShortcut("w")
.disabled(appState.document == nil) .disabled(!hasDocument)
} }
CommandGroup(after: .textEditing) { CommandGroup(after: .textEditing) {
Button("Find in PDF") { Button("Find in PDF") {
appState.showSearch() appState?.showSearch()
} }
.keyboardShortcut("f") .keyboardShortcut("f")
.disabled(appState.document == nil) .disabled(!hasDocument)
Button("Find Next") { Button("Find Next") {
appState.nextSearchResult() appState?.nextSearchResult()
} }
.keyboardShortcut("g") .keyboardShortcut("g")
.disabled(appState.searchResults.isEmpty) .disabled(appState?.searchResults.isEmpty != false)
Button("Find Previous") { Button("Find Previous") {
appState.previousSearchResult() appState?.previousSearchResult()
} }
.keyboardShortcut("g", modifiers: [.command, .shift]) .keyboardShortcut("g", modifiers: [.command, .shift])
.disabled(appState.searchResults.isEmpty) .disabled(appState?.searchResults.isEmpty != false)
} }
CommandMenu("View") { CommandMenu("View") {
Button("Toggle Page Sidebar") { Button("Toggle Page Sidebar") {
appState.showLeftSidebar.toggle() appState?.showLeftSidebar.toggle()
} }
.keyboardShortcut("0", modifiers: [.command, .option]) .keyboardShortcut("0", modifiers: [.command, .option])
.disabled(appState.document == nil) .disabled(!hasDocument)
Button("Toggle Comments Sidebar") { Button("Toggle Comments Sidebar") {
appState.showCommentsSidebar.toggle() appState?.showCommentsSidebar.toggle()
} }
.keyboardShortcut("1", modifiers: [.command, .option]) .keyboardShortcut("1", modifiers: [.command, .option])
.disabled(appState.document == nil) .disabled(!hasDocument)
Divider() Divider()
Button("Zoom In") { Button("Zoom In") {
appState.zoomIn() appState?.zoomIn()
} }
.keyboardShortcut("+") .keyboardShortcut("+")
.disabled(appState.document == nil) .disabled(!hasDocument)
Button("Zoom Out") { Button("Zoom Out") {
appState.zoomOut() appState?.zoomOut()
} }
.keyboardShortcut("-") .keyboardShortcut("-")
.disabled(appState.document == nil) .disabled(!hasDocument)
Button("Fit to Width") { Button("Fit to Width") {
appState.fitWidth() appState?.fitWidth()
} }
.keyboardShortcut("9", modifiers: [.command]) .keyboardShortcut("9", modifiers: [.command])
.disabled(appState.document == nil) .disabled(!hasDocument)
Button("Fit to Page") { Button("Fit to Page") {
appState.fitPage() appState?.fitPage()
} }
.keyboardShortcut("8", modifiers: [.command]) .keyboardShortcut("8", modifiers: [.command])
.disabled(appState.document == nil) .disabled(!hasDocument)
Button("Two Pages Continuous") { Button("Two Pages Continuous") {
appState.twoPageContinuous() appState?.twoPageContinuous()
} }
.keyboardShortcut("7", modifiers: [.command]) .keyboardShortcut("7", modifiers: [.command])
.disabled(appState.document == nil) .disabled(!hasDocument)
} }
CommandMenu("Annotate") { CommandMenu("Annotate") {
Button("Highlight Selection") { Button("Highlight Selection") {
appState.addHighlight() appState?.addHighlight()
} }
.keyboardShortcut("h", modifiers: [.command, .shift]) .keyboardShortcut("h", modifiers: [.command, .shift])
.disabled(appState.document == nil) .disabled(!hasDocument)
Button("Underline Selection") { Button("Underline Selection") {
appState.addUnderline() appState?.addUnderline()
} }
.keyboardShortcut("u", modifiers: [.command, .shift]) .keyboardShortcut("u", modifiers: [.command, .shift])
.disabled(appState.document == nil) .disabled(!hasDocument)
Button("Comment on Selection") { Button("Comment on Selection") {
appState.addComment() appState?.addComment()
} }
.keyboardShortcut("n", modifiers: [.command, .shift]) .keyboardShortcut("n", modifiers: [.command, .shift])
.disabled(appState.document == nil) .disabled(!hasDocument)
Button("Add Free Text") { Button("Add Free Text") {
appState.addFreeText() appState?.addFreeText()
} }
.keyboardShortcut("t", modifiers: [.command, .shift]) .keyboardShortcut("t", modifiers: [.command, .shift])
.disabled(appState.document == nil) .disabled(!hasDocument)
} }
CommandGroup(after: .windowArrangement) { CommandGroup(after: .windowArrangement) {
Button("Minimize") { Button("Minimize") {
appState.minimizeWindow() appState?.minimizeWindow()
} }
.keyboardShortcut("m", modifiers: [.command]) .keyboardShortcut("m", modifiers: [.command])
.disabled(appState == nil)
Button("Toggle Full Screen") { Button("Toggle Full Screen") {
appState.toggleFullScreen() appState?.toggleFullScreen()
} }
.keyboardShortcut("f", modifiers: [.command, .control]) .keyboardShortcut("f", modifiers: [.command, .control])
} .disabled(appState == nil)
} }
} }
} }

View File

@@ -129,6 +129,15 @@ private struct ReaderToolbar: ToolbarContent {
} }
.disabled(appState.document == nil) .disabled(appState.document == nil)
.help("Toggle Page Sidebar") .help("Toggle Page Sidebar")
Button {
appState.showCommentsSidebar.toggle()
} label: {
Label("Comments Sidebar", systemImage: "sidebar.right")
}
.disabled(appState.document == nil)
.help(appState.showCommentsSidebar ? "Hide Comments Sidebar" : "Show Comments Sidebar")
.accessibilityLabel("Toggle Comments Sidebar")
} }
ToolbarItemGroup(placement: .principal) { ToolbarItemGroup(placement: .principal) {
@@ -288,16 +297,5 @@ private struct ReaderToolbar: ToolbarContent {
.disabled(appState.document == nil) .disabled(appState.document == nil)
.help("Share PDF") .help("Share PDF")
} }
ToolbarItemGroup(placement: .primaryAction) {
Button {
appState.showCommentsSidebar.toggle()
} label: {
Label("Comments Sidebar", systemImage: "sidebar.right")
}
.disabled(appState.document == nil)
.help(appState.showCommentsSidebar ? "Hide Comments Sidebar" : "Show Comments Sidebar")
.accessibilityLabel("Toggle Comments Sidebar")
}
} }
} }

View File

@@ -0,0 +1,45 @@
import AppKit
import SwiftUI
extension View {
func commitOnPlainReturn(_ action: @escaping () -> Void) -> some View {
modifier(ReturnKeyCommitMonitor(action: action))
}
}
private struct ReturnKeyCommitMonitor: ViewModifier {
let action: () -> Void
@State private var monitor: Any?
func body(content: Content) -> some View {
content
.onAppear {
installMonitor()
}
.onDisappear {
removeMonitor()
}
}
private func installMonitor() {
removeMonitor()
monitor = NSEvent.addLocalMonitorForEvents(matching: .keyDown) { event in
guard isPlainReturn(event) else { return event }
action()
return nil
}
}
private func removeMonitor() {
guard let monitor else { return }
NSEvent.removeMonitor(monitor)
self.monitor = nil
}
private func isPlainReturn(_ event: NSEvent) -> Bool {
guard event.keyCode == 36 || event.keyCode == 76 else { return false }
let multilineModifiers: NSEvent.ModifierFlags = [.shift, .option, .command, .control]
return event.modifierFlags.intersection(multilineModifiers).isEmpty
}
}

View File

@@ -574,6 +574,11 @@ private struct SidebarReplyComposer: View {
isFocused = true isFocused = true
} }
} }
.commitOnPlainReturn {
if !appState.sidebarReplyDraft.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
appState.commitSidebarReply()
}
}
} }
} }

View File

@@ -3,6 +3,8 @@ set -euo pipefail
APP_NAME="I Hate PDFs" APP_NAME="I Hate PDFs"
EXECUTABLE_NAME="IHatePDFs" EXECUTABLE_NAME="IHatePDFs"
APP_VERSION="${APP_VERSION:-0.2.0}"
BUILD_NUMBER="${BUILD_NUMBER:-2}"
CONFIGURATION="${CONFIGURATION:-release}" CONFIGURATION="${CONFIGURATION:-release}"
if [[ -z "${ARCHS+x}" && "$CONFIGURATION" == "release" ]]; then if [[ -z "${ARCHS+x}" && "$CONFIGURATION" == "release" ]]; then
ARCHS="arm64 x86_64" ARCHS="arm64 x86_64"
@@ -97,9 +99,9 @@ cat > "$CONTENTS_DIR/Info.plist" <<PLIST
</dict> </dict>
</array> </array>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>0.1.0</string> <string>$APP_VERSION</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>1</string> <string>$BUILD_NUMBER</string>
<key>LSMinimumSystemVersion</key> <key>LSMinimumSystemVersion</key>
<string>13.0</string> <string>13.0</string>
<key>NSHighResolutionCapable</key> <key>NSHighResolutionCapable</key>

View File

@@ -3,9 +3,10 @@ set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
APP_NAME="I Hate PDFs" APP_NAME="I Hate PDFs"
RELEASE_VERSION="${RELEASE_VERSION:-0.2}"
DIST_DIR="$ROOT_DIR/dist" DIST_DIR="$ROOT_DIR/dist"
APP_DIR="$DIST_DIR/$APP_NAME.app" APP_DIR="$DIST_DIR/$APP_NAME.app"
DMG_PATH="$DIST_DIR/IHatePDFs.dmg" DMG_PATH="$DIST_DIR/IHatePDFs-v$RELEASE_VERSION-macos.dmg"
if [[ ! -d "$APP_DIR" ]]; then if [[ ! -d "$APP_DIR" ]]; then
"$ROOT_DIR/scripts/build-app.sh" "$ROOT_DIR/scripts/build-app.sh"