Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

fix chat view

Prateek Sunalda9958347fe3
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Chat/ChatView.swift b/mobile/native/darwin/Apps/ensu/ensu/Chat/ChatView.swift
index ffbe65405d..79da281779 100644
--- a/mobile/native/darwin/Apps/ensu/ensu/Chat/ChatView.swift
+++ b/mobile/native/darwin/Apps/ensu/ensu/Chat/ChatView.swift
@@ -53,11 +53,40 @@ struct ChatView: View {
}
} else {
mainContent(showsMenuButton: true)
+ .overlay(alignment: .leading) {
+ #if os(iOS)
+ Color.clear
+ .frame(width: 24)
+ .contentShape(Rectangle())
+ .gesture(
+ DragGesture(minimumDistance: 20)
+ .onEnded { value in
+ guard !isDrawerOpen else { return }
+ guard value.startLocation.x <= 24 else { return }
+ let horizontal = value.translation.width
+ let vertical = value.translation.height
+ guard abs(horizontal) > abs(vertical), horizontal > 40 else { return }
+ isDrawerOpen = true
+ }
+ )
+ #endif
+ }
if isDrawerOpen {
Color.black.opacity(0.25)
.ignoresSafeArea()
.onTapGesture { isDrawerOpen = false }
+ #if os(iOS)
+ .gesture(
+ DragGesture(minimumDistance: 20)
+ .onEnded { value in
+ let horizontal = value.translation.width
+ let vertical = value.translation.height
+ guard abs(horizontal) > abs(vertical), horizontal < -40 else { return }
+ isDrawerOpen = false
+ }
+ )
+ #endif
}
drawerView(isPinned: false)
@@ -198,6 +227,8 @@ struct ChatView: View {
.background(EnsuColor.border)
ZStack(alignment: .top) {
+ let shouldShowDownloadOnboarding = !viewModel.isModelDownloaded
+
MessageListView(
messages: viewModel.messages,
streamingResponse: viewModel.displayedStreamingResponse,
@@ -205,7 +236,7 @@ struct ChatView: View {
isGenerating: viewModel.isGenerating,
sessionId: viewModel.currentSessionId,
keyboardHeight: keyboard.height,
- inputBarHeight: inputBarHeight,
+ inputBarHeight: viewModel.isModelDownloaded ? inputBarHeight : 0,
emptyStateTitle: "Welcome",
emptyStateSubtitle: "Start typing to begin a conversation",
onEdit: { message in
@@ -228,64 +259,66 @@ struct ChatView: View {
)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
.overlay(alignment: .bottom) {
- let shouldAutoFocus = viewModel.isModelDownloaded
- && !viewModel.isDownloading
- && !viewModel.isGenerating
- && !didAutoFocusInput
- && !isDrawerOpen
- && !didDismissKeyboard
- && !showSettings
- && !showDeveloperSettings
-
- MessageInputView(
- text: $viewModel.draftText,
- attachments: $viewModel.draftAttachments,
- isGenerating: viewModel.isGenerating,
- isDownloading: viewModel.isDownloading,
- editingMessage: editingMessage,
- isProcessingAttachments: viewModel.isProcessingAttachments,
- isAttachmentDownloadBlocked: viewModel.isAttachmentDownloadBlocked,
- onSend: {
- viewModel.sendDraft()
- },
- onStop: {
- viewModel.stopGenerating()
- },
- onCancelEdit: {
- viewModel.cancelEditing()
- },
- onAddImage: { data, name in
- viewModel.addImageAttachment(data: data, fileName: name)
- },
- onAddDocument: { url in
- viewModel.addDocumentAttachment(url: url)
- },
- onRemoveAttachment: { attachment in
- viewModel.removeAttachment(attachment)
- },
- onUserFocus: {
- didDismissKeyboard = false
- },
- onDismissKeyboard: {
- didDismissKeyboard = true
- },
- isFocused: $isInputFocused
- )
- .onPreferenceChange(InputBarHeightKey.self) { newValue in
- inputBarHeight = newValue
- }
- .onAppear {
- if shouldAutoFocus {
- requestInputFocus()
- didAutoFocusInput = true
- didDismissKeyboard = false
+ if viewModel.isModelDownloaded {
+ let shouldAutoFocus = viewModel.isModelDownloaded
+ && !viewModel.isDownloading
+ && !viewModel.isGenerating
+ && !didAutoFocusInput
+ && !isDrawerOpen
+ && !didDismissKeyboard
+ && !showSettings
+ && !showDeveloperSettings
+
+ MessageInputView(
+ text: $viewModel.draftText,
+ attachments: $viewModel.draftAttachments,
+ isGenerating: viewModel.isGenerating,
+ isDownloading: viewModel.isDownloading,
+ editingMessage: editingMessage,
+ isProcessingAttachments: viewModel.isProcessingAttachments,
+ isAttachmentDownloadBlocked: viewModel.isAttachmentDownloadBlocked,
+ onSend: {
+ viewModel.sendDraft()
+ },
+ onStop: {
+ viewModel.stopGenerating()
+ },
+ onCancelEdit: {
+ viewModel.cancelEditing()
+ },
+ onAddImage: { data, name in
+ viewModel.addImageAttachment(data: data, fileName: name)
+ },
+ onAddDocument: { url in
+ viewModel.addDocumentAttachment(url: url)
+ },
+ onRemoveAttachment: { attachment in
+ viewModel.removeAttachment(attachment)
+ },
+ onUserFocus: {
+ didDismissKeyboard = false
+ },
+ onDismissKeyboard: {
+ didDismissKeyboard = true
+ },
+ isFocused: $isInputFocused
+ )
+ .onPreferenceChange(InputBarHeightKey.self) { newValue in
+ inputBarHeight = newValue
}
- }
- .onChange(of: shouldAutoFocus) { newValue in
- if newValue {
- requestInputFocus()
- didAutoFocusInput = true
- didDismissKeyboard = false
+ .onAppear {
+ if shouldAutoFocus {
+ requestInputFocus()
+ didAutoFocusInput = true
+ didDismissKeyboard = false
+ }
+ }
+ .onChange(of: shouldAutoFocus) { newValue in
+ if newValue {
+ requestInputFocus()
+ didAutoFocusInput = true
+ didDismissKeyboard = false
+ }
}
}
}
@@ -295,6 +328,20 @@ struct ChatView: View {
.onChange(of: viewModel.messages.count) { _ in
viewModel.autoStartModelDownloadIfNeeded()
}
+
+ if shouldShowDownloadOnboarding {
+ DownloadOnboardingView(
+ isDownloading: viewModel.isDownloading,
+ downloadPercent: viewModel.downloadToast?.percent,
+ statusText: viewModel.downloadToast?.status,
+ totalBytes: viewModel.modelDownloadSizeBytes,
+ sizeText: viewModel.modelDownloadSizeText,
+ onDownload: {
+ viewModel.startModelDownload(userInitiated: true)
+ }
+ )
+ .background(EnsuColor.backgroundBase)
+ }
}
}
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Chat/MessageListView.swift b/mobile/native/darwin/Apps/ensu/ensu/Chat/MessageListView.swift
index 0a4e0e2e43..37391633e5 100644
--- a/mobile/native/darwin/Apps/ensu/ensu/Chat/MessageListView.swift
+++ b/mobile/native/darwin/Apps/ensu/ensu/Chat/MessageListView.swift
@@ -1,6 +1,10 @@
#if canImport(EnteCore)
import SwiftUI
+#if os(macOS)
+import QuickLookUI
+#else
import QuickLook
+#endif
#if os(iOS)
import UIKit
#endif
@@ -307,7 +311,7 @@ private struct QuickLookPreview: NSViewRepresentable {
let url: URL
func makeNSView(context: Context) -> QLPreviewView {
- let view = QLPreviewView(frame: .zero, style: .normal)
+ let view = QLPreviewView(frame: .zero, style: .normal)!
view.autostarts = true
view.previewItem = url as NSURL
return view
diff --git a/mobile/native/darwin/Apps/ensu/ensu/DesignSystem/Platform.swift b/mobile/native/darwin/Apps/ensu/ensu/DesignSystem/Platform.swift
index 636ccf1c6d..21e5d0ab86 100644
--- a/mobile/native/darwin/Apps/ensu/ensu/DesignSystem/Platform.swift
+++ b/mobile/native/darwin/Apps/ensu/ensu/DesignSystem/Platform.swift
@@ -12,6 +12,7 @@ enum PlatformKeyboardType {
case `default`
case emailAddress
case numberPad
+ case decimalPad
case URL
}
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Info.plist b/mobile/native/darwin/Apps/ensu/ensu/Info.plist
index 87482602a8..ebe4aa7078 100644
--- a/mobile/native/darwin/Apps/ensu/ensu/Info.plist
+++ b/mobile/native/darwin/Apps/ensu/ensu/Info.plist
@@ -24,7 +24,7 @@
<string>0.1.0</string>
<key>CFBundleVersion</key>
- <string>6</string>
+ <string>8</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
diff --git a/mobile/native/darwin/Apps/ensu/ensu/ModelSettings/ModelSettingsView.swift b/mobile/native/darwin/Apps/ensu/ensu/ModelSettings/ModelSettingsView.swift
index 9c21cbe5ba..15e1cee26a 100644
--- a/mobile/native/darwin/Apps/ensu/ensu/ModelSettings/ModelSettingsView.swift
+++ b/mobile/native/darwin/Apps/ensu/ensu/ModelSettings/ModelSettingsView.swift
@@ -52,7 +52,9 @@ struct ModelSettingsView: View {
Group {
if embeddedInNavigation {
content
+ #if os(iOS)
.navigationBarTitleDisplayMode(.inline)
+ #endif
.toolbar {
ToolbarItem(placement: .principal) {
Text("Model Settings")
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Settings/LogsView.swift b/mobile/native/darwin/Apps/ensu/ensu/Settings/LogsView.swift
index 49659ccdc5..9c05ab7381 100644
--- a/mobile/native/darwin/Apps/ensu/ensu/Settings/LogsView.swift
+++ b/mobile/native/darwin/Apps/ensu/ensu/Settings/LogsView.swift
@@ -29,7 +29,9 @@ struct LogsView: View {
content
}
.background(EnsuColor.backgroundBase)
+ #if os(iOS)
.navigationBarTitleDisplayMode(.inline)
+ #endif
.toolbar {
toolbarContent
}
@@ -39,7 +41,9 @@ struct LogsView: View {
content
}
.background(EnsuColor.backgroundBase)
+ #if os(iOS)
.navigationBarTitleDisplayMode(.inline)
+ #endif
.toolbar {
toolbarContent
ToolbarItem(placement: .cancellationAction) {
@@ -344,7 +348,9 @@ private struct LogDetailView: View {
.frame(maxWidth: .infinity, alignment: .leading)
}
.navigationTitle("Log details")
+ #if os(iOS)
.navigationBarTitleDisplayMode(.inline)
+ #endif
.toolbar {
ToolbarItem(placement: .cancellationAction) {
Button("Close") { dismiss() }
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Settings/SettingsView.swift b/mobile/native/darwin/Apps/ensu/ensu/Settings/SettingsView.swift
index 4fc1e91ea4..f36499ed60 100644
--- a/mobile/native/darwin/Apps/ensu/ensu/Settings/SettingsView.swift
+++ b/mobile/native/darwin/Apps/ensu/ensu/Settings/SettingsView.swift
@@ -57,8 +57,12 @@ struct SettingsView: View {
.padding(EnsuSpacing.lg)
}
.background(EnsuColor.backgroundBase)
+ #if os(iOS)
.searchable(text: $query, placement: .navigationBarDrawer(displayMode: .always))
.navigationBarTitleDisplayMode(.inline)
+ #else
+ .searchable(text: $query)
+ #endif
.toolbar {
ToolbarItem(placement: .principal) {
Text("Settings")