aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Hotline/Assets.xcassets/News Bundle.imageset/Contents.json6
-rw-r--r--Hotline/Assets.xcassets/News Bundle.imageset/Frame 3.pngbin405 -> 0 bytes
-rw-r--r--Hotline/Assets.xcassets/News Bundle.imageset/Frame 3@2x.pngbin988 -> 0 bytes
-rw-r--r--Hotline/Assets.xcassets/News Bundle.imageset/Frame 3@3x.pngbin1783 -> 0 bytes
-rw-r--r--Hotline/Assets.xcassets/News Bundle.imageset/News Bundle.pngbin0 -> 307 bytes
-rw-r--r--Hotline/Assets.xcassets/News Bundle.imageset/News Bundle@2x.pngbin0 -> 471 bytes
-rw-r--r--Hotline/Assets.xcassets/News Bundle.imageset/News Bundle@3x.pngbin0 -> 646 bytes
-rw-r--r--Hotline/Assets.xcassets/News Category.imageset/Contents.json6
-rw-r--r--Hotline/Assets.xcassets/News Category.imageset/Frame 1.pngbin402 -> 0 bytes
-rw-r--r--Hotline/Assets.xcassets/News Category.imageset/Frame 1@2x.pngbin777 -> 0 bytes
-rw-r--r--Hotline/Assets.xcassets/News Category.imageset/Frame 1@3x.pngbin1178 -> 0 bytes
-rw-r--r--Hotline/Assets.xcassets/News Category.imageset/News Category.pngbin0 -> 355 bytes
-rw-r--r--Hotline/Assets.xcassets/News Category.imageset/News Category@2x.pngbin0 -> 647 bytes
-rw-r--r--Hotline/Assets.xcassets/News Category.imageset/News Category@3x.pngbin0 -> 993 bytes
-rw-r--r--Hotline/Models/Hotline.swift1
-rw-r--r--Hotline/Models/NewsInfo.swift4
-rw-r--r--Hotline/macOS/NewsView.swift50
17 files changed, 41 insertions, 26 deletions
diff --git a/Hotline/Assets.xcassets/News Bundle.imageset/Contents.json b/Hotline/Assets.xcassets/News Bundle.imageset/Contents.json
index bfb6d35..4c19d5a 100644
--- a/Hotline/Assets.xcassets/News Bundle.imageset/Contents.json
+++ b/Hotline/Assets.xcassets/News Bundle.imageset/Contents.json
@@ -1,17 +1,17 @@
{
"images" : [
{
- "filename" : "Frame 3.png",
+ "filename" : "News Bundle.png",
"idiom" : "universal",
"scale" : "1x"
},
{
- "filename" : "Frame 3@2x.png",
+ "filename" : "News Bundle@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
- "filename" : "Frame 3@3x.png",
+ "filename" : "News Bundle@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
diff --git a/Hotline/Assets.xcassets/News Bundle.imageset/Frame 3.png b/Hotline/Assets.xcassets/News Bundle.imageset/Frame 3.png
deleted file mode 100644
index 46d144d..0000000
--- a/Hotline/Assets.xcassets/News Bundle.imageset/Frame 3.png
+++ /dev/null
Binary files differ
diff --git a/Hotline/Assets.xcassets/News Bundle.imageset/Frame 3@2x.png b/Hotline/Assets.xcassets/News Bundle.imageset/Frame 3@2x.png
deleted file mode 100644
index 2dbb989..0000000
--- a/Hotline/Assets.xcassets/News Bundle.imageset/Frame 3@2x.png
+++ /dev/null
Binary files differ
diff --git a/Hotline/Assets.xcassets/News Bundle.imageset/Frame 3@3x.png b/Hotline/Assets.xcassets/News Bundle.imageset/Frame 3@3x.png
deleted file mode 100644
index 649ab86..0000000
--- a/Hotline/Assets.xcassets/News Bundle.imageset/Frame 3@3x.png
+++ /dev/null
Binary files differ
diff --git a/Hotline/Assets.xcassets/News Bundle.imageset/News Bundle.png b/Hotline/Assets.xcassets/News Bundle.imageset/News Bundle.png
new file mode 100644
index 0000000..83e97ed
--- /dev/null
+++ 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
new file mode 100644
index 0000000..114f547
--- /dev/null
+++ 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
new file mode 100644
index 0000000..db8bb27
--- /dev/null
+++ b/Hotline/Assets.xcassets/News Bundle.imageset/News Bundle@3x.png
Binary files differ
diff --git a/Hotline/Assets.xcassets/News Category.imageset/Contents.json b/Hotline/Assets.xcassets/News Category.imageset/Contents.json
index 7245ec5..ee9c6aa 100644
--- a/Hotline/Assets.xcassets/News Category.imageset/Contents.json
+++ b/Hotline/Assets.xcassets/News Category.imageset/Contents.json
@@ -1,17 +1,17 @@
{
"images" : [
{
- "filename" : "Frame 1.png",
+ "filename" : "News Category.png",
"idiom" : "universal",
"scale" : "1x"
},
{
- "filename" : "Frame 1@2x.png",
+ "filename" : "News Category@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
- "filename" : "Frame 1@3x.png",
+ "filename" : "News Category@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
diff --git a/Hotline/Assets.xcassets/News Category.imageset/Frame 1.png b/Hotline/Assets.xcassets/News Category.imageset/Frame 1.png
deleted file mode 100644
index 1c3a080..0000000
--- a/Hotline/Assets.xcassets/News Category.imageset/Frame 1.png
+++ /dev/null
Binary files differ
diff --git a/Hotline/Assets.xcassets/News Category.imageset/Frame 1@2x.png b/Hotline/Assets.xcassets/News Category.imageset/Frame 1@2x.png
deleted file mode 100644
index e1bce20..0000000
--- a/Hotline/Assets.xcassets/News Category.imageset/Frame 1@2x.png
+++ /dev/null
Binary files differ
diff --git a/Hotline/Assets.xcassets/News Category.imageset/Frame 1@3x.png b/Hotline/Assets.xcassets/News Category.imageset/Frame 1@3x.png
deleted file mode 100644
index 6a16cef..0000000
--- a/Hotline/Assets.xcassets/News Category.imageset/Frame 1@3x.png
+++ /dev/null
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
new file mode 100644
index 0000000..2667489
--- /dev/null
+++ 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
new file mode 100644
index 0000000..c92ca23
--- /dev/null
+++ 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
new file mode 100644
index 0000000..e64c7e6
--- /dev/null
+++ b/Hotline/Assets.xcassets/News Category.imageset/News Category@3x.png
Binary files differ
diff --git a/Hotline/Models/Hotline.swift b/Hotline/Models/Hotline.swift
index 48266a9..5dc61ab 100644
--- a/Hotline/Models/Hotline.swift
+++ b/Hotline/Models/Hotline.swift
@@ -387,6 +387,7 @@ class Hotline: Equatable, HotlineClientDelegate, HotlineFileClientDelegate {
if let parentID = article.parentID,
parentID != 0,
let parentArticle = articleMap[parentID] {
+ article.expanded = true
parentArticle.children.append(article)
}
else {
diff --git a/Hotline/Models/NewsInfo.swift b/Hotline/Models/NewsInfo.swift
index b635138..eecd550 100644
--- a/Hotline/Models/NewsInfo.swift
+++ b/Hotline/Models/NewsInfo.swift
@@ -26,6 +26,10 @@ enum NewsInfoType {
var articleDate: Date?
var read: Bool = false
+ var expandable: Bool {
+ self.type == .bundle || self.type == .category || self.children.count > 0
+ }
+
init(hotlineNewsCategory: HotlineNewsCategory) {
self.categoryID = hotlineNewsCategory.id
self.articleID = nil
diff --git a/Hotline/macOS/NewsView.swift b/Hotline/macOS/NewsView.swift
index e87a7f0..906a9a4 100644
--- a/Hotline/macOS/NewsView.swift
+++ b/Hotline/macOS/NewsView.swift
@@ -151,14 +151,14 @@ struct NewsView: View {
}
}
.onKeyPress(.rightArrow) {
- if let s = selection, s.type == .bundle || s.type == .category {
+ if let s = selection, s.expandable {
s.expanded = true
return .handled
}
return .ignored
}
.onKeyPress(.leftArrow) {
- if let s = selection, s.type == .bundle || s.type == .category {
+ if let s = selection, s.expandable {
s.expanded = false
return .handled
}
@@ -248,7 +248,7 @@ struct NewsItemView: View {
var body: some View {
HStack(alignment: .center, spacing: 6) {
- if news.type == .bundle || news.type == .category || news.children.count > 0 {
+ if news.expandable {
Button {
news.expanded.toggle()
} label: {
@@ -260,16 +260,16 @@ struct NewsItemView: View {
}
.buttonStyle(.plain)
.frame(width: 10)
- .padding(.leading, 4)
+ .padding(.leading, 2)
}
else {
Spacer()
- .frame(width: 14)
+ .frame(width: 12)
}
// Tree indent
Spacer()
- .frame(width: CGFloat(max(0, depth-1)) * 16)
+ .frame(width: (CGFloat(depth) * 22))
switch news.type {
case .category:
@@ -281,8 +281,7 @@ struct NewsItemView: View {
.resizable()
.frame(width: 16, height: 16)
case .article:
- Spacer()
- .frame(width: 16)
+ EmptyView()
}
Text(news.name)
@@ -294,12 +293,26 @@ struct NewsItemView: View {
}
Spacer()
if news.type == .bundle || news.type == .category {
- Text("^[\(news.count) \(news.type == .bundle ? "Category" : "Post")](inflect: true)")
- .foregroundStyle(.secondary)
- .lineLimit(1)
- .padding([.leading, .trailing], 8)
- .padding([.top, .bottom], 2)
- .background(Capsule(style: .circular).stroke(.secondary.opacity(0.3), lineWidth: 1))
+ ZStack {
+
+ Text("^[\(news.count) \(news.type == .bundle ? "Category" : "Post")](inflect: true)")
+ .foregroundStyle(.clear)
+ .font(.caption)
+ .lineLimit(1)
+ .padding([.leading, .trailing], 8)
+ .padding([.top, .bottom], 2)
+ .background(.tertiary)
+ .clipShape(Capsule())
+
+ Text("^[\(news.count) \(news.type == .bundle ? "Category" : "Post")](inflect: true)")
+ .foregroundStyle(.white)
+ .font(.caption)
+ .lineLimit(1)
+ .padding([.leading, .trailing], 8)
+ .padding([.top, .bottom], 2)
+ .blendMode(.destinationOut)
+ }
+ .drawingGroup(opaque: false)
}
if news.type == .article && news.articleUsername != nil {
if let d = news.articleDate {
@@ -309,15 +322,12 @@ struct NewsItemView: View {
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.onChange(of: news.expanded) {
- guard news.expanded else {
+ guard news.expanded, news.type == .bundle || news.type == .category else {
return
}
- news.read = true
- if news.type == .bundle || news.type == .category {
- Task {
- await model.getNewsList(at: news.path)
- }
+ Task {
+ await model.getNewsList(at: news.path)
}
}