mirror of
https://github.com/JetBrains/intellij-platform-plugin-template.git
synced 2025-12-05 06:11:52 +00:00
Add Weather and Chat app sample tabs
This commit is contained in:
parent
cf156901c1
commit
acc67cfca6
@ -1,48 +1,20 @@
|
|||||||
package org.jetbrains.plugins.template.toolWindow
|
package org.jetbrains.plugins.template.toolWindow
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.*
|
|
||||||
import androidx.compose.runtime.getValue
|
|
||||||
import androidx.compose.runtime.mutableStateOf
|
|
||||||
import androidx.compose.runtime.remember
|
|
||||||
import androidx.compose.runtime.setValue
|
|
||||||
import androidx.compose.ui.Modifier
|
|
||||||
import androidx.compose.ui.unit.dp
|
|
||||||
import com.intellij.openapi.components.service
|
|
||||||
import com.intellij.openapi.project.DumbAware
|
import com.intellij.openapi.project.DumbAware
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import com.intellij.openapi.wm.ToolWindow
|
import com.intellij.openapi.wm.ToolWindow
|
||||||
import com.intellij.openapi.wm.ToolWindowFactory
|
import com.intellij.openapi.wm.ToolWindowFactory
|
||||||
import com.intellij.ui.content.ContentFactory
|
import org.jetbrains.jewel.bridge.addComposeTab
|
||||||
import org.jetbrains.jewel.bridge.JewelComposePanel
|
import org.jetbrains.plugins.template.ui.ChatAppSample
|
||||||
import org.jetbrains.jewel.ui.component.DefaultButton
|
import org.jetbrains.plugins.template.ui.WeatherAppSample
|
||||||
import org.jetbrains.jewel.ui.component.Text
|
|
||||||
import org.jetbrains.plugins.template.ComposeTemplateBundle
|
|
||||||
import org.jetbrains.plugins.template.services.MyProjectService
|
|
||||||
|
|
||||||
class MyToolWindowFactory : ToolWindowFactory, DumbAware {
|
class MyToolWindowFactory : ToolWindowFactory, DumbAware {
|
||||||
|
|
||||||
override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) {
|
override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) {
|
||||||
val myToolWindow = MyToolWindow()
|
toolWindow.addComposeTab("Weather App") { WeatherAppSample() }
|
||||||
val content = ContentFactory.getInstance().createContent(myToolWindow.getContent(), null, false)
|
toolWindow.addComposeTab("Chat App") { ChatAppSample() }
|
||||||
toolWindow.contentManager.addContent(content)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun shouldBeAvailable(project: Project) = true
|
override fun shouldBeAvailable(project: Project) = true
|
||||||
|
|
||||||
class MyToolWindow() {
|
|
||||||
private val service = service<MyProjectService>()
|
|
||||||
|
|
||||||
fun getContent() = JewelComposePanel {
|
|
||||||
Column(Modifier.fillMaxWidth().padding(16.dp)) {
|
|
||||||
var param by remember { mutableStateOf("?") }
|
|
||||||
Text(ComposeTemplateBundle.message("randomLabel", param))
|
|
||||||
Spacer(Modifier.height(8.dp))
|
|
||||||
DefaultButton(onClick = {
|
|
||||||
param = service.getRandomNumber().toString()
|
|
||||||
}) {
|
|
||||||
Text(ComposeTemplateBundle.message("shuffle"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,24 @@
|
|||||||
|
package org.jetbrains.plugins.template.ui
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.heightIn
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import org.jetbrains.jewel.foundation.theme.JewelTheme
|
||||||
|
import org.jetbrains.jewel.ui.component.Text
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun ChatAppSample() {
|
||||||
|
Column(Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.heightIn(20.dp)
|
||||||
|
.padding(16.dp)) {
|
||||||
|
Text(
|
||||||
|
"Not yet implemented",
|
||||||
|
style = JewelTheme.defaultTextStyle
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
package org.jetbrains.plugins.template.ui
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.*
|
||||||
|
import androidx.compose.runtime.*
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import org.jetbrains.jewel.foundation.theme.JewelTheme
|
||||||
|
import org.jetbrains.jewel.ui.component.Text
|
||||||
|
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun WeatherAppSample() {
|
||||||
|
Column(Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.heightIn(20.dp)
|
||||||
|
.padding(16.dp)) {
|
||||||
|
Text(
|
||||||
|
"Not yet implemented",
|
||||||
|
style = JewelTheme.defaultTextStyle
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user