Redesign of cardsview seems to have been a success!!

This commit is contained in:
breadone 2024-06-23 14:32:03 +12:00
parent 88a78dea92
commit ece8660a1b
No known key found for this signature in database
217 changed files with 187 additions and 88 deletions

View File

@ -4,7 +4,15 @@
"Localizable": [ "Localizable": [
{ {
"comment": "", "comment": "",
"key": "Card %lld" "key": "No Text In Card"
},
{
"comment": "",
"key": "Add new card"
},
{
"comment": "",
"key": "%lld %@"
}, },
{ {
"comment": "", "comment": "",
@ -17,6 +25,14 @@
{ {
"comment": "", "comment": "",
"key": "Teleprompter" "key": "Teleprompter"
},
{
"comment": "",
"key": "OK"
},
{
"comment": "",
"key": "Add some text in the New Card field, then press + again."
} }
] ]
}, },

View File

@ -4,7 +4,15 @@
"Localizable": [ "Localizable": [
{ {
"comment": "", "comment": "",
"key": "Card %lld" "key": "No Text In Card"
},
{
"comment": "",
"key": "Add new card"
},
{
"comment": "",
"key": "%lld %@"
}, },
{ {
"comment": "", "comment": "",
@ -17,6 +25,14 @@
{ {
"comment": "", "comment": "",
"key": "Teleprompter" "key": "Teleprompter"
},
{
"comment": "",
"key": "OK"
},
{
"comment": "",
"key": "Add some text in the New Card field, then press + again."
} }
] ]
}, },

View File

