aboutsummaryrefslogtreecommitdiff
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
parent896d36505ab0f8f4cd00741f9dfd33d0c69d7ec1 (diff)
downloadlibre-edit-42f3aa0f6f9b72b06583715c812b0668801b5689.tar.gz
libre-edit-42f3aa0f6f9b72b06583715c812b0668801b5689.tar.bz2
libre-edit-42f3aa0f6f9b72b06583715c812b0668801b5689.zip
feat: add option to view rendered markdown
-rw-r--r--LibreEdit.xcodeproj/project.pbxproj31
-rw-r--r--LibreEdit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved23
-rw-r--r--LibreEdit/ContentView.swift91
-rw-r--r--LibreEdit/MarkdownView.swift24
-rw-r--r--README.md18
-rw-r--r--Screenshots/editor.pngbin0 -> 107578 bytes
-rw-r--r--Screenshots/file_manager.pngbin0 -> 107923 bytes
-rw-r--r--Screenshots/libre_edit.pngbin147937 -> 0 bytes
-rw-r--r--Screenshots/rendered.pngbin0 -> 104582 bytes
9 files changed, 140 insertions, 47 deletions
diff --git a/LibreEdit.xcodeproj/project.pbxproj b/LibreEdit.xcodeproj/project.pbxproj
index e5b7b6a..46d2211 100644
--- a/LibreEdit.xcodeproj/project.pbxproj
+++ b/LibreEdit.xcodeproj/project.pbxproj
@@ -7,6 +7,8 @@
objects = {
/* Begin PBXBuildFile section */
+ 8B930F732B544EA200413A34 /* MarkdownUI in Frameworks */ = {isa = PBXBuildFile; productRef = 8B930F722B544EA200413A34 /* MarkdownUI */; };
+ 8B930F752B54504D00413A34 /* MarkdownView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B930F742B54504D00413A34 /* MarkdownView.swift */; };
8BCA57062B537F9600DBA94B /* LibreEditApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BCA57052B537F9600DBA94B /* LibreEditApp.swift */; };
8BCA57082B537F9600DBA94B /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BCA57072B537F9600DBA94B /* ContentView.swift */; };
8BCA570A2B537F9700DBA94B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8BCA57092B537F9700DBA94B /* Assets.xcassets */; };
@@ -14,6 +16,7 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
+ 8B930F742B54504D00413A34 /* MarkdownView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarkdownView.swift; sourceTree = "<group>"; };
8BCA57022B537F9600DBA94B /* LibreEdit.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LibreEdit.app; sourceTree = BUILT_PRODUCTS_DIR; };
8BCA57052B537F9600DBA94B /* LibreEditApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LibreEditApp.swift; sourceTree = "<group>"; };
8BCA57072B537F9600DBA94B /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
@@ -26,6 +29,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
+ 8B930F732B544EA200413A34 /* MarkdownUI in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -55,6 +59,7 @@
8BCA57072B537F9600DBA94B /* ContentView.swift */,
8BCA57092B537F9700DBA94B /* Assets.xcassets */,
8BCA570B2B537F9700DBA94B /* Preview Content */,
+ 8B930F742B54504D00413A34 /* MarkdownView.swift */,
);
path = LibreEdit;
sourceTree = "<group>";
@@ -83,6 +88,9 @@
dependencies = (
);
name = LibreEdit;
+ packageProductDependencies = (
+ 8B930F722B544EA200413A34 /* MarkdownUI */,
+ );
productName = LibreEdit;
productReference = 8BCA57022B537F9600DBA94B /* LibreEdit.app */;
productType = "com.apple.product-type.application";
@@ -111,6 +119,9 @@
Base,
);
mainGroup = 8BCA56F92B537F9600DBA94B;
+ packageReferences = (
+ 8B930F712B544EA200413A34 /* XCRemoteSwiftPackageReference "swift-markdown-ui" */,
+ );
productRefGroup = 8BCA57032B537F9600DBA94B /* Products */;
projectDirPath = "";
projectRoot = "";
@@ -137,6 +148,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ 8B930F752B54504D00413A34 /* MarkdownView.swift in Sources */,
8BCA57082B537F9600DBA94B /* ContentView.swift in Sources */,
8BCA57062B537F9600DBA94B /* LibreEditApp.swift in Sources */,
);
@@ -346,6 +358,25 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
+
+/* Begin XCRemoteSwiftPackageReference section */
+ 8B930F712B544EA200413A34 /* XCRemoteSwiftPackageReference "swift-markdown-ui" */ = {
+ isa = XCRemoteSwiftPackageReference;
+ repositoryURL = "https://github.com/gonzalezreal/swift-markdown-ui";
+ requirement = {
+ kind = upToNextMajorVersion;
+ minimumVersion = 2.3.0;
+ };
+ };
+/* End XCRemoteSwiftPackageReference section */
+
+/* Begin XCSwiftPackageProductDependency section */
+ 8B930F722B544EA200413A34 /* MarkdownUI */ = {
+ isa = XCSwiftPackageProductDependency;
+ package = 8B930F712B544EA200413A34 /* XCRemoteSwiftPackageReference "swift-markdown-ui" */;
+ productName = MarkdownUI;
+ };
+/* End XCSwiftPackageProductDependency section */
};
rootObject = 8BCA56FA2B537F9600DBA94B /* Project object */;
}
diff --git a/LibreEdit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/LibreEdit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
new file mode 100644
index 0000000..a1afabf
--- /dev/null
+++ b/LibreEdit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
@@ -0,0 +1,23 @@
+{
+ "pins" : [
+ {
+ "identity" : "networkimage",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/gonzalezreal/NetworkImage",
+ "state" : {
+ "revision" : "7aff8d1b31148d32c5933d75557d42f6323ee3d1",
+ "version" : "6.0.0"
+ }
+ },
+ {
+ "identity" : "swift-markdown-ui",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/gonzalezreal/swift-markdown-ui",
+ "state" : {
+ "revision" : "ae799d015a5374708f7b4c85f3294c05f2a564e2",
+ "version" : "2.3.0"
+ }
+ }
+ ],
+ "version" : 2
+}
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")
+ }
+}
diff --git a/README.md b/README.md
index 367a5cb..4e1f565 100644
--- a/README.md
+++ b/README.md
@@ -3,12 +3,20 @@
LibreEdit intended to be a simple open-source text editing app for iOS, written
in Swift.
-## TODO
+LibreEdit integrates with the native iOS file manager, allowing users full
+control over the files themselves. The editor is simple and should display all
+file types.
-- [ ] Add functionality to `New` button.
-- [ ] Allow custom file names when saving.
-- [ ] Allow editing of existing files.
+There is an option to view rendered Markdown in the secondary actions menu in
+the naviation bar.
## Screenshots
-![Libre Edit](Screenshots/libre_edit.png)
+Native file manager:
+![Libre Edit](Screenshots/file_manager.png)
+
+Editor:
+![Libre Edit](Screenshots/editor.png)
+
+Rendered Markdown:
+![Libre Edit](Screenshots/rendered.png)
diff --git a/Screenshots/editor.png b/Screenshots/editor.png
new file mode 100644
index 0000000..60a8ce5
--- /dev/null
+++ b/Screenshots/editor.png
Binary files differ
diff --git a/Screenshots/file_manager.png b/Screenshots/file_manager.png
new file mode 100644
index 0000000..8becc5c
--- /dev/null
+++ b/Screenshots/file_manager.png
Binary files differ
diff --git a/Screenshots/libre_edit.png b/Screenshots/libre_edit.png
deleted file mode 100644
index 49b7606..0000000
--- a/Screenshots/libre_edit.png
+++ /dev/null
Binary files differ
diff --git a/Screenshots/rendered.png b/Screenshots/rendered.png
new file mode 100644
index 0000000..3098a06
--- /dev/null
+++ b/Screenshots/rendered.png
Binary files differ