diff options
| author | Dustin Mierau <dustin@mierau.me> | 2023-12-12 15:27:00 -0800 |
|---|---|---|
| committer | Dustin Mierau <dustin@mierau.me> | 2023-12-12 15:27:00 -0800 |
| commit | 248fcbbd5dca84747e6f3fd9d1d52c41ab8640c3 (patch) | |
| tree | f8f76c7b071aff2fe56c4e900c72dcbaddd3c62a /Hotline/Views | |
| parent | f71c4cae3b21db506573bcdfa9fdb6cde41cc0ca (diff) | |
New category listing is working again. Added optionset for user access info. Some UI cleanup across the board.
Diffstat (limited to 'Hotline/Views')
| -rw-r--r-- | Hotline/Views/ChatView.swift | 71 | ||||
| -rw-r--r-- | Hotline/Views/FilesView.swift | 19 | ||||
| -rw-r--r-- | Hotline/Views/NewsView.swift | 10 | ||||
| -rw-r--r-- | Hotline/Views/TrackerView.swift | 22 | ||||
| -rw-r--r-- | Hotline/Views/UsersView.swift | 2 |
5 files changed, 64 insertions, 60 deletions
diff --git a/Hotline/Views/ChatView.swift b/Hotline/Views/ChatView.swift index 60951c3..8e5b135 100644 --- a/Hotline/Views/ChatView.swift +++ b/Hotline/Views/ChatView.swift @@ -15,12 +15,12 @@ struct ChatView: View { @State private var contentHeight: CGFloat = 0 @Namespace var bottomID - + var body: some View { NavigationStack { VStack(spacing: 0) { - ScrollView { - ScrollViewReader { reader in + ScrollViewReader { reader in + ScrollView { LazyVStack(alignment: .leading) { ForEach(model.chat) { msg in if msg.type == .agreement { @@ -71,27 +71,27 @@ struct ChatView: View { } Spacer() } - .padding() + .padding(EdgeInsets(top: 4, leading: 16, bottom: 4, trailing: 16)) } } EmptyView().id(bottomID) } - .onChange(of: model.chat.count) { - withAnimation { - reader.scrollTo(bottomID, anchor: .bottom) - } - print("SCROLLED TO BOTTOM") - } - .onAppear { - withAnimation { - reader.scrollTo("bottom view", anchor: .bottom) - } + .padding(.bottom, 12) + } + .onChange(of: model.chat.count) { + withAnimation { + reader.scrollTo(bottomID, anchor: .bottom) } + print("SCROLLED TO BOTTOM") + } + .onAppear { + print("SCROLLED TO BOTTOM ON APPEAR") + reader.scrollTo(bottomID, anchor: .bottom) + } + .scrollDismissesKeyboard(.interactively) + .onTapGesture { + self.endEditing() } - } - .scrollDismissesKeyboard(.interactively) - .onTapGesture { - self.endEditing() } Divider() @@ -104,7 +104,7 @@ struct ChatView: View { .onSubmit { if !self.input.isEmpty { model.sendChat(self.input) -// hotline.sendChat(message: self.input) + // hotline.sendChat(message: self.input) } self.input = "" } @@ -112,7 +112,7 @@ struct ChatView: View { Button { if !self.input.isEmpty { model.sendChat(self.input) -// hotline.sendChat(message: self.input) + // hotline.sendChat(message: self.input) } self.input = "" } label: { @@ -143,37 +143,6 @@ struct ChatView: View { } } - - - // GeometryReader { geometry in - // ScrollView(.vertical) { - // ScrollViewReader { scrollReader in - // VStack(alignment: .leading) { - // Spacer() - // List(hotline.chatMessages) { msg in - // HStack(alignment: .firstTextBaseline) { - // Text("\(msg.username):").bold().fontDesign(.monospaced) - // Text(msg.message) - // .fontDesign(.monospaced) - // .textSelection(.enabled) - // } - // } - // .padding() - // } - // // .frame(width: geometry.size.width) - // .frame(minHeight: geometry.size.height) - //// .background(Color.red) - // .onAppear() { - //// scrollReader.scrollTo("bottomScroll", anchor: .bottom) - // } - // // .onChange() { - // // scrollReader.scrollTo(10000, anchor: .bottomTrailing) - // // } - // } - // } - // } - - } } diff --git a/Hotline/Views/FilesView.swift b/Hotline/Views/FilesView.swift index 23b19b1..5cbf0c9 100644 --- a/Hotline/Views/FilesView.swift +++ b/Hotline/Views/FilesView.swift @@ -27,6 +27,10 @@ struct FileView: View { } } .onChange(of: expanded) { + if !expanded { + return + } + Task { await model.getFileList(path: file.path) } @@ -85,7 +89,7 @@ struct FileView: View { struct FilesView: View { @Environment(Hotline.self) private var model: Hotline - @State var initialLoad = false + @State var initialLoadComplete = false var body: some View { NavigationStack { @@ -94,9 +98,18 @@ struct FilesView: View { .frame(height: 44) } .task { - if !initialLoad { + if !initialLoadComplete { let _ = await model.getFileList() - initialLoad = true + initialLoadComplete = true + } + } + .overlay { + if !initialLoadComplete { + VStack { + ProgressView() + .controlSize(.large) + } + .frame(maxWidth: .infinity) } } .listStyle(.plain) diff --git a/Hotline/Views/NewsView.swift b/Hotline/Views/NewsView.swift index 431b3ce..ad7904e 100644 --- a/Hotline/Views/NewsView.swift +++ b/Hotline/Views/NewsView.swift @@ -9,7 +9,7 @@ struct NewsView: View { @State private var topListHeight: CGFloat = 200 @State private var dividerHeight: CGFloat = 30 - var topList: some View { + var articleList: some View { // Your list content goes here List { @@ -30,10 +30,11 @@ struct NewsView: View { } } } + .scrollBounceBehavior(.basedOnSize) // .listStyle(.plain) } - var bottomList: some View { + var readerView: some View { // Your list content goes here ScrollView(.vertical) { HStack(alignment: .top, spacing: 0) { @@ -43,13 +44,14 @@ struct NewsView: View { } .padding() } + .scrollBounceBehavior(.basedOnSize) .background(colorScheme == .dark ? Color(white: 0.1) : Color(uiColor: UIColor.systemBackground)) } var body: some View { NavigationStack { VStack(spacing: 0) { - topList + articleList .frame(height: topListHeight) VStack(alignment: .center) { Divider() @@ -73,7 +75,7 @@ struct NewsView: View { // bottomListHeight = max(min(bottomListHeight - delta, 400), 0) } ) - bottomList + readerView } .task { if !fetched { diff --git a/Hotline/Views/TrackerView.swift b/Hotline/Views/TrackerView.swift index 01f4311..acb2069 100644 --- a/Hotline/Views/TrackerView.swift +++ b/Hotline/Views/TrackerView.swift @@ -199,13 +199,33 @@ struct TrackerView: View { // "hotline.ubersoft.org" // "tracked.nailbat.com" // "hotline.duckdns.org" - self.servers = await model.getServers(address: "tracked.agent79.org") +// "tracked.agent79.org" + self.servers = await model.getServers(address: "hltracker.com") } var body: some View { ZStack(alignment: .center) { VStack(alignment: .center) { ZStack(alignment: .top) { + HStack(alignment: .center) { + Button { + connectVisible = true + connectDismissed = false + } label: { + Text(Image(systemName: "gearshape.fill")) + .symbolRenderingMode(.hierarchical) + .foregroundColor(.primary) + .font(.title2) + .padding(.leading, 16) + } + .sheet(isPresented: $connectVisible) { + connectDismissed = true + } content: { + TrackerConnectView() + } + Spacer() + } + .frame(height: 40.0) Image("Hotline") .resizable() .renderingMode(.template) diff --git a/Hotline/Views/UsersView.swift b/Hotline/Views/UsersView.swift index ad43131..f923ff4 100644 --- a/Hotline/Views/UsersView.swift +++ b/Hotline/Views/UsersView.swift @@ -13,7 +13,7 @@ struct UsersView: View { .foregroundStyle(u.status.contains(.admin) ? Color(hex: 0xE10000) : Color.accentColor) .opacity(u.status.contains(.idle) ? 0.5 : 1.0) } -// .listStyle(.grouped) + .scrollBounceBehavior(.basedOnSize) .navigationBarTitleDisplayMode(.inline) .toolbar { ToolbarItem(placement: .principal) { |