mirror of
https://github.com/dscyrescotti/Memola.git
synced 2026-05-11 02:10:05 +02:00
feat: fine tune navigation title
This commit is contained in:
@@ -8,23 +8,25 @@
|
||||
import SwiftUI
|
||||
|
||||
struct Placeholder: View {
|
||||
@Environment(\.horizontalSizeClass) var horizontalSizeClass
|
||||
|
||||
let info: Info
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 15) {
|
||||
let iconSize: CGFloat = horizontalSizeClass == .compact ? 40 : 50
|
||||
Image(systemName: info.icon)
|
||||
.font(.system(size: 50))
|
||||
.frame(width: 55, height: 55)
|
||||
.font(.system(size: iconSize))
|
||||
.frame(width: iconSize * 1.1, height: iconSize * 1.1)
|
||||
VStack(spacing: 3) {
|
||||
Text(info.title)
|
||||
.font(.title2)
|
||||
.font(horizontalSizeClass == .compact ? .headline : .title2)
|
||||
.fontWeight(.bold)
|
||||
.foregroundStyle(.primary)
|
||||
Text(info.description)
|
||||
.font(.callout)
|
||||
.font(horizontalSizeClass == .compact ? .caption : .callout)
|
||||
.lineLimit(.none)
|
||||
.fontWeight(.regular)
|
||||
.frame(minHeight: 50, alignment: .top)
|
||||
}
|
||||
}
|
||||
.foregroundStyle(.secondary)
|
||||
|
||||
@@ -43,66 +43,37 @@ struct MemosView: View {
|
||||
|
||||
var body: some View {
|
||||
MemoGrid(memoObjects: memoObjects, placeholder: placeholder) { memoObject in
|
||||
memoCard(memoObject)
|
||||
}
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.searchable(text: $query, placement: .toolbar, prompt: Text("Search"))
|
||||
.toolbar {
|
||||
if horizontalSizeClass == .compact {
|
||||
ToolbarItem(placement: .principal) {
|
||||
Text("Memos")
|
||||
.font(.title3)
|
||||
.fontWeight(.bold)
|
||||
}
|
||||
} else {
|
||||
ToolbarItem(placement: .topBarLeading) {
|
||||
Text("Memola")
|
||||
.font(.title3)
|
||||
.fontWeight(.bold)
|
||||
}
|
||||
memoCard(memoObject)
|
||||
}
|
||||
.navigationTitle(horizontalSizeClass == .compact ? "Memos" : "")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.searchable(text: $query, placement: .toolbar, prompt: Text("Search"))
|
||||
.toolbar {
|
||||
if horizontalSizeClass == .regular {
|
||||
ToolbarItem(placement: .topBarLeading) {
|
||||
Text("Memola")
|
||||
.font(.title3)
|
||||
.fontWeight(.bold)
|
||||
}
|
||||
ToolbarItemGroup(placement: .topBarTrailing) {
|
||||
HStack(spacing: 5) {
|
||||
Button {
|
||||
createMemo(title: "Untitled")
|
||||
} label: {
|
||||
Image(systemName: "square.and.pencil")
|
||||
}
|
||||
.hoverEffect(.lift)
|
||||
if horizontalSizeClass == .compact {
|
||||
Menu {
|
||||
VStack {
|
||||
Picker("", selection: $sort) {
|
||||
ForEach(Sort.all) { sort in
|
||||
Text(sort.name)
|
||||
.tag(sort)
|
||||
}
|
||||
}
|
||||
.pickerStyle(.automatic)
|
||||
Picker("", selection: $filter) {
|
||||
ForEach(Filter.all) { filter in
|
||||
Text(filter.name)
|
||||
.tag(filter)
|
||||
}
|
||||
}
|
||||
.pickerStyle(.automatic)
|
||||
}
|
||||
} label: {
|
||||
Image(systemName: "ellipsis.circle")
|
||||
}
|
||||
} else {
|
||||
Menu {
|
||||
}
|
||||
ToolbarItemGroup(placement: .topBarTrailing) {
|
||||
HStack(spacing: 5) {
|
||||
Button {
|
||||
createMemo(title: "Untitled")
|
||||
} label: {
|
||||
Image(systemName: "square.and.pencil")
|
||||
}
|
||||
.hoverEffect(.lift)
|
||||
if horizontalSizeClass == .compact {
|
||||
Menu {
|
||||
VStack {
|
||||
Picker("", selection: $sort) {
|
||||
ForEach(Sort.all) { sort in
|
||||
Text(sort.name)
|
||||
.tag(sort)
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
Image(systemName: "arrow.up.arrow.down.circle")
|
||||
}
|
||||
.hoverEffect(.lift)
|
||||
Menu {
|
||||
.pickerStyle(.automatic)
|
||||
Picker("", selection: $filter) {
|
||||
ForEach(Filter.all) { filter in
|
||||
Text(filter.name)
|
||||
@@ -110,29 +81,53 @@ struct MemosView: View {
|
||||
}
|
||||
}
|
||||
.pickerStyle(.automatic)
|
||||
} label: {
|
||||
Image(systemName: "line.3.horizontal.decrease.circle")
|
||||
}
|
||||
} label: {
|
||||
Image(systemName: "ellipsis.circle")
|
||||
}
|
||||
} else {
|
||||
Menu {
|
||||
Picker("", selection: $sort) {
|
||||
ForEach(Sort.all) { sort in
|
||||
Text(sort.name)
|
||||
.tag(sort)
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
Image(systemName: "arrow.up.arrow.down.circle")
|
||||
}
|
||||
.hoverEffect(.lift)
|
||||
Menu {
|
||||
Picker("", selection: $filter) {
|
||||
ForEach(Filter.all) { filter in
|
||||
Text(filter.name)
|
||||
.tag(filter)
|
||||
}
|
||||
}
|
||||
.pickerStyle(.automatic)
|
||||
} label: {
|
||||
Image(systemName: "line.3.horizontal.decrease.circle")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.onChange(of: sort) { oldValue, newValue in
|
||||
memoObjects.sortDescriptors = newValue.memoSortDescriptors
|
||||
}
|
||||
.onChange(of: query) { oldValue, newValue in
|
||||
updatePredicate()
|
||||
}
|
||||
.onChange(of: filter) { oldValue, newValue in
|
||||
updatePredicate()
|
||||
}
|
||||
.onReceive(timer) { date in
|
||||
currentDate = date
|
||||
}
|
||||
.onAppear {
|
||||
memoObjects.sortDescriptors = sort.memoSortDescriptors
|
||||
updatePredicate()
|
||||
}
|
||||
}
|
||||
.onChange(of: sort) { oldValue, newValue in
|
||||
memoObjects.sortDescriptors = newValue.memoSortDescriptors
|
||||
}
|
||||
.onChange(of: query) { oldValue, newValue in
|
||||
updatePredicate()
|
||||
}
|
||||
.onChange(of: filter) { oldValue, newValue in
|
||||
updatePredicate()
|
||||
}
|
||||
.onReceive(timer) { date in
|
||||
currentDate = date
|
||||
}
|
||||
.onAppear {
|
||||
memoObjects.sortDescriptors = sort.memoSortDescriptors
|
||||
updatePredicate()
|
||||
}
|
||||
}
|
||||
|
||||
func memoCard(_ memoObject: MemoObject) -> some View {
|
||||
|
||||
@@ -45,51 +45,46 @@ struct TrashView: View {
|
||||
MemoGrid(memoObjects: memoObjects, placeholder: placeholder) { memoObject in
|
||||
memoCard(memoObject)
|
||||
}
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.searchable(text: $query, placement: .toolbar, prompt: Text("Search"))
|
||||
.toolbar {
|
||||
if horizontalSizeClass == .compact {
|
||||
ToolbarItem(placement: .principal) {
|
||||
Text("Trash")
|
||||
.font(.title3)
|
||||
.fontWeight(.bold)
|
||||
}
|
||||
} else {
|
||||
ToolbarItem(placement: .topBarLeading) {
|
||||
Text("Memola")
|
||||
.font(.title3)
|
||||
.fontWeight(.bold)
|
||||
}
|
||||
.navigationTitle(horizontalSizeClass == .compact ? "Trash" : "")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.searchable(text: $query, placement: .toolbar, prompt: Text("Search"))
|
||||
.toolbar {
|
||||
if horizontalSizeClass == .regular {
|
||||
ToolbarItem(placement: .topBarLeading) {
|
||||
Text("Memola")
|
||||
.font(.title3)
|
||||
.fontWeight(.bold)
|
||||
}
|
||||
}
|
||||
.onChange(of: query) { oldValue, newValue in
|
||||
updatePredicate()
|
||||
}
|
||||
.onChange(of: query) { oldValue, newValue in
|
||||
updatePredicate()
|
||||
}
|
||||
.alert("Restore Memo", isPresented: restoresMemo) {
|
||||
Button {
|
||||
restoreMemo(for: restoredMemo)
|
||||
} label: {
|
||||
Text("Restore")
|
||||
}
|
||||
.alert("Restore Memo", isPresented: restoresMemo) {
|
||||
Button {
|
||||
restoreMemo(for: restoredMemo)
|
||||
} label: {
|
||||
Text("Restore")
|
||||
}
|
||||
Button {
|
||||
restoreAndOpenMemo(for: restoredMemo)
|
||||
} label: {
|
||||
Text("Restore and Open")
|
||||
}
|
||||
Button("Cancel", role: .cancel) { }
|
||||
} message: {
|
||||
Text("Would you like to restore this memo or restore and open it?")
|
||||
Button {
|
||||
restoreAndOpenMemo(for: restoredMemo)
|
||||
} label: {
|
||||
Text("Restore and Open")
|
||||
}
|
||||
.alert("Delete Memo Permanently", isPresented: deletesMemo) {
|
||||
Button(role: .destructive) {
|
||||
deleteMemo(for: deletedMemo)
|
||||
} label: {
|
||||
Text("Delete")
|
||||
}
|
||||
Button("Cancel", role: .cancel) { }
|
||||
} message: {
|
||||
Text("Are you sure you want to permanently delete this memo? This action cannot be undone.")
|
||||
Button("Cancel", role: .cancel) { }
|
||||
} message: {
|
||||
Text("Would you like to restore this memo or restore and open it?")
|
||||
}
|
||||
.alert("Delete Memo Permanently", isPresented: deletesMemo) {
|
||||
Button(role: .destructive) {
|
||||
deleteMemo(for: deletedMemo)
|
||||
} label: {
|
||||
Text("Delete")
|
||||
}
|
||||
Button("Cancel", role: .cancel) { }
|
||||
} message: {
|
||||
Text("Are you sure you want to permanently delete this memo? This action cannot be undone.")
|
||||
}
|
||||
}
|
||||
|
||||
func memoCard(_ memoObject: MemoObject) -> some View {
|
||||
|
||||
@@ -16,14 +16,23 @@ struct Sidebar: View {
|
||||
var body: some View {
|
||||
List(selection: $sidebarItem) {
|
||||
ForEach(sidebarItems) { item in
|
||||
Button {
|
||||
sidebarItem = item
|
||||
} label: {
|
||||
Label(item.title, systemImage: item.icon)
|
||||
.foregroundColor(.primary)
|
||||
if horizontalSizeClass == .compact {
|
||||
Button {
|
||||
sidebarItem = item
|
||||
} label: {
|
||||
Label(item.title, systemImage: item.icon)
|
||||
.foregroundColor(.primary)
|
||||
}
|
||||
} else {
|
||||
Button {
|
||||
sidebarItem = item
|
||||
} label: {
|
||||
Label(item.title, systemImage: item.icon)
|
||||
.foregroundColor(.primary)
|
||||
}
|
||||
.buttonStyle(sidebarItem == item ? .selected : .unselected)
|
||||
.listRowInsets(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0))
|
||||
}
|
||||
.buttonStyle(sidebarItem == item ? .selected : .unselected)
|
||||
.listRowInsets(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0))
|
||||
}
|
||||
}
|
||||
.listStyle(.sidebar)
|
||||
|
||||
Reference in New Issue
Block a user