1.更新眠花糖ios控制页空白 2.修复ios首页第一次点击控制无效果 3.修复ios扫描蓝牙的错误提示
This commit is contained in:
@@ -61,7 +61,7 @@ class _BlueteethDevicePageState extends State<BlueteethDevicePage> {
|
|||||||
Get.find<BlueteethBindController>().startStatusPolling();
|
Get.find<BlueteethBindController>().startStatusPolling();
|
||||||
blueteethBindController.search.value = "";
|
blueteethBindController.search.value = "";
|
||||||
blueteethBindController.currentDeviceMac?.value = "";
|
blueteethBindController.currentDeviceMac?.value = "";
|
||||||
BluetoothHelper.listenBluetoothState((isOn) {
|
BluetoothHelper.listenBluetoothState((isOn) async {
|
||||||
blueteethBindController.model.bluetooth = isOn;
|
blueteethBindController.model.bluetooth = isOn;
|
||||||
if (isOn) {
|
if (isOn) {
|
||||||
isScanning = false;
|
isScanning = false;
|
||||||
@@ -69,13 +69,17 @@ class _BlueteethDevicePageState extends State<BlueteethDevicePage> {
|
|||||||
}
|
}
|
||||||
blueteethBindController.updateAll();
|
blueteethBindController.updateAll();
|
||||||
if (!isOn && !_isDialogShowing) {
|
if (!isOn && !_isDialogShowing) {
|
||||||
_isDialogShowing = true;
|
await Future.delayed(Duration(seconds: 2));
|
||||||
blueteethBindController.model.devicelist = [];
|
bool isReallyOn = await FlutterBluePlus.isOn;
|
||||||
blueteethBindController.model.betDevicelist = [];
|
if (!isReallyOn) {
|
||||||
blueteethBindController.updateAll();
|
_isDialogShowing = true;
|
||||||
_showBluetoothNotEnabledDialog().then((_) {
|
blueteethBindController.model.devicelist = [];
|
||||||
_isDialogShowing = false;
|
blueteethBindController.model.betDevicelist = [];
|
||||||
});
|
blueteethBindController.updateAll();
|
||||||
|
_showBluetoothNotEnabledDialog().then((_) {
|
||||||
|
_isDialogShowing = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,18 +63,22 @@ class _MHTBlueteethDevicePageState extends State<MHTBlueteethDevicePage> {
|
|||||||
mhtBlueToothController.startStatusPolling();
|
mhtBlueToothController.startStatusPolling();
|
||||||
mhtBlueToothController.search.value = "";
|
mhtBlueToothController.search.value = "";
|
||||||
mhtBlueToothController.currentDeviceMac?.value = "";
|
mhtBlueToothController.currentDeviceMac?.value = "";
|
||||||
BluetoothHelper.listenBluetoothState((isOn) {
|
BluetoothHelper.listenBluetoothState((isOn) async {
|
||||||
mhtBlueToothController.model.bluetooth = isOn;
|
mhtBlueToothController.model.bluetooth = isOn;
|
||||||
mhtBlueToothController.updateAll();
|
mhtBlueToothController.updateAll();
|
||||||
|
|
||||||
if (!isOn && !_isDialogShowing) {
|
if (!isOn && !_isDialogShowing) {
|
||||||
_isDialogShowing = true;
|
await Future.delayed(Duration(seconds: 2));
|
||||||
mhtBlueToothController.model.blueRawData = [];
|
bool isReallyOn = await FlutterBluePlus.isOn;
|
||||||
mhtBlueToothController.model.deviceDataStatus = [];
|
if (!isReallyOn) {
|
||||||
mhtBlueToothController.updateAll();
|
_isDialogShowing = true;
|
||||||
_showBluetoothNotEnabledDialog().then((_) {
|
mhtBlueToothController.model.blueRawData = [];
|
||||||
_isDialogShowing = false;
|
mhtBlueToothController.model.deviceDataStatus = [];
|
||||||
});
|
mhtBlueToothController.updateAll();
|
||||||
|
_showBluetoothNotEnabledDialog().then((_) {
|
||||||
|
_isDialogShowing = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -238,24 +238,28 @@ Future<Map> checkBlueToothPermissin() async {
|
|||||||
var locationGranted;
|
var locationGranted;
|
||||||
|
|
||||||
if (Platform.isIOS) {
|
if (Platform.isIOS) {
|
||||||
PermissionStatus isBleGranted = await Permission.bluetooth.request();
|
try {
|
||||||
if (!isBleGranted.isGranted) {
|
PermissionStatus isBleGranted = await Permission.bluetooth.request();
|
||||||
// startBluetoothScanning();
|
if (!isBleGranted.isGranted) {
|
||||||
await FlutterBluePlus.startScan(timeout: Duration(seconds: 10));
|
// startBluetoothScanning();
|
||||||
data = {
|
|
||||||
'bluetoothScanGranted': true,
|
|
||||||
'bluetoothConnectGranted': true,
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
await FlutterBluePlus.startScan(timeout: Duration(seconds: 10));
|
await FlutterBluePlus.startScan(timeout: Duration(seconds: 10));
|
||||||
} catch (e) {
|
data = {
|
||||||
TopSlideNotification.show(Get.context!,
|
'bluetoothScanGranted': true,
|
||||||
text: "蓝牙权限未开启,请在设置中开启蓝牙权限".tr,
|
'bluetoothConnectGranted': true,
|
||||||
textColor: themeController.currentColor.sc9);
|
};
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
await FlutterBluePlus.startScan(timeout: Duration(seconds: 10));
|
||||||
|
} catch (e) {
|
||||||
|
TopSlideNotification.show(Get.context!,
|
||||||
|
text: "蓝牙权限未开启,请在设置中开启蓝牙权限".tr,
|
||||||
|
textColor: themeController.currentColor.sc9);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return data;
|
||||||
|
} catch (e) {
|
||||||
|
ef.log("${e.toString()}");
|
||||||
}
|
}
|
||||||
return data;
|
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
// 先显示权限说明弹窗(同屏显示)
|
// 先显示权限说明弹窗(同屏显示)
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class WebviewTestController extends GetControllerEx<WebviewTestModel> {
|
|||||||
),
|
),
|
||||||
settings: buildsettings(),
|
settings: buildsettings(),
|
||||||
params: PlatformHeadlessInAppWebViewCreationParams(
|
params: PlatformHeadlessInAppWebViewCreationParams(
|
||||||
onLoadStop: (controller, url) {
|
onLoadStop: (controller, url) async {
|
||||||
setState(() {
|
setState(() {
|
||||||
ready.value = true;
|
ready.value = true;
|
||||||
});
|
});
|
||||||
@@ -64,6 +64,9 @@ class WebviewTestController extends GetControllerEx<WebviewTestModel> {
|
|||||||
// ef.log("[请求资源时间]${web.requestTimestamp}");
|
// ef.log("[请求资源时间]${web.requestTimestamp}");
|
||||||
// _startMonitoringIfNeeded();
|
// _startMonitoringIfNeeded();
|
||||||
},
|
},
|
||||||
|
initialSettings: InAppWebViewSettings(
|
||||||
|
allowsBackForwardNavigationGestures: false, // 禁用侧滑返回/前进手势
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
@@ -617,186 +620,160 @@ class WebviewTestView extends GetComponent<WebviewTestController> {
|
|||||||
final mainAxisAlignment =
|
final mainAxisAlignment =
|
||||||
showWeb ? MainAxisAlignment.start : MainAxisAlignment.center;
|
showWeb ? MainAxisAlignment.start : MainAxisAlignment.center;
|
||||||
|
|
||||||
return Scaffold(
|
return PopScope(
|
||||||
backgroundColor: Colors.transparent,
|
canPop: false, // 完全禁止页面返回
|
||||||
body: Column(
|
onPopInvoked: (didPop) async {
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
if (didPop) return;
|
||||||
mainAxisSize: MainAxisSize.max,
|
},
|
||||||
mainAxisAlignment: mainAxisAlignment,
|
child: Scaffold(
|
||||||
children: [
|
backgroundColor: Colors.transparent,
|
||||||
// 未登录提示
|
body: Column(
|
||||||
if (!isLoggedIn)
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
Center(
|
mainAxisSize: MainAxisSize.max,
|
||||||
child: InkWell(
|
mainAxisAlignment: mainAxisAlignment,
|
||||||
onTap: () => Get.toNamed("/loginPage"),
|
children: [
|
||||||
child: RichText(
|
// 未登录提示
|
||||||
text: TextSpan(
|
if (!isLoggedIn)
|
||||||
children: [
|
Center(
|
||||||
TextSpan(
|
child: InkWell(
|
||||||
text: "请先".tr,
|
onTap: () => Get.toNamed("/loginPage"),
|
||||||
style: TextStyle(
|
child: RichText(
|
||||||
color: Colors.white,
|
text: TextSpan(
|
||||||
fontSize: 30.rpx,
|
children: [
|
||||||
),
|
TextSpan(
|
||||||
),
|
text: "请先".tr,
|
||||||
WidgetSpan(
|
style: TextStyle(
|
||||||
child: Stack(
|
color: Colors.white,
|
||||||
children: [
|
fontSize: 30.rpx,
|
||||||
Text(
|
|
||||||
"登录".tr,
|
|
||||||
style: TextStyle(
|
|
||||||
color: stringToColor("#84F5FF"),
|
|
||||||
fontSize: 30.rpx,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
Positioned(
|
),
|
||||||
bottom: 0,
|
WidgetSpan(
|
||||||
left: 0,
|
child: Stack(
|
||||||
right: 0,
|
|
||||||
child: Container(
|
|
||||||
height: 1,
|
|
||||||
color: stringToColor("#84F5FF"),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TextSpan(
|
|
||||||
text: "后,再进行设备控制".tr,
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.white,
|
|
||||||
fontSize: 30.rpx,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
// 已登录但无设备提示
|
|
||||||
if (isLoggedIn && !hasDevice)
|
|
||||||
Center(
|
|
||||||
child: InkWell(
|
|
||||||
onTap: () => Get.toNamed("/mHTDeviceTypePage"),
|
|
||||||
child: RichText(
|
|
||||||
text: TextSpan(
|
|
||||||
children: [
|
|
||||||
TextSpan(
|
|
||||||
text: "请先".tr,
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.white,
|
|
||||||
fontSize: 30.rpx,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
WidgetSpan(
|
|
||||||
child: Stack(
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
"绑定设备".tr,
|
|
||||||
style: TextStyle(
|
|
||||||
color: stringToColor("#84F5FF"),
|
|
||||||
fontSize: 30.rpx,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Positioned(
|
|
||||||
bottom: 0,
|
|
||||||
left: 0,
|
|
||||||
right: 0,
|
|
||||||
child: Container(
|
|
||||||
height: 1,
|
|
||||||
color: stringToColor("#84F5FF"),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TextSpan(
|
|
||||||
text: "后,再进行设备控制".tr,
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.white,
|
|
||||||
fontSize: 30.rpx,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
// 显示 WebView
|
|
||||||
if (showWeb)
|
|
||||||
Expanded(
|
|
||||||
child: Align(
|
|
||||||
alignment: Alignment.topLeft,
|
|
||||||
child: Obx(() {
|
|
||||||
// return (controller.ready.value && (MainPageBBottomChange.getCurrentIndex() == 2))
|
|
||||||
// return (controller.ready.value && (MainPageBBottomChange.getCurrentIndex() == 2)&& controller.loadRecource.value == true)
|
|
||||||
// return Stack(children: [
|
|
||||||
// controller.ready.value
|
|
||||||
// ? controller.web.build()
|
|
||||||
// : Container(),
|
|
||||||
// Text("1222121212"),
|
|
||||||
// ]);
|
|
||||||
// return Stack(
|
|
||||||
// children: [
|
|
||||||
// controller.ready.value
|
|
||||||
// ? controller.web.build()
|
|
||||||
// : Container(),
|
|
||||||
|
|
||||||
// // 只有 loadRecource == false 时才显示覆盖文字
|
|
||||||
// if (!controller.loadRecource.value)
|
|
||||||
// Positioned.fill(
|
|
||||||
// child: Container(
|
|
||||||
// color: Colors.black54, // 半透明遮罩,可选
|
|
||||||
// alignment: Alignment.center,
|
|
||||||
// child: Text(
|
|
||||||
// "资源加载中...",
|
|
||||||
// style: TextStyle(
|
|
||||||
// color: Colors.red,
|
|
||||||
// fontSize: 30.rpx,
|
|
||||||
// fontWeight: FontWeight.bold,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ],
|
|
||||||
// );
|
|
||||||
return Stack(
|
|
||||||
children: [
|
|
||||||
controller.ready.value
|
|
||||||
? controller.web.build()
|
|
||||||
: Container(),
|
|
||||||
if (!controller.loadRecource.value)
|
|
||||||
Positioned.fill(
|
|
||||||
child: Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
image: DecorationImage(
|
|
||||||
image: AssetImage(
|
|
||||||
'assets/images/new_background.png'),
|
|
||||||
fit: BoxFit.fill,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
alignment: Alignment.center,
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
children: [
|
||||||
CircularProgressIndicator(
|
Text(
|
||||||
valueColor: AlwaysStoppedAnimation<Color>(
|
"登录".tr,
|
||||||
Colors.white),
|
style: TextStyle(
|
||||||
|
color: stringToColor("#84F5FF"),
|
||||||
|
fontSize: 30.rpx,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
bottom: 0,
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
child: Container(
|
||||||
|
height: 1,
|
||||||
|
color: stringToColor("#84F5FF"),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
TextSpan(
|
||||||
],
|
text: "后,再进行设备控制".tr,
|
||||||
);
|
style: TextStyle(
|
||||||
}),
|
color: Colors.white,
|
||||||
),
|
fontSize: 30.rpx,
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
);
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
// 已登录但无设备提示
|
||||||
|
if (isLoggedIn && !hasDevice)
|
||||||
|
Center(
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () => Get.toNamed("/mHTDeviceTypePage"),
|
||||||
|
child: RichText(
|
||||||
|
text: TextSpan(
|
||||||
|
children: [
|
||||||
|
TextSpan(
|
||||||
|
text: "请先".tr,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 30.rpx,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
WidgetSpan(
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"绑定设备".tr,
|
||||||
|
style: TextStyle(
|
||||||
|
color: stringToColor("#84F5FF"),
|
||||||
|
fontSize: 30.rpx,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
bottom: 0,
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
child: Container(
|
||||||
|
height: 1,
|
||||||
|
color: stringToColor("#84F5FF"),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TextSpan(
|
||||||
|
text: "后,再进行设备控制".tr,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 30.rpx,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
// 显示 WebView
|
||||||
|
if (showWeb)
|
||||||
|
Expanded(
|
||||||
|
child: Align(
|
||||||
|
alignment: Alignment.topLeft,
|
||||||
|
child: Obx(() {
|
||||||
|
return Stack(
|
||||||
|
children: [
|
||||||
|
controller.ready.value
|
||||||
|
? controller.web.build()
|
||||||
|
: Container(),
|
||||||
|
if (!controller.loadRecource.value)
|
||||||
|
Positioned.fill(
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
image: DecorationImage(
|
||||||
|
image: AssetImage(
|
||||||
|
'assets/images/new_background.png'),
|
||||||
|
fit: BoxFit.fill,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
CircularProgressIndicator(
|
||||||
|
valueColor:
|
||||||
|
AlwaysStoppedAnimation<Color>(
|
||||||
|
Colors.white),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user