设置中 添加控制台火灾报警开关

hmxc
张萌 3 years ago
parent 4c3c739c9f
commit fa6c5e0b64

@ -1,3 +1,6 @@
import 'package:aku_community/utils/developer_util.dart';
import 'package:aku_community/utils/websocket/web_socket_util.dart';
import 'package:aku_community/widget/others/user_tool.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@ -160,9 +163,35 @@ class _SettingsPageState extends State<SettingsPage> {
height: 1.w,
)),
53.hb,
if (DeveloperUtil.dev) _closeFireAlert(),
if (DeveloperUtil.dev) 53.hb,
_quitButton(),
],
),
);
}
Widget _closeFireAlert() {
return Container(
color: Colors.white,
padding: EdgeInsets.symmetric(vertical: 12.w, horizontal: 64.w),
child: Row(
children: [
'开启火灾报警'.text.size(28.sp).color(ktextPrimary).bold.make().expand(),
CupertinoSwitch(
value: UserTool.appProveider.fireAlert,
onChanged: (value) {
UserTool.appProveider.setFireAlert(value);
if (UserTool.appProveider.fireAlert) {
WebSocketUtil().startWebSocket();
WebSocketUtil().setPrintHeart(value);
} else {
WebSocketUtil().closeWebSocket();
}
setState(() {});
})
],
),
);
}
}

@ -250,4 +250,11 @@ class AppProvider extends ChangeNotifier {
.toList();
notifyListeners();
}
//
bool _fireAlert = true;
bool get fireAlert => _fireAlert;
void setFireAlert(bool value) {
_fireAlert = value;
notifyListeners();
}
}

@ -205,4 +205,9 @@ class WebSocketUtil {
print(data);
}
}
///
void setPrintHeart(bool value) {
this._consolePrint = value;
}
}

Loading…
Cancel
Save