hi-client/lib/app/modules/kr_home/widgets/kr_subscription_card.dart

127 lines
4.1 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:flutter_screenutil/flutter_screenutil.dart';
import 'package:kaer_with_panels/app/localization/app_translations.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}');
print('🎴 [SubscriptionCard] ScreenUtil 测试 - 12.w=${12.w}, 16.h=${16.h}, 44.w=${44.w}');
// 🔧 关键修复:完全移除 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] 订阅按钮被点击');
KRSubscribeNavigationUtil.navigateToPurchase(tag: 'SubscriptionCard');
},
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.w),
decoration: BoxDecoration(
color: Theme.of(context).cardColor,
borderRadius: BorderRadius.circular(12.w),
),
child: IntrinsicWidth(
child: child,
),
);
}
}