Skip to content

Commit 40a6561

Browse files
committed
Merge branch 'develop'
2 parents 6ec0e28 + 919b9e1 commit 40a6561

File tree

8 files changed

+169
-25
lines changed

8 files changed

+169
-25
lines changed

SnippetsLibrary.xcodeproj/project.pbxproj

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@
130130
B8F95B0926EEAF4D00335D77 /* SnippetImportViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8F95B0826EEAF4D00335D77 /* SnippetImportViewModel.swift */; };
131131
B8F9CA982700F7F40041CE3E /* DisabledCommandGroupButtonType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8F9CA972700F7F40041CE3E /* DisabledCommandGroupButtonType.swift */; };
132132
B8F9CA9A2700F80E0041CE3E /* UploadingStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8F9CA992700F80E0041CE3E /* UploadingStatus.swift */; };
133+
B8FC70E327335DF80090292C /* PopupView in Frameworks */ = {isa = PBXBuildFile; productRef = B8FC70E227335DF80090292C /* PopupView */; };
134+
B8FC70E5273361BD0090292C /* SnippetCreationManualView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8FC70E4273361BD0090292C /* SnippetCreationManualView.swift */; };
133135
/* End PBXBuildFile section */
134136

135137
/* Begin PBXContainerItemProxy section */
@@ -286,6 +288,7 @@
286288
B8F95B0826EEAF4D00335D77 /* SnippetImportViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SnippetImportViewModel.swift; sourceTree = "<group>"; };
287289
B8F9CA972700F7F40041CE3E /* DisabledCommandGroupButtonType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DisabledCommandGroupButtonType.swift; sourceTree = "<group>"; };
288290
B8F9CA992700F80E0041CE3E /* UploadingStatus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UploadingStatus.swift; sourceTree = "<group>"; };
291+
B8FC70E4273361BD0090292C /* SnippetCreationManualView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SnippetCreationManualView.swift; sourceTree = "<group>"; };
289292
/* End PBXFileReference section */
290293

