captains-log

[TO-FIX] audiojournaling app
git clone git://git.figbert.com/captains-log.git
Log | Files | Refs

commit 91d9670d74f0354cd165521ad2abd6a8cb969c62
parent 680b04ee58078caa25d001c9302f9bce547cdc12
Author: therealFIGBERT <figbertwelner@gmail.com>
Date:   Sat,  9 Nov 2019 14:47:00 -0800

Fixing iterateMessage not changing on message change errors

Diffstat:
MGlobalVars.swift | 10+++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/GlobalVars.swift b/GlobalVars.swift @@ -38,12 +38,16 @@ class GlobalVars: ObservableObject { date = Date().stardate() } strDate = date.joined(separator: newValue == 0 ? " " : "") - iterateMessage = strDate.components(separatedBy: " ") messages[0] = "Captain’s log, \(strDate)" + iterateMessage = messages[currentMessage].components(separatedBy: " ") } } @Published var dateListPos: Int = 0 - @Published var currentMessage: Int = 0 + @Published var currentMessage: Int = 0 { + willSet { + iterateMessage = messages[newValue].components(separatedBy: " ") + } + } @Published var name: String = "Unknown" { willSet { messages[1] = "A day in the life of \(name), entry \(1)" @@ -92,7 +96,6 @@ class GlobalVars: ObservableObject { date = Date().stardate() } strDate = date.joined(separator: currentDateFormat == 0 ? " " : "") - iterateMessage = strDate.components(separatedBy: " ") messages = [ "Captain’s log, \(strDate)", "A day in the life of \(name), entry \(1)", @@ -103,5 +106,6 @@ class GlobalVars: ObservableObject { "Here's the tea, sis", "Rise and grind, gamers" ] + iterateMessage = messages[currentMessage].components(separatedBy: " ") } }