如何使用正确的方法使用 Compose for Desktop 构建 Microsoft 和 Mac OS 应用程序

发布于 2025-01-15 22:44:02 字数 840 浏览 5 评论 0原文

我需要使用 Jetbrains Compose Multiplatform< 开发适用于 Windows 和 Mac OS 的桌面应用程序br> 我将使用 Kotlin 语言来设计 UI。
但我需要以下几点指导:

  1. 桌面应用程序中的核心逻辑/计算/网络客户端等需要哪些语言?
  2. 我们可以用 Kotlin 编写整个 Microsoft 桌面应用程序(Compose for Desktop)吗?
  3. 我们可以在 Compose for 中使用 FragmentViewModelsRoom 等 Android 类吗?桌面 ?
  4. 如果我们不能在桌面应用程序中使用 Android 类,那么我们在 Android 的 ViewModel 类中编写的代码应该在哪里编写呢?如何构建代码和包
  5. 对于使用 Compose 或 Desktop 构建的桌面应用程序来说,最佳架构是什么? ?
    我找不到 Desktop Compose 应用程序的任何架构图
  6. 我们可以使用 Jnuit 和 Espresso 在 Compose for Desktop 中编写 UI 和 Instrumented 测试吗?

注意

  1. 我已经阅读了 compose Desktop 的官方文档。
    我还浏览了示例和多个博客的代码,但上述问题没有得到明确的回答。

因此我需要你的指导

I need to develop a desktop app for Windows and Mac OS with Jetbrains Compose Multiplatform
I will use the Kotlin language to design the UI.
But I need guidance on following points:

  1. Which languages will be required for the core logic / calculations / network client, etc. in the desktop app ?
  2. Can we write the entire Microsoft desktop app in Kotlin (Compose for Desktop)
  3. Can we use Android classes like Fragment, ViewModels, Room in Compose for Desktop ?
  4. If we cannot use Android classes in desktop app then, where do we write the code which we write in ViewModel classes in Android ? How to structure the code and packages
  5. What is the best architecture for Desktop app which are being built with Compose or Desktop. ?
    I could not find any architecture diagram for Desktop Compose App
  6. Can we use Jnuit and Espresso for writing UI and Instrumented tests in Compose for Desktop ?

Note:

  1. I have gone through the official documentation of compose desktop.
    I also went though the code of samples and multiple blogs, but the above queries are not answered clearly.

Hence I need your guidance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

故人的歌 2025-01-22 22:44:02

1,2 — 我想任何 JVM 兼容的语言都可以。
3,4 — https://github.com/JetBrains/compose-jb/discussions/第1587章

您应该从 androidx ViewModel 中抽象出来,创建一个可以注入到 android ViewModel 中的纯 Kotlin ViewModel 委托。
因此,在这种情况下,androidx ViewModel 将扮演多平台实现包装器的角色。
但请记住,没有像 Android 世界那样的组件生命周期或导航生态系统。为此,您可以使用 Decompose 库。

我不是 Compose for Desktop 方面的专家,因此我不想回答最后两个问题。另外,我建议您在 Kotlin 的 #compose-desktop 频道中搜索答案官方 Slack 工作区(获取邀请 此处)。

1,2 — I guess that any JVM-compatible language would be fine.
3,4 — https://github.com/JetBrains/compose-jb/discussions/1587

You should abstract from androidx ViewModel creating a pure Kotlin ViewModel delegate that can be injected into android ViewModel.
So in this case androidx ViewModel will play the role of wrapper over multiplatform implementation.
But keep in mind that there is no component's lifecycle or navigation ecosystem like in Android world. For this purpose, you can use Decompose library.

I am not an expert in Compose for Desktop, so I would prefer not to answer the last two questions. Also, I would recommend you to search for answers in the #compose-desktop channel of the Kotlin official Slack workspace(get an invite here).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文