aboutsummaryrefslogtreecommitdiff
path: root/Hotline
diff options
context:
space:
mode:
authorDustin Mierau <dustin@mierau.me>2024-05-13 11:59:41 -0700
committerDustin Mierau <dustin@mierau.me>2024-05-13 11:59:41 -0700
commit67050d06a3bc2d28e969cf1388eafa95400c35a3 (patch)
treea866c6b5684d54d7dd7427902780679ce476092a /Hotline
parent6f166f0f12aab78fb0ab69cca386c8d8450cd9cc (diff)
Make News toolbar buttons disable contextually. Use Finder folder icon in Files list.
Diffstat (limited to 'Hotline')
-rw-r--r--Hotline/Assets.xcassets/News Bundle.imageset/News Bundle.pngbin307 -> 290 bytes
-rw-r--r--Hotline/Assets.xcassets/News Bundle.imageset/News Bundle@2x.pngbin471 -> 437 bytes
-rw-r--r--Hotline/Assets.xcassets/News Bundle.imageset/News Bundle@3x.pngbin646 -> 596 bytes
-rw-r--r--Hotline/Assets.xcassets/News Category.imageset/News Category.pngbin355 -> 326 bytes
-rw-r--r--Hotline/Assets.xcassets/News Category.imageset/News Category@2x.pngbin647 -> 534 bytes
-rw-r--r--Hotline/Assets.xcassets/News Category.imageset/News Category@3x.pngbin993 -> 719 bytes
-rw-r--r--Hotline/Shared/FileIconView.swift16
-rw-r--r--Hotline/macOS/FilesView.swift3
-rw-r--r--Hotline/macOS/NewsView.swift53
9 files changed, 54 insertions, 18 deletions
diff --git a/Hotline/Assets.xcassets/News Bundle.imageset/News Bundle.png b/Hotline/Assets.xcassets/News Bundle.imageset/News Bundle.png
index 83e97ed..ea6fe08 100644
--- a/Hotline/Assets.xcassets/News Bundle.imageset/News Bundle.png
+++ b/Hotline/Assets.xcassets/News Bundle.imageset/News Bundle.png
Binary files differ
diff --git a/Hotline/Assets.xcassets/News Bundle.imageset/News Bundle@2x.png b/Hotline/Assets.xcassets/News Bundle.imageset/News Bundle@2x.png
index 114f547..8271cc3 100644
--- a/Hotline/Assets.xcassets/News Bundle.imageset/News Bundle@2x.png
+++ b/Hotline/Assets.xcassets/News Bundle.imageset/News Bundle@2x.png
Binary files differ
diff --git a/Hotline/Assets.xcassets/News Bundle.imageset/News Bundle@3x.png b/Hotline/Assets.xcassets/News Bundle.imageset/News Bundle@3x.png
index db8bb27..b018b6d 100644
--- a/Hotline/Assets.xcassets/News Bundle.imageset/News Bundle@3x.png
+++ b/Hotline/Assets.xcassets/News Bundle.imageset/News Bundle@3x.png
Binary files differ
diff --git a/Hotline/Assets.xcassets/News Category.imageset/News Category.png b/Hotline/Assets.xcassets/News Category.imageset/News Category.png
index 2667489..cc8554b 100644
--- a/Hotline/Assets.xcassets/News Category.imageset/News Category.png
+++ b/Hotline/Assets.xcassets/News Category.imageset/News Category.png
Binary files differ
diff --git a/Hotline/Assets.xcassets/News Category.imageset/News Category@2x.png b/Hotline/Assets.xcassets/News Category.imageset/News Category@2x.png
index c92ca23..28053fd 100644
--- a/Hotline/Assets.xcassets/News Category.imageset/News Category@2x.png
+++ b/Hotline/Assets.xcassets/News Category.imageset/News Category@2x.png
Binary files differ
diff --git a/Hotline/Assets.xcassets/News Category.imageset/News Category@3x.png b/Hotline/Assets.xcassets/News Category.imageset/News Category@3x.png
index e64c7e6..0c968bb 100644
--- a/Hotline/Assets.xcassets/News Category.imageset/News Category@3x.png
+++ b/Hotline/Assets.xcassets/News Category.imageset/News Category@3x.png
Binary files differ
diff --git a/Hotline/Shared/FileIconView.swift b/Hotline/Shared/FileIconView.swift
index 7336cf3..ffc9051 100644
--- a/Hotline/Shared/FileIconView.swift
+++ b/Hotline/Shared/FileIconView.swift
@@ -1,6 +1,22 @@
import SwiftUI
import UniformTypeIdentifiers
+struct FolderIconView: View {
+ private func folderIcon() -> Image {
+#if os(iOS)
+ return Image(systemName: "folder.fill")
+#elseif os(macOS)
+ return Image(nsImage: NSWorkspace.shared.icon(for: UTType.folder))
+#endif
+ }
+
+ var body: some View {
+ folderIcon()
+ .resizable()
+ .scaledToFit()
+ }
+}
+
struct FileIconView: View {
let filename: String
diff --git a/Hotline/macOS/FilesView.swift b/Hotline/macOS/FilesView.swift
index f698b5d..133e1fd 100644
--- a/Hotline/macOS/FilesView.swift
+++ b/Hotline/macOS/FilesView.swift
@@ -38,7 +38,8 @@ struct FileView: View {
Image(systemName: "questionmark.app.fill").opacity(0.5)
}
else if file.isFolder {
- Image(systemName: "folder.fill")
+ FolderIconView()
+ .frame(width: 16, height: 16)
}
else {
FileIconView(filename: file.name)
diff --git a/Hotline/macOS/NewsView.swift b/Hotline/macOS/NewsView.swift
index 201d3e2..f440cb2 100644
--- a/Hotline/macOS/NewsView.swift
+++ b/Hotline/macOS/NewsView.swift
@@ -56,7 +56,7 @@ struct NewsView: View {
)
.fraction(splitFraction)
.constraints(minPFraction: 0.1, minSFraction: 0.3)
- .hide(splitHidden)
+// .hide(splitHidden)
.styling(color: colorScheme == .dark ? .black : Splitter.defaultColor, inset: 0, visibleThickness: 0.5, invisibleThickness: 5, hideSplitter: true)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color(nsColor: .textBackgroundColor))
@@ -68,11 +68,11 @@ struct NewsView: View {
}
}
}
-// .sheet(isPresented: $editorOpen) {
-// print("Sheet dismissed!")
-// } content: {
-// NewsEditorView()
-// }
+ .sheet(isPresented: $editorOpen) {
+ print("Sheet dismissed!")
+ } content: {
+ NewsEditorView()
+ }
.toolbar {
ToolbarItem(placement: .primaryAction) {
Button {
@@ -84,13 +84,14 @@ struct NewsView: View {
ToolbarItem(placement: .primaryAction) {
Button {
-// if let selection = selection {
-// editorOpen = true
-//// openWindow(id: "news-editor", value: NewsArticle(parentID: nil, path: selection.path, title: "", body: ""))
-// }
+ if selection?.type == .category || selection?.type == .article {
+ editorOpen = true
+// openWindow(id: "news-editor", value: NewsArticle(parentID: nil, path: selection.path, title: "", body: ""))
+ }
} label: {
Image(systemName: "square.and.pencil")
}
+ .disabled(selection?.type != .category && selection?.type != .article)
}
ToolbarItem(placement: .primaryAction) {
@@ -99,6 +100,7 @@ struct NewsView: View {
} label: {
Image(systemName: "arrowshape.turn.up.left")
}
+ .disabled(selection?.type != .article)
}
}
}
@@ -180,8 +182,8 @@ struct NewsView: View {
var articleViewer: some View {
ScrollView {
- if let selection = selection {
- VStack(alignment: .leading, spacing: 0) {
+ VStack(alignment: .leading, spacing: 0) {
+ if let selection = selection, selection.type == .article {
if let poster = selection.articleUsername, let postDate = selection.articleDate {
HStack(alignment: .firstTextBaseline) {
Text(poster)
@@ -215,9 +217,27 @@ struct NewsView: View {
.padding(.top, 16)
}
}
- .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading)
- .padding()
+ else {
+ HStack(alignment: .center) {
+ Spacer()
+ HStack(alignment: .center, spacing: 8) {
+// Image(systemName: "doc.append")
+// .resizable()
+// .scaledToFit()
+// .foregroundStyle(.tertiary)
+// .frame(width: 16, height: 16)
+ Text("Select a news post to read")
+ .foregroundStyle(.tertiary)
+ .font(.system(size: 13))
+ }
+ Spacer()
+ }
+ .padding()
+ .padding(.top, 48)
+ }
}
+ .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading)
+ .padding()
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.transition(.move(edge: .bottom))
@@ -294,10 +314,9 @@ struct NewsItemView: View {
Spacer()
if news.type == .bundle || news.type == .category {
ZStack {
-
Text("^[\(news.count) \(news.type == .bundle ? "Category" : "Post")](inflect: true)")
.foregroundStyle(.clear)
- .font(.caption)
+ .font(.caption2)
.lineLimit(1)
.padding([.leading, .trailing], 8)
.padding([.top, .bottom], 2)
@@ -306,7 +325,7 @@ struct NewsItemView: View {
Text("^[\(news.count) \(news.type == .bundle ? "Category" : "Post")](inflect: true)")
.foregroundStyle(.white)
- .font(.caption)
+ .font(.caption2)
.lineLimit(1)
.padding([.leading, .trailing], 8)
.padding([.top, .bottom], 2)