-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
205 additions
and
24 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+4.4 KB
(110%)
...odeproj/project.xcworkspace/xcuserdata/D032610.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// | ||
// AddCooksDialog.swift | ||
// CookingFam | ||
// | ||
// Created by Alexis on 15.06.23. | ||
// | ||
|
||
import Foundation | ||
import SwiftUI | ||
|
||
struct AddCooksDialog: View { | ||
@Binding var activeView: ActiveView | ||
@Binding var cooks: [String] | ||
@State private var newEntry = "" | ||
|
||
|
||
var body: some View { | ||
ZStack { | ||
BackgroundColor() | ||
|
||
VStack { | ||
HStack { | ||
BackButton(activeView: $activeView, prevView: .details) | ||
.padding(.leading, 16) | ||
|
||
Spacer() | ||
} | ||
Text("Add all awesome chefs") | ||
.font(.title) | ||
.padding() | ||
HStack{ | ||
// adds randomness to default entry for inputfield | ||
let awesome_words = ["Awesome","impressive","superior","topnotch","finest","unrivaled","unsurpassable",""] | ||
let cook_words = ["cook","chef","knife-swinger","deep-fryer","food-creator","vegetable-smasher"] | ||
TextField((awesome_words.randomElement() ?? "awesome") + " " + (cook_words.randomElement() ?? "chef"), text: $newEntry) | ||
.textFieldStyle(RoundedBorderTextFieldStyle()) | ||
.padding() | ||
// TODO: add "enter pressed" to add chefs as well | ||
Button("Add") { | ||
// adds uniqueness with id | ||
var id = "" | ||
let text = newEntry.capitalizingFirstLetter() | ||
if cooks.contains(text){ | ||
id = String(returnUniqueID(entry: text, id: 1)) | ||
} | ||
cooks.append(text + id) | ||
newEntry = "" | ||
} | ||
.padding() | ||
} | ||
|
||
List { | ||
ForEach(cooks, id: \.self) { entry in | ||
Text(entry) | ||
} | ||
.onDelete(perform: deleteEntry) | ||
} | ||
.listRowBackground(Color.clear) | ||
|
||
.padding() | ||
Button("Continue") { | ||
activeView = .sort_directions | ||
} | ||
.disabled(cooks.count == 0) | ||
.padding() | ||
} | ||
} | ||
} | ||
|
||
private func deleteEntry(at offsets: IndexSet) { | ||
cooks.remove(atOffsets: offsets) | ||
} | ||
private func returnUniqueID(entry: String, id: Int) -> Int{ | ||
if cooks.contains(entry + String(id)){ | ||
return returnUniqueID(entry: entry, id: id+1) | ||
} | ||
return id | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters