Make room for the keyboard

This commit is contained in:
Sami Samhuri 2023-02-05 13:39:12 -08:00
parent c9ac47470f
commit 12849d98e7
No known key found for this signature in database
GPG key ID: 4B4195422742FC16
2 changed files with 129 additions and 36 deletions

View file

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1420"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "96372F70299031580022FDD5"
BuildableName = "MemoryTree.app"
BlueprintName = "MemoryTree"
ReferencedContainer = "container:MemoryTree.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "96372F70299031580022FDD5"
BuildableName = "MemoryTree.app"
BlueprintName = "MemoryTree"
ReferencedContainer = "container:MemoryTree.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "96372F70299031580022FDD5"
BuildableName = "MemoryTree.app"
BlueprintName = "MemoryTree"
ReferencedContainer = "container:MemoryTree.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View file

@ -55,51 +55,66 @@ struct ContentView: View {
var body: some View {
NavigationStack {
VStack(spacing: 0) {
NavigationLink(destination: CloudView(entries: $entries)) {
Image(systemName: "wind.snow")
.imageScale(.large)
.foregroundColor(.white)
}
.padding()
.frame(maxWidth: .infinity, alignment: .trailing)
.opacity(entries.isEmpty ? 0 : 1)
windButton
Spacer()
Button {
isEditing = true
} label: {
Image(treeImageName)
.renderingMode(.template)
.resizable()
.scaledToFit()
.foregroundColor(.white)
}
.frame(maxHeight: treeHeight)
treeView
Color.green
.frame(height: 80)
Form {
TextField("What are you grateful for today?", text: $entryText)
.background(Color.white)
.tint(Color.blue)
}
.onSubmit {
// Task {
// try await $entries.insert(Entry(text: entryText))
// }
entries.append(Entry(text: entryText))
entryText = ""
isEditing = false
}
.frame(maxHeight: isEditing ? 120 : 0)
formView
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.edgesIgnoringSafeArea(.bottom)
.edgesIgnoringSafeArea(isEditing ? .top : .bottom)
.background(Color.blue)
}
}
@ViewBuilder var windButton: some View {
NavigationLink(destination: CloudView(entries: $entries)) {
Image(systemName: "wind.snow")
.imageScale(.large)
.foregroundColor(.white)
}
.padding()
.frame(maxWidth: .infinity, alignment: .trailing)
.opacity(entries.isEmpty ? 0 : 1)
}
@ViewBuilder var treeView: some View {
Button {
isEditing.toggle()
} label: {
Image(treeImageName)
.renderingMode(.template)
.resizable()
.scaledToFit()
.foregroundColor(.white)
}
.frame(maxHeight: treeHeight)
Color.green
.frame(height: 80)
}
@ViewBuilder var formView: some View {
Form {
TextField("What are you grateful for today?", text: $entryText)
.background(Color.white)
.tint(Color.blue)
}
.onSubmit {
// Task {
// try await $entries.insert(Entry(text: entryText))
// }
if !entryText.isEmpty {
entries.append(Entry(text: entryText))
}
entryText = ""
isEditing = false
}
.frame(maxHeight: isEditing ? 120 : 0)
.animation(.easeInOut.speed(2), value: isEditing)
}
}
struct ContentView_Previews: PreviewProvider {