mirror of
https://github.com/1SecondEveryday/MemoryTree.git
synced 2026-03-25 08:55:47 +00:00
It's a tree!
This commit is contained in:
parent
d72784c431
commit
493b0a1c8c
15 changed files with 294 additions and 7 deletions
|
|
@ -11,6 +11,8 @@
|
|||
96372F77299031580022FDD5 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96372F76299031580022FDD5 /* ContentView.swift */; };
|
||||
96372F79299031590022FDD5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96372F78299031590022FDD5 /* Assets.xcassets */; };
|
||||
96372F7C299031590022FDD5 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96372F7B299031590022FDD5 /* Preview Assets.xcassets */; };
|
||||
96372F83299035BD0022FDD5 /* CloudView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96372F82299035BD0022FDD5 /* CloudView.swift */; };
|
||||
96372F862990373C0022FDD5 /* Boutique in Frameworks */ = {isa = PBXBuildFile; productRef = 96372F852990373C0022FDD5 /* Boutique */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
|
|
@ -19,6 +21,7 @@
|
|||
96372F76299031580022FDD5 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
|
||||
96372F78299031590022FDD5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
96372F7B299031590022FDD5 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
|
||||
96372F82299035BD0022FDD5 /* CloudView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CloudView.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
|
|
@ -26,6 +29,7 @@
|
|||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
96372F862990373C0022FDD5 /* Boutique in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
@ -53,6 +57,7 @@
|
|||
children = (
|
||||
96372F74299031580022FDD5 /* MemoryTreeApp.swift */,
|
||||
96372F76299031580022FDD5 /* ContentView.swift */,
|
||||
96372F82299035BD0022FDD5 /* CloudView.swift */,
|
||||
96372F78299031590022FDD5 /* Assets.xcassets */,
|
||||
96372F7A299031590022FDD5 /* Preview Content */,
|
||||
);
|
||||
|
|
@ -83,6 +88,9 @@
|
|||
dependencies = (
|
||||
);
|
||||
name = MemoryTree;
|
||||
packageProductDependencies = (
|
||||
96372F852990373C0022FDD5 /* Boutique */,
|
||||
);
|
||||
productName = MemoryTree;
|
||||
productReference = 96372F71299031580022FDD5 /* MemoryTree.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
|
|
@ -111,6 +119,9 @@
|
|||
Base,
|
||||
);
|
||||
mainGroup = 96372F68299031580022FDD5;
|
||||
packageReferences = (
|
||||
96372F842990373C0022FDD5 /* XCRemoteSwiftPackageReference "Boutique" */,
|
||||
);
|
||||
productRefGroup = 96372F72299031580022FDD5 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
|
|
@ -137,6 +148,7 @@
|
|||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
96372F83299035BD0022FDD5 /* CloudView.swift in Sources */,
|
||||
96372F77299031580022FDD5 /* ContentView.swift in Sources */,
|
||||
96372F75299031580022FDD5 /* MemoryTreeApp.swift in Sources */,
|
||||
);
|
||||
|
|
@ -339,6 +351,25 @@
|
|||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
|
||||
/* Begin XCRemoteSwiftPackageReference section */
|
||||
96372F842990373C0022FDD5 /* XCRemoteSwiftPackageReference "Boutique" */ = {
|
||||
isa = XCRemoteSwiftPackageReference;
|
||||
repositoryURL = "https://github.com/mergesort/Boutique.git";
|
||||
requirement = {
|
||||
kind = upToNextMajorVersion;
|
||||
minimumVersion = 2.0.0;
|
||||
};
|
||||
};
|
||||
/* End XCRemoteSwiftPackageReference section */
|
||||
|
||||
/* Begin XCSwiftPackageProductDependency section */
|
||||
96372F852990373C0022FDD5 /* Boutique */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = 96372F842990373C0022FDD5 /* XCRemoteSwiftPackageReference "Boutique" */;
|
||||
productName = Boutique;
|
||||
};
|
||||
/* End XCSwiftPackageProductDependency section */
|
||||
};
|
||||
rootObject = 96372F69299031580022FDD5 /* Project object */;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
"pins" : [
|
||||
{
|
||||
"identity" : "bodega",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/mergesort/Bodega.git",
|
||||
"state" : {
|
||||
"revision" : "3e7c1c58ad9a46aa8551cebfe87770003cdaaaca",
|
||||
"version" : "2.0.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "boutique",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/mergesort/Boutique.git",
|
||||
"state" : {
|
||||
"revision" : "b5b697de67100edc4b2d5c74724f3c1068b49d4e",
|
||||
"version" : "2.1.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "sqlite.swift",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/stephencelis/SQLite.swift.git",
|
||||
"state" : {
|
||||
"revision" : "4d543d811ee644fa4cc4bfa0be996b4dd6ba0f54",
|
||||
"version" : "0.13.3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-collections",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-collections",
|
||||
"state" : {
|
||||
"revision" : "48254824bb4248676bf7ce56014ff57b142b77eb",
|
||||
"version" : "1.0.2"
|
||||
}
|
||||
}
|
||||
],
|
||||
"version" : 2
|
||||
}
|
||||
|
|
@ -1,6 +1,10 @@
|
|||
{
|
||||
"colors" : [
|
||||
{
|
||||
"color" : {
|
||||
"platform" : "tvos",
|
||||
"reference" : "tintColor"
|
||||
},
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "icon.png",
|
||||
"idiom" : "universal",
|
||||
"platform" : "ios",
|
||||
"size" : "1024x1024"
|
||||
|
|
|
|||
BIN
MemoryTree/Assets.xcassets/AppIcon.appiconset/icon.png
Normal file
BIN
MemoryTree/Assets.xcassets/AppIcon.appiconset/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 206 KiB |
21
MemoryTree/Assets.xcassets/TreeBare.imageset/Contents.json
vendored
Normal file
21
MemoryTree/Assets.xcassets/TreeBare.imageset/Contents.json
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "TreeBare.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
MemoryTree/Assets.xcassets/TreeBare.imageset/TreeBare.png
vendored
Normal file
BIN
MemoryTree/Assets.xcassets/TreeBare.imageset/TreeBare.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
21
MemoryTree/Assets.xcassets/TreeBareBG.imageset/Contents.json
vendored
Normal file
21
MemoryTree/Assets.xcassets/TreeBareBG.imageset/Contents.json
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "TreeBareBG.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
MemoryTree/Assets.xcassets/TreeBareBG.imageset/TreeBareBG.png
vendored
Normal file
BIN
MemoryTree/Assets.xcassets/TreeBareBG.imageset/TreeBareBG.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 208 KiB |
21
MemoryTree/Assets.xcassets/TreeLeafy.imageset/Contents.json
vendored
Normal file
21
MemoryTree/Assets.xcassets/TreeLeafy.imageset/Contents.json
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "TreeLeafy.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
MemoryTree/Assets.xcassets/TreeLeafy.imageset/TreeLeafy.png
vendored
Normal file
BIN
MemoryTree/Assets.xcassets/TreeLeafy.imageset/TreeLeafy.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 245 KiB |
21
MemoryTree/Assets.xcassets/TreeLeafyBG.imageset/Contents.json
vendored
Normal file
21
MemoryTree/Assets.xcassets/TreeLeafyBG.imageset/Contents.json
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "TreeLeafyBG.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
MemoryTree/Assets.xcassets/TreeLeafyBG.imageset/TreeLeafyBG.png
vendored
Normal file
BIN
MemoryTree/Assets.xcassets/TreeLeafyBG.imageset/TreeLeafyBG.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 421 KiB |
54
MemoryTree/CloudView.swift
Normal file
54
MemoryTree/CloudView.swift
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
//
|
||||
// CloudView.swift
|
||||
// MemoryTree
|
||||
//
|
||||
// Created by Work on 2023-02-05.
|
||||
//
|
||||
|
||||
import Boutique
|
||||
import SwiftUI
|
||||
|
||||
struct CloudView: View {
|
||||
// @Stored(in: .entriesStore) var entries
|
||||
@Binding var entries: [Entry]
|
||||
|
||||
@Environment(\.dismiss) var dismiss
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
ForEach(entries) { entry in
|
||||
Text(entry.text)
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.edgesIgnoringSafeArea(.bottom)
|
||||
.background(Color.blue)
|
||||
.foregroundColor(.white)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .destructiveAction) {
|
||||
Button {
|
||||
// Task {
|
||||
// try await $entries.removeAll()
|
||||
// }
|
||||
entries.removeAll()
|
||||
dismiss()
|
||||
} label: {
|
||||
Image(systemName: "flame")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct CloudView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
Group {
|
||||
NavigationStack {
|
||||
CloudView(entries: .constant([]))
|
||||
|
||||
CloudView(entries: .constant([Entry(text: "Coffee"), Entry(text: "Trees")]))
|
||||
}
|
||||
}
|
||||
.tint(.white)
|
||||
}
|
||||
}
|
||||
|
|
@ -5,22 +5,94 @@
|
|||
// Created by Work on 2023-02-05.
|
||||
//
|
||||
|
||||
import Boutique
|
||||
import SwiftUI
|
||||
|
||||
struct Entry: Hashable, Identifiable, Codable {
|
||||
let id: UUID
|
||||
let text: String
|
||||
|
||||
init(id: UUID = UUID(), text: String) {
|
||||
self.id = id
|
||||
self.text = text
|
||||
}
|
||||
}
|
||||
|
||||
extension Store where Item == Entry {
|
||||
static let entriesStore = Store<Entry>(
|
||||
storage: SQLiteStorageEngine.default(appendingPath: "Entries")
|
||||
)
|
||||
}
|
||||
|
||||
struct ContentView: View {
|
||||
@State var isEditing = false
|
||||
|
||||
// @Stored(in: .entriesStore) var entries
|
||||
@State var entries: [Entry] = []
|
||||
|
||||
@State var entryText = ""
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
Image(systemName: "globe")
|
||||
.imageScale(.large)
|
||||
.foregroundColor(.accentColor)
|
||||
Text("Hello, world!")
|
||||
NavigationStack {
|
||||
VStack(spacing: 0) {
|
||||
NavigationLink(destination: CloudView(entries: $entries)) {
|
||||
Image(systemName: "wind.snow")
|
||||
.imageScale(.large)
|
||||
.foregroundColor(.white)
|
||||
}
|
||||
.padding()
|
||||
.frame(maxWidth: .infinity, alignment: .trailing)
|
||||
.opacity(entries.isEmpty ? 0 : 1)
|
||||
|
||||
Spacer()
|
||||
|
||||
Button {
|
||||
isEditing = true
|
||||
} label: {
|
||||
Image(entries.isEmpty ? "TreeBare" : "TreeLeafy")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.scaledToFit()
|
||||
.foregroundColor(.white)
|
||||
}
|
||||
.frame(maxHeight: entries.isEmpty ? 100 : 300)
|
||||
|
||||
Color.green
|
||||
.frame(height: 80)
|
||||
|
||||
Form {
|
||||
TextField("What are you grateful for today?", text: $entryText)
|
||||
.background(Color.white)
|
||||
.tint(Color.blue)
|
||||
}
|
||||
.onSubmit {
|
||||
// Task {
|
||||
// try await $entries.insert(Entry(text: entryText))
|
||||
// }
|
||||
entries.append(Entry(text: entryText))
|
||||
entryText = ""
|
||||
isEditing = false
|
||||
}
|
||||
.frame(maxHeight: isEditing ? 120 : 0)
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.edgesIgnoringSafeArea(.bottom)
|
||||
.background(Color.blue)
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
}
|
||||
|
||||
struct ContentView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
ContentView()
|
||||
Group {
|
||||
ContentView()
|
||||
|
||||
ContentView(isEditing: true)
|
||||
|
||||
ContentView(entries: [Entry(text: "Coffee")])
|
||||
|
||||
ContentView(isEditing: true, entries: [Entry(text: "Coffee")])
|
||||
}
|
||||
.tint(.white)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue