|
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; |
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
import 'package:get/get.dart'; |
|
|
import 'package:get/get.dart'; |
|
|
|
|
|
|
|
|
|
|
|
import '../../controllers/meeting_details_controller.dart'; |
|
|
import 'template_all_view.dart'; |
|
|
import 'template_all_view.dart'; |
|
|
import 'template_details_view.dart'; |
|
|
import 'template_details_view.dart'; |
|
|
import 'template_edit_view.dart'; |
|
|
import 'template_edit_view.dart'; |
|
|
@ -9,16 +10,16 @@ import 'template_edit_view.dart'; |
|
|
class TemplateView extends StatefulWidget { |
|
|
class TemplateView extends StatefulWidget { |
|
|
final Map templateData; |
|
|
final Map templateData; |
|
|
final int lastTemplateId; |
|
|
final int lastTemplateId; |
|
|
final List categoryList; |
|
|
|
|
|
|
|
|
|
|
|
const TemplateView(this.templateData, this.lastTemplateId, this.categoryList, |
|
|
const TemplateView(this.templateData, this.lastTemplateId, {super.key}); |
|
|
{super.key}); |
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
@override |
|
|
State<TemplateView> createState() => _TemplateViewState(); |
|
|
State<TemplateView> createState() => _TemplateViewState(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
class _TemplateViewState extends State<TemplateView> { |
|
|
class _TemplateViewState extends State<TemplateView> { |
|
|
|
|
|
final _controller = Get.find<MeetingDetailsController>(); |
|
|
|
|
|
|
|
|
final Map _icons = { |
|
|
final Map _icons = { |
|
|
'auto_stories': Icons.auto_stories, |
|
|
'auto_stories': Icons.auto_stories, |
|
|
'auto_graph': Icons.auto_graph, |
|
|
'auto_graph': Icons.auto_graph, |
|
|
@ -38,7 +39,7 @@ class _TemplateViewState extends State<TemplateView> { |
|
|
'auto_fix_high': Icons.auto_fix_high, |
|
|
'auto_fix_high': Icons.auto_fix_high, |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
final List _categoryTemplateList = []; |
|
|
List _categoryTemplateList = []; |
|
|
Map _templateData = {}; |
|
|
Map _templateData = {}; |
|
|
|
|
|
|
|
|
@override |
|
|
@override |
|
|
@ -47,8 +48,9 @@ class _TemplateViewState extends State<TemplateView> { |
|
|
_getTemplate(); |
|
|
_getTemplate(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void _getTemplate() async { |
|
|
void _getTemplate() { |
|
|
for (var element in widget.categoryList) { |
|
|
_categoryTemplateList = []; |
|
|
|
|
|
for (var element in _controller.categoryTemplateList) { |
|
|
List templateList = []; |
|
|
List templateList = []; |
|
|
bool isAdd = false; |
|
|
bool isAdd = false; |
|
|
if (element['id'] == widget.templateData['categoryid']) { |
|
|
if (element['id'] == widget.templateData['categoryid']) { |
|
|
@ -71,7 +73,28 @@ class _TemplateViewState extends State<TemplateView> { |
|
|
'template': templateList, |
|
|
'template': templateList, |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
_templateData = widget.templateData; |
|
|
setState(() { |
|
|
|
|
|
_templateData = widget.templateData; |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void _returnCallback() { |
|
|
|
|
|
if (_controller.editTemplate.isNotEmpty) { |
|
|
|
|
|
_getTemplate(); |
|
|
|
|
|
if (_controller.editTemplate['id'] == _templateData['id']) { |
|
|
|
|
|
_templateData['name'] = _controller.editTemplate['name']; |
|
|
|
|
|
_templateData['desc'] = _controller.editTemplate['desc']; |
|
|
|
|
|
_templateData['prompt'] = _controller.editTemplate['prompt']; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (_controller.deleteTemplateId != 0) { |
|
|
|
|
|
_getTemplate(); |
|
|
|
|
|
if (_controller.deleteTemplateId == _templateData['id']) { |
|
|
|
|
|
_templateData = {}; |
|
|
|
|
|
} |
|
|
|
|
|
_categoryTemplateList.last['template'].removeWhere( |
|
|
|
|
|
(element) => element['id'] == _controller.deleteTemplateId); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@override |
|
|
@override |
|
|
@ -127,13 +150,15 @@ class _TemplateViewState extends State<TemplateView> { |
|
|
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 20.w), |
|
|
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 20.w), |
|
|
child: GestureDetector( |
|
|
child: GestureDetector( |
|
|
onTap: () { |
|
|
onTap: () { |
|
|
Get.back(result: _templateData); |
|
|
if (_templateData.isNotEmpty) { |
|
|
|
|
|
Get.back(result: _templateData); |
|
|
|
|
|
} |
|
|
}, |
|
|
}, |
|
|
child: Container( |
|
|
child: Container( |
|
|
height: 48.w, |
|
|
height: 48.w, |
|
|
alignment: Alignment.center, |
|
|
alignment: Alignment.center, |
|
|
decoration: BoxDecoration( |
|
|
decoration: BoxDecoration( |
|
|
color: Colors.black, |
|
|
color: _templateData.isNotEmpty ? Colors.black : Colors.grey, |
|
|
borderRadius: BorderRadius.circular(12.r), |
|
|
borderRadius: BorderRadius.circular(12.r), |
|
|
), |
|
|
), |
|
|
child: Text( |
|
|
child: Text( |
|
|
@ -155,13 +180,14 @@ class _TemplateViewState extends State<TemplateView> { |
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
children: [ |
|
|
children: [ |
|
|
GestureDetector( |
|
|
GestureDetector( |
|
|
onTap: () { |
|
|
onTap: () async { |
|
|
Get.to(() => TemplateAllView( |
|
|
await Get.to(() => TemplateAllView( |
|
|
data['name'], |
|
|
data['name'], |
|
|
data['id'], |
|
|
data['id'], |
|
|
_templateData, |
|
|
_templateData, |
|
|
widget.lastTemplateId, |
|
|
widget.lastTemplateId, |
|
|
)); |
|
|
)); |
|
|
|
|
|
_returnCallback(); |
|
|
}, |
|
|
}, |
|
|
child: Padding( |
|
|
child: Padding( |
|
|
padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 10.w), |
|
|
padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 10.w), |
|
|
@ -189,7 +215,7 @@ class _TemplateViewState extends State<TemplateView> { |
|
|
child: isLast && data['template'].length == 0 |
|
|
child: isLast && data['template'].length == 0 |
|
|
? Padding( |
|
|
? Padding( |
|
|
padding: EdgeInsets.symmetric(horizontal: 8.w), |
|
|
padding: EdgeInsets.symmetric(horizontal: 8.w), |
|
|
child: _createTemplate(), |
|
|
child: _createTemplate(data['id']), |
|
|
) |
|
|
) |
|
|
: ListView.builder( |
|
|
: ListView.builder( |
|
|
itemCount: data['template'].length, |
|
|
itemCount: data['template'].length, |
|
|
@ -200,11 +226,11 @@ class _TemplateViewState extends State<TemplateView> { |
|
|
return isLast && index == 0 |
|
|
return isLast && index == 0 |
|
|
? Row( |
|
|
? Row( |
|
|
children: [ |
|
|
children: [ |
|
|
_createTemplate(), |
|
|
_createTemplate(data['id']), |
|
|
_template(template), |
|
|
_template(template, true), |
|
|
], |
|
|
], |
|
|
) |
|
|
) |
|
|
: _template(template); |
|
|
: _template(template, false); |
|
|
}, |
|
|
}, |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
@ -212,7 +238,7 @@ class _TemplateViewState extends State<TemplateView> { |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Widget _template(Map template) { |
|
|
Widget _template(Map template, bool isEdit) { |
|
|
return Container( |
|
|
return Container( |
|
|
width: 200.w, |
|
|
width: 200.w, |
|
|
margin: EdgeInsets.symmetric(horizontal: 4.w), |
|
|
margin: EdgeInsets.symmetric(horizontal: 4.w), |
|
|
@ -309,8 +335,10 @@ class _TemplateViewState extends State<TemplateView> { |
|
|
top: 0, |
|
|
top: 0, |
|
|
right: 0, |
|
|
right: 0, |
|
|
child: GestureDetector( |
|
|
child: GestureDetector( |
|
|
onTap: () { |
|
|
onTap: () async { |
|
|
Get.to(() => TemplateDetailsView(template)); |
|
|
await Get.to( |
|
|
|
|
|
() => TemplateDetailsView(template, isEdit: isEdit)); |
|
|
|
|
|
_returnCallback(); |
|
|
}, |
|
|
}, |
|
|
child: Padding( |
|
|
child: Padding( |
|
|
padding: EdgeInsets.all(10.w), |
|
|
padding: EdgeInsets.all(10.w), |
|
|
@ -371,10 +399,13 @@ class _TemplateViewState extends State<TemplateView> { |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Widget _createTemplate() { |
|
|
Widget _createTemplate(int categoryid) { |
|
|
return GestureDetector( |
|
|
return GestureDetector( |
|
|
onTap: () { |
|
|
onTap: () async { |
|
|
Get.to(() => const TemplateEditView()); |
|
|
await Get.to(() => TemplateEditView(categoryid: categoryid)); |
|
|
|
|
|
if (_controller.editTemplate.isNotEmpty) { |
|
|
|
|
|
_getTemplate(); |
|
|
|
|
|
} |
|
|
}, |
|
|
}, |
|
|
child: Container( |
|
|
child: Container( |
|
|
width: 200.w, |
|
|
width: 200.w, |
|
|
|