summaryrefslogtreecommitdiff
path: root/JuickNext/FeedView.swift
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2024-05-15 09:50:08 +0300
committerGravatar Vitaly Takmazov2024-05-15 09:50:08 +0300
commit891418e90fe29515364a236a2bb9c81e2a37ff65 (patch)
tree35422be50e4b38534ba5a0d442c90668d7d07500 /JuickNext/FeedView.swift
parent517bc874906e5b81cade91f5c7903736779fbeb0 (diff)
Refactor & reorganize project
* LoadableState -> Result
Diffstat (limited to 'JuickNext/FeedView.swift')
-rw-r--r--JuickNext/FeedView.swift60
1 files changed, 0 insertions, 60 deletions
diff --git a/JuickNext/FeedView.swift b/JuickNext/FeedView.swift
deleted file mode 100644
index 7e293bd..0000000
--- a/JuickNext/FeedView.swift
+++ /dev/null
@@ -1,60 +0,0 @@
-//
-// FeedView.swift
-// tst
-//
-// Created by Vitaly Takmazov on 10.12.2019.
-// Copyright © 2019 com.juick. All rights reserved.
-//
-
-import SwiftUI
-
-struct FeedView: View {
- @ObservedObject var messageFetcher : MessageFetcher
-
- let title: String
-
- init(_ title: String, url: String) {
- self.title = title
- messageFetcher = MessageFetcher(url: url)
- }
-
- private var stateContent: AnyView {
- switch messageFetcher.state {
- case .loading:
- return AnyView(
- ProgressView()
- )
- case .fetched(let result):
- switch result {
- case .failure(let error):
- return AnyView(
- Text(error.localizedDescription)
- )
- case .success(let root):
- return AnyView(
- List(root) { (message: Message) in
- MessageView(message: message)
- }
- )
- }
- }
- }
-
- var body: some View {
- NavigationView {
- VStack {
- stateContent
- }.toolbar {
- ToolbarItem(placement: .principal) {
- Text(title)
- }
- }
- }
- }
-}
-
-struct FeedView_Previews: PreviewProvider {
- static var previews: some View {
- FeedView("Discover", url: "https://api.juick.com/messages")
- }
-}