Skip to content

Commit fb61bbd

Browse files
authored
Merge pull request #277 from rainxchzed/feat-translate
2 parents 9e419a7 + 0f5ed34 commit fb61bbd

File tree

46 files changed

+1460
-73
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1460
-73
lines changed
1.86 KB
Binary file not shown.
1.88 KB
Binary file not shown.

composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/app/navigation/AppNavigation.kt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ fun AppNavigation(
102102
)
103103
)
104104
},
105+
onNavigateToDetailsFromLink = { owner, repo ->
106+
navController.navigate(
107+
GithubStoreGraph.DetailsScreen(
108+
owner = owner,
109+
repo = repo
110+
)
111+
)
112+
},
105113
onNavigateToDeveloperProfile = { username ->
106114
navController.navigate(
107115
GithubStoreGraph.DeveloperProfileScreen(
@@ -133,7 +141,7 @@ fun AppNavigation(
133141
)
134142
},
135143
viewModel = koinViewModel {
136-
parametersOf(args.repositoryId, args.owner, args.repo)
144+
parametersOf(args.repositoryId, args.owner, args.repo, args.isComingFromUpdate)
137145
}
138146
)
139147
}
@@ -242,7 +250,8 @@ fun AppNavigation(
242250
onNavigateToRepo = { repoId ->
243251
navController.navigate(
244252
GithubStoreGraph.DetailsScreen(
245-
repositoryId = repoId
253+
repositoryId = repoId,
254+
isComingFromUpdate = true
246255
)
247256
)
248257
},

composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/app/navigation/GithubStoreGraph.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ sealed interface GithubStoreGraph {
1717
data class DetailsScreen(
1818
val repositoryId: Long = -1L,
1919
val owner: String = "",
20-
val repo: String = ""
20+
val repo: String = "",
21+
val isComingFromUpdate: Boolean = false,
2122
) : GithubStoreGraph
2223

2324
@Serializable

core/data/src/androidMain/kotlin/zed/rainxch/core/data/utils/AndroidClipboardHelper.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,11 @@ class AndroidClipboardHelper(
1212
val cm = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
1313
cm.setPrimaryClip(ClipData.newPlainText(label, text))
1414
}
15+
16+
override fun getText(): String? {
17+
val cm = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
18+
val clip = cm.primaryClip ?: return null
19+
if (clip.itemCount == 0) return null
20+
return clip.getItemAt(0).text?.toString()
21+
}
1522
}

core/data/src/commonMain/kotlin/zed/rainxch/core/data/repository/ThemesRepositoryImpl.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class ThemesRepositoryImpl(
1818
private val AMOLED_KEY = booleanPreferencesKey("amoled_theme")
1919
private val IS_DARK_THEME_KEY = booleanPreferencesKey("is_dark_theme")
2020
private val FONT_KEY = stringPreferencesKey("font_theme")
21+
private val AUTO_DETECT_CLIPBOARD_KEY = booleanPreferencesKey("auto_detect_clipboard_links")
2122

2223
override fun getThemeColor(): Flow<AppTheme> {
2324
return preferences.data.map { prefs ->
@@ -73,4 +74,16 @@ class ThemesRepositoryImpl(
7374
prefs[FONT_KEY] = fontTheme.name
7475
}
7576
}
77+
78+
override fun getAutoDetectClipboardLinks(): Flow<Boolean> {
79+
return preferences.data.map { prefs ->
80+
prefs[AUTO_DETECT_CLIPBOARD_KEY] ?: false
81+
}
82+
}
83+
84+
override suspend fun setAutoDetectClipboardLinks(enabled: Boolean) {
85+
preferences.edit { prefs ->
86+
prefs[AUTO_DETECT_CLIPBOARD_KEY] = enabled
87+
}
88+
}
7689
}

core/data/src/jvmMain/kotlin/zed/rainxch/core/data/utils/DesktopClipboardHelper.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,23 @@ package zed.rainxch.core.data.utils
22

33
import zed.rainxch.core.domain.utils.ClipboardHelper
44
import java.awt.Toolkit
5+
import java.awt.datatransfer.DataFlavor
56
import java.awt.datatransfer.StringSelection
67

78
class DesktopClipboardHelper : ClipboardHelper {
89
override fun copy(label: String, text: String) {
910
val clipboard = Toolkit.getDefaultToolkit().systemClipboard
1011
clipboard.setContents(StringSelection(text), null)
1112
}
13+
14+
override fun getText(): String? {
15+
return try {
16+
val clipboard = Toolkit.getDefaultToolkit().systemClipboard
17+
if (clipboard.isDataFlavorAvailable(DataFlavor.stringFlavor)) {
18+
clipboard.getData(DataFlavor.stringFlavor) as? String
19+
} else null
20+
} catch (_: Exception) {
21+
null
22+
}
23+
}
1224
}

core/domain/src/commonMain/kotlin/zed/rainxch/core/domain/repository/ThemesRepository.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@ interface ThemesRepository {
1313
suspend fun setAmoledTheme(enabled: Boolean)
1414
fun getFontTheme(): Flow<FontTheme>
1515
suspend fun setFontTheme(fontTheme: FontTheme)
16+
fun getAutoDetectClipboardLinks(): Flow<Boolean>
17+
suspend fun setAutoDetectClipboardLinks(enabled: Boolean)
1618
}

core/domain/src/commonMain/kotlin/zed/rainxch/core/domain/utils/ClipboardHelper.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ interface ClipboardHelper {
55
label: String,
66
text: String
77
)
8+
9+
fun getText(): String?
810
}

core/presentation/src/commonMain/composeResources/values-bn/strings-bn.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,4 +428,14 @@
428428
<string name="failed_to_share_link">লিংক শেয়ার করতে ব্যর্থ হয়েছে</string>
429429
<string name="link_copied_to_clipboard">লিংক ক্লিপবোর্ডে কপি করা হয়েছে</string>
430430

431+
<!-- Translation feature -->
432+
<string name="translate">অনুবাদ করুন</string>
433+
<string name="translating">অনুবাদ হচ্ছে…</string>
434+
<string name="show_original">মূল দেখান</string>
435+
<string name="translated_to">%1$s এ অনুবাদিত</string>
436+
<string name="translate_to">অনুবাদ করুন…</string>
437+
<string name="search_language">ভাষা খুঁজুন</string>
438+
<string name="change_language">ভাষা পরিবর্তন করুন</string>
439+
<string name="translation_failed">অনুবাদ ব্যর্থ হয়েছে। আবার চেষ্টা করুন।</string>
440+
431441
</resources>

0 commit comments

Comments
 (0)