Skip to content
This repository was archived by the owner on Sep 12, 2024. It is now read-only.

Commit 26a20f6

Browse files
committed
Add preview
1 parent 238669a commit 26a20f6

File tree

16 files changed

+10489
-424
lines changed

16 files changed

+10489
-424
lines changed

Snip.xcodeproj/project.pbxproj

Lines changed: 142 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
7936F89624D637D800F09AE7 /* Introspect in Frameworks */ = {isa = PBXBuildFile; productRef = 7936F89524D637D800F09AE7 /* Introspect */; };
2222
7936F89A24D845B600F09AE7 /* SnipItemsListAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7936F89924D845B600F09AE7 /* SnipItemsListAction.swift */; };
2323
7936F89F24DA02DD00F09AE7 /* TextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7936F89E24DA02DD00F09AE7 /* TextField.swift */; };
24+
794D27CE24F672E4006E3B3D /* SnipTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 794D27CD24F672E4006E3B3D /* SnipTests.swift */; };
25+
794D27D924F68FF2006E3B3D /* Down in Frameworks */ = {isa = PBXBuildFile; productRef = 794D27D824F68FF2006E3B3D /* Down */; };
2426
796B092524D1B4A3006904C4 /* SnipItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 796B092424D1B4A3006904C4 /* SnipItem.swift */; };
2527
796B092924D1B563006904C4 /* Settings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 796B092824D1B563006904C4 /* Settings.swift */; };
2628
796B093124D1B8F5006904C4 /* CodeMirrorView.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 796B092F24D1B8F5006904C4 /* CodeMirrorView.bundle */; };
@@ -50,7 +52,6 @@
5052
79BC1D3324D17124008FD16E /* Sidebar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79BC1D3224D17124008FD16E /* Sidebar.swift */; };
5153
79BC1D3524D17142008FD16E /* CodeViewer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79BC1D3424D17142008FD16E /* CodeViewer.swift */; };
5254
79BC1D3724D17151008FD16E /* SearchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79BC1D3624D17151008FD16E /* SearchBar.swift */; };
53-
79C463CE24F43E17009B2DA3 /* Ink in Frameworks */ = {isa = PBXBuildFile; productRef = 79C463CD24F43E17009B2DA3 /* Ink */; };
5455
79C463D024F44233009B2DA3 /* MarkdownHTMLViewer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79C463CF24F44233009B2DA3 /* MarkdownHTMLViewer.swift */; };
5556
79DBD4CA24D1CBE500568364 /* CodeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79DBD4C924D1CBE500568364 /* CodeView.swift */; };
5657
79F07A2324D2F3DC00469324 /* ModeSelectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79F07A2224D2F3DC00469324 /* ModeSelectionView.swift */; };
@@ -59,6 +60,16 @@
5960
79F07A2924D3050500469324 /* ImageButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79F07A2824D3050500469324 /* ImageButton.swift */; };
6061
/* End PBXBuildFile section */
6162

63+
/* Begin PBXContainerItemProxy section */
64+
794D27D024F672E4006E3B3D /* PBXContainerItemProxy */ = {
65+
isa = PBXContainerItemProxy;
66+
containerPortal = 79BC1D1424D16E67008FD16E /* Project object */;
67+
proxyType = 1;
68+
remoteGlobalIDString = 79BC1D1B24D16E67008FD16E;
69+
remoteInfo = Snip;
70+
};
71+
/* End PBXContainerItemProxy section */
72+
6273
/* Begin PBXFileReference section */
6374
791AC9BD24DAA4FD00CAB87C /* TagView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TagView.swift; sourceTree = "<group>"; };
6475
791AC9C024DAB60900CAB87C /* SnippetManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SnippetManager.swift; sourceTree = "<group>"; };
@@ -73,6 +84,9 @@
7384
7936F89224D6377D00F09AE7 /* List.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = List.swift; sourceTree = "<group>"; };
7485
7936F89924D845B600F09AE7 /* SnipItemsListAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SnipItemsListAction.swift; sourceTree = "<group>"; };
7586
7936F89E24DA02DD00F09AE7 /* TextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextField.swift; sourceTree = "<group>"; };
87+
794D27CB24F672E4006E3B3D /* SnipTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SnipTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
88+
794D27CD24F672E4006E3B3D /* SnipTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SnipTests.swift; sourceTree = "<group>"; };
89+
794D27CF24F672E4006E3B3D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
7690
796B092424D1B4A3006904C4 /* SnipItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SnipItem.swift; sourceTree = "<group>"; };
7791
796B092824D1B563006904C4 /* Settings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Settings.swift; sourceTree = "<group>"; };
7892
796B092F24D1B8F5006904C4 /* CodeMirrorView.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = CodeMirrorView.bundle; path = Snip/External/CodeMirrorView.bundle; sourceTree = "<group>"; };
@@ -113,13 +127,20 @@
113127
/* End PBXFileReference section */
114128

