refactor: 优化日历状态管理与首页输入框,添加API客户端抽象

This commit is contained in:
qzl
2026-02-27 18:36:21 +08:00
parent 80d04688fc
commit 3d6ae7695f
20 changed files with 2146 additions and 801 deletions
@@ -4,9 +4,35 @@ import 'package:lucide_icons/lucide_icons.dart';
import '../../../../core/theme/design_tokens.dart';
import 'home_sheet.dart';
class HomeScreen extends StatelessWidget {
class HomeScreen extends StatefulWidget {
const HomeScreen({super.key});
@override
State<HomeScreen> createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
final TextEditingController _messageController = TextEditingController();
bool get _hasMessage => _messageController.text.trim().isNotEmpty;
@override
void initState() {
super.initState();
_messageController.addListener(_onMessageChanged);
}
@override
void dispose() {
_messageController.removeListener(_onMessageChanged);
_messageController.dispose();
super.dispose();
}
void _onMessageChanged() {
setState(() {});
}
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -47,7 +73,7 @@ class HomeScreen extends StatelessWidget {
size: 24,
color: AppColors.slate900,
),
onPressed: () => context.push('/calendar/dayweek'),
onPressed: () => context.push('/calendar/dayweek?from=home'),
),
const SizedBox(width: 16),
IconButton(
@@ -153,10 +179,10 @@ class HomeScreen extends StatelessWidget {
Widget _buildInputContainer(BuildContext context) {
return Container(
height: 80,
padding: const EdgeInsets.all(16),
color: const Color(0xFFF8FAFC),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
GestureDetector(
onTap: () => _showBottomSheet(context),
@@ -166,7 +192,7 @@ class HomeScreen extends StatelessWidget {
decoration: BoxDecoration(
color: AppColors.white,
shape: BoxShape.circle,
border: Border.all(color: const Color(0xFFE2E8F0)),
border: Border.all(color: AppColors.slate300),
),
child: const Icon(
LucideIcons.plus,
@@ -178,28 +204,40 @@ class HomeScreen extends StatelessWidget {
const SizedBox(width: 8),
Expanded(
child: Container(
height: 48,
padding: const EdgeInsets.symmetric(horizontal: 16),
constraints: const BoxConstraints(minHeight: 48),
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
decoration: BoxDecoration(
color: AppColors.white,
color: Colors.transparent,
borderRadius: BorderRadius.circular(24),
border: Border.all(color: AppColors.slate300),
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Expanded(
Expanded(
child: TextField(
decoration: InputDecoration(
controller: _messageController,
minLines: 1,
maxLines: 3,
decoration: const InputDecoration(
hintText: '输入消息...',
border: InputBorder.none,
enabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,
disabledBorder: InputBorder.none,
errorBorder: InputBorder.none,
focusedErrorBorder: InputBorder.none,
isDense: true,
contentPadding: EdgeInsets.zero,
filled: false,
),
),
),
const Icon(
LucideIcons.mic,
size: 20,
color: AppColors.slate500,
const SizedBox(width: 8),
Icon(
_hasMessage ? LucideIcons.send : LucideIcons.mic,
size: 24,
color: _hasMessage ? AppColors.blue600 : AppColors.slate500,
),
],
),