Skip to content

Commit

Permalink
Markdown: Add MarkdownUI to support Markdown render of post content a…
Browse files Browse the repository at this point in the history
…nd comments
  • Loading branch information
Dimillian committed May 16, 2021
1 parent 9378834 commit ef855c7
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 4 deletions.
17 changes: 17 additions & 0 deletions RedditOs.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
69F74E9624DB0B7300E58BD8 /* GlobalSearchPopoverView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69F74E9524DB0B7300E58BD8 /* GlobalSearchPopoverView.swift */; };
9F19B57A26505DCF00FBEEDA /* SidebarMultiView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F19B57926505DCF00FBEEDA /* SidebarMultiView.swift */; };
9F4812CC264FC8DB007A719D /* SearchMainContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F4812CB264FC8DB007A719D /* SearchMainContentView.swift */; };
9F8EE49126510BCF00BDE4AC /* MarkdownUI in Frameworks */ = {isa = PBXBuildFile; productRef = 9F8EE49026510BCF00BDE4AC /* MarkdownUI */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -134,6 +135,7 @@
69D459FE264BBB0000A98C6F /* Kingfisher in Frameworks */,
697E324524E3E7D90006F00F /* UI in Frameworks */,
69EACF1C24B7272E00303A16 /* Backend in Frameworks */,
9F8EE49126510BCF00BDE4AC /* MarkdownUI in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -400,6 +402,7 @@
69EACF1B24B7272E00303A16 /* Backend */,
697E324424E3E7D90006F00F /* UI */,
69D459FD264BBB0000A98C6F /* Kingfisher */,
9F8EE49026510BCF00BDE4AC /* MarkdownUI */,
);
productName = RedditOs;
productReference = 69EACEFF24B63D5800303A16 /* Curiosity.app */;
Expand Down Expand Up @@ -430,6 +433,7 @@
mainGroup = 69EACEF624B63D5800303A16;
packageReferences = (
6923F8CB250250FC0003870F /* XCRemoteSwiftPackageReference "Kingfisher" */,
9F8EE48F26510BCF00BDE4AC /* XCRemoteSwiftPackageReference "MarkdownUI" */,
);
productRefGroup = 69EACF0024B63D5800303A16 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -715,6 +719,14 @@
minimumVersion = 6.0.0;
};
};
9F8EE48F26510BCF00BDE4AC /* XCRemoteSwiftPackageReference "MarkdownUI" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/gonzalezreal/MarkdownUI";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 0.5.1;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
Expand All @@ -731,6 +743,11 @@
isa = XCSwiftPackageProductDependency;
productName = Backend;
};
9F8EE49026510BCF00BDE4AC /* MarkdownUI */ = {
isa = XCSwiftPackageProductDependency;
package = 9F8EE48F26510BCF00BDE4AC /* XCRemoteSwiftPackageReference "MarkdownUI" */;
productName = MarkdownUI;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 69EACEF724B63D5800303A16 /* Project object */;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
{
"object": {
"pins": [
{
"package": "AttributedText",
"repositoryURL": "https://github.com/gonzalezreal/AttributedText",
"state": {
"branch": null,
"revision": "bf076de48dbb2172525486936d512e1bba062642",
"version": "0.3.0"
}
},
{
"package": "combine-schedulers",
"repositoryURL": "https://github.com/pointfreeco/combine-schedulers",
"state": {
"branch": null,
"revision": "c37e5ae8012fb654af776cc556ff8ae64398c841",
"version": "0.5.0"
}
},
{
"package": "KeychainAccess",
"repositoryURL": "https://github.com/kishikawakatsumi/KeychainAccess",
Expand All @@ -18,6 +36,51 @@
"revision": "44450a8f564d7c0165f736ba2250649ff8d3e556",
"version": "6.3.0"
}
},
{
"package": "MarkdownUI",
"repositoryURL": "https://github.com/gonzalezreal/MarkdownUI",
"state": {
"branch": null,
"revision": "e8931e37dcf777b4c03ca76aa09c10cf246a2ced",
"version": "0.5.1"
}
},
{
"package": "NetworkImage",
"repositoryURL": "https://github.com/gonzalezreal/NetworkImage",
"state": {
"branch": null,
"revision": "15582b821cb097012b41b83d6219717926ec4ed6",
"version": "2.1.0"
}
},
{
"package": "cmark",
"repositoryURL": "https://github.com/SwiftDocOrg/swift-cmark.git",
"state": {
"branch": null,
"revision": "9c8096a23f44794bde297452d87c455fc4f76d42",
"version": "0.29.0+20210102.9c8096a"
}
},
{
"package": "SwiftCommonMark",
"repositoryURL": "https://github.com/gonzalezreal/SwiftCommonMark",
"state": {
"branch": null,
"revision": "f1575c37110a386e50da3208a04266b398bcefaa",
"version": "0.1.1"
}
},
{
"package": "xctest-dynamic-overlay",
"repositoryURL": "https://github.com/pointfreeco/xctest-dynamic-overlay",
"state": {
"branch": null,
"revision": "603974e3909ad4b48ba04aad7e0ceee4f077a518",
"version": "0.1.0"
}
}
]
},
Expand Down
5 changes: 3 additions & 2 deletions RedditOs/Features/Comments/CommentRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import SwiftUI
import Backend
import MarkdownUI

struct CommentRow: View {
@StateObject private var viewModel: CommentViewModel
Expand Down Expand Up @@ -68,9 +69,9 @@ struct CommentRow: View {
}
}
if let body = viewModel.comment.body {
Text(body)
Markdown(Document(body))
.font(.body)
.fixedSize(horizontal: false, vertical: true)
.fixedSize(horizontal: false, vertical: true)
} else {
Text("Deleted comment")
.font(.footnote)
Expand Down
3 changes: 2 additions & 1 deletion RedditOs/Features/Post/PostDetailContent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import SwiftUI
import Backend
import AVKit
import Kingfisher
import MarkdownUI

struct PostDetailContent: View {
let listing: SubredditPost
Expand All @@ -17,7 +18,7 @@ struct PostDetailContent: View {
@ViewBuilder
var body: some View {
if let text = listing.selftext ?? listing.description {
Text(text)
Markdown(Document(text))
.font(.body)
.fixedSize(horizontal: false, vertical: true)
}
Expand Down
1 change: 1 addition & 0 deletions RedditOs/Features/Post/PostDetailHeader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ struct PostDetailHeader: View {
.lineLimit(10)
.multilineTextAlignment(.leading)
.truncationMode(.tail)
.fixedSize(horizontal: false, vertical: true)
if let url = listing.thumbnailURL, url.pathExtension != "jpg", url.pathExtension != "png" {
KFImage(url)
.frame(width: 80, height: 60)
Expand Down
1 change: 0 additions & 1 deletion RedditOs/Features/Search/ToolbarSearchBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ struct ToolbarSearchBar: View {
} onCommit: {
onCommit()
}

.keyboardShortcut("f", modifiers: .command)
.padding(8)
.background(RoundedRectangle(cornerRadius: 8)
Expand Down

0 comments on commit ef855c7

Please sign in to comment.