- 新增模型目录占位文件与翻译类型拆分 - 调整路由配置与桌面端窗口初始化 - 移除多处冗余图表配置项 - 重构右侧面板注册表与三栏布局组件 - 添加智能AppBar、拖拽书签等新功能组件 - 优化安卓编译配置与多平台插件注册 - 新增翻译覆盖率测试与共享组件 - 格式化代码与修复静态分析警告
87 lines
2.4 KiB
Dart
87 lines
2.4 KiB
Dart
/// ============================================================
|
||
/// 闲言APP — 智能AppBar组件
|
||
/// 创建时间: 2026-05-29
|
||
/// 更新时间: 2026-05-29
|
||
/// 作用: 自动识别宽屏/窄屏,标题在AppBar居中或内容区靠左
|
||
/// 上次更新: 初始创建
|
||
/// ============================================================
|
||
|
||
import 'package:flutter/cupertino.dart';
|
||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||
|
||
import '../layout/adaptive_split_view.dart';
|
||
import '../theme/app_theme.dart';
|
||
import '../theme/app_typography.dart';
|
||
|
||
/// 智能 AppBar 组件
|
||
///
|
||
/// 窄屏(< 900px): 使用 CupertinoNavigationBar,标题居中
|
||
/// 宽屏(>= 900px): 使用内容区头部,标题靠左,更高效利用空间
|
||
class SmartAppBar extends ConsumerWidget {
|
||
const SmartAppBar({
|
||
required this.title,
|
||
this.actions,
|
||
this.leading,
|
||
super.key,
|
||
});
|
||
|
||
/// 标题文本
|
||
final String title;
|
||
|
||
/// 右侧操作按钮
|
||
final List<Widget>? actions;
|
||
|
||
/// 左侧导航按钮
|
||
final Widget? leading;
|
||
|
||
@override
|
||
Widget build(BuildContext context, WidgetRef ref) {
|
||
final screenWidth = MediaQuery.of(context).size.width;
|
||
final isWidescreen = screenWidth >= kSplitViewBreakpoint;
|
||
|
||
if (isWidescreen) {
|
||
return _buildContentHeader(context);
|
||
}
|
||
return _buildCupertinoAppBar(context);
|
||
}
|
||
|
||
/// 窄屏: CupertinoNavigationBar 标题居中
|
||
Widget _buildCupertinoAppBar(BuildContext context) {
|
||
final ext = AppTheme.ext(context);
|
||
return CupertinoNavigationBar(
|
||
middle: Text(
|
||
title,
|
||
style: AppTypography.title3.copyWith(color: ext.textPrimary),
|
||
),
|
||
leading: leading,
|
||
trailing: actions != null
|
||
? Row(mainAxisSize: MainAxisSize.min, children: actions!)
|
||
: null,
|
||
backgroundColor: ext.bgElevated.withValues(alpha: 0.9),
|
||
border: null,
|
||
);
|
||
}
|
||
|
||
/// 宽屏: 内容区头部标题靠左
|
||
Widget _buildContentHeader(BuildContext context) {
|
||
final ext = AppTheme.ext(context);
|
||
return Container(
|
||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||
child: Row(
|
||
children: [
|
||
if (leading != null) leading!,
|
||
Text(
|
||
title,
|
||
style: AppTypography.title2.copyWith(
|
||
color: ext.textPrimary,
|
||
fontWeight: FontWeight.w700,
|
||
),
|
||
),
|
||
const Spacer(),
|
||
if (actions != null) ...actions!,
|
||
],
|
||
),
|
||
);
|
||
}
|
||
}
|