feat: 更新Flutter OHOS适配和依赖版本

refactor(fluttertoast_ohos): 重构OHOS平台插件代码结构
fix(discover): 修改迷你卡片显示文本为"作者精选"
chore: 更新pubspec版本号至0.95.0+94
build: 添加flutter_card_swiper和更新flutter_markdown_plus依赖
This commit is contained in:
Developer
2026-04-14 20:33:30 +08:00
parent 9aa8565ca7
commit 3788902f98
161 changed files with 28820 additions and 1404 deletions

View File

@@ -251,7 +251,7 @@ class MiniCardImageView extends StatelessWidget {
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 4),
const SizedBox(height: 6),
Row(
children: [
if (catInfo != null) _buildCategoryChip(catInfo),
@@ -261,24 +261,31 @@ class MiniCardImageView extends StatelessWidget {
const SizedBox(width: 6),
const Text('❤️', style: TextStyle(fontSize: 12)),
],
const SizedBox(width: 6),
Expanded(
child: Text(
desc,
style: TextStyle(
color: CupertinoColors.white.withValues(alpha: 0.7),
fontSize: DesignTokens.fontXs,
shadows: const [
Shadow(color: Colors.black38, blurRadius: 4),
],
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
if (onDetailTap != null) _buildDetailButton(),
if (onDetailTap != null) ...[
const SizedBox(width: 6),
_buildDetailButton(),
],
],
),
if (desc.isNotEmpty) ...[
const SizedBox(height: 6),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 2),
child: Text(
desc,
style: TextStyle(
color: CupertinoColors.white.withValues(alpha: 0.85),
fontSize: DesignTokens.fontSm,
height: 1.4,
shadows: const [
Shadow(color: Colors.black45, blurRadius: 6),
],
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
),
],
],
),
),

File diff suppressed because it is too large Load Diff

View File

@@ -41,6 +41,8 @@ class _CacheManagePageState extends State<CacheManagePage> {
int _miniCardLikedCount = 0;
int _miniCardDislikedCount = 0;
int _miniCardCacheCount = 0;
int _miniCardImageCacheCount = 0;
int _miniCardImageCacheSize = 0;
List<_CachedRecipeItem> _cachedRecipes = [];
List<IngredientCacheEntry> _cachedIngredients = [];
@@ -288,6 +290,56 @@ class _CacheManagePageState extends State<CacheManagePage> {
_miniCardDislikedCount = 0;
_miniCardCacheCount = 0;
}
await _loadMiniCardImageCache();
}
Future<void> _loadMiniCardImageCache() async {
try {
final cacheManager = DefaultCacheManager();
var count = 0;
var totalSize = 0;
for (int i = 1; i <= 500; i++) {
final url = 'https://eat.wktyl.com/api/assets/mpic/$i.jpeg';
final file = await cacheManager.getFileFromCache(url);
if (file != null) {
count++;
try {
totalSize += await file.file.length();
} catch (_) {}
}
}
_miniCardImageCacheCount = count;
_miniCardImageCacheSize = totalSize;
} catch (_) {
_miniCardImageCacheCount = 0;
_miniCardImageCacheSize = 0;
}
}
Future<void> _clearMiniCardImageCache() async {
final confirmed = await _showConfirmDialog(
title: '清理迷你卡片图片缓存',
message:
'将清理已缓存的 $_miniCardImageCacheCount 张菜品图片(约 ${_formatSize(_miniCardImageCacheSize)})。\n清理后需要重新下载图片。\n\n确定要清理吗?',
);
if (!confirmed) return;
try {
for (int i = 1; i <= 500; i++) {
final url = 'https://eat.wktyl.com/api/assets/mpic/$i.jpeg';
await DefaultCacheManager().removeFile(url);
}
ToastService.show(message: '迷你卡片图片缓存已清理 🖼️');
await _load();
} catch (e) {
ToastService.show(message: '清理失败: $e');
}
}
String _formatSize(int bytes) {
if (bytes < 1024) return '$bytes B';
if (bytes < 1024 * 1024) return '${(bytes / 1024).toStringAsFixed(1)} KB';
return '${(bytes / (1024 * 1024)).toStringAsFixed(1)} MB';
}
Future<void> _clearMiniCardCache() async {
@@ -458,6 +510,13 @@ class _CacheManagePageState extends State<CacheManagePage> {
value:
'❤️$_miniCardLikedCount 👎$_miniCardDislikedCount 📦$_miniCardCacheCount',
),
const SizedBox(height: DesignTokens.space2),
_buildRow(
isDark,
title: '迷你卡片图片缓存',
value:
'🖼️$_miniCardImageCacheCount 张 (${_formatSize(_miniCardImageCacheSize)})',
),
],
),
);
@@ -533,6 +592,16 @@ class _CacheManagePageState extends State<CacheManagePage> {
onTap: _clearMiniCardCache,
destructive: true,
),
_buildDivider(isDark),
_buildActionTile(
isDark,
icon: CupertinoIcons.photo_on_rectangle,
title: '清理迷你卡片图片缓存',
subtitle:
'🖼️$_miniCardImageCacheCount 张 (${_formatSize(_miniCardImageCacheSize)})',
onTap: _clearMiniCardImageCache,
destructive: false,
),
],
),
);

