aboutsummaryrefslogtreecommitdiff
path: root/LibreEdit
diff options
context:
space:
mode:
authorChristian Cleberg <hello@cleberg.net>2024-01-14 12:01:54 -0600
committerChristian Cleberg <hello@cleberg.net>2024-01-14 12:01:54 -0600
commit42f3aa0f6f9b72b06583715c812b0668801b5689 (patch)
tree92d10decacce0ff79f9dd763db4a29459a94aaf0 /LibreEdit
parent896d36505ab0f8f4cd00741f9dfd33d0c69d7ec1 (diff)
downloadlibre-edit-42f3aa0f6f9b72b06583715c812b0668801b5689.tar.gz
libre-edit-42f3aa0f6f9b72b06583715c812b0668801b5689.tar.bz2
libre-edit-42f3aa0f6f9b72b06583715c812b0668801b5689.zip
feat: add option to view rendered markdown
Diffstat (limited to 'LibreEdit')
-rw-r--r--LibreEdit/ContentView.swift91
-rw-r--r--LibreEdit/MarkdownView.swift24
2 files changed, 73 insertions, 42 deletions
diff --git a/LibreEdit/ContentView.swift b/LibreEdit/ContentView.swift
index 3b6d69e..33dab38 100644
--- a/LibreEdit/ContentView.swift
+++ b/LibreEdit/ContentView.swift
@@ -43,51 +43,58 @@ struct ContentView: View {
@Binding var document: TextFile
@State private var showingPopover = false
@State private var wordCount: Int = 0
-
+
var body: some View {
- Text("\(wordCount) words")
- .foregroundColor(Color.white)
- .font(.headline)
- .padding(.trailing)
- .frame(maxWidth: .infinity, maxHeight: 50)
- .background(Color.gray.opacity(0.3))
- .padding(.top, 20)
- TextEditor(text: $document.text)
- .onAppear {
- self.wordCount = countWords(text: document.text)
- }
- .onChange(of: document.text) {
- self.wordCount = countWords(text: document.text)
- }
- .toolbar {
- ToolbarItemGroup(placement: .secondaryAction) {
- Button {
- showingPopover = true
- } label: {
- Text("More Info")
- }.popover(isPresented: $showingPopover) {
- VStack(alignment: .leading) {
- Text("More Info")
- .font(.largeTitle)
- Text("")
- Text("Instructions")
- .font(.title)
- Text("")
- Text("LibreEdit provides a direct interface with the Apple Files app on your iPhone. Simply navigate to your preferred directory, edit existing files, or create new files!")
- Text("")
- Text("Developer")
- .font(.title)
- Text("")
- Text("LibreEdit is a free and open source text editor for iOS built by [Christian Cleberg](https://cleberg.net).")
- Text("")
- Text("Visit the [GitHub Repository](https://github.com/ccleberg/ios-edit) to view the source code.")
- Text("")
- Text("This project was developed under the [GNU GPL v3 license](https://github.com/ccleberg/ios-edit/LICENSE).")
- Spacer()
+ NavigationView {
+ VStack {
+ Text("\(wordCount) words")
+ .foregroundColor(Color.white)
+ .font(.headline)
+ .padding(.trailing)
+ .frame(maxWidth: .infinity, maxHeight: 50)
+ .background(Color.gray.opacity(0.3))
+ .padding(.top, 20)
+ TextEditor(text: $document.text)
+ .onAppear {
+ self.wordCount = countWords(text: document.text)
+ }
+ .onChange(of: document.text) {
+ self.wordCount = countWords(text: document.text)
+ }
+ .toolbar {
+ ToolbarItemGroup(placement: .secondaryAction) {
+ NavigationLink(destination: MarkdownView(document: $document)) {
+ Text("Show Rendered Markdown")
+ }
+ Button {
+ showingPopover = true
+ } label: {
+ Text("More Info")
+ }.popover(isPresented: $showingPopover) {
+ VStack(alignment: .leading) {
+ Text("More Info")
+ .font(.largeTitle)
+ Text("")
+ Text("Instructions")
+ .font(.title)
+ Text("")
+ Text("LibreEdit provides a direct interface with the Apple Files app on your iPhone. Simply navigate to your preferred directory, edit existing files, or create new files!")
+ Text("")
+ Text("Developer")
+ .font(.title)
+ Text("")
+ Text("LibreEdit is a free and open source text editor for iOS built by [Christian Cleberg](https://cleberg.net).")
+ Text("")
+ Text("Visit the [GitHub Repository](https://github.com/ccleberg/ios-edit) to view the source code.")
+ Text("")
+ Text("This project was developed under the [GNU GPL v3 license](https://github.com/ccleberg/ios-edit/LICENSE).")
+ Spacer()
+ }
+ .padding()
+ }
}
- .padding()
}
- }
}
+ }
}
}
diff --git a/LibreEdit/MarkdownView.swift b/LibreEdit/MarkdownView.swift
new file mode 100644
index 0000000..ebbf012
--- /dev/null
+++ b/LibreEdit/MarkdownView.swift
@@ -0,0 +1,24 @@
+//
+// MarkdownView.swift
+// LibreEdit
+//
+// Created by Christian Cleberg on 2024-01-14.
+//
+
+import SwiftUI
+import MarkdownUI
+
+struct MarkdownView: View {
+ @Binding var document: TextFile
+
+ var body: some View {
+ ScrollView {
+ Markdown {
+ MarkdownContent(document.text)
+ }
+ .markdownTheme(.docC)
+ .padding()
+ }
+ .navigationTitle("Rendered Markdown")
+ }
+}