115129
/* Begin PBXFrameworksBuildPhase section */
130+
794D27C824F672E4006E3B3D /* Frameworks */ = {
131+
isa = PBXFrameworksBuildPhase;
132+
buildActionMask = 2147483647;
133+
files = (
134+
);
135+
runOnlyForDeploymentPostprocessing = 0;
136+
};
116137
79BC1D1924D16E67008FD16E /* Frameworks */ = {
117138
isa = PBXFrameworksBuildPhase;
118139
buildActionMask = 2147483647;
119140
files = (
120-
79C463CE24F43E17009B2DA3 /* Ink in Frameworks */,
121141
79956A5B24F3B45300B823E1 /* KeychainAccess in Frameworks */,
122142
7936F89624D637D800F09AE7 /* Introspect in Frameworks */,
143+
794D27D924F68FF2006E3B3D /* Down in Frameworks */,
123144
);
124145
runOnlyForDeploymentPostprocessing = 0;
125146
};
@@ -143,6 +164,15 @@
143164
path = Helper;
144165
sourceTree = "<group>";
145166
};
167+
794D27CC24F672E4006E3B3D /* SnipTests */ = {
168+
isa = PBXGroup;
169+
children = (
170+
794D27CD24F672E4006E3B3D /* SnipTests.swift */,
171+
794D27CF24F672E4006E3B3D /* Info.plist */,
172+
);
173+
path = SnipTests;
174+
sourceTree = "<group>";
175+
};
146176
796B092324D1B48F006904C4 /* Model */ = {
147177
isa = PBXGroup;
148178
children = (
@@ -221,6 +251,7 @@
221251
isa = PBXGroup;
222252
children = (
223253
79BC1D1E24D16E67008FD16E /* Snip */,
254+
794D27CC24F672E4006E3B3D /* SnipTests */,
224255
79BC1D1D24D16E67008FD16E /* Products */,
225256
);
226257
sourceTree = "<group>";
@@ -229,6 +260,7 @@
229260
isa = PBXGroup;
230261
children = (
231262
79BC1D1C24D16E67008FD16E /* Snip.app */,
263+
794D27CB24F672E4006E3B3D /* SnipTests.xctest */,
232264
);
233265
name = Products;
234266
sourceTree = "<group>";
@@ -314,6 +346,24 @@
314346
/* End PBXGroup section */
315347

316348
/* Begin PBXNativeTarget section */
349+
794D27CA24F672E4006E3B3D /* SnipTests */ = {
350+
isa = PBXNativeTarget;
351+
buildConfigurationList = 794D27D424F672E4006E3B3D /* Build configuration list for PBXNativeTarget "SnipTests" */;
352+
buildPhases = (
353+
794D27C724F672E4006E3B3D /* Sources */,
354+
794D27C824F672E4006E3B3D /* Frameworks */,
355+
794D27C924F672E4006E3B3D /* Resources */,
356+
);
357+
buildRules = (
358+
);
359+
dependencies = (
360+
794D27D124F672E4006E3B3D /* PBXTargetDependency */,
361+
);
362+
name = SnipTests;
363+
productName = SnipTests;
364+
productReference = 794D27CB24F672E4006E3B3D /* SnipTests.xctest */;
365+
productType = "com.apple.product-type.bundle.unit-test";
366+
};
317367
79BC1D1B24D16E67008FD16E /* Snip */ = {
318368
isa = PBXNativeTarget;
319369
buildConfigurationList = 79BC1D2F24D16E6A008FD16E /* Build configuration list for PBXNativeTarget "Snip" */;
@@ -330,7 +380,7 @@
330380
packageProductDependencies = (
331381
7936F89524D637D800F09AE7 /* Introspect */,
332382
79956A5A24F3B45300B823E1 /* KeychainAccess */,
333-
79C463CD24F43E17009B2DA3 /* Ink */,
383+
794D27D824F68FF2006E3B3D /* Down */,
334384
);
335385
productName = Snip;
336386
productReference = 79BC1D1C24D16E67008FD16E /* Snip.app */;
@@ -346,6 +396,10 @@
346396
LastUpgradeCheck = 1160;
347397
ORGANIZATIONNAME = pictarine;
348398
TargetAttributes = {
399+
794D27CA24F672E4006E3B3D = {
400+
CreatedOnToolsVersion = 11.6;
401+
TestTargetID = 79BC1D1B24D16E67008FD16E;
402+
};
349403
79BC1D1B24D16E67008FD16E = {
350404
CreatedOnToolsVersion = 11.6;
351405
};
@@ -363,18 +417,26 @@
363417
packageReferences = (
364418
7936F89424D637D800F09AE7 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */,
365419
79956A5924F3B45300B823E1 /* XCRemoteSwiftPackageReference "KeychainAccess" */,
366-
79C463CC24F43E17009B2DA3 /* XCRemoteSwiftPackageReference "ink" */,
420+
794D27D724F68FF2006E3B3D /* XCRemoteSwiftPackageReference "Down" */,
367421
);
368422
productRefGroup = 79BC1D1D24D16E67008FD16E /* Products */;
369423
projectDirPath = "";
370424
projectRoot = "";
371425
targets = (
372426
79BC1D1B24D16E67008FD16E /* Snip */,
427+
794D27CA24F672E4006E3B3D /* SnipTests */,
373428
);
374429
};
375430
/* End PBXProject section */
376431

377432
/* Begin PBXResourcesBuildPhase section */
433+
794D27C924F672E4006E3B3D /* Resources */ = {
434+
isa = PBXResourcesBuildPhase;
435+
buildActionMask = 2147483647;
436+
files = (
437+
);
438+
runOnlyForDeploymentPostprocessing = 0;
439+
};
378440
79BC1D1A24D16E67008FD16E /* Resources */ = {
379441
isa = PBXResourcesBuildPhase;
380442
buildActionMask = 2147483647;
@@ -389,6 +451,14 @@
389451
/* End PBXResourcesBuildPhase section */
390452

391453
/* Begin PBXSourcesBuildPhase section */
454+
794D27C724F672E4006E3B3D /* Sources */ = {
455+
isa = PBXSourcesBuildPhase;
456+
buildActionMask = 2147483647;
457+
files = (
458+
794D27CE24F672E4006E3B3D /* SnipTests.swift in Sources */,
459+
);
460+
runOnlyForDeploymentPostprocessing = 0;
461+
};
392462
79BC1D1824D16E67008FD16E /* Sources */ = {
393463
isa = PBXSourcesBuildPhase;
394464
buildActionMask = 2147483647;
@@ -441,6 +511,14 @@
441511
};
442512
/* End PBXSourcesBuildPhase section */
443513

514+
/* Begin PBXTargetDependency section */
515+
794D27D124F672E4006E3B3D /* PBXTargetDependency */ = {
516+
isa = PBXTargetDependency;
517+
target = 79BC1D1B24D16E67008FD16E /* Snip */;
518+
targetProxy = 794D27D024F672E4006E3B3D /* PBXContainerItemProxy */;
519+
};
520+
/* End PBXTargetDependency section */
521+
444522
/* Begin PBXVariantGroup section */
445523
79BC1D2824D16E6A008FD16E /* Main.storyboard */ = {
446524
isa = PBXVariantGroup;
@@ -453,6 +531,46 @@
453531
/* End PBXVariantGroup section */
454532

455533
/* Begin XCBuildConfiguration section */
534+
794D27D224F672E4006E3B3D /* Debug */ = {
535+
isa = XCBuildConfiguration;
536+
buildSettings = {
537+
BUNDLE_LOADER = "$(TEST_HOST)";
538+
CODE_SIGN_STYLE = Automatic;
539+
COMBINE_HIDPI_IMAGES = YES;
540+
DEVELOPMENT_TEAM = 7XBGRFP286;
541+
INFOPLIST_FILE = SnipTests/Info.plist;
542+
LD_RUNPATH_SEARCH_PATHS = (
543+
"$(inherited)",
544+
"@executable_path/../Frameworks",
545+
"@loader_path/../Frameworks",
546+
);
547+
PRODUCT_BUNDLE_IDENTIFIER = com.pictarine.SnipTests;
548+
PRODUCT_NAME = "$(TARGET_NAME)";
549+
SWIFT_VERSION = 5.0;
550+
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Snip.app/Contents/MacOS/Snip";
551+
};
552+
name = Debug;
553+
};
554+
794D27D324F672E4006E3B3D /* Release */ = {
555+
isa = XCBuildConfiguration;
556+
buildSettings = {
557+
BUNDLE_LOADER = "$(TEST_HOST)";
558+
CODE_SIGN_STYLE = Automatic;
559+
COMBINE_HIDPI_IMAGES = YES;
560+
DEVELOPMENT_TEAM = 7XBGRFP286;
561+
INFOPLIST_FILE = SnipTests/Info.plist;
562+
LD_RUNPATH_SEARCH_PATHS = (
563+
"$(inherited)",
564+
"@executable_path/../Frameworks",
565+
"@loader_path/../Frameworks",
566+
);
567+
PRODUCT_BUNDLE_IDENTIFIER = com.pictarine.SnipTests;
568+
PRODUCT_NAME = "$(TARGET_NAME)";
569+
SWIFT_VERSION = 5.0;
570+
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Snip.app/Contents/MacOS/Snip";
571+
};
572+
name = Release;
573+
};
456574
79BC1D2D24D16E6A008FD16E /* Debug */ = {
457575
isa = XCBuildConfiguration;
458576
buildSettings = {
@@ -621,6 +739,15 @@
621739
/* End XCBuildConfiguration section */
622740

623741
/* Begin XCConfigurationList section */
742+
794D27D424F672E4006E3B3D /* Build configuration list for PBXNativeTarget "SnipTests" */ = {
743+
isa = XCConfigurationList;
744+
buildConfigurations = (
745+
794D27D224F672E4006E3B3D /* Debug */,
746+
794D27D324F672E4006E3B3D /* Release */,
747+
);
748+
defaultConfigurationIsVisible = 0;
749+
defaultConfigurationName = Release;
750+
};
624751
79BC1D1724D16E67008FD16E /* Build configuration list for PBXProject "Snip" */ = {
625752
isa = XCConfigurationList;
626753
buildConfigurations = (
@@ -650,20 +777,20 @@
650777
minimumVersion = 0.1.0;
651778
};
652779
};
653-
79956A5924F3B45300B823E1 /* XCRemoteSwiftPackageReference "KeychainAccess" */ = {
780+
794D27D724F68FF2006E3B3D /* XCRemoteSwiftPackageReference "Down" */ = {
654781
isa = XCRemoteSwiftPackageReference;
655-
repositoryURL = "https://github.com/kishikawakatsumi/KeychainAccess";
782+
repositoryURL = "https://github.com/iwasrobbed/Down";
656783
requirement = {
657784
kind = upToNextMajorVersion;
658-
minimumVersion = 4.2.0;
785+
minimumVersion = 0.9.3;
659786
};
660787
};
661-
79C463CC24F43E17009B2DA3 /* XCRemoteSwiftPackageReference "ink" */ = {
788+
79956A5924F3B45300B823E1 /* XCRemoteSwiftPackageReference "KeychainAccess" */ = {
662789
isa = XCRemoteSwiftPackageReference;
663-
repositoryURL = "https://github.com/johnsundell/ink.git";
790+
repositoryURL = "https://github.com/kishikawakatsumi/KeychainAccess";
664791
requirement = {
665792
kind = upToNextMajorVersion;
666-
minimumVersion = 0.5.0;
793+
minimumVersion = 4.2.0;
667794
};
668795
};
669796
/* End XCRemoteSwiftPackageReference section */
@@ -674,16 +801,16 @@
674801
package = 7936F89424D637D800F09AE7 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */;
675802
productName = Introspect;
676803
};
804+
794D27D824F68FF2006E3B3D /* Down */ = {
805+
isa = XCSwiftPackageProductDependency;
806+
package = 794D27D724F68FF2006E3B3D /* XCRemoteSwiftPackageReference "Down" */;
807+
productName = Down;
808+
};
677809
79956A5A24F3B45300B823E1 /* KeychainAccess */ = {
678810
isa = XCSwiftPackageProductDependency;
679811
package = 79956A5924F3B45300B823E1 /* XCRemoteSwiftPackageReference "KeychainAccess" */;
680812
productName = KeychainAccess;
681813
};
682-
79C463CD24F43E17009B2DA3 /* Ink */ = {
683-
isa = XCSwiftPackageProductDependency;
684-
package = 79C463CC24F43E17009B2DA3 /* XCRemoteSwiftPackageReference "ink" */;
685-
productName = Ink;
686-
};
687814
/* End XCSwiftPackageProductDependency section */
688815
};
689816
rootObject = 79BC1D1424D16E67008FD16E /* Project object */;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"scale" : "1x"
6+
},
7+
{
8+
"filename" : "markdown-brands-1.png",
9+
"idiom" : "universal",
10+
"scale" : "2x"
11+
},
12+
{
13+
"filename" : "markdown-brands.png",
14+
"idiom" : "universal",
15+
"scale" : "3x"
16+
}
17+
],
18+
"info" : {
19+
"author" : "xcode",
20+
"version" : 1
21+
}
22+
}
655 Bytes
Loading
655 Bytes
Loading

Snip/Components/CodeViewer/CodeViewer.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ struct CodeViewer: View {
3939
onUpload: {
4040
self.viewModel.onTrigger(.createGist(id: self.snipItem.id))
4141
},
42-
onPreviewToggle: self.snipItem.mode == CodeMode.html.mode() ? {
42+
onPreviewToggle: self.snipItem.mode == CodeMode.html.mode() || self.snipItem.mode == CodeMode.markdown.mode() ? {
4343
withAnimation(Animation.easeOut(duration: 0.6)) { () -> () in
4444
self.shouldShowPreview.toggle()
4545
}
@@ -68,14 +68,12 @@ struct CodeViewer: View {
6868
minHeight: 100,
6969
maxHeight: .infinity)
7070
.overlay(
71-
HStack() {
72-
Text("ok")
73-
}
71+
MarkdownHTMLViewer(code: self.snipItem.snippet, mode: self.snipItem.mode)
7472
.frame(minWidth: 100,
7573
maxWidth: .infinity,
7674
minHeight: 100,
7775
maxHeight: .infinity)
78-
.background(Color.YELLOW_500)
76+
.background(Color.GREY_200)
7977
.offset(x: self.shouldShowPreview ? 0 : 10000, y: 0)
8078
.transition(AnyTransition.move(edge: .trailing)), alignment: .topLeading)
8179

Snip/Components/CodeViewer/ModeSelectionView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ struct ModeSelectionView: View {
5151
CustomTextField(placeholder: Text("New Tag").foregroundColor(Color.white.opacity(0.7)),
5252
text: $newTag,
5353
commit: {
54-
54+
print("Commit")
5555
guard self.newTag.count > 1 else { return }
5656

5757
//self.viewModel.tags.append(self.newTag)

Snip/Extensions/Color.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ extension Color {
3030

3131
static let ORANGE_500 = Color.init(hex: "E5946A")
3232

33+
static let GREY_200 = Color.init(hex: "F6F8FA")
34+
3335
init(hex: String) {
3436
let hex = hex.trimmingCharacters(in: CharacterSet.alphanumerics.inverted)
3537
var int: UInt64 = 0

Snip/Extensions/String.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,16 @@ extension String {
3636
let size = bcf.string(fromByteCount: Int64(data!.count))
3737
return size
3838
}
39+
40+
func fromBase64() -> String? {
41+
guard let data = Data(base64Encoded: self) else {
42+
return nil
43+
}
44+
45+
return String(data: data, encoding: .utf8)
46+
}
47+
48+
func toBase64() -> String {
49+
return Data(self.utf8).base64EncodedString()
50+
}
3951
}

0 commit comments

Comments
 (0)