Skip to content

Commit 80af3f6

Browse files
authored
Merge pull request #29 from tryboxx/develop
Improve code snippets uploading
2 parents 19d7326 + bbb1ebd commit 80af3f6

File tree

6 files changed

+122
-66
lines changed

6 files changed

+122
-66
lines changed

SnippetsLibrary.xcodeproj/project.pbxproj

+49-25
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
B80D24B2270A72ED0057582F /* SnippetsLibraryWidgetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B80D24B0270A72CC0057582F /* SnippetsLibraryWidgetView.swift */; };
3333
B80D24B6270A734E0057582F /* WidgetEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = B80D24B4270A73490057582F /* WidgetEntry.swift */; };
3434
B80D24B8270A739F0057582F /* Provider.swift in Sources */ = {isa = PBXBuildFile; fileRef = B80D24B7270A739F0057582F /* Provider.swift */; };
35+
B816C71A275817EA00680174 /* FirebaseAnalytics in Frameworks */ = {isa = PBXBuildFile; productRef = B816C719275817EA00680174 /* FirebaseAnalytics */; };
36+
B816C71C275817EA00680174 /* FirebaseCrashlytics in Frameworks */ = {isa = PBXBuildFile; productRef = B816C71B275817EA00680174 /* FirebaseCrashlytics */; };
37+
B816C71E275817EA00680174 /* FirebaseDatabase in Frameworks */ = {isa = PBXBuildFile; productRef = B816C71D275817EA00680174 /* FirebaseDatabase */; };
38+
B816C720275817EA00680174 /* FirebaseRemoteConfig in Frameworks */ = {isa = PBXBuildFile; productRef = B816C71F275817EA00680174 /* FirebaseRemoteConfig */; };
39+
B816C722275817EA00680174 /* FirebaseStorage in Frameworks */ = {isa = PBXBuildFile; productRef = B816C721275817EA00680174 /* FirebaseStorage */; };
3540
B8190DF826FA388500E3994C /* SnippetType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8190DF726FA388500E3994C /* SnippetType.swift */; };
3641
B81B0877270232B600E59F86 /* NSNotification+Name.swift in Sources */ = {isa = PBXBuildFile; fileRef = B81B0876270232B600E59F86 /* NSNotification+Name.swift */; };
3742
B81B0879270245CE00E59F86 /* AppMenu+HideWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = B81B0878270245CE00E59F86 /* AppMenu+HideWindow.swift */; };
@@ -100,8 +105,6 @@
100105
B8BEF5AD26FFEB600098A778 /* EmptySnippetsListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8BEF5AC26FFEB600098A778 /* EmptySnippetsListView.swift */; };
101106
B8C1F6C0270E13BA0088E5B5 /* Sourceful in Frameworks */ = {isa = PBXBuildFile; productRef = B8C1F6BF270E13BA0088E5B5 /* Sourceful */; };
102107
B8C1F6C3270E13C30088E5B5 /* SwiftUISkeleton in Frameworks */ = {isa = PBXBuildFile; productRef = B8C1F6C2270E13C30088E5B5 /* SwiftUISkeleton */; };
103-
B8C1F6C6270E13E60088E5B5 /* FirebaseCrashlytics in Frameworks */ = {isa = PBXBuildFile; productRef = B8C1F6C5270E13E60088E5B5 /* FirebaseCrashlytics */; };
104-
B8C1F6C8270E13E60088E5B5 /* FirebaseDatabase in Frameworks */ = {isa = PBXBuildFile; productRef = B8C1F6C7270E13E60088E5B5 /* FirebaseDatabase */; };
105108
B8C549BA26FF9C0800720E62 /* NetworkObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8C549B926FF9C0800720E62 /* NetworkObserver.swift */; };
106109
B8C549BC26FFA71300720E62 /* AppView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8C549BB26FFA71300720E62 /* AppView.swift */; };
107110
B8C549C426FFBA8600720E62 /* View+Skeletonable.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8C549C326FFBA8600720E62 /* View+Skeletonable.swift */; };
@@ -305,10 +308,13 @@
305308
isa = PBXFrameworksBuildPhase;
306309
buildActionMask = 2147483647;
307310
files = (
308-
B8C1F6C6270E13E60088E5B5 /* FirebaseCrashlytics in Frameworks */,
311+
B816C71E275817EA00680174 /* FirebaseDatabase in Frameworks */,
309312
B8C1F6C0270E13BA0088E5B5 /* Sourceful in Frameworks */,
310313
B8FC70E327335DF80090292C /* PopupView in Frameworks */,
311-
B8C1F6C8270E13E60088E5B5 /* FirebaseDatabase in Frameworks */,
314+
B816C720275817EA00680174 /* FirebaseRemoteConfig in Frameworks */,
315+
B816C71C275817EA00680174 /* FirebaseCrashlytics in Frameworks */,
316+
B816C722275817EA00680174 /* FirebaseStorage in Frameworks */,
317+
B816C71A275817EA00680174 /* FirebaseAnalytics in Frameworks */,
312318
B8C1F6C3270E13C30088E5B5 /* SwiftUISkeleton in Frameworks */,
313319
);
314320
runOnlyForDeploymentPostprocessing = 0;
@@ -827,9 +833,12 @@
827833
packageProductDependencies = (
828834
B8C1F6BF270E13BA0088E5B5 /* Sourceful */,
829835
B8C1F6C2270E13C30088E5B5 /* SwiftUISkeleton */,
830-
B8C1F6C5270E13E60088E5B5 /* FirebaseCrashlytics */,
831-
B8C1F6C7270E13E60088E5B5 /* FirebaseDatabase */,
832836
B8FC70E227335DF80090292C /* PopupView */,
837+
B816C719275817EA00680174 /* FirebaseAnalytics */,
838+
B816C71B275817EA00680174 /* FirebaseCrashlytics */,
839+
B816C71D275817EA00680174 /* FirebaseDatabase */,
840+
B816C71F275817EA00680174 /* FirebaseRemoteConfig */,
841+
B816C721275817EA00680174 /* FirebaseStorage */,
833842
);
834843
productName = SnippetsLibrary;
835844
productReference = B82561B026E81D570040A67E /* Snippets Library.app */;
@@ -908,8 +917,8 @@
908917
packageReferences = (
909918
B8C1F6BE270E13BA0088E5B5 /* XCRemoteSwiftPackageReference "Sourceful" */,
910919
B8C1F6C1270E13C30088E5B5 /* XCRemoteSwiftPackageReference "SwiftUISkeleton" */,
911-
B8C1F6C4270E13E60088E5B5 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */,
912920
B8FC70E127335DF80090292C /* XCRemoteSwiftPackageReference "PopupView" */,
921+
B816C718275817EA00680174 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */,
913922
);
914923
productRefGroup = B82561B126E81D570040A67E /* Products */;
915924
projectDirPath = "";
@@ -1517,25 +1526,25 @@
15171526
/* End XCConfigurationList section */
15181527

