From 980b82d42eb8e5160f0495ad6f4472b1fc649bfe Mon Sep 17 00:00:00 2001 From: Dustin Mierau Date: Wed, 20 Dec 2023 08:08:19 -0800 Subject: Added usernames to News list. Improved date/username header on news article display. Fixed icon for message board. Removed agreement title bar. Fixed bug in News on iOS where article reader didn't span full display width when no article was selected. --- Hotline/iOS/ChatView.swift | 26 ++++++------------------ Hotline/iOS/NewsView.swift | 47 ++++++++++++++++++++++++++++++-------------- Hotline/iOS/ServerView.swift | 2 +- 3 files changed, 39 insertions(+), 36 deletions(-) diff --git a/Hotline/iOS/ChatView.swift b/Hotline/iOS/ChatView.swift index e8c7754..08b6a75 100644 --- a/Hotline/iOS/ChatView.swift +++ b/Hotline/iOS/ChatView.swift @@ -25,28 +25,14 @@ struct ChatView: View { ForEach(model.chat) { msg in if msg.type == .agreement { VStack(alignment: .leading) { - VStack(alignment: .leading, spacing: 0) { - Text(msg.text) - .textSelection(.enabled) - .padding() - .opacity(0.75) - HStack { - Spacer() - Text((model.serverTitle) + " Server Agreement") - .font(.caption) - .fontWeight(.medium) - .opacity(0.4) - .lineLimit(1) - .truncationMode(.middle) - Spacer() - } + Text(msg.text) + .textSelection(.enabled) .padding() - .background(colorScheme == .dark ? Color(white: 0.2) : Color(white: 0.9)) - } - .background(colorScheme == .dark ? Color(white: 0.1) : Color(white: 0.96)) - .cornerRadius(16) - .frame(maxWidth: .infinity) + .opacity(0.75) } + .background(colorScheme == .dark ? Color(white: 0.1) : Color(white: 0.96)) + .cornerRadius(16) + .frame(maxWidth: .infinity) .padding() } else if msg.type == .status { diff --git a/Hotline/iOS/NewsView.swift b/Hotline/iOS/NewsView.swift index d3e0bbd..92e8303 100644 --- a/Hotline/iOS/NewsView.swift +++ b/Hotline/iOS/NewsView.swift @@ -8,10 +8,18 @@ struct NewsItemView: View { let news: NewsInfo static var dateFormatter: DateFormatter = { - var dateFormatter = DateFormatter() - dateFormatter.dateFormat = "MM/dd/yy, h:mm a" - dateFormatter.timeZone = .gmt - return dateFormatter + var formatter = DateFormatter() + formatter.dateFormat = "MM/dd/yy, h:mm a" + formatter.timeZone = .gmt + return formatter + }() + + static var relativeDateFormatter: RelativeDateTimeFormatter = { + var formatter = RelativeDateTimeFormatter() + formatter.unitsStyle = .abbreviated + formatter.dateTimeStyle = .numeric + formatter.formattingContext = .listItem + return formatter }() @State var expanded = false @@ -48,7 +56,7 @@ struct NewsItemView: View { } } else { - HStack { + HStack(alignment: .firstTextBaseline) { Text(Image(systemName: "quote.opening")) Text(news.name) .lineLimit(1) @@ -56,8 +64,18 @@ struct NewsItemView: View { Spacer() if news.count > 0 { Text("\(news.count)") + .lineLimit(1) .foregroundStyle(.secondary) } + else if let postAuthor = news.articleUsername { +// Text("\(NewsItemView.relativeDateFormatter.localizedString(for: postDate, relativeTo: Date.now))") + Text(postAuthor) + .foregroundStyle(.secondary) + .truncationMode(.tail) +// .frame(maxWidth: 50) + .font(.caption) + .lineLimit(1) + } } .onTapGesture { if news.type == .article { @@ -84,7 +102,7 @@ struct NewsView: View { @State private var fetched = false @State private var selectedCategory: NewsInfo? = nil - @State private var topListHeight: CGFloat = 200 + @State private var topListHeight: CGFloat = 280 @State private var dividerHeight: CGFloat = 30 @State private var articleSelection = NewsItemSelection() @@ -171,31 +189,30 @@ struct NewsView: View { .lineLimit(1) .truncationMode(.tail) .textSelection(.enabled) - .padding() +// .padding() Spacer() Text("\(NewsItemView.dateFormatter.string(from: postDate))") .foregroundStyle(.secondary) .font(.subheadline) .lineLimit(1) .textSelection(.enabled) - .padding() } - .background(RoundedRectangle(cornerSize: CGSize(width: 8, height: 8)).fill(Color(uiColor: .tertiarySystemFill))) -// Capsule(style: .circular).fill(.secondary)) -// .padding(.bottom, 16) .padding(.bottom, 8) + + Divider() + .padding(.bottom, 16) } - Text(news.name).font(.title3) + Text(news.name).font(.title3).fontWeight(.medium) .textSelection(.enabled) - - Divider() + .padding(.bottom, 8) } Text(self.articleText) .multilineTextAlignment(.leading) - .padding(.top, 16) + .textSelection(.enabled) } + .frame(maxWidth: .infinity) .padding() } .scrollBounceBehavior(.basedOnSize) diff --git a/Hotline/iOS/ServerView.swift b/Hotline/iOS/ServerView.swift index 09ab877..1ce0a9c 100644 --- a/Hotline/iOS/ServerView.swift +++ b/Hotline/iOS/ServerView.swift @@ -32,7 +32,7 @@ struct ServerView: View { MessageBoardView() .tabItem { - Image(systemName: "book.closed") + Image(systemName: "note.text") } .tag(Tab.messageBoard) -- cgit