feat: 重构提示词选择区布局,快捷按钮与下拉框同排,显示提示词名称和内容,结果区改为'大模型返回结果'
This commit is contained in:
@@ -190,36 +190,57 @@ impl FlomoAiApp {
|
||||
|
||||
ui.separator();
|
||||
|
||||
ui.label(egui::RichText::new("快速操作").size(11.0).color(egui::Color32::GRAY));
|
||||
ui.add_space(6.0);
|
||||
|
||||
// 提示词选择区:左侧标签+下拉框,右侧快捷按钮
|
||||
ui.horizontal(|ui| {
|
||||
let buttons = vec![
|
||||
("🔍", "检查错别字"),
|
||||
("📋", "总结"),
|
||||
("🌐", "翻译"),
|
||||
("✨", "润色"),
|
||||
];
|
||||
ui.vertical(|ui| {
|
||||
ui.label(egui::RichText::new("提示词").size(11.0).color(egui::Color32::GRAY));
|
||||
ui.add_space(4.0);
|
||||
|
||||
for (emoji, name) in buttons {
|
||||
let btn = egui::Button::new(egui::RichText::new(emoji).size(16.0))
|
||||
.fill(ui.style().visuals.widgets.inactive.bg_fill)
|
||||
.stroke(egui::Stroke::new(1.0, egui::Color32::from_rgb(210, 210, 220)))
|
||||
.rounding(6.0)
|
||||
.min_size(egui::vec2(36.0, 36.0));
|
||||
let selected_text = if self.selected_prompt_index == 0 {
|
||||
"无系统提示词".to_string()
|
||||
} else if self.selected_prompt_index <= self.settings.prompt_configs.len() {
|
||||
self.settings.prompt_configs[self.selected_prompt_index - 1].title.clone()
|
||||
} else {
|
||||
"无系统提示词".to_string()
|
||||
};
|
||||
|
||||
if ui.add(btn).on_hover_text(name).clicked() {
|
||||
self.select_prompt_by_name(name, ctx);
|
||||
egui::ComboBox::from_id_salt("prompt_selector")
|
||||
.selected_text(&selected_text)
|
||||
.width(180.0)
|
||||
.show_ui(ui, |ui| {
|
||||
ui.selectable_value(&mut self.selected_prompt_index, 0, "无系统提示词");
|
||||
for (i, prompt) in self.settings.prompt_configs.iter().enumerate() {
|
||||
ui.selectable_value(&mut self.selected_prompt_index, i + 1, &prompt.title);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
let buttons = vec![
|
||||
("🔍", "检查错别字"),
|
||||
("📋", "总结"),
|
||||
("🌐", "翻译"),
|
||||
("✨", "润色"),
|
||||
];
|
||||
|
||||
for (emoji, name) in buttons {
|
||||
let btn = egui::Button::new(egui::RichText::new(emoji).size(16.0))
|
||||
.fill(ui.style().visuals.widgets.inactive.bg_fill)
|
||||
.stroke(egui::Stroke::new(1.0, egui::Color32::from_rgb(210, 210, 220)))
|
||||
.rounding(6.0)
|
||||
.min_size(egui::vec2(36.0, 36.0));
|
||||
|
||||
if ui.add(btn).on_hover_text(name).clicked() {
|
||||
self.select_prompt_by_name(name, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
ui.add_space(14.0);
|
||||
|
||||
ui.label(egui::RichText::new("提示词").size(11.0).color(egui::Color32::GRAY));
|
||||
ui.add_space(6.0);
|
||||
|
||||
let selected_text = if self.selected_prompt_index == 0 {
|
||||
// 提示词详情:显示名称和内容
|
||||
let prompt_name = if self.selected_prompt_index == 0 {
|
||||
"无系统提示词".to_string()
|
||||
} else if self.selected_prompt_index <= self.settings.prompt_configs.len() {
|
||||
self.settings.prompt_configs[self.selected_prompt_index - 1].title.clone()
|
||||
@@ -227,17 +248,6 @@ impl FlomoAiApp {
|
||||
"无系统提示词".to_string()
|
||||
};
|
||||
|
||||
egui::ComboBox::from_id_salt("prompt_selector")
|
||||
.selected_text(&selected_text)
|
||||
.show_ui(ui, |ui| {
|
||||
ui.selectable_value(&mut self.selected_prompt_index, 0, "无系统提示词");
|
||||
for (i, prompt) in self.settings.prompt_configs.iter().enumerate() {
|
||||
ui.selectable_value(&mut self.selected_prompt_index, i + 1, &prompt.title);
|
||||
}
|
||||
});
|
||||
|
||||
ui.separator();
|
||||
|
||||
let prompt_content = if self.selected_prompt_index == 0 {
|
||||
"无特殊指令".to_string()
|
||||
} else if self.selected_prompt_index <= self.settings.prompt_configs.len() {
|
||||
@@ -246,10 +256,23 @@ impl FlomoAiApp {
|
||||
"无特殊指令".to_string()
|
||||
};
|
||||
|
||||
ui.label(egui::RichText::new(&prompt_content).size(11.0).color(egui::Color32::GRAY));
|
||||
egui::Frame::none()
|
||||
.fill(ui.style().visuals.widgets.inactive.bg_fill)
|
||||
.stroke(egui::Stroke::new(1.0, egui::Color32::from_rgb(210, 210, 220)))
|
||||
.rounding(6.0)
|
||||
.inner_margin(egui::Margin::same(12.0))
|
||||
.show(ui, |ui: &mut egui::Ui| {
|
||||
ui.label(egui::RichText::new(&prompt_name).size(13.0).strong());
|
||||
ui.add_space(6.0);
|
||||
ui.add_sized([ui.available_width(), 1.0], egui::Separator::default());
|
||||
ui.add_space(6.0);
|
||||
ui.label(egui::RichText::new(&prompt_content).size(11.0).color(egui::Color32::GRAY));
|
||||
});
|
||||
|
||||
ui.add_space(14.0);
|
||||
|
||||
ui.label(egui::RichText::new("输入").size(11.0).color(egui::Color32::GRAY));
|
||||
// 大模型返回结果
|
||||
ui.label(egui::RichText::new("大模型返回结果").size(11.0).color(egui::Color32::GRAY));
|
||||
ui.add_space(4.0);
|
||||
|
||||
egui::Frame::none()
|
||||
@@ -293,7 +316,7 @@ impl FlomoAiApp {
|
||||
|
||||
ui.add_space(14.0);
|
||||
|
||||
ui.label(egui::RichText::new("优化结果").size(11.0).color(egui::Color32::GRAY));
|
||||
ui.label(egui::RichText::new("大模型返回结果").size(11.0).color(egui::Color32::GRAY));
|
||||
ui.add_space(6.0);
|
||||
|
||||
let status_text = match &self.status {
|
||||
|
||||
@@ -38,6 +38,7 @@ class MainActivity : AppCompatActivity() {
|
||||
private lateinit var outputStatusLabel: TextView
|
||||
private lateinit var outputTextView: TextView
|
||||
private lateinit var promptSelector: Spinner
|
||||
private lateinit var promptNameText: TextView
|
||||
private lateinit var promptContentText: TextView
|
||||
|
||||
// Data classes matching SecondActivity
|
||||
@@ -61,6 +62,7 @@ class MainActivity : AppCompatActivity() {
|
||||
Log.d("MainActivity", "onCreate: Layout set")
|
||||
|
||||
promptSelector = findViewById<Spinner>(R.id.promptSelector)
|
||||
promptNameText = findViewById<TextView>(R.id.promptNameText)
|
||||
promptContentText = findViewById<TextView>(R.id.promptContentText)
|
||||
inputEditText = findViewById<EditText>(R.id.inputEditText)
|
||||
val sendButton = findViewById<Button>(R.id.sendButton)
|
||||
@@ -90,7 +92,6 @@ class MainActivity : AppCompatActivity() {
|
||||
override fun onItemSelected(parent: android.widget.AdapterView<*>, view: android.view.View?, position: Int, id: Long) {
|
||||
val selectedTitle = promptSelector.getItemAtPosition(position) as String
|
||||
|
||||
// Get the prompt map from tag
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val promptMap = promptSelector.tag as? MutableMap<String, String>
|
||||
|
||||
@@ -100,11 +101,13 @@ class MainActivity : AppCompatActivity() {
|
||||
"无特殊指令"
|
||||
}
|
||||
|
||||
promptNameText.text = selectedTitle
|
||||
promptContentText.text = content
|
||||
Log.d("MainActivity", "Prompt selected: $selectedTitle, content: $content")
|
||||
}
|
||||
|
||||
override fun onNothingSelected(parent: android.widget.AdapterView<*>) {
|
||||
promptNameText.text = "无系统提示词"
|
||||
promptContentText.text = "无特殊指令"
|
||||
}
|
||||
})
|
||||
@@ -349,10 +352,10 @@ class MainActivity : AppCompatActivity() {
|
||||
else -> ""
|
||||
}
|
||||
|
||||
promptNameText.text = promptName
|
||||
promptContentText.text = content
|
||||
Toast.makeText(this, "已选择: $promptName", Toast.LENGTH_SHORT).show()
|
||||
|
||||
// Auto-trigger send if input is not empty
|
||||
if (inputEditText.text.isNotEmpty()) {
|
||||
findViewById<Button>(R.id.sendButton).performClick()
|
||||
}
|
||||
|
||||
@@ -84,102 +84,113 @@
|
||||
android:orientation="vertical"
|
||||
android:padding="20dp">
|
||||
|
||||
<!-- 快速操作 -->
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="快速操作"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@color/text_hint"
|
||||
android:textAllCaps="true"
|
||||
android:letterSpacing="0.15"
|
||||
android:layout_marginBottom="14dp"/>
|
||||
|
||||
<!-- 提示词选择区:左侧标签+下拉框,右侧快捷按钮 -->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_marginBottom="18dp">
|
||||
android:gravity="center_vertical"
|
||||
android:layout_marginBottom="14dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/btnCheckTypos"
|
||||
android:layout_width="34dp"
|
||||
android:layout_height="34dp"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/button_quick_bg"
|
||||
android:layout_marginEnd="10dp">
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:text="🔍"
|
||||
android:textSize="14sp"
|
||||
android:gravity="center"/>
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="提示词"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@color/text_hint"
|
||||
android:textAllCaps="true"
|
||||
android:letterSpacing="0.15"/>
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/promptSelector"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="36dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:spinnerMode="dropdown"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/btnSummarize"
|
||||
android:layout_width="34dp"
|
||||
android:layout_height="34dp"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/button_quick_bg"
|
||||
android:layout_marginEnd="10dp">
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:text="📋"
|
||||
android:textSize="14sp"
|
||||
android:gravity="center"/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/btnCheckTypos"
|
||||
android:layout_width="34dp"
|
||||
android:layout_height="34dp"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/button_quick_bg"
|
||||
android:layout_marginEnd="6dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/btnTranslate"
|
||||
android:layout_width="34dp"
|
||||
android:layout_height="34dp"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/button_quick_bg"
|
||||
android:layout_marginEnd="10dp">
|
||||
<TextView
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:text="🔍"
|
||||
android:textSize="14sp"
|
||||
android:gravity="center"/>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:text="🌐"
|
||||
android:textSize="14sp"
|
||||
android:gravity="center"/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/btnSummarize"
|
||||
android:layout_width="34dp"
|
||||
android:layout_height="34dp"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/button_quick_bg"
|
||||
android:layout_marginEnd="6dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/btnPolishing"
|
||||
android:layout_width="34dp"
|
||||
android:layout_height="34dp"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/button_quick_bg">
|
||||
<TextView
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:text="📋"
|
||||
android:textSize="14sp"
|
||||
android:gravity="center"/>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:text="✨"
|
||||
android:textSize="14sp"
|
||||
android:gravity="center"/>
|
||||
<LinearLayout
|
||||
android:id="@+id/btnTranslate"
|
||||
android:layout_width="34dp"
|
||||
android:layout_height="34dp"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/button_quick_bg"
|
||||
android:layout_marginEnd="6dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:text="🌐"
|
||||
android:textSize="14sp"
|
||||
android:gravity="center"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/btnPolishing"
|
||||
android:layout_width="34dp"
|
||||
android:layout_height="34dp"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/button_quick_bg">
|
||||
|
||||
<TextView
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:text="✨"
|
||||
android:textSize="14sp"
|
||||
android:gravity="center"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<!-- 提示词 -->
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="提示词"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@color/text_hint"
|
||||
android:textAllCaps="true"
|
||||
android:letterSpacing="0.15"
|
||||
android:layout_marginBottom="14dp"/>
|
||||
|
||||
<!-- 提示词详情:显示名称和内容 -->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -188,13 +199,14 @@
|
||||
android:padding="14dp"
|
||||
android:layout_marginBottom="18dp">
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/promptSelector"
|
||||
<TextView
|
||||
android:id="@+id/promptNameText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:spinnerMode="dropdown"
|
||||
android:padding="4dp"/>
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="13sp"
|
||||
android:textColor="@color/text_secondary"
|
||||
android:textStyle="bold"
|
||||
android:text="无系统提示词"/>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
@@ -210,14 +222,15 @@
|
||||
android:textSize="12sp"
|
||||
android:textColor="@color/text_hint"
|
||||
android:minLines="1"
|
||||
android:maxLines="3"/>
|
||||
android:maxLines="3"
|
||||
android:text="无特殊指令"/>
|
||||
</LinearLayout>
|
||||
|
||||
<!-- 优化结果 -->
|
||||
<!-- 大模型返回结果 -->
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="优化结果"
|
||||
android:text="大模型返回结果"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@color/text_hint"
|
||||
android:textAllCaps="true"
|
||||
|
||||
Reference in New Issue
Block a user