马良AI写作初始化仓库

This commit is contained in:
邓滨杰
2025-09-10 00:07:52 +08:00
parent 3c06bb1a03
commit 39c0f8840f
1309 changed files with 318528 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
import 'package:flutter/material.dart';
class ChapterCountField extends StatelessWidget {
final int value;
final int min;
final int max;
final ValueChanged<int> onChanged;
final String title;
final String description;
const ChapterCountField({
super.key,
required this.value,
this.min = 1,
this.max = 12,
required this.onChanged,
this.title = '章节数量',
this.description = '生成的章节数(黄金三章=3可自定义',
});
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(title, style: Theme.of(context).textTheme.titleSmall),
const SizedBox(height: 6),
Text(description, style: Theme.of(context).textTheme.bodySmall?.copyWith(color: Theme.of(context).hintColor)),
const SizedBox(height: 8),
Row(
children: [
Expanded(
child: Slider(
min: min.toDouble(),
max: max.toDouble(),
divisions: (max - min),
value: value.toDouble().clamp(min.toDouble(), max.toDouble()),
label: '$value',
onChanged: (v) => onChanged(v.round()),
),
),
SizedBox(
width: 48,
child: Text('$value', textAlign: TextAlign.center),
),
],
),
],
);
}
}

View File

@@ -0,0 +1,99 @@
import 'package:flutter/material.dart';
class ChapterLengthField extends StatefulWidget {
final String? preset; // 'short' | 'medium' | 'long' | null
final String? customLength;
final ValueChanged<String?> onPresetChanged;
final ValueChanged<String> onCustomChanged;
final String title;
final String description;
const ChapterLengthField({
super.key,
this.preset,
this.customLength,
required this.onPresetChanged,
required this.onCustomChanged,
this.title = '每章长度',
this.description = '每章期望长度(短/中/长)或自定义字数',
});
@override
State<ChapterLengthField> createState() => _ChapterLengthFieldState();
}
class _ChapterLengthFieldState extends State<ChapterLengthField> {
late TextEditingController _controller;
String? _preset;
@override
void initState() {
super.initState();
_preset = widget.preset;
_controller = TextEditingController(text: widget.customLength ?? '');
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(widget.title, style: Theme.of(context).textTheme.titleSmall),
const SizedBox(height: 6),
Text(widget.description, style: Theme.of(context).textTheme.bodySmall?.copyWith(color: Theme.of(context).hintColor)),
const SizedBox(height: 8),
Wrap(
spacing: 8,
runSpacing: 8,
children: [
ChoiceChip(
label: const Text(''),
selected: _preset == 'short',
onSelected: (_) {
setState(() { _preset = 'short'; _controller.clear(); });
widget.onPresetChanged('short');
},
),
ChoiceChip(
label: const Text(''),
selected: _preset == 'medium',
onSelected: (_) {
setState(() { _preset = 'medium'; _controller.clear(); });
widget.onPresetChanged('medium');
},
),
ChoiceChip(
label: const Text(''),
selected: _preset == 'long',
onSelected: (_) {
setState(() { _preset = 'long'; _controller.clear(); });
widget.onPresetChanged('long');
},
),
],
),
const SizedBox(height: 8),
TextField(
controller: _controller,
decoration: const InputDecoration(
border: OutlineInputBorder(),
hintText: '自定义字数,如 2000 字',
),
onChanged: (v) {
setState(() { _preset = null; });
widget.onCustomChanged(v);
},
),
],
);
}
}

View File

@@ -0,0 +1,47 @@
import 'package:flutter/material.dart';
class IncludeDepthField extends StatelessWidget {
final String value; // 'summaryOnly' | 'full'
final ValueChanged<String> onChanged;
final String title;
final String description;
const IncludeDepthField({
super.key,
required this.value,
required this.onChanged,
this.title = '上下文深度',
this.description = '选择将设定或既有内容以摘要或全文形式纳入上下文',
});
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(title, style: Theme.of(context).textTheme.titleSmall),
const SizedBox(height: 6),
Text(description, style: Theme.of(context).textTheme.bodySmall?.copyWith(color: Theme.of(context).hintColor)),
const SizedBox(height: 8),
Wrap(
spacing: 8,
children: [
ChoiceChip(
label: const Text('仅摘要'),
selected: value == 'summaryOnly',
onSelected: (_) => onChanged('summaryOnly'),
),
ChoiceChip(
label: const Text('全文'),
selected: value == 'full',
onSelected: (_) => onChanged('full'),
),
],
),
],
);
}
}