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