fix:修复设备列表显示异常的问题
This commit is contained in:
parent
46caa46338
commit
0593da7598
@ -10,14 +10,14 @@ import io.flutter.embedding.engine.FlutterEngine;
|
||||
import io.flutter.plugins.GeneratedPluginRegistrant
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
|
||||
class MainActivity: FlutterActivity() {
|
||||
class MainActivity : FlutterActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
GeneratedPluginRegistrant.registerWith(flutterEngine!!)
|
||||
MethodChannel(flutterEngine?.dartExecutor!!.binaryMessenger, "starLockFlutterSend").setMethodCallHandler { call, result ->
|
||||
if (call.method == "loadNativeShare") {
|
||||
var map = call.arguments as Map<String, String>
|
||||
shareText(map["shareText"], "分享")
|
||||
shareText(map["shareText"] , "分享")
|
||||
} else if (call.method == "sendGetBlueStatus") {
|
||||
// 蓝牙是否开启
|
||||
// println("收到原生的信息了 methodmethodmethod: ${call.method}")
|
||||
@ -58,8 +58,7 @@ class MainActivity: FlutterActivity() {
|
||||
|
||||
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
||||
GeneratedPluginRegistrant.registerWith(flutterEngine);
|
||||
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "starLockFlutterSend").setMethodCallHandler {
|
||||
call, result ->
|
||||
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "starLockFlutterSend").setMethodCallHandler { call, result ->
|
||||
println("methodmethodmethod: ${call.method}")
|
||||
// 在这里处理从 Flutter 发送过来的方法调用
|
||||
if (call.method == "loadNativeShare") {
|
||||
|
||||
@ -230,25 +230,20 @@ class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware {
|
||||
|
||||
Widget _xhjLockInfoListItem(
|
||||
LockListInfoItemEntity keyInfo, bool isLast, Function() action) {
|
||||
String lockAlias = keyInfo.lockAlias!;
|
||||
final String lockAlias = keyInfo.lockAlias!;
|
||||
final TextStyle lockAliasTextStyle = TextStyle(
|
||||
fontSize: 24.sp,
|
||||
fontSize: 25.sp,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: keyInfo.passageMode == 1
|
||||
? AppColors.openPassageModeColor
|
||||
: AppColors.darkGrayTextColor,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
);
|
||||
final TextPainter textPainter = TextPainter(
|
||||
text: TextSpan(text: lockAlias, style: lockAliasTextStyle),
|
||||
maxLines: 1,
|
||||
textDirection: TextDirection.ltr)
|
||||
..layout(minWidth: 0, maxWidth: double.infinity);
|
||||
final List<String> useKeyTypeListStr = logic.getUseKeyTypeListStr(
|
||||
keyInfo.startDate, keyInfo.endDate, keyInfo.keyType);
|
||||
final bool isThree = useKeyTypeListStr.length == 3;
|
||||
final bool isOne = useKeyTypeListStr.length == 1;
|
||||
|
||||
final double textSizeWidth = textPainter.size.width; // 获取文本的尺寸
|
||||
if (textSizeWidth > Get.width * .6) {
|
||||
lockAlias = '${lockAlias.substring(0, 14)}...';
|
||||
}
|
||||
return GestureDetector(
|
||||
onTap: action,
|
||||
child: Container(
|
||||
@ -270,6 +265,7 @@ class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Image.asset(
|
||||
'images/icon_lock_circle.png',
|
||||
@ -277,50 +273,85 @@ class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware {
|
||||
height: 48.r,
|
||||
color: AppColors.mainColor,
|
||||
),
|
||||
const Spacer(),
|
||||
Column(
|
||||
children: <Widget>[
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Image.asset(
|
||||
logic.showElectricIcon(keyInfo.electricQuantity!),
|
||||
width: 30.w,
|
||||
height: 24.w,
|
||||
),
|
||||
SizedBox(width: 2.w),
|
||||
Text(
|
||||
'${keyInfo.electricQuantity!}%',
|
||||
style: TextStyle(
|
||||
fontSize: 16.sp,
|
||||
color: AppColors.darkGrayTextColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
keyInfo.isLockOwner == 1
|
||||
? '超级管理员'.tr
|
||||
: (keyInfo.keyRight == 1 ? '授权管理员'.tr : '普通用户'.tr),
|
||||
style: TextStyle(
|
||||
fontSize: 16.sp,
|
||||
color: AppColors.darkGrayTextColor),
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
height: 8.h,
|
||||
),
|
||||
FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Text(lockAlias, style: lockAliasTextStyle, maxLines: 1),
|
||||
Text(
|
||||
lockAlias,
|
||||
style: lockAliasTextStyle,
|
||||
maxLines: 2,
|
||||
),
|
||||
Visibility(
|
||||
visible: keyInfo.passageMode == 1,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(top: 5.h),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.only(right: 5.w, left: 5.w),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(5.w),
|
||||
color: AppColors.openPassageModeColor,
|
||||
),
|
||||
child: Text('常开模式开启'.tr,
|
||||
Row(
|
||||
children: [
|
||||
Visibility(
|
||||
visible: keyInfo.passageMode == 1,
|
||||
child: Container(
|
||||
padding:
|
||||
EdgeInsets.only(top: 5.h, right: 5.w, left: 5.w),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(5.w),
|
||||
color: AppColors.openPassageModeColor,
|
||||
),
|
||||
child: Text('常开模式开启'.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 18.sp,
|
||||
color: AppColors.appBarIconColor)),
|
||||
)),
|
||||
SizedBox(
|
||||
width: 5.w,
|
||||
),
|
||||
Visibility(
|
||||
visible: keyInfo.lockSetting!.remoteUnlock == 1,
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.only(
|
||||
top: 5.h, right: 5.w, left: 5.w),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(5.w),
|
||||
color: AppColors.mainColor,
|
||||
),
|
||||
child: Text(
|
||||
'远程开锁'.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 18.sp,
|
||||
color: AppColors.appBarIconColor)),
|
||||
),
|
||||
],
|
||||
),
|
||||
)),
|
||||
Visibility(
|
||||
visible: keyInfo.lockSetting!.remoteUnlock == 1,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(top: 5.h),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'远程开锁'.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 18.sp,
|
||||
color: AppColors.darkGrayTextColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
)),
|
||||
fontSize: 18.sp, color: Colors.white),
|
||||
),
|
||||
),
|
||||
],
|
||||
)),
|
||||
],
|
||||
),
|
||||
Visibility(
|
||||
visible: (keyInfo.keyType == XSConstantMacro.keyTypeTime ||
|
||||
keyInfo.keyType == XSConstantMacro.keyTypeLoop) &&
|
||||
@ -331,7 +362,7 @@ class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware {
|
||||
keyInfo.keyStatus ==
|
||||
XSConstantMacro.keyStatusExpired),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(top: 20.h),
|
||||
padding: EdgeInsets.only(top: 5.h),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
@ -353,37 +384,40 @@ class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware {
|
||||
),
|
||||
)),
|
||||
SizedBox(height: 5.h),
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Text(
|
||||
keyInfo.isLockOwner == 1
|
||||
? '超级管理员'.tr
|
||||
: (keyInfo.keyRight == 1 ? '授权管理员'.tr : '普通用户'.tr),
|
||||
if (isThree)
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
Characters(useKeyTypeListStr[0]).join('\u{200B}'),
|
||||
style: TextStyle(
|
||||
fontSize: 16.sp, color: AppColors.darkGrayTextColor),
|
||||
),
|
||||
),
|
||||
Image.asset(
|
||||
logic.showElectricIcon(keyInfo.electricQuantity!),
|
||||
width: 30.w,
|
||||
height: 24.w,
|
||||
),
|
||||
SizedBox(width: 2.w),
|
||||
Text(
|
||||
'${keyInfo.electricQuantity!}%',
|
||||
style: TextStyle(
|
||||
fontSize: 16.sp, color: AppColors.darkGrayTextColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
Characters(logic.getUseKeyTypeStr(
|
||||
keyInfo.startDate, keyInfo.endDate, keyInfo.keyType))
|
||||
.join('\u{200B}'),
|
||||
style: TextStyle(
|
||||
fontSize: 16.sp, color: AppColors.darkGrayTextColor),
|
||||
)
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
Characters(useKeyTypeListStr[1]).join('\u{200B}'),
|
||||
style: TextStyle(
|
||||
fontSize: 16.sp,
|
||||
color: AppColors.darkGrayTextColor),
|
||||
),
|
||||
SizedBox(width: 5.w),
|
||||
Text(
|
||||
useKeyTypeListStr[2],
|
||||
style: TextStyle(
|
||||
fontSize: 16.sp,
|
||||
color: AppColors.darkGrayTextColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
else if (isOne)
|
||||
Text(
|
||||
useKeyTypeListStr[0],
|
||||
style: TextStyle(
|
||||
fontSize: 16.sp, color: AppColors.darkGrayTextColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@ -21,7 +21,7 @@ class BaseGetXController extends GetxController {
|
||||
|
||||
bool currentPage = true;
|
||||
var pageNo = 1;
|
||||
var pageSize = "20";
|
||||
var pageSize = '20';
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
@ -93,7 +93,7 @@ class BaseGetXController extends GetxController {
|
||||
}
|
||||
|
||||
void showBlueConnetctToast() {
|
||||
bool isContains = BlueManage().connectDeviceName.contains("T9A");
|
||||
bool isContains = BlueManage().connectDeviceName.contains('T9A');
|
||||
showToast(
|
||||
"${'操作失败,请确认锁是否在附近,或重启手机蓝牙后再试。'.tr}${isContains == true ? "如果是全自动锁,请使屏幕变亮" : ""}");
|
||||
}
|
||||
@ -123,10 +123,10 @@ class BaseGetXController extends GetxController {
|
||||
}
|
||||
|
||||
void showOperationSuccessful({String? status, Function? something}) =>
|
||||
showSuccess(status ?? "成功", something: something);
|
||||
showSuccess(status ?? '成功', something: something);
|
||||
|
||||
void showOperationFailed({String? status, Function? something}) =>
|
||||
showError(status ?? "失败", something: something);
|
||||
showError(status ?? '失败', something: something);
|
||||
|
||||
void logOff() async {
|
||||
await ClientManager().logOff();
|
||||
@ -136,11 +136,11 @@ class BaseGetXController extends GetxController {
|
||||
void checkBlueIsOpen(void Function() action) {
|
||||
NativeInteractionTool().sendGetBlueStatus();
|
||||
NativeInteractionTool().receiveChannelBlueIsOnEvent((String status) {
|
||||
if (status == "1") {
|
||||
if (status == '1') {
|
||||
// 蓝牙已打开
|
||||
AppLog.log('蓝牙已打开');
|
||||
action();
|
||||
} else if (status == "0") {
|
||||
} else if (status == '0') {
|
||||
// 蓝牙未打开
|
||||
AppLog.log('蓝牙未打开');
|
||||
showIosTipViewDialog();
|
||||
@ -148,7 +148,7 @@ class BaseGetXController extends GetxController {
|
||||
} else {
|
||||
// 蓝牙未打开
|
||||
AppLog.log('设备不支持蓝牙');
|
||||
showToast("设备不支持蓝牙");
|
||||
showToast('设备不支持蓝牙');
|
||||
return;
|
||||
}
|
||||
});
|
||||
@ -159,8 +159,8 @@ class BaseGetXController extends GetxController {
|
||||
context: Get.context!,
|
||||
builder: (BuildContext context) {
|
||||
return ShowIosTipView(
|
||||
title: "提示",
|
||||
tipTitle: "蓝牙未打开,请到设置里面打开蓝牙",
|
||||
title: '提示',
|
||||
tipTitle: '蓝牙未打开,请到设置里面打开蓝牙',
|
||||
sureClick: () {
|
||||
Get.back();
|
||||
if (Platform.isIOS) {
|
||||
@ -184,23 +184,45 @@ class BaseGetXController extends GetxController {
|
||||
"${DateTool().dateToYMDHNString(startDate.toString())}-${DateTool().dateToYMDHNString(endDate.toString())} ${"限时".tr}";
|
||||
} else if (keyType == XSConstantMacro.keyTypeLong) {
|
||||
//永久
|
||||
// DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
|
||||
// useDateStr = '${dateStr.toLocal().toString().substring(0, 16)}\n永久';
|
||||
useDateStr = '永久'.tr;
|
||||
} else if (keyType == XSConstantMacro.keyTypeOnce) {
|
||||
//单次
|
||||
// DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!);
|
||||
// useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} \n单次';
|
||||
useDateStr = '单次'.tr;
|
||||
} else if (keyType == XSConstantMacro.keyTypeLoop) {
|
||||
//循环
|
||||
useDateStr =
|
||||
"${DateTool().dateToYMDString(startDate.toString())}-${DateTool().dateToYMDString(endDate.toString())} ${"循环".tr}";
|
||||
}
|
||||
|
||||
return useDateStr;
|
||||
}
|
||||
|
||||
List<String> getUseKeyTypeListStr(
|
||||
int? startDate, int? endDate, int? keyType) {
|
||||
final List<String> useDateListStr = <String>[];
|
||||
if (keyType == XSConstantMacro.keyTypeTime) {
|
||||
//限期
|
||||
useDateListStr.addAll(<String>[
|
||||
DateTool().dateToYMDHNString(startDate.toString()),
|
||||
DateTool().dateToYMDHNString(endDate.toString()),
|
||||
'限时'.tr,
|
||||
]);
|
||||
} else if (keyType == XSConstantMacro.keyTypeLong) {
|
||||
//永久
|
||||
useDateListStr.add('永久'.tr);
|
||||
} else if (keyType == XSConstantMacro.keyTypeOnce) {
|
||||
//单次
|
||||
useDateListStr.add('单次'.tr);
|
||||
} else if (keyType == XSConstantMacro.keyTypeLoop) {
|
||||
//循环
|
||||
useDateListStr.addAll(<String>[
|
||||
DateTool().dateToYMDString(startDate.toString()),
|
||||
DateTool().dateToYMDString(endDate.toString()),
|
||||
'循环'.tr,
|
||||
]);
|
||||
}
|
||||
return useDateListStr;
|
||||
}
|
||||
|
||||
static List splitList(List list, int len) {
|
||||
if (len <= 1) {
|
||||
return [list];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user