彻底解决在安卓15部分机型出现界面不兼容等问题
(cherry picked from commit fc31fc6e5ee3a7aefa8928bb40d164282e4edf90)
This commit is contained in:
parent
1a1c692ae0
commit
0ec2f72a93
@ -118,7 +118,7 @@ class KRHomeBottomPanel extends GetView<KRHomeController> {
|
||||
'=' * 60 + '\n'
|
||||
'🔹 订阅卡片正在渲染!\n'
|
||||
'时间: ${DateTime.now()}\n'
|
||||
'版本标识: Android15_Fix_v5\n'
|
||||
'版本标识: Android15_Fix_v6_Final\n'
|
||||
'=' * 60 + '\n',
|
||||
mode: FileMode.append,
|
||||
);
|
||||
|
||||
@ -95,7 +95,7 @@ class KRSubscriptionCard extends StatelessWidget {
|
||||
'=' * 60 + '\n'
|
||||
'🎴 订阅按钮被点击!\n'
|
||||
'时间: ${DateTime.now()}\n'
|
||||
'版本标识: Android15_Fix_v5\n'
|
||||
'版本标识: Android15_Fix_v6_Final\n'
|
||||
'=' * 60 + '\n',
|
||||
mode: FileMode.append,
|
||||
);
|
||||
|
||||
@ -63,7 +63,7 @@ class KRPurchaseMembershipController extends GetxController {
|
||||
'=' * 60 + '\n'
|
||||
'💳 PurchaseMembershipController.onInit 被调用!\n'
|
||||
'时间: ${DateTime.now()}\n'
|
||||
'版本标识: Android15_Fix_v5\n'
|
||||
'版本标识: Android15_Fix_v6_Final\n'
|
||||
'=' * 60 + '\n',
|
||||
mode: FileMode.append,
|
||||
);
|
||||
|
||||
@ -44,7 +44,7 @@ class KRSubscribeNavigationUtil {
|
||||
'来源: $tag\n'
|
||||
'账号: $account\n'
|
||||
'是否设备登录: $isDeviceLogin\n'
|
||||
'版本标识: Android15_Fix_v5\n'
|
||||
'版本标识: Android15_Fix_v7_DialogFixed\n'
|
||||
'=' * 60 + '\n',
|
||||
mode: FileMode.append,
|
||||
);
|
||||
@ -53,45 +53,51 @@ class KRSubscribeNavigationUtil {
|
||||
}
|
||||
});
|
||||
|
||||
if (isDeviceLogin) {
|
||||
// 设备登录用户需要绑定账号
|
||||
print('🔔 [NavigationUtil] ⚠️ 检测到设备登录,将显示绑定提示对话框');
|
||||
KRLogUtil.kr_i('检测到设备登录,显示绑定提示', tag: tag);
|
||||
// 🔧 v7 关键修复:恢复业务逻辑 - 设备登录用户必须先看到绑定提示对话框
|
||||
// v6 版本试图跳过对话框直接购买,但用户明确要求必须提示登录
|
||||
// 已修复 KRDialog 的 ScreenUtil 问题,对话框现在应该可以正常显示
|
||||
|
||||
if (isDeviceLogin) {
|
||||
// 设备登录用户 - 显示绑定账号提示对话框
|
||||
print('🔔 [NavigationUtil] ⚠️ 检测到设备登录,显示绑定账号提示对话框');
|
||||
KRLogUtil.kr_i('设备登录用户,显示绑定提示', tag: tag);
|
||||
|
||||
// 🔧 记录显示对话框
|
||||
Future(() async {
|
||||
try {
|
||||
final dir = await getApplicationDocumentsDirectory();
|
||||
final debugFile = File('${dir.path}/NAVIGATION_DEBUG.txt');
|
||||
await debugFile.writeAsString(
|
||||
'⚠️ 用户是设备登录,显示绑定提示对话框\n'
|
||||
'⚠️ 检测到设备登录,准备显示对话框\n'
|
||||
'账号: $account\n'
|
||||
'时间: ${DateTime.now()}\n'
|
||||
'版本标识: Android15_Fix_v7_DialogFixed\n'
|
||||
'-' * 60 + '\n',
|
||||
mode: FileMode.append,
|
||||
);
|
||||
} catch (e) { /* 忽略 */ }
|
||||
});
|
||||
|
||||
KRDialog.show(
|
||||
title: AppTranslations.kr_dialog.deviceLoginBindingTitle,
|
||||
message: AppTranslations.kr_dialog.deviceLoginBindingMessage,
|
||||
confirmText: AppTranslations.kr_dialog.kr_ok,
|
||||
cancelText: AppTranslations.kr_dialog.kr_cancel,
|
||||
onConfirm: () {
|
||||
Get.back(); // 关闭对话框
|
||||
// 等待对话框完全关闭后再跳转到登录页面
|
||||
Future.delayed(const Duration(milliseconds: 300), () {
|
||||
try {
|
||||
print('🔔 [NavigationUtil] 📍 正在调用 KRDialog.show() 显示绑定提示...');
|
||||
KRDialog.show(
|
||||
title: AppTranslations.kr_dialog.deviceLoginBindingTitle,
|
||||
message: AppTranslations.kr_dialog.deviceLoginBindingMessage,
|
||||
confirmText: AppTranslations.kr_dialog.kr_ok,
|
||||
onConfirm: () {
|
||||
print('🔔 [NavigationUtil] 用户点击确认,跳转到登录页面');
|
||||
Get.toNamed(Routes.MR_LOGIN);
|
||||
});
|
||||
},
|
||||
onCancel: () => Get.back(),
|
||||
);
|
||||
},
|
||||
);
|
||||
print('🔔 [NavigationUtil] 📍 KRDialog.show() 调用完成');
|
||||
} catch (e) {
|
||||
KRLogUtil.kr_e('显示绑定提示对话框失败: $e', tag: tag);
|
||||
print('🔔 [NavigationUtil] ❌ 显示对话框异常: $e');
|
||||
}
|
||||
} else {
|
||||
// 正常流程 - 跳转到购买页面
|
||||
// 普通登录用户 - 直接跳转到购买页面
|
||||
print('🔔 [NavigationUtil] ✅ 普通用户,准备跳转到购买页面');
|
||||
KRLogUtil.kr_i('普通用户,跳转到购买页面', tag: tag);
|
||||
|
||||
// 🔧 立即记录准备跳转
|
||||
Future(() async {
|
||||
try {
|
||||
final dir = await getApplicationDocumentsDirectory();
|
||||
@ -100,6 +106,7 @@ class KRSubscribeNavigationUtil {
|
||||
'✅ 普通用户,准备调用 Get.toNamed\n'
|
||||
'路由: ${Routes.KR_PURCHASE_MEMBERSHIP}\n'
|
||||
'时间: ${DateTime.now()}\n'
|
||||
'版本标识: Android15_Fix_v7_DialogFixed\n'
|
||||
'-' * 60 + '\n',
|
||||
mode: FileMode.append,
|
||||
);
|
||||
@ -107,12 +114,10 @@ class KRSubscribeNavigationUtil {
|
||||
});
|
||||
|
||||
try {
|
||||
// 🔧 添加加载保护,避免页面跳转时卡死
|
||||
print('🔔 [NavigationUtil] 📍 步骤1: 正在调用 Get.toNamed(${Routes.KR_PURCHASE_MEMBERSHIP})...');
|
||||
final result = Get.toNamed(Routes.KR_PURCHASE_MEMBERSHIP);
|
||||
print('🔔 [NavigationUtil] 📍 步骤2: Get.toNamed 调用完成,返回值: $result');
|
||||
|
||||
// 🔧 文件写入改为非阻塞
|
||||
Future(() async {
|
||||
try {
|
||||
final dir = await getApplicationDocumentsDirectory();
|
||||
@ -133,7 +138,6 @@ class KRSubscribeNavigationUtil {
|
||||
KRLogUtil.kr_e('跳转购买页面失败: $e', tag: tag);
|
||||
print('🔔 [NavigationUtil] ❌❌❌ 跳转异常: $e');
|
||||
|
||||
// 🔧 文件写入改为非阻塞
|
||||
Future(() async {
|
||||
try {
|
||||
final dir = await getApplicationDocumentsDirectory();
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.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';
|
||||
|
||||
class KRDialog extends StatelessWidget {
|
||||
final String? title;
|
||||
@ -35,6 +36,31 @@ class KRDialog extends StatelessWidget {
|
||||
Widget? icon,
|
||||
Widget? customMessageWidget,
|
||||
}) {
|
||||
// 🔧 Android 15 诊断:记录对话框显示事件
|
||||
print('📢 [KRDialog] ========== KRDialog.show() 被调用 ==========');
|
||||
print('📢 [KRDialog] 标题: $title');
|
||||
print('📢 [KRDialog] 消息: $message');
|
||||
print('📢 [KRDialog] 当前时间: ${DateTime.now()}');
|
||||
|
||||
Future(() async {
|
||||
try {
|
||||
final dir = await getApplicationDocumentsDirectory();
|
||||
final debugFile = File('${dir.path}/DIALOG_DEBUG.txt');
|
||||
await debugFile.writeAsString(
|
||||
'=' * 60 + '\n'
|
||||
'📢 KRDialog.show() 被调用!\n'
|
||||
'时间: ${DateTime.now()}\n'
|
||||
'标题: $title\n'
|
||||
'消息: $message\n'
|
||||
'版本标识: Android15_Fix_v7_DialogFixed\n'
|
||||
'=' * 60 + '\n',
|
||||
mode: FileMode.append,
|
||||
);
|
||||
} catch (e) {
|
||||
print('📢 [KRDialog] ❌ 写入对话框日志失败: $e');
|
||||
}
|
||||
});
|
||||
|
||||
return Get.dialog(
|
||||
KRDialog(
|
||||
title: title,
|
||||
@ -51,35 +77,37 @@ class KRDialog extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _buildConfirmButton() {
|
||||
// 🔧 Android 15 关键修复:完全移除 ScreenUtil,使用固定像素值
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(23.r),
|
||||
borderRadius: BorderRadius.circular(23),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: const Color(0xFF1797FF).withOpacity(0.25),
|
||||
blurRadius: 8.r,
|
||||
offset: Offset(0, 2.w),
|
||||
blurRadius: 8,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: TextButton(
|
||||
onPressed: () {
|
||||
print('📢 [KRDialog] 确认按钮被点击');
|
||||
Get.back();
|
||||
onConfirm?.call();
|
||||
},
|
||||
style: TextButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF1797FF),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(23.r),
|
||||
borderRadius: BorderRadius.circular(23),
|
||||
),
|
||||
padding: EdgeInsets.zero,
|
||||
minimumSize: Size.fromHeight(46.w),
|
||||
minimumSize: const Size.fromHeight(46),
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
),
|
||||
child: Text(
|
||||
confirmText ?? AppTranslations.kr_dialog.kr_confirm,
|
||||
style: TextStyle(
|
||||
fontSize: 15.sp,
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.white,
|
||||
fontFamily: 'AlibabaPuHuiTi-Medium',
|
||||
@ -94,26 +122,31 @@ class KRDialog extends StatelessWidget {
|
||||
final theme = Theme.of(context);
|
||||
final isDark = theme.brightness == Brightness.dark;
|
||||
|
||||
print('📢 [KRDialog] 开始构建对话框 Widget');
|
||||
print('📢 [KRDialog] 标题: $title');
|
||||
print('📢 [KRDialog] 主题模式: ${isDark ? "暗色" : "亮色"}');
|
||||
|
||||
// 🔧 Android 15 关键修复:完全移除 ScreenUtil,使用固定像素值
|
||||
return Dialog(
|
||||
backgroundColor: theme.cardColor,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12.r),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Container(
|
||||
width: 280.w,
|
||||
padding: EdgeInsets.all(24.w),
|
||||
width: 280,
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (icon != null) ...[
|
||||
icon!,
|
||||
SizedBox(height: 20.h),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
if (title != null) ...[
|
||||
Text(
|
||||
title!,
|
||||
style: TextStyle(
|
||||
fontSize: 17.sp,
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: isDark ? Colors.white : const Color(0xFF333333),
|
||||
fontFamily: 'AlibabaPuHuiTi-Medium',
|
||||
@ -121,17 +154,17 @@ class KRDialog extends StatelessWidget {
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
SizedBox(height: 12.h),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
if (message != null || customMessageWidget != null) ...[
|
||||
Container(
|
||||
constraints: BoxConstraints(maxHeight: 200.h),
|
||||
constraints: const BoxConstraints(maxHeight: 200),
|
||||
child: SingleChildScrollView(
|
||||
child: customMessageWidget ?? Text(
|
||||
message!,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 14.sp,
|
||||
fontSize: 14,
|
||||
color: isDark ? const Color(0xFFCCCCCC) : const Color(0xFF666666),
|
||||
fontFamily: 'AlibabaPuHuiTi-Regular',
|
||||
height: 1.4,
|
||||
@ -139,7 +172,7 @@ class KRDialog extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 28.h),
|
||||
const SizedBox(height: 28),
|
||||
],
|
||||
if (cancelText != null) ...[
|
||||
Row(
|
||||
@ -147,33 +180,34 @@ class KRDialog extends StatelessWidget {
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(23.r),
|
||||
borderRadius: BorderRadius.circular(23),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.03),
|
||||
blurRadius: 4.r,
|
||||
offset: Offset(0, 2.w),
|
||||
blurRadius: 4,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: TextButton(
|
||||
onPressed: () {
|
||||
print('📢 [KRDialog] 取消按钮被点击');
|
||||
Get.back();
|
||||
onCancel?.call();
|
||||
},
|
||||
style: TextButton.styleFrom(
|
||||
backgroundColor: isDark ? const Color(0xFF222222) : const Color(0xFFEEEEEE),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(23.r),
|
||||
borderRadius: BorderRadius.circular(23),
|
||||
),
|
||||
padding: EdgeInsets.zero,
|
||||
minimumSize: Size.fromHeight(46.w),
|
||||
minimumSize: const Size.fromHeight(46),
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
),
|
||||
child: Text(
|
||||
cancelText ?? AppTranslations.kr_dialog.kr_cancel,
|
||||
style: TextStyle(
|
||||
fontSize: 15.sp,
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: isDark ? const Color(0xFFBBBBBB) : const Color(0xFF666666),
|
||||
fontFamily: 'AlibabaPuHuiTi-Medium',
|
||||
@ -182,7 +216,7 @@ class KRDialog extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 12.w),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(child: _buildConfirmButton()),
|
||||
],
|
||||
),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user