Skip to content

Commit

Permalink
Lots of UI updates + save/new button
Browse files Browse the repository at this point in the history
  • Loading branch information
sssynk committed Jan 13, 2022
1 parent 082ac03 commit 6056753
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
4 changes: 2 additions & 2 deletions swiftapp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.jamesssystems.swiftapp;
PRODUCT_NAME = "$(TARGET_NAME)";
PRODUCT_NAME = swiftapp;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
};
Expand Down Expand Up @@ -472,7 +472,7 @@
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.jamesssystems.swiftapp;
PRODUCT_NAME = "$(TARGET_NAME)";
PRODUCT_NAME = swiftapp;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
};
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions swiftapp/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ struct ContentView: View {
struct Login: View {
@State var title: String = ""
@State var cont: String = ""
@State var savestr: String = ""
@State var currentNote: Note = Note(noteid: "n/a", title: "n/a", contents: "n/a")
@EnvironmentObject private var current_data: CurrentApp
var body: some View {
Expand All @@ -210,6 +211,8 @@ struct Login: View {
handleSave()
}
.padding(.bottom, 70)
Text(savestr)
.padding(.bottom, 70)
}
.frame(width: 500, height: 500, alignment: .topLeading)
.padding(.bottom, 80)
Expand All @@ -235,10 +238,20 @@ struct Login: View {
cont = ""
currentNote = Note(noteid: "n/a", title: "", contents: "")
}
func setStr(text: String) {
savestr = text
DispatchQueue.main.asyncAfter(deadline: .now() + 4) {
if (savestr == text) {
savestr = ""
}
}
}
func handleSave() {
if(currentNote.noteid == "n/a") {
setStr(text: "Saving new note...")
newNote(note: Note(noteid: "n/a", title: title, contents: cont))
} else {
setStr(text: "Saving note...")
updateNote(note: Note(noteid: currentNote.noteid, title: title, contents: cont))
}
}
Expand All @@ -247,7 +260,9 @@ struct Login: View {
if(ret["status"] as! Int == 201) {
current_data.all_notes.append(Note(noteid: ret["note_id"] as! String, title: note.title, contents: note.contents))
currentNote = Note(noteid: ret["note_id"] as! String, title: note.title, contents: note.contents)
setStr(text: "Created new note!")
} else {
setStr(text: "New note creation failed!")
print(ret)
print("the funny occurred!!! (unable to make new note)")
}
Expand All @@ -260,7 +275,9 @@ struct Login: View {
}
current_data.all_notes.append(Note(noteid: note.noteid, title: note.title, contents: note.contents))
currentNote = Note(noteid: note.noteid, title: note.title, contents: note.contents)
setStr(text: "Saved note!")
} else {
setStr(text: "Unable to save note!")
print("the funny occurred!!! (unable to update note)")
}
}
Expand Down

0 comments on commit 6056753

Please sign in to comment.