123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- import 'package:flutter/material.dart';
- import 'package:get/get.dart';
- import 'package:vitalapp/architecture/utils/prompt_box.dart';
- import 'package:vitalapp/components/appbar.dart';
- import 'package:vitalapp/rpc.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)),
- const SizedBox(height: 8),
- _buildNetOnlineControl(),
- const SizedBox(height: 8),
- _buildDeviceLogControl(),
- if (controller.state.isDeveloper) ...[
- const SizedBox(height: 8),
- _buildDbCpControl(),
- const SizedBox(height: 8),
- _buildServerControl(),
- ],
- ],
- ),
- );
- }
- 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"),
- ),
- ],
- );
- }
- }
|