Skip to content

Commit

Permalink
fixes spacing of camera/send buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
ctate committed May 22, 2024
1 parent eb287db commit bf33464
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 27 deletions.
55 changes: 28 additions & 27 deletions platforms/apple/Crystal/Chat/ChatView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ struct ChatContentView: View {
@State private var animate = false
@ObservedObject var speechRecognizer = SpeechRecognizerService()
@State private var isSheetPresented = false
@State private var keyboardHeight: CGFloat = 0
@State var presentSheet = ""
@State private var showPopover = false
@State private var showRecorder = false
Expand All @@ -38,16 +39,15 @@ struct ChatContentView: View {
}

HStack(alignment: .bottom) {
VStack {
Button(action: {
presentSheet = "camera"
}) {
Image(systemName: "camera")
.imageScale(.large)
.foregroundColor(.white)
}
.buttonStyle(PlainButtonStyle())
Button(action: {
presentSheet = "camera"
}) {
Image(systemName: "camera")
.imageScale(.large)
.foregroundColor(.white)
}
.buttonStyle(PlainButtonStyle())
.padding(.bottom, 20)

Spacer()

Expand Down Expand Up @@ -98,23 +98,6 @@ struct ChatContentView: View {

Spacer()

#if os(iOS)
Menu {
Button(action: { presentSheet = "image" }) {
Label("Select Image", systemImage: "photo")
}
Button(action: { presentSheet = "document" }) {
Label("Select File", systemImage: "folder")
}
} label: {
Image(systemName: "paperclip")
.imageScale(.large)
.foregroundColor(.white)
}
.padding(.bottom, 36)
#endif

#if os(macOS)
Button(action: {
viewModel.sendMessage(
userInput,
Expand All @@ -141,7 +124,7 @@ struct ChatContentView: View {
.padding()
}
.keyboardShortcut(.return, modifiers: [.command])
#endif
.padding(.bottom, 20)
}
.padding()

Expand Down Expand Up @@ -208,6 +191,24 @@ struct ChatContentView: View {
conversationManager.selectedConversation = nil
})
}
#if os(iOS)
.padding(.bottom, keyboardHeight)
.onAppear {
NotificationCenter.default.addObserver(forName: UIResponder.keyboardWillShowNotification, object: nil, queue: .main) { notification in
let value = notification.userInfo![UIResponder.keyboardFrameEndUserInfoKey] as! CGRect
let height = value.height
keyboardHeight = 1
}

NotificationCenter.default.addObserver(forName: UIResponder.keyboardWillHideNotification, object: nil, queue: .main) { _ in
keyboardHeight = 0
}
}
.onDisappear {
NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardWillShowNotification, object: nil)
NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardWillHideNotification, object: nil)
}
#endif
}
}

Expand Down
4 changes: 4 additions & 0 deletions platforms/apple/Crystal/Sheets/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ struct IntegrationDetailView: View {
}
}
.navigationTitle(integration.name)
#if os(iOS)
.navigationBarTitleDisplayMode(.inline)
#endif
}
}

Expand Down Expand Up @@ -170,7 +172,9 @@ struct ProviderDetailView: View {
}
}
.navigationTitle(provider.name)
#if os(iOS)
.navigationBarTitleDisplayMode(.inline)
#endif
.toolbar {
Button(action: {
UserDefaults.standard.set(isEnabled, forKey: "\(provider.id):isEnabled")
Expand Down

0 comments on commit bf33464

Please sign in to comment.