291294
/* Begin PBXFrameworksBuildPhase section */
@@ -304,6 +307,7 @@
304307
files = (
305308
B8C1F6C6270E13E60088E5B5 /* FirebaseCrashlytics in Frameworks */,
306309
B8C1F6C0270E13BA0088E5B5 /* Sourceful in Frameworks */,
310+
B8FC70E327335DF80090292C /* PopupView in Frameworks */,
307311
B8C1F6C8270E13E60088E5B5 /* FirebaseDatabase in Frameworks */,
308312
B8C1F6C3270E13C30088E5B5 /* SwiftUISkeleton in Frameworks */,
309313
);
@@ -510,6 +514,7 @@
510514
B8CE1CAA26FD4193004AD5D5 /* DisabledCommandGroupButton.swift */,
511515
B8BEF5A826FFBF7E0098A778 /* ToastView.swift */,
512516
B8BEF5AC26FFEB600098A778 /* EmptySnippetsListView.swift */,
517+
B8FC70E4273361BD0090292C /* SnippetCreationManualView.swift */,
513518
);
514519
path = Views;
515520
sourceTree = "<group>";
@@ -824,6 +829,7 @@
824829
B8C1F6C2270E13C30088E5B5 /* SwiftUISkeleton */,
825830
B8C1F6C5270E13E60088E5B5 /* FirebaseCrashlytics */,
826831
B8C1F6C7270E13E60088E5B5 /* FirebaseDatabase */,
832+
B8FC70E227335DF80090292C /* PopupView */,
827833
);
828834
productName = SnippetsLibrary;
829835
productReference = B82561B026E81D570040A67E /* Snippets Library.app */;
@@ -903,6 +909,7 @@
903909
B8C1F6BE270E13BA0088E5B5 /* XCRemoteSwiftPackageReference "Sourceful" */,
904910
B8C1F6C1270E13C30088E5B5 /* XCRemoteSwiftPackageReference "SwiftUISkeleton" */,
905911
B8C1F6C4270E13E60088E5B5 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */,
912+
B8FC70E127335DF80090292C /* XCRemoteSwiftPackageReference "PopupView" */,
906913
);
907914
productRefGroup = B82561B126E81D570040A67E /* Products */;
908915
projectDirPath = "";
@@ -1061,6 +1068,7 @@
10611068
B82561E926E8C7D60040A67E /* SnippetsLibraryView.swift in Sources */,
10621069
B85AC934270215ED00A008A6 /* StatusViewModel.swift in Sources */,
10631070
B85AC9302702158300A008A6 /* AppDelegate+NSMenuDelegate.swift in Sources */,
1071+
B8FC70E5273361BD0090292C /* SnippetCreationManualView.swift in Sources */,
10641072
B8546F3A270773FE0043A99F /* SnippetsLibraryListFilterView.swift in Sources */,
10651073
B8EB5ADF26F00A4A00BE3EF6 /* SnippetDetailsViewType.swift in Sources */,
10661074
B84BFEA926F57018007E5109 /* System.swift in Sources */,
@@ -1159,9 +1167,10 @@
11591167
"@executable_path/../../../../Frameworks",
11601168
);
11611169
MACOSX_DEPLOYMENT_TARGET = 11.0;
1162-
MARKETING_VERSION = 1.0.2;
1170+
MARKETING_VERSION = 1.0.3;
11631171
PRODUCT_BUNDLE_IDENTIFIER = com.cphlowiec.SnippetsLibrary.SnippetsLibraryWidget;
11641172
PRODUCT_NAME = "$(TARGET_NAME)";
1173+
PROVISIONING_PROFILE_SPECIFIER = "";
11651174
SKIP_INSTALL = YES;
11661175
SWIFT_EMIT_LOC_STRINGS = YES;
11671176
SWIFT_VERSION = 5.0;
@@ -1191,9 +1200,10 @@
11911200
"@executable_path/../../../../Frameworks",
11921201
);
11931202
MACOSX_DEPLOYMENT_TARGET = 11.0;
1194-
MARKETING_VERSION = 1.0.2;
1203+
MARKETING_VERSION = 1.0.3;
11951204
PRODUCT_BUNDLE_IDENTIFIER = com.cphlowiec.SnippetsLibrary.SnippetsLibraryWidget;
11961205
PRODUCT_NAME = "$(TARGET_NAME)";
1206+
PROVISIONING_PROFILE_SPECIFIER = "";
11971207
SKIP_INSTALL = YES;
11981208
SWIFT_EMIT_LOC_STRINGS = YES;
11991209
SWIFT_VERSION = 5.0;
@@ -1322,8 +1332,8 @@
13221332
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
13231333
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
13241334
CODE_SIGN_ENTITLEMENTS = SnippetsLibrary/SnippetsLibraryDebug.entitlements;
1325-
CODE_SIGN_IDENTITY = "Apple Development";
1326-
CODE_SIGN_STYLE = Automatic;
1335+
CODE_SIGN_IDENTITY = "Mac Developer";
1336+
CODE_SIGN_STYLE = Manual;
13271337
COMBINE_HIDPI_IMAGES = YES;
13281338
CURRENT_PROJECT_VERSION = 18;
13291339
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
@@ -1340,7 +1350,7 @@
13401350
MARKETING_VERSION = 1.0.2;
13411351
PRODUCT_BUNDLE_IDENTIFIER = com.cphlowiec.SnippetsLibrary;
13421352
PRODUCT_NAME = "Snippets Library";
1343-
PROVISIONING_PROFILE_SPECIFIER = "";
1353+
PROVISIONING_PROFILE_SPECIFIER = "SnippetsLibrary Development";
13441354
SWIFT_VERSION = 5.0;
13451355
};
13461356
name = Debug;
@@ -1352,8 +1362,8 @@
13521362
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
13531363
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
13541364
CODE_SIGN_ENTITLEMENTS = SnippetsLibrary/SnippetsLibrary.entitlements;
1355-
CODE_SIGN_IDENTITY = "Apple Development";
1356-
CODE_SIGN_STYLE = Automatic;
1365+
CODE_SIGN_IDENTITY = "Mac Developer";
1366+
CODE_SIGN_STYLE = Manual;
13571367
COMBINE_HIDPI_IMAGES = YES;
13581368
CURRENT_PROJECT_VERSION = 18;
13591369
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
@@ -1370,7 +1380,7 @@
13701380
MARKETING_VERSION = 1.0.2;
13711381
PRODUCT_BUNDLE_IDENTIFIER = com.cphlowiec.SnippetsLibrary;
13721382
PRODUCT_NAME = "Snippets Library";
1373-
PROVISIONING_PROFILE_SPECIFIER = "";
1383+
PROVISIONING_PROFILE_SPECIFIER = "SnippetsLibrary Development";
13741384
SWIFT_ACTIVE_COMPILATION_CONDITIONS = RELEASE;
13751385
SWIFT_VERSION = 5.0;
13761386
};
@@ -1531,6 +1541,14 @@
15311541
kind = branch;
15321542
};
15331543
};
1544+
B8FC70E127335DF80090292C /* XCRemoteSwiftPackageReference "PopupView" */ = {
1545+
isa = XCRemoteSwiftPackageReference;
1546+
repositoryURL = "https://github.com/exyte/PopupView.git";
1547+
requirement = {
1548+
kind = upToNextMajorVersion;
1549+
minimumVersion = 1.0.0;
1550+
};
1551+
};
15341552
/* End XCRemoteSwiftPackageReference section */
15351553

