Skip to content

Commit d5c89cc

Browse files
committed
feat(harmonyos): add support for parsing select text
Add support for parsing the selected text in the `AutoArkUi` class. This allows for further manipulation and processing of the selected text for the HarmonyOS project. Also, introduce an enum class `ComponentType` to define different types of components with their descriptions and example usage. Add a sample XML file for testing purposes in the `exts/ext-harmonyos/src/test/resources` directory.
1 parent 62042f1 commit d5c89cc

File tree

2 files changed

+33
-11
lines changed

2 files changed

+33
-11
lines changed

exts/ext-harmonyos/src/main/kotlin/cc/unitmesh/harmonyos/actions/AndroidPageToArkUiAction.kt

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class AndroidPageToArkUiAction : ChatBaseIntention() {
2626

2727
sendToChatPanel(project) { contentPanel, _ ->
2828
val llmProvider = LlmFactory().create(project)
29-
// val context = AutoPageContext.build(reactAutoPage, language, frameworks)
29+
// val context = AutoPageContext.build(reactAutoPage, language, frameworks)
3030
// val prompter = AutoPageFlow(context, contentPanel, llmProvider)
3131
//
3232
// ProgressManager.getInstance()
@@ -36,22 +36,23 @@ class AndroidPageToArkUiAction : ChatBaseIntention() {
3636
}
3737

3838
class AutoArkUi(project: Project, selectedText: @NlsSafe String, editor: Editor) {
39-
39+
// parse select text
4040
}
4141

42-
data class Component(val name: String, val type: String, val example: String) {
43-
fun list() {
44-
val button = Component("Button", "Button", "Button('Ok', { type: ButtonType.Normal, stateEffect: true }) \n" +
42+
enum class ComponentType(description: String, example: String) {
43+
Button(
44+
"Button", "Button('Ok', { type: ButtonType.Normal, stateEffect: true }) \n" +
4545
" .borderRadius(8) \n" +
4646
" .backgroundColor(0x317aff) \n" +
4747
" .width(90)\n" +
48-
" .height(40)")
49-
50-
val radio = Component("Radio", "Radio", " Radio({ value: 'Radio1', group: 'radioGroup' })\n" +
48+
" .height(40)"
49+
),
50+
Radio(
51+
"Radio", " Radio({ value: 'Radio1', group: 'radioGroup' })\n" +
5152
" .onChange((isChecked: boolean) => {\n" +
5253
" if(isChecked) {\n" +
5354
" //需要执行的操作\n" +
5455
" }\n" +
55-
" })")
56-
}
57-
}
56+
" })"
57+
)
58+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
android:orientation="vertical">
6+
<TextView android:id="@+id/text"
7+
android:layout_width="wrap_content"
8+
android:layout_height="wrap_content"
9+
android:layout_margin="16dp"
10+
android:padding="8dp"
11+
android:text="Hello, I am a TextView"/>
12+
<Button android:id="@+id/button"
13+
android:layout_width="wrap_content"
14+
android:layout_height="wrap_content"
15+
android:layout_marginTop="16dp"
16+
android:paddingBottom="4dp"
17+
android:paddingEnd="8dp"
18+
android:paddingStart="8dp"
19+
android:paddingTop="4dp"
20+
android:text="Hello, I am a Button"/>
21+
</LinearLayout>

0 commit comments

Comments
 (0)