mirror of
https://github.com/dscyrescotti/Memola.git
synced 2026-04-24 01:28:40 +02:00
feat: update memos and trash view
This commit is contained in:
@@ -21,6 +21,14 @@ struct MemolaApp: App {
|
|||||||
try context.saveIfNeeded()
|
try context.saveIfNeeded()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if os(macOS)
|
||||||
|
.frame(minWidth: 1000, minHeight: 600)
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
#if os(macOS)
|
||||||
|
.defaultPosition(.center)
|
||||||
|
.windowResizability(.contentSize)
|
||||||
|
.defaultSize(width: 1200, height: 800)
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,9 +26,7 @@ struct DashboardView: View {
|
|||||||
MemosView(memo: $memo)
|
MemosView(memo: $memo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if os(macOS)
|
#if os(iOS)
|
||||||
#warning("TODO: implement for macOS")
|
|
||||||
#else
|
|
||||||
.fullScreenCover(item: $memo) { memo in
|
.fullScreenCover(item: $memo) { memo in
|
||||||
MemoView(memo: memo)
|
MemoView(memo: memo)
|
||||||
.onDisappear {
|
.onDisappear {
|
||||||
@@ -38,6 +36,7 @@ struct DashboardView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ struct MemosView: View {
|
|||||||
let standard = UserDefaults.standard
|
let standard = UserDefaults.standard
|
||||||
var descriptors: [SortDescriptor<MemoObject>] = []
|
var descriptors: [SortDescriptor<MemoObject>] = []
|
||||||
var predicates: [NSPredicate] = [NSPredicate(format: "isTrash = NO")]
|
var predicates: [NSPredicate] = [NSPredicate(format: "isTrash = NO")]
|
||||||
let sort = Sort(rawValue: standard.value(forKey: "memola.memo-objects.sort") as? String ?? "") ?? .recent
|
let sort = Sort(rawValue: standard.value(forKey: "memola.memo-objects.memos.sort") as? String ?? "") ?? .recent
|
||||||
let filter = Filter(rawValue: standard.value(forKey: "memola.memo-objects.filter") as? String ?? "") ?? .none
|
let filter = Filter(rawValue: standard.value(forKey: "memola.memo-objects.memos.filter") as? String ?? "") ?? .none
|
||||||
if filter == .favorites {
|
if filter == .favorites {
|
||||||
predicates.append(NSPredicate(format: "isFavorite = YES"))
|
predicates.append(NSPredicate(format: "isFavorite = YES"))
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,32 @@ struct MemosView: View {
|
|||||||
.searchable(text: $query, placement: .toolbar, prompt: Text("Search"))
|
.searchable(text: $query, placement: .toolbar, prompt: Text("Search"))
|
||||||
.toolbar {
|
.toolbar {
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
#warning("TODO: implement for macos")
|
ToolbarItem(placement: .navigation) {
|
||||||
|
Text("Memola")
|
||||||
|
.font(.title3)
|
||||||
|
.fontWeight(.bold)
|
||||||
|
}
|
||||||
|
ToolbarItemGroup(placement: .primaryAction) {
|
||||||
|
HStack(spacing: 5) {
|
||||||
|
Button {
|
||||||
|
createMemo(title: "Untitled")
|
||||||
|
} label: {
|
||||||
|
Image(systemName: "square.and.pencil")
|
||||||
|
}
|
||||||
|
Picker("", selection: $sort) {
|
||||||
|
ForEach(Sort.all) { sort in
|
||||||
|
Text(sort.name)
|
||||||
|
.tag(sort)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Picker("", selection: $filter) {
|
||||||
|
ForEach(Filter.all) { filter in
|
||||||
|
Text(filter.name)
|
||||||
|
.tag(filter)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
if horizontalSizeClass == .regular {
|
if horizontalSizeClass == .regular {
|
||||||
ToolbarItem(placement: .topBarLeading) {
|
ToolbarItem(placement: .topBarLeading) {
|
||||||
@@ -78,14 +103,12 @@ struct MemosView: View {
|
|||||||
.tag(sort)
|
.tag(sort)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.pickerStyle(.automatic)
|
|
||||||
Picker("", selection: $filter) {
|
Picker("", selection: $filter) {
|
||||||
ForEach(Filter.all) { filter in
|
ForEach(Filter.all) { filter in
|
||||||
Text(filter.name)
|
Text(filter.name)
|
||||||
.tag(filter)
|
.tag(filter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.pickerStyle(.automatic)
|
|
||||||
}
|
}
|
||||||
} label: {
|
} label: {
|
||||||
Image(systemName: "ellipsis.circle")
|
Image(systemName: "ellipsis.circle")
|
||||||
@@ -109,10 +132,10 @@ struct MemosView: View {
|
|||||||
.tag(filter)
|
.tag(filter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.pickerStyle(.automatic)
|
|
||||||
} label: {
|
} label: {
|
||||||
Image(systemName: "line.3.horizontal.decrease.circle")
|
Image(systemName: "line.3.horizontal.decrease.circle")
|
||||||
}
|
}
|
||||||
|
.hoverEffect(.lift)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,10 +153,6 @@ struct MemosView: View {
|
|||||||
.onReceive(timer) { date in
|
.onReceive(timer) { date in
|
||||||
currentDate = date
|
currentDate = date
|
||||||
}
|
}
|
||||||
.onAppear {
|
|
||||||
memoObjects.sortDescriptors = sort.memoSortDescriptors
|
|
||||||
updatePredicate()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func memoCard(_ memoObject: MemoObject, _ cellWidth: CGFloat) -> some View {
|
func memoCard(_ memoObject: MemoObject, _ cellWidth: CGFloat) -> some View {
|
||||||
@@ -144,11 +163,13 @@ struct MemosView: View {
|
|||||||
openMemo(for: memoObject)
|
openMemo(for: memoObject)
|
||||||
} label: {
|
} label: {
|
||||||
Label("Open", systemImage: "doc.text")
|
Label("Open", systemImage: "doc.text")
|
||||||
|
.labelStyle(.titleAndIcon)
|
||||||
}
|
}
|
||||||
Button(role: .destructive) {
|
Button(role: .destructive) {
|
||||||
markAsTrash(for: memoObject)
|
markAsTrash(for: memoObject)
|
||||||
} label: {
|
} label: {
|
||||||
Label("Delete", systemImage: "trash")
|
Label("Delete", systemImage: "trash")
|
||||||
|
.labelStyle(.titleAndIcon)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.overlay(alignment: .topTrailing) {
|
.overlay(alignment: .topTrailing) {
|
||||||
@@ -158,7 +179,11 @@ struct MemosView: View {
|
|||||||
.animation(.easeInOut, value: memoObject.isFavorite)
|
.animation(.easeInOut, value: memoObject.isFavorite)
|
||||||
.frame(width: 20, height: 20)
|
.frame(width: 20, height: 20)
|
||||||
.padding(5)
|
.padding(5)
|
||||||
|
#if os(macOS)
|
||||||
|
.background(.gray)
|
||||||
|
#else
|
||||||
.background(.gray.tertiary)
|
.background(.gray.tertiary)
|
||||||
|
#endif
|
||||||
.cornerRadius(5)
|
.cornerRadius(5)
|
||||||
.contentShape(Rectangle())
|
.contentShape(Rectangle())
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
|
|||||||
@@ -52,7 +52,11 @@ struct TrashView: View {
|
|||||||
.searchable(text: $query, placement: .toolbar, prompt: Text("Search"))
|
.searchable(text: $query, placement: .toolbar, prompt: Text("Search"))
|
||||||
.toolbar {
|
.toolbar {
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
#warning("TODO: implement for macos")
|
ToolbarItem(placement: .navigation) {
|
||||||
|
Text("Memola")
|
||||||
|
.font(.title3)
|
||||||
|
.fontWeight(.bold)
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
if horizontalSizeClass == .regular {
|
if horizontalSizeClass == .regular {
|
||||||
ToolbarItem(placement: .topBarLeading) {
|
ToolbarItem(placement: .topBarLeading) {
|
||||||
@@ -101,11 +105,13 @@ struct TrashView: View {
|
|||||||
restoreMemo(for: memoObject)
|
restoreMemo(for: memoObject)
|
||||||
} label: {
|
} label: {
|
||||||
Label("Restore", systemImage: "square.and.arrow.down")
|
Label("Restore", systemImage: "square.and.arrow.down")
|
||||||
|
.labelStyle(.titleAndIcon)
|
||||||
}
|
}
|
||||||
Button(role: .destructive) {
|
Button(role: .destructive) {
|
||||||
deletedMemo = memoObject
|
deletedMemo = memoObject
|
||||||
} label: {
|
} label: {
|
||||||
Label("Delete Permanently", systemImage: "trash")
|
Label("Delete Permanently", systemImage: "trash")
|
||||||
|
.labelStyle(.titleAndIcon)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} details: {
|
} details: {
|
||||||
|
|||||||
@@ -201,10 +201,9 @@ struct PenDock: View {
|
|||||||
} preview: {
|
} preview: {
|
||||||
penPreview(pen)
|
penPreview(pen)
|
||||||
.drawingGroup()
|
.drawingGroup()
|
||||||
#if os(macOS)
|
#if os(iOS)
|
||||||
#warning("TODO: implement for macos")
|
|
||||||
#else
|
|
||||||
.contentShape(.contextMenuPreview, .rect(cornerRadius: 10))
|
.contentShape(.contextMenuPreview, .rect(cornerRadius: 10))
|
||||||
|
#else
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
.onDrag(if: pen.strokeStyle != .eraser) {
|
.onDrag(if: pen.strokeStyle != .eraser) {
|
||||||
@@ -278,10 +277,9 @@ struct PenDock: View {
|
|||||||
} preview: {
|
} preview: {
|
||||||
penPreview(pen)
|
penPreview(pen)
|
||||||
.drawingGroup()
|
.drawingGroup()
|
||||||
#if os(macOS)
|
#if os(iOS)
|
||||||
#warning("TODO: implement for macos")
|
|
||||||
#else
|
|
||||||
.contentShape(.contextMenuPreview, .rect(cornerRadius: 10))
|
.contentShape(.contextMenuPreview, .rect(cornerRadius: 10))
|
||||||
|
#else
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
.onDrag(if: pen.strokeStyle != .eraser) {
|
.onDrag(if: pen.strokeStyle != .eraser) {
|
||||||
|
|||||||
Reference in New Issue
Block a user