You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
114 lines
3.6 KiB
114 lines
3.6 KiB
2 months ago
|
import 'package:flutter/material.dart';
|
||
|
|
||
|
class TemplateParser extends StatelessWidget {
|
||
|
const TemplateParser({Key? key}) : super(key: key);
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return Card(
|
||
|
margin: EdgeInsets.zero, // 移除默认边距以填满整个区域
|
||
|
color: Colors.grey[100],
|
||
|
child: Column(
|
||
|
children: [
|
||
|
// 四个编辑框区域
|
||
|
Expanded(
|
||
|
child: GridView.builder(
|
||
|
padding: const EdgeInsets.all(8.0),
|
||
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||
|
crossAxisCount: 2,
|
||
|
childAspectRatio: 1.0,
|
||
|
crossAxisSpacing: 8.0,
|
||
|
mainAxisSpacing: 8.0,
|
||
|
),
|
||
|
itemCount: 4,
|
||
|
itemBuilder: (context, index) {
|
||
|
return _buildEditorPanel(context, index);
|
||
|
},
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
|
||
|
Widget _buildEditorPanel(BuildContext context, int index) {
|
||
|
// 定义每个面板的标题
|
||
|
final titles = ['输入内容', '输出内容', '参考文件', '模板'];
|
||
|
|
||
|
return Column(
|
||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||
|
children: [
|
||
|
// 工具条
|
||
|
Container(
|
||
|
padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0),
|
||
|
decoration: BoxDecoration(
|
||
|
color: Colors.grey[100],
|
||
|
borderRadius: const BorderRadius.vertical(top: Radius.circular(4.0)),
|
||
|
),
|
||
|
child: Row(
|
||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||
|
children: [
|
||
|
// 左侧标题
|
||
|
Text(
|
||
|
titles[index],
|
||
|
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 14),
|
||
|
),
|
||
|
// 右侧工具按钮
|
||
|
Row(
|
||
|
mainAxisSize: MainAxisSize.min,
|
||
|
children: [
|
||
|
IconButton(
|
||
|
icon: const Icon(Icons.folder_open, size: 18),
|
||
|
onPressed: () {},
|
||
|
padding: EdgeInsets.zero,
|
||
|
constraints: const BoxConstraints(),
|
||
|
),
|
||
|
IconButton(
|
||
|
icon: const Icon(Icons.content_copy, size: 18),
|
||
|
onPressed: () {},
|
||
|
padding: EdgeInsets.zero,
|
||
|
constraints: const BoxConstraints(),
|
||
|
),
|
||
|
IconButton(
|
||
|
icon: const Icon(Icons.save, size: 18),
|
||
|
onPressed: () {},
|
||
|
padding: EdgeInsets.zero,
|
||
|
constraints: const BoxConstraints(),
|
||
|
),
|
||
|
IconButton(
|
||
|
icon: const Icon(Icons.close, size: 18),
|
||
|
onPressed: () {},
|
||
|
padding: EdgeInsets.zero,
|
||
|
constraints: const BoxConstraints(),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
|
||
|
// 编辑框
|
||
|
Expanded(
|
||
|
child: Container(
|
||
|
decoration: BoxDecoration(
|
||
|
border: Border.all(color: Colors.grey),
|
||
|
borderRadius: const BorderRadius.vertical(bottom: Radius.circular(4.0)),
|
||
|
),
|
||
|
child: const TextField(
|
||
|
maxLines: null,
|
||
|
expands: true,
|
||
|
decoration: InputDecoration(
|
||
|
fillColor: Colors.white,
|
||
|
filled: true,
|
||
|
border: InputBorder.none,
|
||
|
contentPadding: EdgeInsets.all(8.0),
|
||
|
hintText: '输入内容...',
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
);
|
||
|
}
|
||
|
}
|