123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- import 'package:flutter/material.dart';
- import 'package:get/get.dart';
- import 'package:vitalapp/architecture/app_parameters.dart';
- import 'package:vitalapp/architecture/utils/prompt_box.dart';
- import 'package:vitalapp/components/appbar.dart';
- import 'package:vitalapp/rpc.dart';
- import 'package:wifi_iot/wifi_iot.dart';
- import 'blank_door.dart';
- import 'controller.dart';
- /// 后面管理页
- class AdminPage extends GetView<AdminController> {
- const AdminPage({super.key});
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: VAppBar(
- titleText: "Blank Door",
- actions: [
- TextButton.icon(
- onPressed: () {
- BlankDoor.reset();
- Get.back();
- },
- icon: Icon(
- Icons.restore,
- size: 32,
- color: Colors.white,
- ),
- label: Text(
- "Reset",
- style: TextStyle(
- color: Colors.white,
- ),
- ),
- ),
- ],
- ),
- body: ListView(
- padding: const EdgeInsets.symmetric(horizontal: 40),
- children: [
- const Text("欢迎补充", style: TextStyle(fontSize: 26)),
- SizedBox(
- height: 40,
- child: FutureBuilder(
- builder: (context, snapshot) {
- if (snapshot.hasData) {
- return Text("WIFI: ${snapshot.data ?? "Unknow"}");
- }
- return Text("WIFI: Loading...");
- },
- future: WiFiForIoTPlugin.getSSID(),
- ),
- ),
- const SizedBox(height: 8),
- _buildIsLocalStation(),
- const SizedBox(height: 8),
- _buildNetOnlineControl(),
- const SizedBox(height: 8),
- _buildDeviceLogControl(),
- if (controller.state.isDeveloper) ...[
- const SizedBox(height: 8),
- _buildDbCpControl(),
- const SizedBox(height: 8),
- _buildServerControl(),
- ],
- _buildCameraList(),
- ],
- ),
- );
- }
- Widget _buildIsLocalStation() {
- bool isLocalStation = AppParameters.data.isLocalStation;
- if (isLocalStation) {
- return Text("工作站模式", style: TextStyle(fontSize: 26));
- } else {
- return Text("一体机模式", style: TextStyle(fontSize: 26));
- }
- }
- Widget _buildNetOnlineControl() {
- return Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Text("Network Online: "),
- Obx(
- () => Switch(
- value: controller.state.isNetOnline,
- onChanged: (value) {
- controller.switchOnlineOffline();
- },
- ),
- ),
- ],
- );
- }
- Widget _buildDeviceLogControl() {
- return Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Text("DeviceLog Enable: "),
- Obx(
- () => Switch(
- value: controller.state.isDeviceLogEnable,
- onChanged: (value) {
- controller.setLogSwitch();
- },
- ),
- ),
- ],
- );
- }
- Widget _buildDbCpControl() {
- return Row(
- mainAxisAlignment: MainAxisAlignment.spaceEvenly,
- children: [
- ElevatedButton(
- onPressed: controller.cpDbFileLoki,
- child: const Text("Loki CP DB Out"),
- ),
- ElevatedButton(
- onPressed: controller.cpDbFileFinlay,
- child: const Text("Finlay CP DB In"),
- ),
- ],
- );
- }
- Widget _buildServerControl() {
- return Row(
- mainAxisAlignment: MainAxisAlignment.spaceEvenly,
- children: [
- ElevatedButton(
- onPressed: () {
- final host = rpc.currentHostAddress;
- if (host.contains('@_@')) {
- PromptBox.toast("已关闭");
- return;
- }
- final uri = Uri.parse(host);
- rpc.setServerHost(
- "${uri.host}:${uri.port}@_@", uri.scheme == 'https');
- rpc.clearCache();
- },
- child: const Text("CloseServer"),
- ),
- ElevatedButton(
- onPressed: () {
- final host = rpc.currentHostAddress.replaceAll('@_@', '');
- final uri = Uri.parse(host);
- rpc.setServerHost("${uri.host}:${uri.port}", uri.scheme == 'https');
- rpc.clearCache();
- PromptBox.toast("已开启");
- },
- child: const Text("OpenServer"),
- ),
- ],
- );
- }
- Widget _buildCameraList() {
- return Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- children: [
- Text("Camera List", style: TextStyle(fontSize: 26)),
- SizedBox(width: 20),
- ElevatedButton.icon(
- label: Text("Detect Camera"),
- icon: Icon(
- Icons.refresh,
- size: 30,
- ),
- onPressed: () {
- controller.detectCamera();
- },
- ),
- ElevatedButton.icon(
- label: Text("Open Camera Test Page"),
- icon: Icon(
- Icons.refresh,
- size: 30,
- ),
- onPressed: () {
- controller.openCameraTest();
- },
- ),
- ],
- ),
- // 多行文本
- Obx(() {
- if (controller.state.cameraList.isEmpty) {
- return Text("No Camera Detected ${controller.state.errorMessage}");
- }
- return Column(
- children: controller.state.cameraList
- .map(
- (e) => ListTile(
- title: Text(e),
- ),
- )
- .toList(),
- );
- }),
- ],
- );
- }
- }
|