Skip to content

Commit

Permalink
Added flexible support
Browse files Browse the repository at this point in the history
  • Loading branch information
developerfromjokela committed Jul 8, 2022
1 parent 4c16430 commit 548b1c0
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
24 changes: 12 additions & 12 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@
"object": {
"pins": [
{
"package": "AttributedText",
"repositoryURL": "https://github.com/gonzalezreal/AttributedText",
"package": "combine-schedulers",
"repositoryURL": "https://github.com/pointfreeco/combine-schedulers",
"state": {
"branch": null,
"revision": "2dc2d7864e0fee4b524a5850d7d7cf9a7eeda0fc",
"version": "1.0.0"
"revision": "0ba3a562716efabb585ccb169450c5389107286b",
"version": "0.6.0"
}
},
{
"package": "combine-schedulers",
"repositoryURL": "https://github.com/pointfreeco/combine-schedulers",
"package": "AttributedText",
"repositoryURL": "https://github.com/wilmaplus/FlexibleAttributedText",
"state": {
"branch": null,
"revision": "4cf088c29a20f52be0f2ca54992b492c54e0076b",
"version": "0.5.3"
"revision": "2dc2d7864e0fee4b524a5850d7d7cf9a7eeda0fc",
"version": "1.0.0"
}
},
{
"package": "NetworkImage",
"repositoryURL": "https://github.com/gonzalezreal/NetworkImage",
"state": {
"branch": null,
"revision": "f8b8ed0be39d2f4aa00a6e8d3b18a62a94eff8d8",
"version": "4.0.0"
"revision": "c97f83e771c95186af80ef6118f158852a9e54be",
"version": "4.0.1"
}
},
{
Expand All @@ -51,8 +51,8 @@
"repositoryURL": "https://github.com/pointfreeco/xctest-dynamic-overlay",
"state": {
"branch": null,
"revision": "50a70a9d3583fe228ce672e8923010c8df2deddd",
"version": "0.2.1"
"revision": "ef8e14e7ce1c0c304c644c6ba365d06c468ded6b",
"version": "0.3.3"
}
}
]
Expand Down
6 changes: 3 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ let package = Package(
from: "1.0.0"
),
.package(
name: "AttributedText",
url: "https://github.com/gonzalezreal/AttributedText",
name: "FlexibleAttributedText",
url: "https://github.com/wilmaplus/FlexibleAttributedText",
from: "1.0.0"
),
.package(
Expand All @@ -43,7 +43,7 @@ let package = Package(
name: "MarkdownUI",
dependencies: [
.product(name: "CommonMark", package: "SwiftCommonMark"),
"AttributedText",
"FlexibleAttributedText",
"NetworkImage",
.product(name: "CombineSchedulers", package: "combine-schedulers"),
]
Expand Down
4 changes: 2 additions & 2 deletions Sources/MarkdownUI/Markdown.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import AttributedText
import FlexibleAttributedText
import Combine
import CombineSchedulers
@_exported import CommonMark
Expand Down Expand Up @@ -227,7 +227,7 @@ public struct Markdown: View {
}

public var body: some View {
AttributedText(self.viewState.attributedString, onOpenLink: openMarkdownLink?.handler)
FlexibleAttributedText(self.viewState.attributedString, onOpenLink: openMarkdownLink?.handler, flexibleWidth: style.measurements.flexibleWidth)
.onReceive(self.viewStatePublisher) { viewState in
self.viewState = viewState
}
Expand Down
7 changes: 6 additions & 1 deletion Sources/MarkdownUI/Style/Measurements.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ extension MarkdownStyle {

/// The distance between the bottom of a heading and the top of the next block, relative to the base font size.
public var headingSpacing: CGFloat

public var flexibleWidth: Bool

/// Creates a `Measurements` instance.
/// - Parameters:
Expand All @@ -39,14 +41,16 @@ extension MarkdownStyle {
/// - headingScales: The scale that the `Markdown` view applies to each heading level.
/// - headingSpacing: The distance between the bottom of a heading and the top of the next block,
/// relative to the base font size. The default is `0.67`.
/// - flexibleWidth: Flexible width does not take full width of available space
public init(
codeFontScale: CGFloat = 0.94,
headIndentStep: CGFloat = 1.97,
tailIndentStep: CGFloat = -1,
paragraphSpacing: CGFloat = 1,
listMarkerSpacing: CGFloat = 0.47,
headingScales: HeadingScales = .default,
headingSpacing: CGFloat = 0.67
headingSpacing: CGFloat = 0.67,
flexibleWidth: Bool = false
) {
self.codeFontScale = codeFontScale
self.headIndentStep = headIndentStep
Expand All @@ -55,6 +59,7 @@ extension MarkdownStyle {
self.listMarkerSpacing = listMarkerSpacing
self.headingScales = headingScales
self.headingSpacing = headingSpacing
self.flexibleWidth = flexibleWidth
}
}
}

0 comments on commit 548b1c0

Please sign in to comment.