@ -11,9 +11,9 @@ import SwiftUI
extension CardsView { extension CardsView {
@_dynamicReplacement(for: deleteItems(offsets:)) private func __preview__deleteItems(offsets: IndexSet) { @_dynamicReplacement(for: deleteItems(offsets:)) private func __preview__deleteItems(offsets: IndexSet) {
#sourceLocation(file: "/Users/pradyun/Code/Apps/OnCue/OnCue/View/CardsView.swift", line: 68) #sourceLocation(file: "/Users/pradyun/Code/Apps/OnCue/OnCue/View/CardsView.swift", line: 82)
withAnimation { withAnimation {
project.cards.remove(atOffsets: offsets) project.sortedCards.remove(atOffsets: offsets)
try! ctx.save() try! ctx.save()
} }
@ -23,10 +23,16 @@ extension CardsView {
extension CardsView { extension CardsView {
@_dynamicReplacement(for: addNewCard(txt:)) private func __preview__addNewCard(txt: String) { @_dynamicReplacement(for: addNewCard(txt:)) private func __preview__addNewCard(txt: String) {
#sourceLocation(file: "/Users/pradyun/Code/Apps/OnCue/OnCue/View/CardsView.swift", line: 62) #sourceLocation(file: "/Users/pradyun/Code/Apps/OnCue/OnCue/View/CardsView.swift", line: 70)
let card = OCCard(content: txt, index: (project.sortedCards.last?.index ?? __designTimeInteger("#12918.[2].[6].[0].value.arg[1].value.[0]", fallback: -1)) + __designTimeInteger("#12918.[2].[6].[0].value.arg[1].value.[1]", fallback: 1)) // adds one to the index, unless there arent any cards in which case default to 0 guard txt != "" else {
showNoTextInNewCardError.toggle()
return
}
let card = OCCard(content: txt, index: (project.sortedCards.last?.index ?? __designTimeInteger("#12918.[2].[6].[1].value.arg[1].value.[0]", fallback: -1)) + __designTimeInteger("#12918.[2].[6].[1].value.arg[1].value.[1]", fallback: 1)) // adds one to the index, unless there arent any cards in which case default to 0
project.cards.append(card) project.cards.append(card)
try! ctx.save() try! ctx.save()
newCardText = __designTimeString("#12918.[2].[6].[4].[0]", fallback: "")
#sourceLocation() #sourceLocation()
} }
@ -36,37 +42,39 @@ extension CardsView {
@_dynamicReplacement(for: body) private var __preview__body: some View { @_dynamicReplacement(for: body) private var __preview__body: some View {
#sourceLocation(file: "/Users/pradyun/Code/Apps/OnCue/OnCue/View/CardsView.swift", line: 20) #sourceLocation(file: "/Users/pradyun/Code/Apps/OnCue/OnCue/View/CardsView.swift", line: 20)
List { List {
ForEach(project.sortedCards) { card in
Section { Section {
VStack(alignment: .trailing) { TextEditor(text: $newCardText)
} header: {
Text(__designTimeString("#12918.[2].[5].property.[0].[0].arg[0].value.[0].arg[1].value.[0].arg[0].value", fallback: "Add new card"))
}
Section {
ForEach(project.sortedCards) { card in
Text(card.content) Text(card.content)
} }
.frame(minHeight: __designTimeInteger("#12918.[2].[5].property.[0].[0].arg[0].value.[0].arg[1].value.[0].arg[0].value.[0].modifier[0].arg[0].value", fallback: 150))
} header: {
Text("Card \(card.index + __designTimeInteger("#12918.[2].[5].property.[0].[0].arg[0].value.[0].arg[1].value.[0].arg[1].value.[0].arg[0].value.[1].value.arg[0].value.[0]", fallback: 1))")
}
}
.onDelete(perform: deleteItems) .onDelete(perform: deleteItems)
} header: {
Text("\(project.cards.count) \(project.cards.count == __designTimeInteger("#12918.[2].[5].property.[0].[0].arg[0].value.[1].arg[1].value.[0].arg[0].value.[3].value.arg[0].value.if.[0]", fallback: 1) ? __designTimeString("#12918.[2].[5].property.[0].[0].arg[0].value.[1].arg[1].value.[0].arg[0].value.[3].value.arg[0].value.then", fallback: "Card") : __designTimeString("#12918.[2].[5].property.[0].[0].arg[0].value.[1].arg[1].value.[0].arg[0].value.[3].value.arg[0].value.else", fallback: "Cards"))")
}
} }
.listStyle(.sidebar)
.navigationTitle(project.name) .navigationTitle(project.name)
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)
.toolbar { .toolbar {
ToolbarItem(placement: .topBarTrailing) { ToolbarItem(placement: .topBarTrailing) {
Button(action: { addNewCard.toggle() }) { Button(action: { addNewCard(txt: newCardText) }) {
Label(__designTimeString("#12918.[2].[5].property.[0].[0].modifier[3].arg[0].value.[0].arg[1].value.[0].arg[1].value.[0].arg[0].value", fallback: "Add Item"), systemImage: __designTimeString("#12918.[2].[5].property.[0].[0].modifier[3].arg[0].value.[0].arg[1].value.[0].arg[1].value.[0].arg[1].value", fallback: "plus")) Label(__designTimeString("#12918.[2].[5].property.[0].[0].modifier[2].arg[0].value.[0].arg[1].value.[0].arg[1].value.[0].arg[0].value", fallback: "Add Item"), systemImage: __designTimeString("#12918.[2].[5].property.[0].[0].modifier[2].arg[0].value.[0].arg[1].value.[0].arg[1].value.[0].arg[1].value", fallback: "plus"))
} }
} }
ToolbarItem(placement: .topBarTrailing) { ToolbarItem(placement: .topBarTrailing) {
Menu { Menu {
NavigationLink(destination: {ProjectSlideshowView(project: project)}) { NavigationLink(destination: {ProjectSlideshowView(project: project)}) {
Label(title: { Text(__designTimeString("#12918.[2].[5].property.[0].[0].modifier[3].arg[0].value.[1].arg[1].value.[0].arg[0].value.[0].arg[1].value.[0].arg[0].value.[0].arg[0].value", fallback: "Cue Cards"))}, icon: {Image(systemName: __designTimeString("#12918.[2].[5].property.[0].[0].modifier[3].arg[0].value.[1].arg[1].value.[0].arg[0].value.[0].arg[1].value.[0].arg[1].value.[0].arg[0].value", fallback: "rectangle.stack")) }) Label(title: { Text(__designTimeString("#12918.[2].[5].property.[0].[0].modifier[2].arg[0].value.[1].arg[1].value.[0].arg[0].value.[0].arg[1].value.[0].arg[0].value.[0].arg[0].value", fallback: "Cue Cards"))}, icon: {Image(systemName: __designTimeString("#12918.[2].[5].property.[0].[0].modifier[2].arg[0].value.[1].arg[1].value.[0].arg[0].value.[0].arg[1].value.[0].arg[1].value.[0].arg[0].value", fallback: "rectangle.stack")) })
} }
NavigationLink(destination: {TeleprompterView(project: project)}) { NavigationLink(destination: {TeleprompterView(project: project)}) {
Label(title: { Text(__designTimeString("#12918.[2].[5].property.[0].[0].modifier[3].arg[0].value.[1].arg[1].value.[0].arg[0].value.[1].arg[1].value.[0].arg[0].value.[0].arg[0].value", fallback: "Teleprompter"))}, icon: {Image(systemName: __designTimeString("#12918.[2].[5].property.[0].[0].modifier[3].arg[0].value.[1].arg[1].value.[0].arg[0].value.[1].arg[1].value.[0].arg[1].value.[0].arg[0].value", fallback: "note.text")) }) Label(title: { Text(__designTimeString("#12918.[2].[5].property.[0].[0].modifier[2].arg[0].value.[1].arg[1].value.[0].arg[0].value.[1].arg[1].value.[0].arg[0].value.[0].arg[0].value", fallback: "Teleprompter"))}, icon: {Image(systemName: __designTimeString("#12918.[2].[5].property.[0].[0].modifier[2].arg[0].value.[1].arg[1].value.[0].arg[0].value.[1].arg[1].value.[0].arg[1].value.[0].arg[0].value", fallback: "note.text")) })
} }
} label: { } label: {
Image(systemName: __designTimeString("#12918.[2].[5].property.[0].[0].modifier[3].arg[0].value.[1].arg[1].value.[0].arg[1].value.[0].arg[0].value", fallback: "play.fill")) Image(systemName: __designTimeString("#12918.[2].[5].property.[0].[0].modifier[2].arg[0].value.[1].arg[1].value.[0].arg[1].value.[0].arg[0].value", fallback: "play.fill"))
} }
} }
@ -74,6 +82,12 @@ extension CardsView {
.sheet(isPresented: $addNewCard) { .sheet(isPresented: $addNewCard) {
AddNewCardView(completionHandler: addNewCard) AddNewCardView(completionHandler: addNewCard)
} }
.alert(__designTimeString("#12918.[2].[5].property.[0].[0].modifier[4].arg[0].value", fallback: "No Text In Card"), isPresented: $showNoTextInNewCardError) {
Button(__designTimeString("#12918.[2].[5].property.[0].[0].modifier[4].arg[2].value.[0].arg[0].value", fallback: "OK"), role: .cancel) {}
} message: {
Text(__designTimeString("#12918.[2].[5].property.[0].[0].modifier[4].arg[3].value.[0].arg[0].value", fallback: "Add some text in the New Card field, then press + again."))
}
#sourceLocation() #sourceLocation()
} }

View File

@ -4,7 +4,15 @@
"Localizable": [ "Localizable": [
{ {
"comment": "", "comment": "",
"key": "Card %lld" "key": "No Text In Card"
},
{
"comment": "",
"key": "Add new card"
},
{
"comment": "",
"key": "%lld %@"
}, },
{ {
"comment": "", "comment": "",
@ -17,6 +25,14 @@
{ {
"comment": "", "comment": "",
"key": "Teleprompter" "key": "Teleprompter"
},
{
"comment": "",
"key": "OK"
},
{
"comment": "",
"key": "Add some text in the New Card field, then press + again."
} }
] ]
}, },

View File

@ -11,7 +11,7 @@ import SwiftData
extension OCProject { extension OCProject {
@_dynamicReplacement(for: addCards(cards:)) private func __preview__addCards(cards: OCCard...) { @_dynamicReplacement(for: addCards(cards:)) private func __preview__addCards(cards: OCCard...) {
#sourceLocation(file: "/Users/pradyun/Code/Apps/OnCue/OnCue/Model/OCProject.swift", line: 42) #sourceLocation(file: "/Users/pradyun/Code/Apps/OnCue/OnCue/Model/OCProject.swift", line: 47)
cards.forEach({ self.cards.append($0) }) cards.forEach({ self.cards.append($0) })
#sourceLocation() #sourceLocation()
@ -20,7 +20,7 @@ extension OCProject {
extension OCProject { extension OCProject {
@_dynamicReplacement(for: updateEditedDate(newDate:)) private func __preview__updateEditedDate(newDate: Date = Date()) { @_dynamicReplacement(for: updateEditedDate(newDate:)) private func __preview__updateEditedDate(newDate: Date = Date()) {
#sourceLocation(file: "/Users/pradyun/Code/Apps/OnCue/OnCue/Model/OCProject.swift", line: 38) #sourceLocation(file: "/Users/pradyun/Code/Apps/OnCue/OnCue/Model/OCProject.swift", line: 43)
self.lastEditedDate = newDate self.lastEditedDate = newDate
#sourceLocation() #sourceLocation()
@ -29,17 +29,27 @@ extension OCProject {
extension OCProject { extension OCProject {
@_dynamicReplacement(for: sortedCards) private var __preview__sortedCards: [OCCard] { @_dynamicReplacement(for: sortedCards) private var __preview__sortedCards: [OCCard] {
#sourceLocation(file: "/Users/pradyun/Code/Apps/OnCue/OnCue/Model/OCProject.swift", line: 26) get {
#sourceLocation(file: "/Users/pradyun/Code/Apps/OnCue/OnCue/Model/OCProject.swift", line: 27)
return self.cards.sorted(by: { $0.index < $1.index }) return self.cards.sorted(by: { $0.index < $1.index })
#sourceLocation() #sourceLocation()
}
set {
#sourceLocation(file: "/Users/pradyun/Code/Apps/OnCue/OnCue/Model/OCProject.swift", line: 30)
#sourceLocation()
}
} }
} }
extension OCProject { extension OCProject {
@_dynamicReplacement(for: script) private var __preview__script: String { @_dynamicReplacement(for: script) private var __preview__script: String {
#sourceLocation(file: "/Users/pradyun/Code/Apps/OnCue/OnCue/Model/OCProject.swift", line: 20) #sourceLocation(file: "/Users/pradyun/Code/Apps/OnCue/OnCue/Model/OCProject.swift", line: 20)
var txt = __designTimeString("#7544.[2].[5].property.[0].[0].value", fallback: "") var txt = __designTimeString("#34169.[2].[5].property.[0].[0].value", fallback: "")
sortedCards.forEach { txt.append("\($0.content)\n---\n") } sortedCards.forEach { txt.append("\($0.content)\n---\n") }
return txt return txt

Some files were not shown because too many files have changed in this diff Show More