generated from dellevin/template
ok了老铁
This commit is contained in:
@@ -410,6 +410,12 @@ class _NoteFormPageState extends State<NoteFormPage> {
|
||||
void _showAddTagDialog() {
|
||||
final controller = TextEditingController();
|
||||
|
||||
// 获取所有已有标签(从所有笔记中收集)
|
||||
final provider = context.read<AppProvider>();
|
||||
final allTags = _getAllExistingTags(provider);
|
||||
// 过滤掉已添加的标签
|
||||
final availableTags = allTags.where((tag) => !_tags.contains(tag)).toList();
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
@@ -423,17 +429,67 @@ class _NoteFormPageState extends State<NoteFormPage> {
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
content: TextField(
|
||||
controller: controller,
|
||||
autofocus: true,
|
||||
decoration: const InputDecoration(
|
||||
hintText: '输入标签名称',
|
||||
border: UnderlineInputBorder(),
|
||||
content: SizedBox(
|
||||
width: double.maxFinite,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 输入框
|
||||
TextField(
|
||||
controller: controller,
|
||||
autofocus: true,
|
||||
decoration: const InputDecoration(
|
||||
hintText: '输入新标签名称',
|
||||
border: UnderlineInputBorder(),
|
||||
),
|
||||
onSubmitted: (value) {
|
||||
_addTag(value);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
|
||||
// 已有标签列表
|
||||
if (availableTags.isNotEmpty) ...[
|
||||
const SizedBox(height: 16),
|
||||
const Text(
|
||||
'或选择已有标签:',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Color(0xFF999999),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: availableTags.map((tag) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
_addTag(tag);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFF5F5F5),
|
||||
border: Border.all(color: const Color(0xFFE5E5E5)),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Text(
|
||||
tag,
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFF666666),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
onSubmitted: (value) {
|
||||
_addTag(value);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
@@ -451,6 +507,15 @@ class _NoteFormPageState extends State<NoteFormPage> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 获取所有已有标签(从所有笔记中收集)
|
||||
List<String> _getAllExistingTags(AppProvider provider) {
|
||||
final allTags = <String>{};
|
||||
for (final note in provider.notes) {
|
||||
allTags.addAll(note.tags);
|
||||
}
|
||||
return allTags.toList()..sort();
|
||||
}
|
||||
|
||||
/// 添加标签
|
||||
void _addTag(String tag) {
|
||||
|
||||
@@ -53,7 +53,7 @@ class _WebDAVSyncPageState extends State<WebDAVSyncPage> {
|
||||
try {
|
||||
if (value) {
|
||||
await WebDAVService.instance.startAutoSync();
|
||||
ToastUtil.show(context, '自动备份已开启,每2分钟执行一次');
|
||||
ToastUtil.show(context, '自动备份已开启,每5分钟执行一次');
|
||||
} else {
|
||||
await WebDAVService.instance.stopAutoSync();
|
||||
ToastUtil.show(context, '自动备份已关闭');
|
||||
@@ -386,7 +386,7 @@ class _WebDAVSyncPageState extends State<WebDAVSyncPage> {
|
||||
),
|
||||
SizedBox(height: 2),
|
||||
Text(
|
||||
'每2分钟自动备份一次,保留最近10个备份',
|
||||
'每5分钟自动备份一次,保留最近10个备份',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Color(0xFF999999),
|
||||
|
||||
Reference in New Issue
Block a user