15361554
/* Begin XCSwiftPackageProductDependency section */
@@ -1554,6 +1572,11 @@
15541572
package = B8C1F6C4270E13E60088E5B5 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
15551573
productName = FirebaseDatabase;
15561574
};
1575+
B8FC70E227335DF80090292C /* PopupView */ = {
1576+
isa = XCSwiftPackageProductDependency;
1577+
package = B8FC70E127335DF80090292C /* XCRemoteSwiftPackageReference "PopupView" */;
1578+
productName = PopupView;
1579+
};
15571580
/* End XCSwiftPackageProductDependency section */
15581581
};
15591582
rootObject = B82561A826E81D570040A67E /* Project object */;

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

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SnippetsLibrary/Modules/SnippetsLibrary/SnippetsLibraryView.swift

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//
77

88
import SwiftUI
9+
import PopupView
910

1011
struct SnippetsLibraryView: View {
1112

@@ -15,29 +16,32 @@ struct SnippetsLibraryView: View {
1516

1617
@Binding internal var activeSheet: AppSheet?
1718
@State private var appAlert: AppAlert? = nil
19+
@State private var shouldShowSnippetManual = false
1820

1921
// MARK: - Views
2022

2123
var body: some View {
22-
HSplitView {
23-
SnippetsLibraryListView(
24-
viewModel: SnippetsLibraryListViewModel(
24+
ZStack {
25+
HSplitView {
26+
SnippetsLibraryListView(
27+
viewModel: SnippetsLibraryListViewModel(
28+
snippets: $viewModel.snippets,
29+
selectedSnippetId: $viewModel.selectedSnippetId
30+
) {
31+
viewModel.fetchSnippets()
32+
} onRemove: {
33+
viewModel.onRemove($0)
34+
}
35+
)
36+
37+
SnippetsLibraryPreviewView(
2538
snippets: $viewModel.snippets,
26-
selectedSnippetId: $viewModel.selectedSnippetId
39+
selectedSnippetId: $viewModel.selectedSnippetId,
40+
activeSheet: $activeSheet,
41+
appAlert: $appAlert
2742
) {
28-
viewModel.fetchSnippets()
29-
} onRemove: {
30-
viewModel.onRemove($0)
43+
viewModel.saveSnippetToRecentSnippets($0)
3144
}
32-
)
33-
34-
SnippetsLibraryPreviewView(
35-
snippets: $viewModel.snippets,
36-
selectedSnippetId: $viewModel.selectedSnippetId,
37-
activeSheet: $activeSheet,
38-
appAlert: $appAlert
39-
) {
40-
viewModel.saveSnippetToRecentSnippets($0)
4145
}
4246
}
4347
.frame(
@@ -83,6 +87,28 @@ struct SnippetsLibraryView: View {
8387
subtitle: "Requested operation couldn't be completed",
8488
state: .failure
8589
)
90+
.popup(
91+
isPresented: $shouldShowSnippetManual,
92+
type: .floater(verticalPadding: Layout.defaultWindowSize.height),
93+
position: .bottom,
94+
animation: .easeInOut,
95+
closeOnTapOutside: true,
96+
backgroundColor: Color.black.opacity(Layout.mediumOpacity)
97+
) {
98+
viewModel.markSnippetManualAsReaded()
99+
} view: {
100+
SnippetCreationManualView()
101+
}
102+
.onAppear {
103+
showSnippetManualIfNeeded()
104+
}
105+
}
106+
107+
// MARK: - Methods
108+
109+
private func showSnippetManualIfNeeded() {
110+
let userDefaultsService = DIContainer.userDefaultsService
111+
shouldShowSnippetManual = userDefaultsService.shouldShowSnippetManual()
86112
}
87113

88114
}

SnippetsLibrary/Modules/SnippetsLibrary/SnippetsLibraryViewModel.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ final class SnippetsLibraryViewModel: ObservableObject {
8888
}
8989
}
9090

91+
internal func markSnippetManualAsReaded() {
92+
userDefaultsService.markSnippetManualAsReaded()
93+
}
94+
9195
private func fetchLocalSnippets() {
9296
userDefaultsService.fetchSnippets(fetchingType: .local)
9397
.receive(on: DispatchQueue.main)

SnippetsLibrary/Services/UserDefaults/UserDefaultsService.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ protocol UserDefaultsService {
1414
func saveSnippetsLocally(_ snippets: [Snippet])
1515

1616
func fetchRecentSnippetsFromAppGroup() -> [Snippet]
17+
18+
func shouldShowSnippetManual() -> Bool
19+
func markSnippetManualAsReaded()
1720
}
1821

1922
final class UserDefaultsServiceImpl: UserDefaultsService {
@@ -22,6 +25,7 @@ final class UserDefaultsServiceImpl: UserDefaultsService {
2225
static let recentSnippetKey = "RecentSnippet"
2326
static let localSnippetKey = "LocalSnippet"
2427
static let appGroupName = "group.com.cphlowiec.SnippetsLibrary"
28+
static let snippetManualKey = "wasSnippetManualReaded"
2529
}
2630

2731
// MARK: - Stored Properties
@@ -122,4 +126,18 @@ final class UserDefaultsServiceImpl: UserDefaultsService {
122126
)
123127
}
124128

129+
// MARK: - Snippet Manual
130+
131+
internal func shouldShowSnippetManual() -> Bool {
132+
let wasSnippetsManualReaded = userDefaults.bool(forKey: Constants.snippetManualKey)
133+
return !wasSnippetsManualReaded
134+
}
135+
136+
internal func markSnippetManualAsReaded() {
137+
userDefaults.set(
138+
true,
139+
forKey: Constants.snippetManualKey
140+
)
141+
}
142+
125143
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
//
2+
// SnippetCreationManualView.swift
3+
// SnippetsLibrary
4+
//
5+
// Created by Krzysztof Łowiec on 03/11/2021.
6+
//
7+
8+
import SwiftUI
9+
10+
struct SnippetCreationManualView: View {
11+
12+
private enum Constants {
13+
static let imageHeight: CGFloat = 38.0
14+
static let lineSpacing: CGFloat = 5.0
15+
static let viewSize = CGSize(width: 350.0, height: 400.0)
16+
static let cornerRadius: CGFloat = 12.0
17+
}
18+
19+
// MARK: - Views
20+
21+
var body: some View {
22+
VStack {
23+
Image("icSnippetFileWhite")
24+
.resizable()
25+
.aspectRatio(contentMode: .fit)
26+
.frame(height: Constants.imageHeight)
27+
28+
Text("How to create a snippet?")
29+
.font(.system(size: 17, weight: .bold))
30+
.padding(.bottom, Layout.smallPadding)
31+
32+
Text("To maintain consistency and unify all code snippets in the Snippets Library, follow this two main rules:")
33+
.font(.system(size: 11, weight: .medium))
34+
.padding(.bottom)
35+
.opacity(Layout.mediumOpacity)
36+
.multilineTextAlignment(.center)
37+
38+
Text(
39+
"""
40+
✅ Make sure, that your snippet is helpful, complete and contains only the necessary lines required for use.
41+
42+
✅ Enter the title, summary, supported platforms and scopes and remember, that the completion should be self-explaining.
43+
"""
44+
)
45+
.lineSpacing(Constants.lineSpacing)
46+
.font(.system(size: 13))
47+
.multilineTextAlignment(.leading)
48+
}
49+
.padding(Layout.largePadding)
50+
.frame(
51+
width: Constants.viewSize.width,
52+
height: Constants.viewSize.height
53+
)
54+
.background(Color("defaultBackground"))
55+
.cornerRadius(Constants.cornerRadius)
56+
}
57+
58+
}
59+
60+
struct SnippetCreationManualView_Previews: PreviewProvider {
61+
static var previews: some View {
62+
SnippetCreationManualView()
63+
}
64+
}

SnippetsLibraryWidget/Views/MediumWidget/MediumWidgetView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct MediumWidgetView: View {
2727
Spacer()
2828

2929
Rectangle()
30-
.foregroundColor(Color("widgetBackground"))
30+
.foregroundColor(Color("defaultBackground"))
3131
.frame(width: geometry.size.width / 2)
3232
}
3333

0 commit comments

Comments
 (0)