-
Notifications
You must be signed in to change notification settings - Fork 100
Introduce MessageViewModel
+ Show original translated message
#815
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
ad10b1d
Introduction of ChatMessageViewModel
nuno-vieira ef9efc7
Add ChatChannelViewModel and ChatMessageViewModel as environment objects
nuno-vieira fc44f5e
Extract the Message View Model to a separate file
nuno-vieira 5b133a5
Fix show original text not working properly
nuno-vieira 4d56529
Extract some properties from the view to the MessageViewModel
nuno-vieira ab0e511
Fix MessageContainerView_Tests
nuno-vieira b3b00ef
Fix MessageListView_Tests
nuno-vieira 43df718
Fix MessageListViewAvatars_Tests
nuno-vieira 5e947ec
Use EnvironmentObject for the main container and EnvironmentValue for…
nuno-vieira bd695bf
Fix existing unit tests
nuno-vieira 81f89fe
Add Stream's show original translation button + make it configurable
nuno-vieira 66fdfea
Add test coverage to show original text feature
nuno-vieira f890c13
Fix reaction overlay tests
nuno-vieira ab8f758
Fix message container tests
nuno-vieira 44391c2
Refactor code to avoid environment objects in MessageContainerView
nuno-vieira 654de72
Provide view model by default
nuno-vieira 2adc09b
Add warning about thread-safeness in the singletone store
nuno-vieira afd7e0e
Example of performing translations from message actions
nuno-vieira 4584aa7
Revert "Example of performing translations from message actions"
nuno-vieira af2745e
Merge branch 'develop' into add/show-original-translated-message
nuno-vieira d5a51f4
Fix reactions overlay view not shown correct translated or original text
nuno-vieira c54da27
Open `ChatChannelViewModel.messageActionExecuted` so that it can be o…
nuno-vieira a4a2763
Rename originalTextTranslationsStore to originalTranslationsStore
nuno-vieira 2aa26c9
Make the LinkDetectionTextView change wheneve the translations store …
nuno-vieira be6aa99
Clear the original translations when opening the channel
nuno-vieira c114ec5
Add TODO v5 comments
nuno-vieira eca63b1
PR Feedback
nuno-vieira a722442
Refactor using utils
nuno-vieira 33520f9
Reapply "Example of performing translations from message actions"
nuno-vieira f37f114
Revert "Reapply "Example of performing translations from message acti…
nuno-vieira 90fd7d9
Update CHANGELOG.md
nuno-vieira 10a46e2
Fix editing message not working
nuno-vieira 0042189
Revert "Fix MessageListView_Tests"
nuno-vieira 8e0b1f8
Revert "Fix MessageListViewAvatars_Tests"
nuno-vieira eb69af2
Revert "Fix MessageContainerView_Tests"
nuno-vieira 959962e
Revert "Fix existing unit tests"
nuno-vieira 4d7aa6a
Revert "Fix message container tests"
nuno-vieira 330450b
Fix message container tests
nuno-vieira 862593c
Allow providing custom view models to reactions view
nuno-vieira File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
63 changes: 63 additions & 0 deletions
63
Sources/StreamChatSwiftUI/ChatChannel/MessageList/MessageTranslationFooterView.swift
This file contains hidden or 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,63 @@ | ||
// | ||
// Copyright © 2025 Stream.io Inc. All rights reserved. | ||
// | ||
|
||
import StreamChat | ||
import SwiftUI | ||
|
||
public struct MessageTranslationFooterView: View { | ||
@ObservedObject var messageViewModel: MessageViewModel | ||
|
||
@Injected(\.fonts) private var fonts | ||
@Injected(\.colors) private var colors | ||
@Injected(\.utils) private var utils | ||
|
||
public init( | ||
messageViewModel: MessageViewModel | ||
) { | ||
self.messageViewModel = messageViewModel | ||
} | ||
|
||
public var body: some View { | ||
if utils.messageListConfig.messageDisplayOptions.showOriginalTranslatedButton { | ||
HStack(spacing: 4) { | ||
if !messageViewModel.originalTextShown { | ||
translatedToView | ||
separatorView | ||
} | ||
showOriginalButton | ||
} | ||
} else { | ||
translatedToView | ||
} | ||
} | ||
|
||
private var translatedToView: some View { | ||
Text(messageViewModel.translatedLanguageText ?? "") | ||
.font(fonts.footnote) | ||
.foregroundColor(Color(colors.subtitleText)) | ||
} | ||
|
||
private var separatorView: some View { | ||
Text("•") | ||
.font(fonts.footnote) | ||
.foregroundColor(Color(colors.subtitleText)) | ||
} | ||
|
||
private var showOriginalButton: some View { | ||
Button( | ||
action: { | ||
if messageViewModel.originalTextShown { | ||
messageViewModel.hideOriginalText() | ||
} else { | ||
messageViewModel.showOriginalText() | ||
} | ||
}, | ||
label: { | ||
Text(messageViewModel.originalTranslationButtonText) | ||
.font(fonts.footnote) | ||
.foregroundColor(Color(colors.subtitleText)) | ||
} | ||
) | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.