Clean up: move docs to Obsidian vault, remove outdated md files

This commit is contained in:
2026-04-21 15:54:20 +05:00
parent 448403d7ee
commit 4c50036172
22 changed files with 1295 additions and 2869 deletions
+151
View File
@@ -0,0 +1,151 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import '../providers/gitea_sync_provider.dart';
import '../core/markdown_mindmap_parser.dart';
class GiteaMindmapsListScreen extends ConsumerWidget {
const GiteaMindmapsListScreen({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final state = ref.watch(mindmapSyncProvider);
final notifier = ref.read(mindmapSyncProvider.notifier);
return Scaffold(
appBar: AppBar(
title: const Text('Mindmaps из Gitea'),
actions: [
IconButton(
icon: const Icon(Icons.settings),
onPressed: () => context.pushNamed('gitea-sync'),
),
if (state.isConfigured)
IconButton(
icon: state.isSyncing
? const SizedBox(
width: 20,
height: 20,
child: CircularProgressIndicator(strokeWidth: 2, color: Colors.white),
)
: const Icon(Icons.sync),
onPressed: state.isSyncing ? null : () => notifier.syncFromGitea(),
),
],
),
body: _buildBody(context, state, notifier),
);
}
Widget _buildBody(BuildContext context, MindmapSyncState state, MindmapSyncNotifier notifier) {
if (!state.isConfigured) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(Icons.cloud_off, size: 64, color: Colors.grey),
const SizedBox(height: 16),
const Text('Gitea не настроен'),
const SizedBox(height: 16),
ElevatedButton(
onPressed: () => context.pushNamed('gitea-sync'),
child: const Text('Настроить'),
),
],
),
);
}
if (state.isSyncing && state.cachedMindmaps.isEmpty) {
return const Center(child: CircularProgressIndicator());
}
if (state.error != null && state.cachedMindmaps.isEmpty) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(Icons.error_outline, size: 64, color: Colors.red),
const SizedBox(height: 16),
Text('Ошибка: ${state.error}'),
const SizedBox(height: 16),
ElevatedButton(
onPressed: () => notifier.syncFromGitea(),
child: const Text('Повторить'),
),
],
),
);
}
final mindmaps = state.cachedMindmaps;
if (mindmaps.isEmpty) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(Icons.folder_open, size: 64, color: Colors.grey),
const SizedBox(height: 16),
const Text('Нет mindmaps в кэше'),
const SizedBox(height: 16),
ElevatedButton(
onPressed: () => notifier.syncFromGitea(),
child: const Text('Синхронизировать с Gitea'),
),
],
),
);
}
return ListView.builder(
itemCount: mindmaps.length,
itemBuilder: (context, index) {
final mm = mindmaps[index];
final nodes = MarkdownMindmapParser.parse(mm.content, mm.path);
final rootTitle = nodes.isNotEmpty ? nodes.first.title : mm.path;
return Card(
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
child: ListTile(
leading: CircleAvatar(
backgroundColor: _getColorForPath(mm.path),
child: const Icon(Icons.account_tree, color: Colors.white),
),
title: Text(rootTitle),
subtitle: Text(
'${mm.path}\n'
'${mm.lastSync.toLocal().toString().split('.').first}',
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
isThreeLine: true,
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
if (mm.path.endsWith('.canvas'))
const Chip(
label: Text('Canvas', style: TextStyle(fontSize: 10)),
padding: EdgeInsets.zero,
),
const Icon(Icons.chevron_right),
],
),
onTap: () {
// TODO: открыть просмотр mindmap
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Открытие ${mm.path}...')),
);
},
),
);
},
);
}
Color _getColorForPath(String path) {
if (path.endsWith('.canvas')) return Colors.purple;
if (path.endsWith('.md')) return Colors.blue;
return Colors.grey;
}
}
+203
View File
@@ -0,0 +1,203 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import '../providers/gitea_sync_provider.dart';
class GiteaSyncSettingsScreen extends ConsumerStatefulWidget {
const GiteaSyncSettingsScreen({super.key});
@override
ConsumerState<GiteaSyncSettingsScreen> createState() => _GiteaSyncSettingsScreenState();
}
class _GiteaSyncSettingsScreenState extends ConsumerState<GiteaSyncSettingsScreen> {
final _formKey = GlobalKey<FormState>();
final _urlCtrl = TextEditingController(text: 'http://git.a-crm.controlsystem.kz');
final _tokenCtrl = TextEditingController();
final _ownerCtrl = TextEditingController(text: 'Alexyz');
final _repoCtrl = TextEditingController(text: 'CMMNANAXE-CRM');
bool _testing = false;
@override
void dispose() {
_urlCtrl.dispose();
_tokenCtrl.dispose();
_ownerCtrl.dispose();
_repoCtrl.dispose();
super.dispose();
}
Future<void> _testAndSave() async {
if (!_formKey.currentState!.validate()) return;
setState(() => _testing = true);
final notifier = ref.read(mindmapSyncProvider.notifier);
try {
await notifier.configure(
baseUrl: _urlCtrl.text.trim(),
token: _tokenCtrl.text.trim(),
owner: _ownerCtrl.text.trim(),
repo: _repoCtrl.text.trim(),
);
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Подключение к Gitea установлено')),
);
}
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Ошибка: $e'), backgroundColor: Colors.red),
);
}
} finally {
if (mounted) setState(() => _testing = false);
}
}
Future<void> _syncNow() async {
setState(() => _testing = true);
final notifier = ref.read(mindmapSyncProvider.notifier);
try {
await notifier.syncFromGitea();
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Синхронизация завершена')),
);
}
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Ошибка синхронизации: $e'), backgroundColor: Colors.red),
);
}
} finally {
if (mounted) setState(() => _testing = false);
}
}
@override
Widget build(BuildContext context) {
final state = ref.watch(mindmapSyncProvider);
return Scaffold(
appBar: AppBar(
title: const Text('Синхронизация с Gitea'),
leading: IconButton(
icon: const Icon(Icons.arrow_back),
onPressed: () => context.pop(),
),
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Form(
key: _formKey,
child: ListView(
children: [
// Статус
Card(
child: ListTile(
leading: Icon(
state.isConfigured ? Icons.cloud_done : Icons.cloud_off,
color: state.isConfigured ? Colors.green : Colors.grey,
),
title: Text(
state.isConfigured ? 'Подключено к Gitea' : 'Не подключено',
style: Theme.of(context).textTheme.titleMedium,
),
subtitle: state.isSyncing
? const Text('Синхронизация...')
: state.error != null
? Text('Ошибка: ${state.error}')
: const Text('Настройте подключение ниже'),
),
),
const SizedBox(height: 16),
// URL
TextFormField(
controller: _urlCtrl,
decoration: const InputDecoration(
labelText: 'Gitea URL',
hintText: 'http://git.a-crm.controlsystem.kz',
border: OutlineInputBorder(),
prefixIcon: Icon(Icons.link),
),
validator: (v) => v == null || v.isEmpty ? 'Укажите URL' : null,
),
const SizedBox(height: 12),
// Token
TextFormField(
controller: _tokenCtrl,
decoration: const InputDecoration(
labelText: 'Access Token',
hintText: 'Ваш токен из Gitea (Settings → Applications)',
border: OutlineInputBorder(),
prefixIcon: Icon(Icons.key),
),
obscureText: true,
validator: (v) => v == null || v.isEmpty ? 'Укажите токен' : null,
),
const SizedBox(height: 12),
// Owner
TextFormField(
controller: _ownerCtrl,
decoration: const InputDecoration(
labelText: 'Owner (пользователь/организация)',
hintText: 'Alexyz',
border: OutlineInputBorder(),
prefixIcon: Icon(Icons.person),
),
validator: (v) => v == null || v.isEmpty ? 'Укажите владельца' : null,
),
const SizedBox(height: 12),
// Repo
TextFormField(
controller: _repoCtrl,
decoration: const InputDecoration(
labelText: 'Repository',
hintText: 'CMMNANAXE-CRM',
border: OutlineInputBorder(),
prefixIcon: Icon(Icons.folder),
),
validator: (v) => v == null || v.isEmpty ? 'Укажите репозиторий' : null,
),
const SizedBox(height: 24),
// Кнопки
ElevatedButton.icon(
onPressed: _testing ? null : _testAndSave,
icon: _testing
? const SizedBox(
width: 20,
height: 20,
child: CircularProgressIndicator(strokeWidth: 2),
)
: const Icon(Icons.save),
label: const Text('Сохранить и проверить'),
),
const SizedBox(height: 12),
if (state.isConfigured)
ElevatedButton.icon(
onPressed: _testing ? null : _syncNow,
icon: const Icon(Icons.sync),
label: const Text('Синхронизировать сейчас'),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.green,
foregroundColor: Colors.white,
),
),
],
),
),
),
);
}
}