hi-client/lib/app/modules/kr_home/widgets/kr_subscription_card.dart
Rust 0ec2f72a93 彻底解决在安卓15部分机型出现界面不兼容等问题
(cherry picked from commit fc31fc6e5ee3a7aefa8928bb40d164282e4edf90)
2025-11-02 02:48:03 -08:00

155 lines
5.4 KiB
Dart
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:kaer_with_panels/app/localization/app_translations.dart';
import 'dart:io';
import 'package:path_provider/path_provider.dart';
import 'package:kaer_with_panels/app/routes/app_pages.dart';
import 'package:kaer_with_panels/app/utils/kr_subscribe_navigation_util.dart';
import '../../../widgets/kr_app_text_style.dart';
/// 订阅卡片组件
class KRSubscriptionCard extends StatelessWidget {
const KRSubscriptionCard({
super.key,
});
@override
Widget build(BuildContext context) {
return _kr_buildSubscriptionCard(context);
}
// 构建订阅卡片
Widget _kr_buildSubscriptionCard(BuildContext context) {
// 🔧 新增:订阅卡片渲染日志
print('🎴 [SubscriptionCard] 开始构建订阅卡片');
print('🎴 [SubscriptionCard] 卡片颜色: ${Theme.of(context).cardColor}');
print('🎴 [SubscriptionCard] 主题亮度: ${Theme.of(context).brightness}');
print('🎴 [SubscriptionCard] 文本颜色: ${Theme.of(context).textTheme.bodyMedium?.color}');
// 🔧 关键修复:完全移除 ScreenUtil使用固定像素值避免缩放问题
return Container(
// 添加固定高度,确保卡片可见
constraints: const BoxConstraints(minHeight: 200),
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Theme.of(context).cardColor,
borderRadius: BorderRadius.circular(12),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// 图标
Container(
width: 48,
height: 48,
decoration: BoxDecoration(
color: Colors.blue.withOpacity(0.1),
shape: BoxShape.circle,
),
child: const Icon(
Icons.language,
color: Colors.blue,
size: 28,
),
),
const SizedBox(height: 16),
// 描述文字
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
AppTranslations.kr_home.subscriptionDescription,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w400,
height: 1.5,
// 🔧 关键修复:确保文本颜色可见
color: Theme.of(context).brightness == Brightness.dark
? Colors.white
: Colors.black87,
),
),
),
const SizedBox(height: 20),
// 订阅按钮
SizedBox(
width: double.infinity,
height: 46,
child: ElevatedButton(
onPressed: () {
print('🎴 [SubscriptionCard] ========== 订阅按钮被点击 ==========');
print('🎴 [SubscriptionCard] 当前时间: ${DateTime.now()}');
print('🎴 [SubscriptionCard] 准备调用导航方法...');
// 🔧 关键修复:文件写入改为非阻塞,不影响主流程
Future(() async {
try {
final dir = await getApplicationDocumentsDirectory();
final debugFile = File('${dir.path}/SUBSCRIBE_BUTTON_DEBUG.txt');
await debugFile.writeAsString(
'=' * 60 + '\n'
'🎴 订阅按钮被点击!\n'
'时间: ${DateTime.now()}\n'
'版本标识: Android15_Fix_v6_Final\n'
'=' * 60 + '\n',
mode: FileMode.append,
);
print('🎴 [SubscriptionCard] ✅ 按钮点击日志已写入文件: ${debugFile.path}');
} catch (e) {
print('🎴 [SubscriptionCard] ❌ 写入按钮点击日志失败: $e');
}
});
try {
KRSubscribeNavigationUtil.navigateToPurchase(tag: 'SubscriptionCard');
print('🎴 [SubscriptionCard] 导航方法调用成功');
} catch (e, stackTrace) {
print('🎴 [SubscriptionCard] ❌ 导航方法调用失败: $e');
print('🎴 [SubscriptionCard] StackTrace: $stackTrace');
}
},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blue,
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
child: Text(
AppTranslations.kr_home.subscribe,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: Colors.white,
),
),
),
),
],
),
);
}
Widget _kr_buildListContainer(
BuildContext context, {
required Widget child,
EdgeInsetsGeometry? margin,
bool addBottomPadding = true,
}) {
return Container(
margin: margin ?? EdgeInsets.symmetric(horizontal: 16),
decoration: BoxDecoration(
color: Theme.of(context).cardColor,
borderRadius: BorderRadius.circular(12),
),
child: IntrinsicWidth(
child: child,
),
);
}
}