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.

184 lines
5.5 KiB

import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
class TemplateDetailsView extends StatelessWidget {
final Map data;
const TemplateDetailsView(this.data, {super.key});
@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),
);
}
// 构建应用栏
PreferredSizeWidget _buildAppBar(bool isDarkMode) {
return AppBar(
backgroundColor: isDarkMode ? Colors.black : Colors.white,
elevation: 0.5,
leading: IconButton(
icon: Icon(
Icons.arrow_back_ios,
color: isDarkMode ? Colors.white : Colors.black,
size: 20.sp,
),
onPressed: () => Get.back(),
),
title: Text(
'模版详情',
style: TextStyle(
fontSize: 17.sp,
fontWeight: FontWeight.w600,
color: isDarkMode ? Colors.white : Colors.black,
),
),
centerTitle: true,
);
}
// 构建主体内容
Widget _buildBody(bool isDarkMode) {
return Column(
children: [
Expanded(
child: ListView(
padding: EdgeInsets.symmetric(horizontal: 12.w),
children: [
Padding(
padding: EdgeInsets.only(top: 20.w),
child: Text(
data['name'],
style: TextStyle(
fontSize: 20.sp,
fontWeight: FontWeight.bold,
),
),
),
Padding(
padding: EdgeInsets.only(top: 20.w, bottom: 5.w),
child: Text(
'标签',
style: TextStyle(
fontSize: 12.sp,
fontWeight: FontWeight.bold,
),
),
),
Wrap(
spacing: 5.w,
children: List.generate(
data['tag'].length,
(int idx) {
return Container(
padding:
EdgeInsets.symmetric(horizontal: 5.w, vertical: 2.w),
decoration: BoxDecoration(
color: Colors.grey[200],
borderRadius: BorderRadius.circular(4.r),
),
child: Text(
data['tag'][idx],
style: TextStyle(
fontSize: 10.sp,
color: Colors.grey[600],
),
),
);
},
),
),
Padding(
padding: EdgeInsets.only(top: 20.w, bottom: 5.w),
child: Text(
'描述',
style: TextStyle(
fontSize: 12.sp,
fontWeight: FontWeight.bold,
),
),
),
Text(
data['desc'],
style: TextStyle(
fontSize: 14.sp,
color: Colors.grey[600],
),
),
Padding(
padding: EdgeInsets.only(top: 20.w, bottom: 5.w),
child: Text(
'模版',
style: TextStyle(
fontSize: 12.sp,
fontWeight: FontWeight.bold,
),
),
),
MarkdownBody(
data: data['prompt'],
),
],
),
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 20.w),
child: Row(
children: [
Expanded(
child: GestureDetector(
onTap: () {},
child: Container(
height: 48.w,
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.r),
border: Border.all(
color: Colors.black,
),
),
child: Text(
'修改',
style: TextStyle(
fontSize: 16.sp,
color: Colors.black,
),
),
),
),
),
15.horizontalSpace,
Expanded(
child: GestureDetector(
onTap: () {},
child: Container(
height: 48.w,
alignment: Alignment.center,
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(12.r),
),
child: Text(
'删除',
style: TextStyle(
fontSize: 16.sp,
color: Colors.white,
),
),
),
),
),
],
),
),
],
);
}
}