15191528
/* Begin XCRemoteSwiftPackageReference section */
1520-
B8C1F6BE270E13BA0088E5B5 /* XCRemoteSwiftPackageReference "Sourceful" */ = {
1529+
B816C718275817EA00680174 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */ = {
15211530
isa = XCRemoteSwiftPackageReference;
1522-
repositoryURL = "https://github.com/twostraws/Sourceful.git";
1531+
repositoryURL = "https://github.com/firebase/firebase-ios-sdk.git";
15231532
requirement = {
1524-
branch = main;
1533+
branch = master;
15251534
kind = branch;
15261535
};
15271536
};
1528-
B8C1F6C1270E13C30088E5B5 /* XCRemoteSwiftPackageReference "SwiftUISkeleton" */ = {
1537+
B8C1F6BE270E13BA0088E5B5 /* XCRemoteSwiftPackageReference "Sourceful" */ = {
15291538
isa = XCRemoteSwiftPackageReference;
1530-
repositoryURL = "https://github.com/serbats/SwiftUISkeleton.git";
1539+
repositoryURL = "https://github.com/twostraws/Sourceful.git";
15311540
requirement = {
1532-
branch = master;
1541+
branch = main;
15331542
kind = branch;
15341543
};
15351544
};
1536-
B8C1F6C4270E13E60088E5B5 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */ = {
1545+
B8C1F6C1270E13C30088E5B5 /* XCRemoteSwiftPackageReference "SwiftUISkeleton" */ = {
15371546
isa = XCRemoteSwiftPackageReference;
1538-
repositoryURL = "https://github.com/firebase/firebase-ios-sdk.git";
1547+
repositoryURL = "https://github.com/serbats/SwiftUISkeleton.git";
15391548
requirement = {
15401549
branch = master;
15411550
kind = branch;
@@ -1552,6 +1561,31 @@
15521561
/* End XCRemoteSwiftPackageReference section */
15531562

15541563
/* Begin XCSwiftPackageProductDependency section */
1564+
B816C719275817EA00680174 /* FirebaseAnalytics */ = {
1565+
isa = XCSwiftPackageProductDependency;
1566+
package = B816C718275817EA00680174 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
1567+
productName = FirebaseAnalytics;
1568+
};
1569+
B816C71B275817EA00680174 /* FirebaseCrashlytics */ = {
1570+
isa = XCSwiftPackageProductDependency;
1571+
package = B816C718275817EA00680174 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
1572+
productName = FirebaseCrashlytics;
1573+
};
1574+
B816C71D275817EA00680174 /* FirebaseDatabase */ = {
1575+
isa = XCSwiftPackageProductDependency;
1576+
package = B816C718275817EA00680174 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
1577+
productName = FirebaseDatabase;
1578+
};
1579+
B816C71F275817EA00680174 /* FirebaseRemoteConfig */ = {
1580+
isa = XCSwiftPackageProductDependency;
1581+
package = B816C718275817EA00680174 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
1582+
productName = FirebaseRemoteConfig;
1583+
};
1584+
B816C721275817EA00680174 /* FirebaseStorage */ = {
1585+
isa = XCSwiftPackageProductDependency;
1586+
package = B816C718275817EA00680174 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
1587+
productName = FirebaseStorage;
1588+
};
15551589
B8C1F6BF270E13BA0088E5B5 /* Sourceful */ = {
15561590
isa = XCSwiftPackageProductDependency;
15571591
package = B8C1F6BE270E13BA0088E5B5 /* XCRemoteSwiftPackageReference "Sourceful" */;
@@ -1562,16 +1596,6 @@
15621596
package = B8C1F6C1270E13C30088E5B5 /* XCRemoteSwiftPackageReference "SwiftUISkeleton" */;
15631597
productName = SwiftUISkeleton;
15641598
};
1565-
B8C1F6C5270E13E60088E5B5 /* FirebaseCrashlytics */ = {
1566-
isa = XCSwiftPackageProductDependency;
1567-
package = B8C1F6C4270E13E60088E5B5 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
1568-
productName = FirebaseCrashlytics;
1569-
};
1570-
B8C1F6C7270E13E60088E5B5 /* FirebaseDatabase */ = {
1571-
isa = XCSwiftPackageProductDependency;
1572-
package = B8C1F6C4270E13E60088E5B5 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
1573-
productName = FirebaseDatabase;
1574-
};
15751599
B8FC70E227335DF80090292C /* PopupView */ = {
15761600
isa = XCSwiftPackageProductDependency;
15771601
package = B8FC70E127335DF80090292C /* XCRemoteSwiftPackageReference "PopupView" */;

SnippetsLibrary.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

+7-7
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"repositoryURL": "https://github.com/firebase/firebase-ios-sdk.git",
2525
"state": {
2626
"branch": "master",
27-
"revision": "a5859f9cece53368c33558c530fdd97c7824ae4f",
27+
"revision": "08686f04881483d2bc098b2696e674c0ba135e47",
2828
"version": null
2929
}
3030
},
@@ -33,26 +33,26 @@
3333
"repositoryURL": "https://github.com/google/GoogleAppMeasurement.git",
3434
"state": {
3535
"branch": null,
36-
"revision": "06add56b27b88ae5180e92d4ee21a1199ee888a1",
37-
"version": "8.8.0"
36+
"revision": "9b2f6aca5b4685c45f9f5481f19bee8e7982c538",
37+
"version": "8.9.1"
3838
}
3939
},
4040
{
4141
"package": "GoogleDataTransport",
4242
"repositoryURL": "https://github.com/google/GoogleDataTransport.git",
4343
"state": {
4444
"branch": null,
45-
"revision": "7fb27ea49414b9c5483503cd06baa821c8654d1e",
46-
"version": "9.1.1"
45+
"revision": "15ccdfd25ac55b9239b82809531ff26605e7556e",
46+
"version": "9.1.2"
4747
}
4848
},
4949
{
5050
"package": "GoogleUtilities",
5151
"repositoryURL": "https://github.com/google/GoogleUtilities.git",
5252
"state": {
5353
"branch": null,
54-
"revision": "616fac2626b6b2d1424d79a6f786b4e2ed1cfb49",
55-
"version": "7.5.2"
54+
"revision": "797005ad8a1f0614063933e2fa010a5d13cb09d0",
55+
"version": "7.6.0"
5656
}
5757
},
5858
{

SnippetsLibrary/Modules/SnippetDetails/SnippetDetailsView.swift

+11-1
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,18 @@ struct SnippetDetailsView: View {
3030
// MARK: - Views
3131

3232
var body: some View {
33-
VStack(alignment: .leading, spacing: .zero) {
33+
VStack(
34+
alignment: .leading,
35+
spacing: .zero
36+
) {
3437
TextField(
3538
"Snippet title",
3639
text: $viewModel.snippet.title
3740
)
3841
.modifier(TextFieldStyleModifier(type: viewModel.type))
3942
.font(.system(size: 15, weight: .bold))
4043
.foregroundColor(Color.primary)
44+
.help("Provide the title in a common format for all snippets, e.g. Basic Service.")
4145

4246
TextField(
4347
"Snippet summary",
@@ -46,6 +50,7 @@ struct SnippetDetailsView: View {
4650
.modifier(TextFieldStyleModifier(type: viewModel.type))
4751
.font(.system(size: 11, weight: .regular))
4852
.foregroundColor(Color.primary)
53+
.help("Describe your snippet in a few words.")
4954
.padding(.top, Layout.smallPadding / 2)
5055

5156
GeometryReader { geometry in
@@ -64,6 +69,7 @@ struct SnippetDetailsView: View {
6469
width: geometry.frame(in: .global).width,
6570
height: geometry.frame(in: .global).height
6671
)
72+
.help("Remember, that the provided code snippet should be ready to use.")
6773
}
6874
.padding(.horizontal, Constants.codeEditorHorizontalPadding)
6975
.padding(.vertical, Constants.codeEditorVerticlaPadding)
@@ -100,6 +106,7 @@ struct SnippetDetailsView: View {
100106
viewModel.snippet.platform = viewModel.platforms[index]
101107
}
102108
}
109+
.help("Supported platform by code snippet.")
103110

104111
HStack {
105112
Text("Completion")
@@ -123,6 +130,7 @@ struct SnippetDetailsView: View {
123130
)
124131
.padding(.leading, Layout.smallPadding)
125132
}
133+
.help("Completion should be unique to this snippet and easy to remember.")
126134
.padding(.top, Constants.lineTopPadding)
127135

128136
HStack {
@@ -150,6 +158,7 @@ struct SnippetDetailsView: View {
150158
viewModel.snippet.availability = viewModel.availabilities[index]
151159
}
152160
}
161+
.help("Scope for this code snippet.")
153162
.padding(.top, Constants.lineTopPadding)
154163

155164
HStack {
@@ -184,6 +193,7 @@ struct SnippetDetailsView: View {
184193
.padding(.leading, Layout.smallPadding)
185194
}
186195
}
196+
.help("Author of this code snippet.")
187197
.padding(.top, Constants.lineTopPadding)
188198

189199
Spacer()

SnippetsLibrary/Modules/SnippetDetails/SnippetDetailsViewModel.swift

+13-11
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@ final class SnippetDetailsViewModel: ObservableObject {
1212

1313
// MARK: - Stored Properties
1414

15-
@Published internal var snippet: Snippet
16-
@Binding internal var activeAppView: ActiveAppView?
15+
@Published var snippet: Snippet
16+
@Binding private(set) var activeAppView: ActiveAppView?
1717

18-
internal let type: SnippetDetailsViewType
18+
let type: SnippetDetailsViewType
1919
private var lastSavedSnippet: Snippet? = nil
2020

21-
@Published internal var platformSelectionIndex: Int = 0
22-
internal var platforms = SnippetPlatform.allCases
21+
@Published var platformSelectionIndex = 0
22+
let platforms = SnippetPlatform.allCases
2323

24-
@Published internal var availabilitySelectionIndex: Int = 0
25-
internal var availabilities = SnippetAvailability.allCases
24+
@Published var availabilitySelectionIndex = 0
25+
let availabilities = SnippetAvailability.allCases
2626

2727
@Published private(set) var shouldDismissView = false
28-
@Published internal var shouldShowErrorAlert = false
28+
@Published var shouldShowErrorAlert = false
2929

3030
private let snippetsParserService: SnippetsParserService
3131
private let databaseService: DatabaseService
@@ -34,8 +34,10 @@ final class SnippetDetailsViewModel: ObservableObject {
3434

3535
// MARK: - Computed Properties
3636

37-
internal var hasChanges: Bool {
38-
lastSavedSnippet != snippet
37+
var hasChanges: Bool {
38+
lastSavedSnippet != snippet && !snippet.title.isEmpty &&
39+
!snippet.summary.isEmpty && !snippet.content.isEmpty &&
40+
!snippet.completion.isEmpty
3941
}
4042

4143
// MARK: - Initialization
@@ -58,7 +60,7 @@ final class SnippetDetailsViewModel: ObservableObject {
5860

5961
// MARK: - Methods
6062

61-
internal func performChanges() {
63+
func performChanges() {
6264
guard hasChanges else { return }
6365

6466
if type == .create {

SnippetsLibrary/Modules/SnippetsLibrary/SnippetsLibraryViewModel.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ final class SnippetsLibraryViewModel: ObservableObject {
5555
}
5656

5757
internal func fetchSnippets() {
58-
databaseService.fetchSnippets()
58+
databaseService.snippets
5959
.receive(on: DispatchQueue.main)
6060
.sink { [weak self] completion in
6161
switch completion {

0 commit comments

Comments
 (0)