|
|
|
@ -10,16 +10,36 @@ class TemplateEditView extends StatefulWidget { |
|
|
|
} |
|
|
|
|
|
|
|
class _TemplateEditViewState extends State<TemplateEditView> { |
|
|
|
TextEditingController titleController = TextEditingController(); |
|
|
|
final TextEditingController _nameController = TextEditingController(); |
|
|
|
final TextEditingController _descController = TextEditingController(); |
|
|
|
final TextEditingController _promptController = TextEditingController(); |
|
|
|
|
|
|
|
bool _isEnable = false; |
|
|
|
|
|
|
|
@override |
|
|
|
void initState() { |
|
|
|
super.initState(); |
|
|
|
} |
|
|
|
|
|
|
|
@override |
|
|
|
void dispose() { |
|
|
|
_nameController.dispose(); |
|
|
|
_descController.dispose(); |
|
|
|
_promptController.dispose(); |
|
|
|
super.dispose(); |
|
|
|
} |
|
|
|
|
|
|
|
@override |
|
|
|
Widget build(BuildContext context) { |
|
|
|
final isDarkMode = Theme.of(context).brightness == Brightness.dark; |
|
|
|
|
|
|
|
return Scaffold( |
|
|
|
backgroundColor: isDarkMode ? Colors.black : Colors.grey[50], |
|
|
|
appBar: _buildAppBar(isDarkMode), |
|
|
|
body: _buildBody(isDarkMode), |
|
|
|
return GestureDetector( |
|
|
|
onTap: () => FocusScope.of(context).unfocus(), |
|
|
|
child: Scaffold( |
|
|
|
backgroundColor: isDarkMode ? Colors.black : Colors.grey[50], |
|
|
|
appBar: _buildAppBar(isDarkMode), |
|
|
|
body: _buildBody(isDarkMode), |
|
|
|
), |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
@ -54,18 +74,38 @@ class _TemplateEditViewState extends State<TemplateEditView> { |
|
|
|
children: [ |
|
|
|
Expanded( |
|
|
|
child: ListView( |
|
|
|
children: [], |
|
|
|
padding: EdgeInsets.symmetric(horizontal: 12.w), |
|
|
|
children: [ |
|
|
|
_input(isDarkMode, '名称', _nameController), |
|
|
|
_input(isDarkMode, '描述', _descController), |
|
|
|
_input( |
|
|
|
isDarkMode, |
|
|
|
'模版', |
|
|
|
_promptController, |
|
|
|
minLines: 8, |
|
|
|
maxLines: 100, |
|
|
|
hintText: '请输入模版内容!温馨提示:点击上方AI,根据上面填写的名称和描述,可以帮助你快速生成模版内容', |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
Padding( |
|
|
|
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 20.w), |
|
|
|
child: GestureDetector( |
|
|
|
onTap: () {}, |
|
|
|
onTap: () { |
|
|
|
if (_nameController.text.isNotEmpty && |
|
|
|
_descController.text.isNotEmpty && |
|
|
|
_promptController.text.isNotEmpty) {} |
|
|
|
}, |
|
|
|
child: Container( |
|
|
|
height: 48.w, |
|
|
|
alignment: Alignment.center, |
|
|
|
decoration: BoxDecoration( |
|
|
|
color: Colors.black, |
|
|
|
color: _nameController.text.isNotEmpty && |
|
|
|
_descController.text.isNotEmpty && |
|
|
|
_promptController.text.isNotEmpty |
|
|
|
? Colors.black |
|
|
|
: Colors.grey, |
|
|
|
borderRadius: BorderRadius.circular(12.r), |
|
|
|
), |
|
|
|
child: Text( |
|
|
|
@ -81,4 +121,77 @@ class _TemplateEditViewState extends State<TemplateEditView> { |
|
|
|
], |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
Widget _input( |
|
|
|
bool isDarkMode, |
|
|
|
String title, |
|
|
|
TextEditingController controller, { |
|
|
|
int minLines = 1, |
|
|
|
int maxLines = 1, |
|
|
|
String? hintText, |
|
|
|
}) { |
|
|
|
return Column( |
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
children: [ |
|
|
|
Padding( |
|
|
|
padding: EdgeInsets.only(left: 10.w), |
|
|
|
child: Text( |
|
|
|
title, |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 14.sp, |
|
|
|
color: isDarkMode ? Colors.white60 : Colors.black87, |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
Container( |
|
|
|
margin: EdgeInsets.only(top: 10.w, bottom: 20.w), |
|
|
|
alignment: Alignment.center, |
|
|
|
decoration: BoxDecoration( |
|
|
|
color: Colors.white, |
|
|
|
borderRadius: BorderRadius.circular(12.w), |
|
|
|
boxShadow: [ |
|
|
|
BoxShadow( |
|
|
|
color: Colors.black.withValues(alpha: 0.05), |
|
|
|
blurRadius: 10, |
|
|
|
offset: const Offset(0, 2), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
child: TextField( |
|
|
|
controller: controller, |
|
|
|
minLines: minLines, |
|
|
|
maxLines: maxLines, |
|
|
|
style: TextStyle( |
|
|
|
color: Colors.black87, |
|
|
|
fontSize: 14.sp, |
|
|
|
), |
|
|
|
decoration: InputDecoration( |
|
|
|
hintText: hintText ?? '请输入$title', |
|
|
|
hintStyle: TextStyle( |
|
|
|
color: Colors.black54, |
|
|
|
fontSize: 14.sp, |
|
|
|
), |
|
|
|
isDense: true, |
|
|
|
fillColor: Colors.transparent, |
|
|
|
border: InputBorder.none, |
|
|
|
contentPadding: EdgeInsets.all(10.w), |
|
|
|
), |
|
|
|
onChanged: (value) { |
|
|
|
bool isEnable = false; |
|
|
|
if (_nameController.text.isNotEmpty && |
|
|
|
_descController.text.isNotEmpty && |
|
|
|
_promptController.text.isNotEmpty) { |
|
|
|
isEnable = true; |
|
|
|
} |
|
|
|
if (_isEnable != isEnable) { |
|
|
|
setState(() { |
|
|
|
_isEnable = isEnable; |
|
|
|
}); |
|
|
|
} |
|
|
|
}, |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|