質問編集履歴
3
編集
test
CHANGED
File without changes
|
test
CHANGED
@@ -125,4 +125,5 @@
|
|
125
125
|
|
126
126
|
です
|
127
127
|
|
128
|
+
|
128
129
|
添削したので、抜粋です
|
2
編集
test
CHANGED
File without changes
|
test
CHANGED
@@ -23,6 +23,8 @@
|
|
23
23
|
|
24
24
|
追記
|
25
25
|
|
26
|
+
```swift
|
27
|
+
|
26
28
|
struct AView: View {
|
27
29
|
@FetchRequest(
|
28
30
|
sortDescriptors: [NSSortDescriptor(keyPath: \Item.nowDate, ascending: true)],
|
@@ -41,6 +43,9 @@
|
|
41
43
|
}
|
42
44
|
}
|
43
45
|
|
46
|
+
```
|
47
|
+
|
48
|
+
```swift
|
44
49
|
|
45
50
|
struct BView: View {
|
46
51
|
@FetchRequest(sortDescriptors: [NSSortDescriptor(keyPath: \Item.timestamp, ascending: true)], animation: .default) private var items: FetchedResults<Item>
|
@@ -65,6 +70,9 @@
|
|
65
70
|
|
66
71
|
}
|
67
72
|
|
73
|
+
```
|
74
|
+
|
75
|
+
```swift
|
68
76
|
|
69
77
|
struct CView: View {
|
70
78
|
@Environment(\.managedObjectContext) private var viewContext
|
@@ -113,6 +121,8 @@
|
|
113
121
|
|
114
122
|
}
|
115
123
|
|
124
|
+
```
|
125
|
+
|
116
126
|
です
|
117
127
|
|
118
128
|
添削したので、抜粋です
|
1
編集
test
CHANGED
File without changes
|
test
CHANGED
@@ -20,3 +20,99 @@
|
|
20
20
|
これではちがうのでしょうか?
|
21
21
|
|
22
22
|
また、addToFolder()というものも調べたのですが、これらは別ものでしょうか?
|
23
|
+
|
24
|
+
追記
|
25
|
+
|
26
|
+
struct AView: View {
|
27
|
+
@FetchRequest(
|
28
|
+
sortDescriptors: [NSSortDescriptor(keyPath: \Item.nowDate, ascending: true)],
|
29
|
+
animation: .default)
|
30
|
+
private var items: FetchedResults<Item>
|
31
|
+
@FetchRequest(sortDescriptors: [NSSortDescriptor(keyPath: \ Folder.folderMadeTime, ascending: true)], animation: .default) private var folders: FetchedResults<Folder>
|
32
|
+
@Environment(\.dismiss) var dismiss
|
33
|
+
|
34
|
+
var body: some View {
|
35
|
+
NavigationStack {
|
36
|
+
List {
|
37
|
+
Section(header: Text("Sections")) {
|
38
|
+
|
39
|
+
ForEach(folders) { folder in NavigationLink(destination: BView(item: item, folder: folder), label: {Text(folder.folderName ?? "a")})
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
|
45
|
+
struct BView: View {
|
46
|
+
@FetchRequest(sortDescriptors: [NSSortDescriptor(keyPath: \Item.timestamp, ascending: true)], animation: .default) private var items: FetchedResults<Item>
|
47
|
+
var item: Item
|
48
|
+
var folder: Folder
|
49
|
+
|
50
|
+
var body: some View {
|
51
|
+
|
52
|
+
NavigationView {
|
53
|
+
List{
|
54
|
+
Section(header: Text("テキスト")){
|
55
|
+
ForEach(folderItems){folderItem in
|
56
|
+
NavigationLink(destination: CView(item: item, folder: folder), label: {Text(folderItem.text ?? "a")})
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
private var folderItems: [Item] {
|
61
|
+
if let folderItems = folder.item?.allObjects as? [Item] {
|
62
|
+
return folderItems
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
66
|
+
}
|
67
|
+
|
68
|
+
|
69
|
+
struct CView: View {
|
70
|
+
@Environment(\.managedObjectContext) private var viewContext
|
71
|
+
|
72
|
+
var item: Item
|
73
|
+
var folder: Folder
|
74
|
+
|
75
|
+
var body: some View {
|
76
|
+
|
77
|
+
ZStack {
|
78
|
+
NavigationStack{
|
79
|
+
GeometryReader { geometryProxy in
|
80
|
+
VStack {
|
81
|
+
ZStack{
|
82
|
+
|
83
|
+
let size = geometryProxy.size
|
84
|
+
TextEditor(text: $textEditorText).textInputAutocapitalization(.never)
|
85
|
+
.background(profile.bcolor)
|
86
|
+
.opacity(0.99)
|
87
|
+
.foregroundColor(profile.tcolor)
|
88
|
+
.frame(width: size.width, height: size.height)
|
89
|
+
.scrollContentBackground(.hidden)
|
90
|
+
|
91
|
+
}
|
92
|
+
}
|
93
|
+
|
94
|
+
}
|
95
|
+
|
96
|
+
}
|
97
|
+
|
98
|
+
}
|
99
|
+
|
100
|
+
.onDisappear(perform: {saveLink(folder: folder)})
|
101
|
+
|
102
|
+
}
|
103
|
+
|
104
|
+
func saveLink(folder: Folder) {
|
105
|
+
let newItem = Item(context: viewContext)
|
106
|
+
if textEditorText != "" {
|
107
|
+
newItem.text = textEditorText
|
108
|
+
|
109
|
+
newItem.folder = folder
|
110
|
+
try? viewContext.save()
|
111
|
+
}
|
112
|
+
}
|
113
|
+
|
114
|
+
}
|
115
|
+
|
116
|
+
です
|
117
|
+
|
118
|
+
添削したので、抜粋です
|