import 'package:flutter/material.dart'; import '../api/oa_client.dart'; import '../labels.dart'; import '../widgets/common.dart'; import 'record_detail_page.dart'; class CalendarPage extends StatefulWidget { const CalendarPage({super.key, required this.api}); final OaClient api; @override State createState() => _CalendarPageState(); } class _CalendarPageState extends State { List> _items = []; bool _loading = true; @override void initState() { super.initState(); _load(); } Future _load() async { try { final data = await widget.api.get('/office/calendar'); if (!mounted) return; setState(() { _items = asMaps(data); _loading = false; }); } catch (_) { if (mounted) setState(() => _loading = false); } } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: const Text('我的日程')), body: _loading ? const Center(child: CircularProgressIndicator()) : _items.isEmpty ? const EmptyHint('近期没有日程') : RefreshIndicator( onRefresh: _load, child: ListView( children: [ for (final r in _items) KvTile( title: '${r['title'] ?? r['name'] ?? '日程'}', subtitle: '${fmtTime(r['start'] ?? r['beginAt'] ?? r['createdAt'])} ${zh(r['type'] ?? r['kind'])}', onTap: () => openRecord(context, widget.api, r, title: '${r['title'] ?? r['name'] ?? '日程'}'), ), ], ), ), ); } }