-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNotesView.swift
More file actions
152 lines (134 loc) · 4.31 KB
/
NotesView.swift
File metadata and controls
152 lines (134 loc) · 4.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
//
// NotesView.swift
// Notes
//
// Created by SwiftieDev on 10/01/2024.
// MARK: SwiftieDev
import SwiftUI
struct NotesView: View {
@State private var selectedColor: backgroundTextColor = .blue
var body: some View {
NavigationView {
VStack(spacing: 10) {
Text("one. two. ")
.foregroundColor(.gray)
.font(.largeTitle) +
Text("focus!")
.font(.largeTitle)
Image(systemName: "plus")
.frame(maxWidth: .infinity)
.frame(height: 50)
.foregroundColor(.black)
.background(.gray.opacity(0.2))
.clipShape(RoundedRectangle(cornerRadius: 10))
HStack {
ExtractedNoteView(icon: "case", text: "work", background: .green)
ExtractedNoteView(icon: "person", text: "personal", background: .purple)
}
HStack {
ExtractedNoteView(icon: "book.closed", text: "reading", background: .brown)
ExtractedNoteView(icon: "moon", text: "sleep", background: .blue)
}
}
.padding(25)
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .topBarLeading) {
Text("Your Notes")
.font(.title)
.padding()
}
ToolbarItem(placement: .topBarTrailing) {
Image(systemName: "calendar")
}
}
.toolbar {
ToolbarItemGroup(placement: .bottomBar) {
Button {} label: {
Image(systemName: "house")
.foregroundColor(.black)
.padding()
}
Spacer()
Button {} label: {
Image(systemName: "chart.bar")
.foregroundColor(.gray)
}
Spacer()
Button {} label: {
Image(systemName: "gearshape")
.foregroundColor(.black)
.padding()
}
}
}
}
}
}
#Preview {
NavigationView {
NotesView()
}
}
enum backgroundTextColor: String, CaseIterable, Identifiable {
case blue
case brown
case green
case yellow
case indigo
case red
case cyan
var id: Self { self }
var color: Color {
switch self {
case .blue:
return .blue
case .brown:
return .brown
case .green:
return .green
case .yellow:
return .yellow
case .indigo:
return .indigo
case .red:
return .red
case .cyan:
return .cyan
}
}
}
struct ExtractedNoteView: View {
@State private var selectedColor: backgroundTextColor = .blue
let icon: String
let text: String
let background: Color
var body: some View {
VStack(alignment: .leading, spacing: 10) {
HStack {
Image(systemName: icon)
.padding()
.background(selectedColor.color.opacity(0.3))
.clipShape(RoundedRectangle(cornerRadius: 10))
Spacer()
}
Spacer()
Text(text)
.font(.title)
}
.padding()
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(selectedColor.color.opacity(0.2))
.cornerRadius(15)
.contextMenu {
Picker("Select a color", selection: $selectedColor) {
ForEach(backgroundTextColor.allCases) { item in
Label(item.rawValue.capitalized, systemImage: "circle")
.tint(item.color)
}
}
.paletteSelectionEffect(.symbolVariant(.fill))
.pickerStyle(.palette)
}
}
}