Skip to content

Commit bbb1ebd

Browse files
committed
Improve code snippets uploading
1 parent 919b9e1 commit bbb1ebd

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 */; };
@@ -303,10 +306,13 @@
303306
isa = PBXFrameworksBuildPhase;
304307
buildActionMask = 2147483647;
305308
files = (
306-
B8C1F6C6270E13E60088E5B5 /* FirebaseCrashlytics in Frameworks */,
309+
B816C71E275817EA00680174 /* FirebaseDatabase in Frameworks */,
307310
B8C1F6C0270E13BA0088E5B5 /* Sourceful in Frameworks */,
308311
B8FC70E327335DF80090292C /* PopupView in Frameworks */,
309-
B8C1F6C8270E13E60088E5B5 /* FirebaseDatabase in Frameworks */,
312+
B816C720275817EA00680174 /* FirebaseRemoteConfig in Frameworks */,
313+
B816C71C275817EA00680174 /* FirebaseCrashlytics in Frameworks */,
314+
B816C722275817EA00680174 /* FirebaseStorage in Frameworks */,
315+
B816C71A275817EA00680174 /* FirebaseAnalytics in Frameworks */,
310316
B8C1F6C3270E13C30088E5B5 /* SwiftUISkeleton in Frameworks */,
311317
);
312318
runOnlyForDeploymentPostprocessing = 0;
@@ -824,9 +830,12 @@
824830
packageProductDependencies = (
825831
B8C1F6BF270E13BA0088E5B5 /* Sourceful */,
826832
B8C1F6C2270E13C30088E5B5 /* SwiftUISkeleton */,
827-
B8C1F6C5270E13E60088E5B5 /* FirebaseCrashlytics */,
828-
B8C1F6C7270E13E60088E5B5 /* FirebaseDatabase */,
829833
B8FC70E227335DF80090292C /* PopupView */,
834+
B816C719275817EA00680174 /* FirebaseAnalytics */,
835+
B816C71B275817EA00680174 /* FirebaseCrashlytics */,
836+
B816C71D275817EA00680174 /* FirebaseDatabase */,
837+
B816C71F275817EA00680174 /* FirebaseRemoteConfig */,
838+
B816C721275817EA00680174 /* FirebaseStorage */,
830839
);
831840
productName = SnippetsLibrary;
832841
productReference = B82561B026E81D570040A67E /* Snippets Library.app */;
@@ -905,8 +914,8 @@
905914
packageReferences = (
906915
B8C1F6BE270E13BA0088E5B5 /* XCRemoteSwiftPackageReference "Sourceful" */,
907916
B8C1F6C1270E13C30088E5B5 /* XCRemoteSwiftPackageReference "SwiftUISkeleton" */,
908-
B8C1F6C4270E13E60088E5B5 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */,
909917
B8FC70E127335DF80090292C /* XCRemoteSwiftPackageReference "PopupView" */,
918+
B816C718275817EA00680174 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */,
910919
);
911920
productRefGroup = B82561B126E81D570040A67E /* Products */;
912921
projectDirPath = "";
@@ -1513,25 +1522,25 @@
15131522
/* End XCConfigurationList section */
15141523

15151524
/* Begin XCRemoteSwiftPackageReference section */
1516-
B8C1F6BE270E13BA0088E5B5 /* XCRemoteSwiftPackageReference "Sourceful" */ = {
1525+
B816C718275817EA00680174 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */ = {
15171526
isa = XCRemoteSwiftPackageReference;
1518-
repositoryURL = "https://github.com/twostraws/Sourceful.git";
1527+
repositoryURL = "https://github.com/firebase/firebase-ios-sdk.git";
15191528
requirement = {
1520-
branch = main;
1529+
branch = master;
15211530
kind = branch;
15221531
};
15231532
};
1524-
B8C1F6C1270E13C30088E5B5 /* XCRemoteSwiftPackageReference "SwiftUISkeleton" */ = {
1533+
B8C1F6BE270E13BA0088E5B5 /* XCRemoteSwiftPackageReference "Sourceful" */ = {
15251534
isa = XCRemoteSwiftPackageReference;
1526-
repositoryURL = "https://github.com/serbats/SwiftUISkeleton.git";
1535+
repositoryURL = "https://github.com/twostraws/Sourceful.git";
15271536
requirement = {
1528-
branch = master;
1537+
branch = main;
15291538
kind = branch;
15301539
};
15311540
};
1532-
B8C1F6C4270E13E60088E5B5 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */ = {
1541+
B8C1F6C1270E13C30088E5B5 /* XCRemoteSwiftPackageReference "SwiftUISkeleton" */ = {
15331542
isa = XCRemoteSwiftPackageReference;
1534-
repositoryURL = "https://github.com/firebase/firebase-ios-sdk.git";
1543+
repositoryURL = "https://github.com/serbats/SwiftUISkeleton.git";
15351544
requirement = {
15361545
branch = master;
15371546
kind = branch;
@@ -1548,6 +1557,31 @@
15481557
/* End XCRemoteSwiftPackageReference section */
15491558

15501559
/* Begin XCSwiftPackageProductDependency section */
1560+
B816C719275817EA00680174 /* FirebaseAnalytics */ = {
1561+
isa = XCSwiftPackageProductDependency;
1562+
package = B816C718275817EA00680174 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
1563+
productName = FirebaseAnalytics;
1564+
};
1565+
B816C71B275817EA00680174 /* FirebaseCrashlytics */ = {
1566+
isa = XCSwiftPackageProductDependency;
1567+
package = B816C718275817EA00680174 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
1568+
productName = FirebaseCrashlytics;
1569+
};
1570+
B816C71D275817EA00680174 /* FirebaseDatabase */ = {
1571+
isa = XCSwiftPackageProductDependency;
1572+
package = B816C718275817EA00680174 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
1573+
productName = FirebaseDatabase;
1574+
};
1575+
B816C71F275817EA00680174 /* FirebaseRemoteConfig */ = {
1576+
isa = XCSwiftPackageProductDependency;
1577+
package = B816C718275817EA00680174 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
1578+
productName = FirebaseRemoteConfig;
1579+
};
1580+
B816C721275817EA00680174 /* FirebaseStorage */ = {
1581+
isa = XCSwiftPackageProductDependency;
1582+
package = B816C718275817EA00680174 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
1583+
productName = FirebaseStorage;
1584+
};
15511585
B8C1F6BF270E13BA0088E5B5 /* Sourceful */ = {
15521586
isa = XCSwiftPackageProductDependency;
15531587
package = B8C1F6BE270E13BA0088E5B5 /* XCRemoteSwiftPackageReference "Sourceful" */;
@@ -1558,16 +1592,6 @@
15581592
package = B8C1F6C1270E13C30088E5B5 /* XCRemoteSwiftPackageReference "SwiftUISkeleton" */;
15591593
productName = SwiftUISkeleton;
15601594
};
1561-
B8C1F6C5270E13E60088E5B5 /* FirebaseCrashlytics */ = {
1562-
isa = XCSwiftPackageProductDependency;
1563-
package = B8C1F6C4270E13E60088E5B5 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
1564-
productName = FirebaseCrashlytics;
1565-
};
1566-
B8C1F6C7270E13E60088E5B5 /* FirebaseDatabase */ = {
1567-
isa = XCSwiftPackageProductDependency;
1568-
package = B8C1F6C4270E13E60088E5B5 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
1569-
productName = FirebaseDatabase;
1570-
};
15711595
B8FC70E227335DF80090292C /* PopupView */ = {
15721596
isa = XCSwiftPackageProductDependency;
15731597
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)