Skip to content
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

♻️ Add a translate button to the session details screen. #981

Merged

Conversation

Corvus400
Copy link
Contributor

@Corvus400 Corvus400 commented Aug 27, 2023

Issue

  • None.

Overview (Required)

  • The i18nDesc item is now used to switch the text in the Description.

Links

Screenshot (Optional if screenshot test is present or unrelated to UI)

Before After

Movie (Optional)

Before After
---
translate.mp4

@github-actions
Copy link

Hi @Corvus400! Codes seem to be unformatted. To resolve this issue, please run ./gradlew detekt --auto-correct and fix the results of ./gradlew lintDebug.. Thank you for your contribution.

@github-actions
Copy link

github-actions bot commented Aug 27, 2023

Test Results

205 tests   205 ✔️  7m 12s ⏱️
  11 suites      0 💤
  11 files        0

Results for commit e855387.

♻️ This comment has been updated with latest results.

@github-actions github-actions bot temporarily deployed to deploygate-distribution August 27, 2023 06:51 Inactive
@github-actions github-actions bot temporarily deployed to deploygate-distribution August 27, 2023 14:38 Inactive
@github-actions github-actions bot temporarily deployed to deploygate-distribution August 27, 2023 15:17 Inactive
@Corvus400 Corvus400 marked this pull request as ready for review August 27, 2023 15:49
@Corvus400 Corvus400 requested a review from a team as a code owner August 27, 2023 15:49
@Corvus400 Corvus400 changed the title [WIP] Add a translate button to the session details screen. ♻️ Add a translate button to the session details screen. Aug 27, 2023
@Corvus400
Copy link
Contributor Author

I need to fix the Swift code, but I couldn't fix it with my knowledge.
Can someone please fix the code on the iOS side?🙇‍♂️

@Corvus400 Corvus400 changed the title ♻️ Add a translate button to the session details screen. [Need help from iOS developers.] ♻️ Add a translate button to the session details screen. Aug 27, 2023
@woxtu
Copy link
Contributor

woxtu commented Aug 27, 2023

diff --git a/app-ios/Modules/Sources/Session/SessionView.swift b/app-ios/Modules/Sources/Session/SessionView.swift
index 87f79e2a..7531d030 100644
--- a/app-ios/Modules/Sources/Session/SessionView.swift
+++ b/app-ios/Modules/Sources/Session/SessionView.swift
@@ -65,12 +65,12 @@ public struct SessionView: View {

                 if let session = viewModel.timetableItem as? TimetableItem.Session {
                     VStack(alignment: .leading, spacing: 16) {
-                        Text(session.description_)
+                        Text(session.description_.currentLangTitle)
                             .textSelection(.enabled)
                             .lineLimit(isDescriptionExpanded ? nil : 5)
                             .background {
                                 ViewThatFits(in: .vertical) {
-                                    Text(session.description_)
+                                    Text(session.description_.currentLangTitle)
                                         .hidden()
                                     // Just for receiving onAppear event if the description exceeds its line limit
                                     Color.clear

@Corvus400 Corvus400 requested a review from a team as a code owner August 28, 2023 02:13
@Corvus400 Corvus400 changed the title [Need help from iOS developers.] ♻️ Add a translate button to the session details screen. ♻️ Add a translate button to the session details screen. Aug 28, 2023
@github-actions github-actions bot temporarily deployed to deploygate-distribution August 28, 2023 02:46 Inactive
@Corvus400
Copy link
Contributor Author

@woxtu
Thank you very much!
Thanks to you, I can now successfully build iOS!🥳

@@ -117,8 +117,14 @@ fun SessionsAllResponse.Companion.fake(): SessionsAllResponse {
en = "DroidKaigi App Architecture day$day room${room.name.en} index$index",
),
speakers = listOf("1", "2"),
description = "これはディスクリプションです。\nこれはディスクリプションです。\nこれはディスクリプションです。\n" +
"これはディスクリプションです。\nこれはディスクリプションです。\nこれはディスクリプションです。\n",
description = "\"これはディスクリプションです。\\nこれはディスクリプションです。\\nこれはディスクリプションです。\\n\" +\n" +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image There may be a little mistake 😄

@github-actions github-actions bot temporarily deployed to deploygate-distribution August 28, 2023 03:40 Inactive
@@ -52,9 +54,14 @@ class TimetableItemDetailViewModel @Inject constructor(
)
private val viewBookmarkListRequestStateFlow =
MutableStateFlow<ViewBookmarkListRequestState>(ViewBookmarkListRequestState.NotRequested)
private val currentDescriptionLanguage = MutableStateFlow(defaultLang())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially, I was hoping that the session would be displayed in its original default language. The reason is that it would reflect what the speaker actually wrote. 👀
Maybe you can have userSelectedDescriptionLanguage = MutableStateFlow(null)

@github-actions github-actions bot temporarily deployed to deploygate-distribution August 29, 2023 03:58 Inactive
@@ -119,6 +119,12 @@ fun SessionsAllResponse.Companion.fake(): SessionsAllResponse {
speakers = listOf("1", "2"),
description = "これはディスクリプションです。\nこれはディスクリプションです。\nこれはディスクリプションです。\n" +
"これはディスクリプションです。\nこれはディスクリプションです。\nこれはディスクリプションです。\n",
i18nDesc = LocaledResponse(
ja = "\"これはディスクリプションです。\\nこれはディスクリプションです。\\nこれはディスクリプションです。\\n\" +\n" +
Copy link
Member

@takahirom takahirom Aug 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think \\n should be \n 👀
You can work on this another PR!

@@ -52,18 +53,28 @@ class TimetableItemDetailViewModel @Inject constructor(
)
private val viewBookmarkListRequestStateFlow =
MutableStateFlow<ViewBookmarkListRequestState>(ViewBookmarkListRequestState.NotRequested)
private val currentDescriptionLanguageStateFlow: MutableStateFlow<Lang?> =
Copy link
Member

@takahirom takahirom Aug 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you name this variable selectedDescriptionLanguageStateFlow? I think currentDescriptionLanguageStateFlow is a little wrong name because if it is null, we show the sessions default lang 🙏

@github-actions github-actions bot temporarily deployed to deploygate-distribution August 30, 2023 03:31 Inactive
Copy link
Member

@takahirom takahirom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thank you for your suggestion! We may not have this feature without you!

@takahirom takahirom merged commit ec38840 into DroidKaigi:main Aug 30, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants