Skip to content

Commit 1a3acdc

Browse files
authored
Merge pull request #11 from tryboxx/develop
Develop
2 parents dd26c00 + 1999d85 commit 1a3acdc

File tree

31 files changed

+827
-110
lines changed

31 files changed

+827
-110
lines changed

SnippetsLibrary.xcodeproj/project.pbxproj

Lines changed: 108 additions & 35 deletions
Large diffs are not rendered by default.

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

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

SnippetsLibrary.xcodeproj/xcshareddata/xcschemes/SnippetsLibrary.xcscheme

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@
5151
</Testables>
5252
</TestAction>
5353
<LaunchAction
54-
buildConfiguration = "Release"
55-
selectedDebuggerIdentifier = ""
56-
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
54+
buildConfiguration = "Debug"
55+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
56+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
5757
launchStyle = "0"
5858
useCustomWorkingDirectory = "NO"
5959
ignoresPersistentStateOnLaunch = "NO"

SnippetsLibrary/Application/SnippetsLibraryApp.swift

Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ import SwiftUI
1111
struct SnippetsLibraryApp: App {
1212

1313
// MARK: - Stored Properties
14-
15-
@Environment(\.scenePhase) var scenePhase
14+
1615
@Environment(\.openURL) var openURL
1716

1817
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
@@ -25,7 +24,11 @@ struct SnippetsLibraryApp: App {
2524

2625
var body: some Scene {
2726
WindowGroup {
28-
showActiveAppView()
27+
AppView(
28+
activeAppView: $activeAppView,
29+
activeAppSheet: $activeAppSheet,
30+
shouldBeDisabled: $shouldBeDisabled
31+
)
2932
}
3033
.windowStyle(HiddenTitleBarWindowStyle())
3134
.onChange(of: activeAppView) {
@@ -79,44 +82,6 @@ struct SnippetsLibraryApp: App {
7982

8083
// MARK: - Methods
8184

82-
@ViewBuilder
83-
private func showActiveAppView() -> some View {
84-
switch activeAppView {
85-
case .create:
86-
SnippetsLibraryView(
87-
viewModel: SnippetsLibraryViewModel(),
88-
activeSheet: $activeAppSheet
89-
)
90-
case .importSnippet:
91-
SnippetImportView(viewModel: SnippetImportViewModel(activeAppView: $activeAppView))
92-
case let .snippetsLibrary(snippetId):
93-
SnippetsLibraryView(
94-
viewModel: SnippetsLibraryViewModel(activeSnippetId: snippetId),
95-
activeSheet: $activeAppSheet
96-
)
97-
case .none:
98-
StartView(
99-
viewModel: StartViewModel(
100-
activeAppView: $activeAppView,
101-
activeAppSheet: $activeAppSheet
102-
)
103-
)
104-
.onChange(of: scenePhase) {
105-
guard $0 == .active else { return }
106-
107-
updateSystemButtons(hidden: true)
108-
}
109-
}
110-
}
111-
112-
private func updateSystemButtons(hidden: Bool) {
113-
for window in NSApplication.shared.windows {
114-
window.standardWindowButton(.zoomButton)?.isHidden = hidden
115-
window.standardWindowButton(.miniaturizeButton)?.isHidden = hidden
116-
window.standardWindowButton(.closeButton)?.isHidden = hidden
117-
}
118-
}
119-
12085
private func composeEmail() {
12186
let service = NSSharingService(named: NSSharingService.Name.composeEmail)
12287
service?.recipients = ["[email protected]"]
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"colors" : [
3+
{
4+
"color" : {
5+
"color-space" : "srgb",
6+
"components" : {
7+
"alpha" : "1.000",
8+
"blue" : "0.837",
9+
"green" : "0.837",
10+
"red" : "0.837"
11+
}
12+
},
13+
"idiom" : "universal"
14+
},
15+
{
16+
"appearances" : [
17+
{
18+
"appearance" : "luminosity",
19+
"value" : "dark"
20+
}
21+
],
22+
"color" : {
23+
"color-space" : "srgb",
24+
"components" : {
25+
"alpha" : "1.000",
26+
"blue" : "0.261",
27+
"green" : "0.261",
28+
"red" : "0.261"
29+
}
30+
},
31+
"idiom" : "universal"
32+
}
33+
],
34+
"info" : {
35+
"author" : "xcode",
36+
"version" : 1
37+
}
38+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"colors" : [
3+
{
4+
"color" : {
5+
"color-space" : "srgb",
6+
"components" : {
7+
"alpha" : "1.000",
8+
"blue" : "0.754",
9+
"green" : "0.754",
10+
"red" : "0.754"
11+
}
12+
},
13+
"idiom" : "universal"
14+
},
15+
{
16+
"appearances" : [
17+
{
18+
"appearance" : "luminosity",
19+
"value" : "dark"
20+
}
21+
],
22+
"color" : {
23+
"color-space" : "srgb",
24+
"components" : {
25+
"alpha" : "1.000",
26+
"blue" : "0.371",
27+
"green" : "0.371",
28+
"red" : "0.371"
29+
}
30+
},
31+
"idiom" : "universal"
32+
}
33+
],
34+
"info" : {
35+
"author" : "xcode",
36+
"version" : 1
37+
}
38+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"colors" : [
3+
{
4+
"color" : {
5+
"color-space" : "display-p3",
6+
"components" : {
7+
"alpha" : "1.000",
8+
"blue" : "0.894",
9+
"green" : "0.895",
10+
"red" : "0.894"
11+
}
12+
},
13+
"idiom" : "universal"
14+
},
15+
{
16+
"appearances" : [
17+
{
18+
"appearance" : "luminosity",
19+
"value" : "dark"
20+
}
21+
],
22+
"color" : {
23+
"color-space" : "srgb",
24+
"components" : {
25+
"alpha" : "1.000",
26+
"blue" : "0.130",
27+
"green" : "0.130",
28+
"red" : "0.130"
29+
}
30+
},
31+
"idiom" : "universal"
32+
}
33+
],
34+
"info" : {
35+
"author" : "xcode",
36+
"version" : 1
37+
}
38+
}

SnippetsLibrary/Dependencies/DependencyContainer.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ final class DependencyContainer {
1515

1616
lazy var snippetsParserService: SnippetsParserService = SnippetsParserServiceImpl()
1717
lazy var urlFactory: URLFactory = URLFactoryImpl()
18+
lazy var networkServcie: NetworkService = NetworkServiceImpl()
1819

1920
lazy var databaseService: DatabaseService = DatabaseServiceImpl(
2021
logsService: logsService,
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//
2+
// DatabaseReference+Timeout.swift
3+
// SnippetsLibrary
4+
//
5+
// Created by Krzysztof Łowiec on 25/09/2021.
6+
//
7+
8+
import FirebaseDatabase
9+
10+
extension DatabaseReference {
11+
12+
func observe(
13+
_ eventType: DataEventType,
14+
timeout: TimeInterval,
15+
with block: @escaping (DataSnapshot?) -> Void
16+
) -> UInt {
17+
var handle: UInt!
18+
19+
let timer = Timer.scheduledTimer(
20+
withTimeInterval: timeout,
21+
repeats: false
22+
) { _ in
23+
self.removeObserver(withHandle: handle)
24+
block(nil)
25+
}
26+
27+
handle = observe(eventType) { snapshot in
28+
timer.invalidate()
29+
block(snapshot)
30+
}
31+
32+
return handle
33+
}
34+
35+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// SnippetsLibraryView+Equatable.swift
3+
// SnippetsLibrary
4+
//
5+
// Created by Krzysztof Łowiec on 25/09/2021.
6+
//
7+
8+
import Foundation
9+
10+
extension SnippetsLibraryView: Equatable {
11+
12+
static func == (lhs: SnippetsLibraryView, rhs: SnippetsLibraryView) -> Bool {
13+
return lhs.viewModel.snippets != rhs.viewModel.snippets
14+
}
15+
16+
}

0 commit comments

Comments
 (0)