View File

@@ -11,8 +11,6 @@ import 'package:get/get.dart';
import 'package:mom_kitchen/src/config/design_tokens.dart';
import 'package:mom_kitchen/src/controllers/tools/tools_controller.dart';
import 'package:mom_kitchen/src/models/tool_item_model.dart';
import 'package:mom_kitchen/src/models/recipe/tag_model.dart';
import 'package:mom_kitchen/src/repositories/recipe_repository.dart';
class ToolsCenterPage extends StatefulWidget {
final bool embedded;
@@ -29,9 +27,6 @@ class _ToolsCenterPageState extends State<ToolsCenterPage>
bool _isInitialized = false;
late AnimationController _animationController;
String _searchQuery = '';
List<TagModel> _tags = [];
bool _isTagsLoading = false;
final RecipeRepository _recipeRepo = RecipeRepository();
@override
void initState() {
@@ -54,28 +49,8 @@ class _ToolsCenterPageState extends State<ToolsCenterPage>
if (!_isInitialized) {
_isInitialized = true;
_initController();
_loadTags();
_animationController.forward();
}
}
Future<void> _loadTags() async {
setState(() => _isTagsLoading = true);
try {
final tags = await _recipeRepo.fetchTags(limit: 30);
debugPrint('ToolsCenterPage: Loaded ${tags.length} tags');
if (mounted) {
setState(() {
_tags = tags;
_isTagsLoading = false;
});
}
} catch (e, stackTrace) {
debugPrint('ToolsCenterPage: Load tags error: $e');
debugPrint('Stack trace: $stackTrace');
if (mounted) {
setState(() => _isTagsLoading = false);
}
_animationController.forward();
}
}
@@ -186,116 +161,10 @@ class _ToolsCenterPageState extends State<ToolsCenterPage>
hasScrollBody: false,
child: _buildEmptyState(isDark),
),
SliverToBoxAdapter(child: _buildTagsSection(isDark)),
],
);
}
Widget _buildTagsSection(bool isDark) {
debugPrint(
'ToolsCenterPage: _buildTagsSection called, tags count: ${_tags.length}',
);
return Container(
padding: EdgeInsets.all(DesignTokens.space3),
decoration: BoxDecoration(
color: DesignTokens.dynamicPrimary.withValues(alpha: 0.08),
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
border: Border(
top: BorderSide(
color: DesignTokens.dynamicPrimary.withValues(alpha: 0.2),
width: 1,
),
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: EdgeInsets.only(
left: DesignTokens.space1,
bottom: DesignTokens.space2,
),
child: Row(
children: [
Text('🏷️', style: TextStyle(fontSize: 18)),
SizedBox(width: DesignTokens.space2),
Text(
'口味 & 工艺',
style: TextStyle(
fontSize: DesignTokens.fontLg,
fontWeight: FontWeight.w700,
color: DesignTokens.dynamicPrimary,
),
),
const Spacer(),
Text(
'${_tags.length}',
style: TextStyle(
fontSize: DesignTokens.fontXs,
color: isDark ? DarkDesignTokens.text3 : DesignTokens.text3,
),
),
],
),
),
if (_isTagsLoading)
const Center(child: CupertinoActivityIndicator())
else if (_tags.isEmpty)
Padding(
padding: const EdgeInsets.all(DesignTokens.space2),
child: Center(
child: Text(
'暂无标签数据',
style: TextStyle(
fontSize: DesignTokens.fontSm,
color: isDark ? DarkDesignTokens.text3 : DesignTokens.text3,
),
),
),
)
else
Wrap(
spacing: DesignTokens.space2,
runSpacing: DesignTokens.space2,
children: _tags.take(20).map((tag) {
return GestureDetector(
onTap: () => _navigateToTagRecipes(tag),
child: Container(
padding: EdgeInsets.symmetric(
horizontal: DesignTokens.space3,
vertical: DesignTokens.space2,
),
decoration: BoxDecoration(
color: DesignTokens.dynamicPrimary.withValues(alpha: 0.1),
borderRadius: DesignTokens.borderRadiusLg,
border: Border.all(
color: DesignTokens.dynamicPrimary.withValues(
alpha: 0.2,
),
),
),
child: Text(
tag.name,
style: TextStyle(
fontSize: DesignTokens.fontSm,
color: DesignTokens.dynamicPrimary,
fontWeight: FontWeight.w500,
),
),
),
);
}).toList(),
),
],
),
);
}
void _navigateToTagRecipes(TagModel tag) {
Get.toNamed('/search', arguments: {'keyword': tag.name, 'tagId': tag.id});
}
Widget _buildHeader(bool isDark) {
return Padding(
padding: const EdgeInsets.fromLTRB(

View File

@@ -134,7 +134,7 @@ class MiniCardDiscoverCard extends StatelessWidget {
const Text('🃏', style: TextStyle(fontSize: 11)),
const SizedBox(width: 4),
Text(
'迷你卡片',
'作者精选',
style: TextStyle(
color: CupertinoColors.white.withValues(
alpha: 0.95,