summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2024-05-15 09:38:05 +0300
committerGravatar Vitaly Takmazov2024-05-15 09:38:05 +0300
commitf2bf132d6df251ea7d5224d0d86c2ca5b0c02320 (patch)
tree0e3206404d934c8bff590ba1f3c757ab05192def
parent1b058af687bac9dfe8c78209fe7ba510b2d78257 (diff)
Integrate feeds from good old `tst` 2019 project
-rw-r--r--Juick.xcodeproj/project.pbxproj48
-rw-r--r--Juick/Images.xcassets/Contents.json6
-rw-r--r--Juick/Images.xcassets/Discover.imageset/Contents.json16
-rw-r--r--Juick/Images.xcassets/Discover.imageset/Discover.pdfbin0 -> 3990 bytes
-rw-r--r--JuickNext/FeedView.swift55
-rw-r--r--JuickNext/Helpers/Image+Data.swift35
-rw-r--r--JuickNext/ImageFetcher.swift28
-rw-r--r--JuickNext/LoadableImageView.swift29
-rw-r--r--JuickNext/LoadableState.swift25
-rw-r--r--JuickNext/MessageFetcher.swift39
-rw-r--r--JuickNext/MessageView.swift43
-rw-r--r--JuickNext/Models.swift47
-rw-r--r--JuickNext/View/ContentView.swift13
-rw-r--r--JuickNext/View/Discussions.swift21
-rw-r--r--JuickNext/View/Today.swift24
15 files changed, 369 insertions, 60 deletions
diff --git a/Juick.xcodeproj/project.pbxproj b/Juick.xcodeproj/project.pbxproj
index 7da0fdd..68ca4a4 100644
--- a/Juick.xcodeproj/project.pbxproj
+++ b/Juick.xcodeproj/project.pbxproj
@@ -14,9 +14,7 @@
77163AB62A104786009BEE0E /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77163AB52A104786009BEE0E /* ContentView.swift */; };
77163AB82A104787009BEE0E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 77163AB72A104787009BEE0E /* Assets.xcassets */; };
77163ABC2A104787009BEE0E /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 77163ABB2A104787009BEE0E /* Preview Assets.xcassets */; };
- 77163AC42A104AFC009BEE0E /* Today.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77163AC32A104AFC009BEE0E /* Today.swift */; };
77163AC52A104C67009BEE0E /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 77317BC6181BBE8500D60005 /* Images.xcassets */; };
- 77163AC72A10509A009BEE0E /* Discussions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77163AC62A10509A009BEE0E /* Discussions.swift */; };
772B4E6C2199811E0029706E /* Entity.m in Sources */ = {isa = PBXBuildFile; fileRef = 772B4E6B2199811E0029706E /* Entity.m */; };
77317BAC181BBE8500D60005 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 77317BAB181BBE8500D60005 /* Foundation.framework */; };
77317BAE181BBE8500D60005 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 77317BAD181BBE8500D60005 /* CoreGraphics.framework */; };
@@ -58,6 +56,14 @@
77975A1F182BDCE900410C2B /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 77975A1E182BDCE900410C2B /* SystemConfiguration.framework */; };
779F82C72A146CE700D996D3 /* SafariServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 779F82C62A146CE600D996D3 /* SafariServices.framework */; };
77A0954A181F1F25002BDECD /* Message.m in Sources */ = {isa = PBXBuildFile; fileRef = 77A09549181F1F25002BDECD /* Message.m */; };
+ 77AA76462BF48818007A0FA8 /* LoadableImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77AA763E2BF48818007A0FA8 /* LoadableImageView.swift */; };
+ 77AA76472BF48818007A0FA8 /* MessageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77AA763F2BF48818007A0FA8 /* MessageView.swift */; };
+ 77AA76482BF48818007A0FA8 /* Models.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77AA76402BF48818007A0FA8 /* Models.swift */; };
+ 77AA764A2BF48818007A0FA8 /* FeedView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77AA76422BF48818007A0FA8 /* FeedView.swift */; };
+ 77AA764B2BF48818007A0FA8 /* MessageFetcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77AA76432BF48818007A0FA8 /* MessageFetcher.swift */; };
+ 77AA764C2BF48818007A0FA8 /* LoadableState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77AA76442BF48818007A0FA8 /* LoadableState.swift */; };
+ 77AA764D2BF48818007A0FA8 /* ImageFetcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77AA76452BF48818007A0FA8 /* ImageFetcher.swift */; };
+ 77AA76502BF488A9007A0FA8 /* Image+Data.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77AA764F2BF488A9007A0FA8 /* Image+Data.swift */; };
77B09994189D0B9900A84F59 /* UIImage+Utils.m in Sources */ = {isa = PBXBuildFile; fileRef = 77B09993189D0B9900A84F59 /* UIImage+Utils.m */; };
77B099A6189D57F000A84F59 /* User.m in Sources */ = {isa = PBXBuildFile; fileRef = 77B099A5189D57F000A84F59 /* User.m */; };
77B8B399207A52BD005CB20C /* MessageInputView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 77B8B398207A52BD005CB20C /* MessageInputView.xib */; };
@@ -119,8 +125,6 @@
77163AB52A104786009BEE0E /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
77163AB72A104787009BEE0E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
77163ABB2A104787009BEE0E /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
- 77163AC32A104AFC009BEE0E /* Today.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Today.swift; sourceTree = "<group>"; };
- 77163AC62A10509A009BEE0E /* Discussions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Discussions.swift; sourceTree = "<group>"; };
772B4E6A2199811E0029706E /* Entity.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Entity.h; sourceTree = "<group>"; };
772B4E6B2199811E0029706E /* Entity.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Entity.m; sourceTree = "<group>"; };
77317BA8181BBE8500D60005 /* Juick.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Juick.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -186,6 +190,14 @@
779F82C62A146CE600D996D3 /* SafariServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SafariServices.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/System/iOSSupport/System/Library/Frameworks/SafariServices.framework; sourceTree = DEVELOPER_DIR; };
77A09548181F1F25002BDECD /* Message.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Message.h; sourceTree = "<group>"; };
77A09549181F1F25002BDECD /* Message.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Message.m; sourceTree = "<group>"; };
+ 77AA763E2BF48818007A0FA8 /* LoadableImageView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoadableImageView.swift; sourceTree = "<group>"; };
+ 77AA763F2BF48818007A0FA8 /* MessageView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageView.swift; sourceTree = "<group>"; };
+ 77AA76402BF48818007A0FA8 /* Models.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Models.swift; sourceTree = "<group>"; };
+ 77AA76422BF48818007A0FA8 /* FeedView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedView.swift; sourceTree = "<group>"; };
+ 77AA76432BF48818007A0FA8 /* MessageFetcher.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageFetcher.swift; sourceTree = "<group>"; };
+ 77AA76442BF48818007A0FA8 /* LoadableState.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoadableState.swift; sourceTree = "<group>"; };
+ 77AA76452BF48818007A0FA8 /* ImageFetcher.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageFetcher.swift; sourceTree = "<group>"; };
+ 77AA764F2BF488A9007A0FA8 /* Image+Data.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Image+Data.swift"; sourceTree = "<group>"; };
77B09992189D0B9900A84F59 /* UIImage+Utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+Utils.h"; sourceTree = "<group>"; };
77B09993189D0B9900A84F59 /* UIImage+Utils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+Utils.m"; sourceTree = "<group>"; };
77B099A4189D57F000A84F59 /* User.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = User.h; sourceTree = "<group>"; };
@@ -267,8 +279,6 @@
77163AC82A1051DE009BEE0E /* View */ = {
isa = PBXGroup;
children = (
- 77163AC32A104AFC009BEE0E /* Today.swift */,
- 77163AC62A10509A009BEE0E /* Discussions.swift */,
77163AB52A104786009BEE0E /* ContentView.swift */,
);
path = View;
@@ -444,6 +454,14 @@
779F82C52A146AC200D996D3 /* JuickNext */ = {
isa = PBXGroup;
children = (
+ 77AA764E2BF48890007A0FA8 /* Helpers */,
+ 77AA76422BF48818007A0FA8 /* FeedView.swift */,
+ 77AA76452BF48818007A0FA8 /* ImageFetcher.swift */,
+ 77AA763E2BF48818007A0FA8 /* LoadableImageView.swift */,
+ 77AA76442BF48818007A0FA8 /* LoadableState.swift */,
+ 77AA76432BF48818007A0FA8 /* MessageFetcher.swift */,
+ 77AA763F2BF48818007A0FA8 /* MessageView.swift */,
+ 77AA76402BF48818007A0FA8 /* Models.swift */,
77163AC82A1051DE009BEE0E /* View */,
77163AB32A104786009BEE0E /* JuickApp.swift */,
77163AB72A104787009BEE0E /* Assets.xcassets */,
@@ -452,6 +470,14 @@
path = JuickNext;
sourceTree = "<group>";
};
+ 77AA764E2BF48890007A0FA8 /* Helpers */ = {
+ isa = PBXGroup;
+ children = (
+ 77AA764F2BF488A9007A0FA8 /* Image+Data.swift */,
+ );
+ path = Helpers;
+ sourceTree = "<group>";
+ };
77F2B6A0251249F300E42F6F /* JuickTests */ = {
isa = PBXGroup;
children = (
@@ -674,10 +700,16 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ 77AA76472BF48818007A0FA8 /* MessageView.swift in Sources */,
+ 77AA764B2BF48818007A0FA8 /* MessageFetcher.swift in Sources */,
+ 77AA764C2BF48818007A0FA8 /* LoadableState.swift in Sources */,
+ 77AA76502BF488A9007A0FA8 /* Image+Data.swift in Sources */,
+ 77AA764A2BF48818007A0FA8 /* FeedView.swift in Sources */,
77163AB62A104786009BEE0E /* ContentView.swift in Sources */,
- 77163AC42A104AFC009BEE0E /* Today.swift in Sources */,
- 77163AC72A10509A009BEE0E /* Discussions.swift in Sources */,
+ 77AA76462BF48818007A0FA8 /* LoadableImageView.swift in Sources */,
+ 77AA764D2BF48818007A0FA8 /* ImageFetcher.swift in Sources */,
77163AB42A104786009BEE0E /* JuickApp.swift in Sources */,
+ 77AA76482BF48818007A0FA8 /* Models.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/Juick/Images.xcassets/Contents.json b/Juick/Images.xcassets/Contents.json
index da4a164..73c0059 100644
--- a/Juick/Images.xcassets/Contents.json
+++ b/Juick/Images.xcassets/Contents.json
@@ -1,6 +1,6 @@
{
"info" : {
- "version" : 1,
- "author" : "xcode"
+ "author" : "xcode",
+ "version" : 1
}
-} \ No newline at end of file
+}
diff --git a/Juick/Images.xcassets/Discover.imageset/Contents.json b/Juick/Images.xcassets/Discover.imageset/Contents.json
new file mode 100644
index 0000000..995a673
--- /dev/null
+++ b/Juick/Images.xcassets/Discover.imageset/Contents.json
@@ -0,0 +1,16 @@
+{
+ "images" : [
+ {
+ "filename" : "Discover.pdf",
+ "idiom" : "universal"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ },
+ "properties" : {
+ "preserves-vector-representation" : true,
+ "template-rendering-intent" : "template"
+ }
+}
diff --git a/Juick/Images.xcassets/Discover.imageset/Discover.pdf b/Juick/Images.xcassets/Discover.imageset/Discover.pdf
new file mode 100644
index 0000000..104f06d
--- /dev/null
+++ b/Juick/Images.xcassets/Discover.imageset/Discover.pdf
Binary files differ
diff --git a/JuickNext/FeedView.swift b/JuickNext/FeedView.swift
new file mode 100644
index 0000000..399da1f
--- /dev/null
+++ b/JuickNext/FeedView.swift
@@ -0,0 +1,55 @@
+//
+// 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 {
+ stateContent
+ .navigationBarTitle(Text(title), displayMode: .inline)
+ }
+ }
+}
+
+struct FeedView_Previews: PreviewProvider {
+ static var previews: some View {
+ FeedView("Discover", url: "https://api.juick.com/messages")
+ }
+}
diff --git a/JuickNext/Helpers/Image+Data.swift b/JuickNext/Helpers/Image+Data.swift
new file mode 100644
index 0000000..dee2693
--- /dev/null
+++ b/JuickNext/Helpers/Image+Data.swift
@@ -0,0 +1,35 @@
+//
+// Image+Data.swift
+// JuickNext
+//
+// Created by Vitaly Takmazov on 15.05.2024.
+// Copyright © 2024 com.juick. All rights reserved.
+//
+
+import Foundation
+import SwiftUI
+#if canImport(UIKit)
+import UIKit
+#elseif canImport(AppKit)
+import AppKit
+#endif
+extension Image {
+ /// Initializes a SwiftUI `Image` from data.
+ init?(data: Data) {
+#if canImport(UIKit)
+ if let uiImage = UIImage(data: data) {
+ self.init(uiImage: uiImage)
+ } else {
+ return nil
+ }
+#elseif canImport(AppKit)
+ if let nsImage = NSImage(data: data) {
+ self.init(nsImage: nsImage)
+ } else {
+ return nil
+ }
+#else
+ return nil
+#endif
+ }
+}
diff --git a/JuickNext/ImageFetcher.swift b/JuickNext/ImageFetcher.swift
new file mode 100644
index 0000000..f76c0ba
--- /dev/null
+++ b/JuickNext/ImageFetcher.swift
@@ -0,0 +1,28 @@
+//
+// ImageFetcher.swift
+// tst
+//
+// Created by Vitaly Takmazov on 10.12.2019.
+// Copyright © 2019 com.juick. All rights reserved.
+//
+
+import Foundation
+import Combine
+
+class ImageFetcher: ObservableObject {
+
+ @Published var data: Data = Data()
+
+ init(url: String) {
+ guard let imageUrl = URL(string: url) else {
+ return
+ }
+
+ URLSession.shared.dataTask(with: imageUrl) { (data, _, _) in
+ guard let data = data else { return }
+ DispatchQueue.main.async { [weak self] in
+ self?.data = data
+ }
+ }.resume()
+ }
+}
diff --git a/JuickNext/LoadableImageView.swift b/JuickNext/LoadableImageView.swift
new file mode 100644
index 0000000..6a41dc2
--- /dev/null
+++ b/JuickNext/LoadableImageView.swift
@@ -0,0 +1,29 @@
+//
+// LoadableImageView.swift
+// tst
+//
+// Created by Vitaly Takmazov on 10.12.2019.
+// Copyright © 2019 com.juick. All rights reserved.
+//
+
+import SwiftUI
+
+struct LoadableImageView: View {
+ @ObservedObject var imageFetcher: ImageFetcher
+
+ init(with urlString: String) {
+ imageFetcher = ImageFetcher(url: urlString)
+ }
+
+ var body: some View {
+ if let image = Image(data: imageFetcher.data) {
+ return AnyView(
+ image.resizable()
+ )
+ } else {
+ return AnyView(
+ ProgressView()
+ )
+ }
+ }
+}
diff --git a/JuickNext/LoadableState.swift b/JuickNext/LoadableState.swift
new file mode 100644
index 0000000..a45edb2
--- /dev/null
+++ b/JuickNext/LoadableState.swift
@@ -0,0 +1,25 @@
+//
+// LoadableState.swift
+// tst
+//
+// Created by Vitaly Takmazov on 10.12.2019.
+// Copyright © 2019 com.juick. All rights reserved.
+//
+
+import Foundation
+
+enum LoadableState<T> {
+ case loading
+ case fetched(Result<T, FetchError>)
+}
+
+enum FetchError: Error {
+ case error(String)
+
+ var localizedDescription: String {
+ switch self {
+ case .error(let message):
+ return message
+ }
+ }
+}
diff --git a/JuickNext/MessageFetcher.swift b/JuickNext/MessageFetcher.swift
new file mode 100644
index 0000000..565cca0
--- /dev/null
+++ b/JuickNext/MessageFetcher.swift
@@ -0,0 +1,39 @@
+//
+// MessageFetcher.swift
+// tst
+//
+// Created by Vitaly Takmazov on 10.12.2019.
+// Copyright © 2019 com.juick. All rights reserved.
+//
+
+import Foundation
+import Combine
+
+class MessageFetcher: ObservableObject {
+
+ @Published var state: LoadableState<Root> = .loading
+
+ init(url: String) {
+ guard let apiUrl = URL(string: url) else {
+ state = .fetched(.failure(.error("Malformed API URL.")))
+ return
+ }
+
+ URLSession.shared.dataTask(with: apiUrl) { [weak self] (data, _, error) in
+ if let error = error {
+ self?.state = .fetched(.failure(.error(error.localizedDescription)))
+ return
+ }
+
+ guard let data = data else {
+ self?.state = .fetched(.failure(.error("Malformed response data")))
+ return
+ }
+ let root = try! JSONDecoder().decode(Root.self, from: data)
+
+ DispatchQueue.main.async { [weak self] in
+ self?.state = .fetched(.success(root))
+ }
+ }.resume()
+ }
+}
diff --git a/JuickNext/MessageView.swift b/JuickNext/MessageView.swift
new file mode 100644
index 0000000..398978b
--- /dev/null
+++ b/JuickNext/MessageView.swift
@@ -0,0 +1,43 @@
+//
+// MessageView.swift
+// tst
+//
+// Created by Vitaly Takmazov on 10.12.2019.
+// Copyright © 2019 com.juick. All rights reserved.
+//
+
+import SwiftUI
+
+struct MessageView: View {
+ var message: Message
+ var body: some View {
+ VStack(alignment: .leading) {
+ HStack {
+ LoadableImageView(with: message.user.avatar ?? "")
+ .frame(width: 48, height: 48, alignment: .center)
+ Text(message.user.name)
+ .font(.headline)
+ .foregroundColor(.accentColor)
+ }
+ message.tags.map {
+ Text($0.joined(separator: ", "))
+ .font(.subheadline)
+ .italic()
+ .foregroundColor(.secondary)
+ }
+ Text(message.text ?? "")
+ .font(.body)
+ .padding()
+ message.attachment.map {
+ LoadableImageView(with: $0.url).scaledToFit()
+ }
+ }
+ }
+}
+
+struct MessageView_Previews: PreviewProvider {
+ static let msg = Message(id: 0, user: User(id: 0, name: "ugnich"), text: "Lorem ipsum")
+ static var previews: some View {
+ MessageView(message: msg)
+ }
+}
diff --git a/JuickNext/Models.swift b/JuickNext/Models.swift
new file mode 100644
index 0000000..77a12f5
--- /dev/null
+++ b/JuickNext/Models.swift
@@ -0,0 +1,47 @@
+//
+// Models.swift
+// tst
+//
+// Created by Vitaly Takmazov on 10.12.2019.
+// Copyright © 2019 com.juick. All rights reserved.
+//
+
+import Foundation
+
+
+typealias Model = Decodable & Identifiable
+
+typealias Root = Array<Message>
+
+struct Attachment: Decodable {
+ var url: String
+}
+
+struct Entity: Decodable {
+ var type: String
+ var text: String
+ var link: String?
+ var start: Int?
+ var end: Int?
+}
+
+struct User: Model {
+ var id: Int
+ var name: String
+ var avatar: String?
+ private enum CodingKeys : String, CodingKey {
+ case id = "uid", name = "uname", avatar
+ }
+}
+
+struct Message : Model {
+ var id: Int
+ var user: User
+ var text : String?
+ var attachment: Attachment?
+ var entities: [Entity]?
+ var tags: [String]?
+ private enum CodingKeys : String, CodingKey {
+ case id = "mid", user, text = "body", attachment, entities, tags
+ }
+}
diff --git a/JuickNext/View/ContentView.swift b/JuickNext/View/ContentView.swift
index e77d6e7..22e74e0 100644
--- a/JuickNext/View/ContentView.swift
+++ b/JuickNext/View/ContentView.swift
@@ -10,17 +10,22 @@ import SwiftUI
struct ContentView: View {
@Environment(\.horizontalSizeClass) private var size
+
+ let today = FeedView("Today", url: "https://api.juick.com/messages?popular=1")
+ let discussions = FeedView("Discussions", url: "https://api.juick.com/messages/discussions")
+ let discover = FeedView("Discover", url: "https://api.juick.com/messages")
var body: some View {
let view = (size == .compact) ?
AnyView(TabView {
- Today()
- .tabItem {
+ today.tabItem {
Image("ei-clock")
}
- Discussions()
- .tabItem {
+ discussions.tabItem {
Image("ei-bell")
}
+ discover.tabItem {
+ Image("Discover")
+ }
}): AnyView(NavigationView {
VStack {
Text("Discussions")
diff --git a/JuickNext/View/Discussions.swift b/JuickNext/View/Discussions.swift
deleted file mode 100644
index 20e7fa8..0000000
--- a/JuickNext/View/Discussions.swift
+++ /dev/null
@@ -1,21 +0,0 @@
-//
-// Discussions.swift
-// Juick
-//
-// Created by Vitaly Takmazov on 14.05.2023.
-// Copyright © 2023 com.juick. All rights reserved.
-//
-
-import SwiftUI
-
-struct Discussions: View {
- var body: some View {
- Text("Discussions")
- }
-}
-
-struct Discussions_Previews: PreviewProvider {
- static var previews: some View {
- Discussions()
- }
-}
diff --git a/JuickNext/View/Today.swift b/JuickNext/View/Today.swift
deleted file mode 100644
index 161a353..0000000
--- a/JuickNext/View/Today.swift
+++ /dev/null
@@ -1,24 +0,0 @@
-//
-// TodayView.swift
-// Juick
-//
-// Created by Vitaly Takmazov on 14.05.2023.
-// Copyright © 2023 com.juick. All rights reserved.
-//
-
-import SwiftUI
-
-struct Today: View {
- let title = "Today"
- var body: some View {
- NavigationView {
- Text(title)
- }
- }
-}
-
-struct Today_Previews: PreviewProvider {
- static var previews: some View {
- Today()
- }
-}