-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c3184fa
commit a7c3c9c
Showing
8 changed files
with
206 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// | ||
// PaddingGroup.swift | ||
// Example | ||
// | ||
// Created by 王楚江 on 2022/3/11. | ||
// | ||
|
||
import Markdown | ||
import SwiftUI | ||
|
||
struct MarkdownStyleGroup: View { | ||
@State private var mdStr: String = """ | ||
.markdownStyle() | ||
=== | ||
Render Markdown text in SwiftUI. It is a preview based on the [`Marked`](https://github.com/markedjs/marked) implementation. | ||
## Usage | ||
```swift | ||
Markdown(content: $mdStr) | ||
.markdownStyle( | ||
MarkdownStyle( | ||
padding: 0, paddingTop: 115, paddingBottom: 2, paddingLeft: 130, paddingRight: 5 | ||
) | ||
) | ||
``` | ||
```swift | ||
Markdown(content: $mdStr) | ||
.markdownStyle(MarkdownStyle(padding: 35 )) | ||
``` | ||
## `.markdownStyle()` | ||
```swift | ||
import SwiftUI | ||
import Markdown | ||
struct ContentView: View { | ||
@State private var mdStr: String = \"\"" | ||
## Hello World | ||
Render Markdown text in SwiftUI. | ||
\"\"" | ||
var body: some View { | ||
VStack { | ||
Markdown(content: $mdStr) | ||
.markdownStyle( | ||
MarkdownStyle(padding: 0, paddingTop: 115, paddingBottom: 2, paddingLeft: 130, paddingRight: 5) | ||
) | ||
} | ||
} | ||
} | ||
``` | ||
## License | ||
Licensed under the MIT License. | ||
""" | ||
var body: some View { | ||
Markdown(content: $mdStr) | ||
// .markdownStyle(MarkdownStyle(padding: 90)) | ||
.markdownStyle(MarkdownStyle( | ||
paddingTop: 100, paddingBottom: 55, paddingLeft: 88, paddingRight: 23 | ||
)) | ||
|
||
// .markdownStyle(MarkdownStyle(padding: 0, paddingTop: 115, paddingBottom: 2, paddingLeft: 130, paddingRight: 5)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// SwiftUIView.swift | ||
// | ||
// | ||
// Created by 王楚江 on 2022/3/11. | ||
// | ||
|
||
import SwiftUI | ||
|
||
public struct MarkdownStyle: Hashable { | ||
public var padding: Int? | ||
public var paddingTop: Int? | ||
public var paddingRight: Int? | ||
public var paddingLeft: Int? | ||
public var paddingBottom: Int? | ||
public init(padding: Int = 18) { | ||
self.padding = padding | ||
} | ||
public init(paddingTop: Int = 18, paddingBottom: Int = 18, paddingLeft: Int = 18, paddingRight: Int = 18) { | ||
self.paddingTop = paddingTop | ||
self.paddingBottom = paddingBottom | ||
self.paddingLeft = paddingLeft | ||
self.paddingRight = paddingRight | ||
} | ||
public init(padding: Int = 18, paddingTop: Int = 18, paddingBottom: Int = 18, paddingLeft: Int = 18, paddingRight: Int = 18) { | ||
self.padding = padding | ||
self.paddingTop = paddingTop | ||
self.paddingBottom = paddingBottom | ||
self.paddingLeft = paddingLeft | ||
self.paddingRight = paddingRight | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters