π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
ensu ios: mirror drawer/loading illustration and send-only smooth scroll
Prateek Sunal4d392b4d9fc0
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Chat/MessageList/MessageListComponents.swift b/mobile/native/darwin/Apps/ensu/ensu/Chat/MessageList/MessageListComponents.swiftindex dfbe67db60..df296e9055 100644--- a/mobile/native/darwin/Apps/ensu/ensu/Chat/MessageList/MessageListComponents.swift+++ b/mobile/native/darwin/Apps/ensu/ensu/Chat/MessageList/MessageListComponents.swift@@ -223,92 +223,33 @@ struct StreamingBubbleView: View {@State private var storageId = UUID().uuidStringvar body: some View {+ let hasText = !text.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty+HStack(alignment: .bottom) {VStack(alignment: .leading, spacing: EnsuSpacing.sm) {- VStack(alignment: .leading, spacing: EnsuSpacing.sm) {- if text.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {- LoadingDotsView()- } else {- TimelineView(.periodic(from: .now, by: 0.55)) { context in- let phase = Int(context.date.timeIntervalSinceReferenceDate * 2) % 2- let showCursor = phase == 0- AssistantMessageRenderer(- text: text,- isStreaming: true,- storageId: storageId,- showsCursor: showCursor- )- }+ EnsuBrandIllustration(width: 92, height: 42)++ if hasText {+ TimelineView(.periodic(from: .now, by: 0.55)) { context in+ let phase = Int(context.date.timeIntervalSinceReferenceDate * 2) % 2+ let showCursor = phase == 0+ AssistantMessageRenderer(+ text: text,+ isStreaming: true,+ storageId: storageId,+ showsCursor: showCursor+ )}}- .padding(.vertical, EnsuSpacing.md)- .padding(.horizontal, EnsuSpacing.sm)}+ .padding(.vertical, EnsuSpacing.md)+ .padding(.horizontal, EnsuSpacing.sm).frame(maxWidth: .infinity, alignment: .leading)}.foregroundStyle(EnsuColor.textPrimary)}}-struct LoadingDotsView: View {- @State private var phrase: String = LoadingDotsView.randomPhrase()-- var body: some View {- TimelineView(.periodic(from: .now, by: 0.5)) { context in- let phase = Int(context.date.timeIntervalSinceReferenceDate * 2) % 3- Text(phrase + dots(for: phase))- .font(EnsuTypography.message)- .foregroundStyle(EnsuColor.textMuted)- }- }-- private static let loadingPhraseVerbs = [- "Generating",- "Thinking through",- "Assembling",- "Drafting",- "Composing",- "Crunching",- "Exploring",- "Piecing together",- "Reviewing",- "Organizing",- "Synthesizing",- "Sketching",- "Refining",- "Shaping"- ]-- private static let loadingPhraseTargets = [- "your reply",- "an answer",- "ideas",- "context",- "details",- "the response",- "the next steps",- "a solution",- "the summary",- "insights",- "the draft",- "the explanation"- ]-- private static func randomPhrase() -> String {- let verb = loadingPhraseVerbs.randomElement() ?? "Generating"- let target = loadingPhraseTargets.randomElement() ?? "your reply"- return "\(verb) \(target)"- }-- private func dots(for phase: Int) -> String {- switch phase {- case 0: return "."- case 1: return ".."- default: return "..."- }- }-}-struct TimestampView: View {let date: Datediff --git a/mobile/native/darwin/Apps/ensu/ensu/Chat/MessageListView.swift b/mobile/native/darwin/Apps/ensu/ensu/Chat/MessageListView.swiftindex 3dd8f22689..c1405cdba7 100644--- a/mobile/native/darwin/Apps/ensu/ensu/Chat/MessageListView.swift+++ b/mobile/native/darwin/Apps/ensu/ensu/Chat/MessageListView.swift@@ -20,15 +20,11 @@ struct MessageListView: View {@State private var isAtBottom = true@State private var autoScrollEnabled = true@State private var previewItem: AttachmentPreviewItem?- @State private var lastHapticLength = 0@State private var wasAtBottomBeforeKeyboard = false@State private var isUserDragging = false@State private var lastContentHeight: CGFloat = 0@State private var lastScrollChange = ScrollChange()@State private var didInitialScroll = false- #if os(iOS)- @State private var haptic: UIImpactFeedbackGenerator?- #endifvar body: some View {GeometryReader { proxy in@@ -66,8 +62,9 @@ struct MessageListView: View {.onPreferenceChange(ContentHeightKey.self) { newHeight inlet delta = newHeight - lastContentHeightlastContentHeight = newHeight- if delta > 1, autoScrollEnabled, !isUserDragging {- scrollToBottom(scrollProxy, force: true, animated: false)+ let lastMessageIsUser = messages.last?.role == .user+ if delta > 1, autoScrollEnabled, !isUserDragging, !isGenerating, lastMessageIsUser {+ scrollToBottom(scrollProxy, force: true, animated: true)}}.onChange(of: currentScrollChange) { newValue in@@ -75,9 +72,6 @@ struct MessageListView: View {}.onAppear {lastScrollChange = currentScrollChange- #if os(iOS)- prepareHaptic()- #endifdidInitialScroll = falsescheduleInitialScroll(scrollProxy)}@@ -107,8 +101,9 @@ struct MessageListView: View {if newValue.messagesCount != previous.messagesCount {if !didInitialScroll {scheduleInitialScroll(scrollProxy)- } else {- scrollToBottom(scrollProxy, animated: newValue.isGenerating)+ } else if messages.last?.role == .user {+ autoScrollEnabled = true+ scrollToBottom(scrollProxy, force: true, animated: true)}}@@ -118,19 +113,6 @@ struct MessageListView: View {scheduleInitialScroll(scrollProxy)}- if newValue.streamingLength != previous.streamingLength {- #if os(iOS)- if newValue.isGenerating {- let length = newValue.streamingLength- if length > lastHapticLength {- impactHaptic()- lastHapticLength = length- }- }- #endif- scrollToBottom(scrollProxy, animated: false)- }-if newValue.keyboardHeight != previous.keyboardHeight {if newValue.keyboardHeight > 0 {wasAtBottomBeforeKeyboard = isAtBottom@@ -145,18 +127,7 @@ struct MessageListView: View {}if newValue.inputBarHeight != previous.inputBarHeight {- if autoScrollEnabled && !isUserDragging {- scrollToBottom(scrollProxy, force: true, animated: false)- }- }-- if newValue.isGenerating != previous.isGenerating {- if newValue.isGenerating {- autoScrollEnabled = true- lastHapticLength = 0- #if os(iOS)- prepareHaptic()- #endif+ if autoScrollEnabled && !isUserDragging && !isGenerating {scrollToBottom(scrollProxy, force: true, animated: false)}}@@ -164,26 +135,10 @@ struct MessageListView: View {if newValue.isAtBottom != previous.isAtBottom {if newValue.isAtBottom && !isUserDragging {autoScrollEnabled = true- scrollToBottom(scrollProxy, force: true, animated: false)}}}- #if os(iOS)- private func prepareHaptic() {- let generator = haptic ?? UIImpactFeedbackGenerator(style: .medium)- haptic = generator- generator.prepare()- }-- private func impactHaptic() {- let generator = haptic ?? UIImpactFeedbackGenerator(style: .medium)- haptic = generator- generator.impactOccurred()- generator.prepare()- }- #endif-@ViewBuilderprivate func messageListContent(containerHeight: CGFloat) -> some View {let emptyStateMinHeight = max(0, containerHeight - contentBottomPadding - (EnsuSpacing.lg * 2))diff --git a/mobile/native/darwin/Apps/ensu/ensu/Chat/SessionDrawerView.swift b/mobile/native/darwin/Apps/ensu/ensu/Chat/SessionDrawerView.swiftindex ceb76118f4..9584ecec93 100644--- a/mobile/native/darwin/Apps/ensu/ensu/Chat/SessionDrawerView.swift+++ b/mobile/native/darwin/Apps/ensu/ensu/Chat/SessionDrawerView.swift@@ -79,7 +79,7 @@ struct SessionDrawerView: View {}private var drawerLogo: some View {- EnsuLogo(height: 27)+ EnsuBrandIllustration(width: 32, height: 32)}private var headerControls: some View {diff --git a/mobile/native/darwin/Apps/ensu/ensu/Components/EnsuBrandIllustration.swift b/mobile/native/darwin/Apps/ensu/ensu/Components/EnsuBrandIllustration.swiftnew file mode 100644index 0000000000..17d1574cdc--- /dev/null+++ b/mobile/native/darwin/Apps/ensu/ensu/Components/EnsuBrandIllustration.swift@@ -0,0 +1,34 @@+import SwiftUI++struct EnsuBrandIllustration: View {+ var width: CGFloat = 92+ var height: CGFloat = 42+ var animated: Bool = true++ @State private var isAnimating = false++ var body: some View {+ let activePhase = animated ? isAnimating : true++ Image("EnsuLogoForeground")+ .resizable()+ .scaledToFit()+ .frame(width: width, height: height, alignment: .leading)+ .scaleEffect(activePhase ? 1 : 0.94)+ .opacity(activePhase ? 1 : 0.84)+ .animation(+ animated+ ? .easeInOut(duration: 0.9).repeatForever(autoreverses: true)+ : nil,+ value: isAnimating+ )+ .onAppear {+ guard animated else { return }+ isAnimating = true+ }+ .onDisappear {+ isAnimating = false+ }+ .accessibilityLabel("Ensu")+ }+}