view.dart 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import 'package:flutter/material.dart';
  2. import 'package:get/get.dart';
  3. import 'package:vitalapp/components/button.dart';
  4. import 'package:vitalapp/components/cell.dart';
  5. import 'package:vitalapp/components/dialog_input.dart';
  6. import 'package:vitalapp/components/dialog_number.dart';
  7. import 'package:vitalapp/components/dialog_select.dart';
  8. import 'package:vitalapp/pages/settings/server/widgets/protocol_switch.dart';
  9. import 'controller.dart';
  10. import 'widgets/dialog_saved_list.dart';
  11. class ServerSettingPage extends GetView<ServerSettingController> {
  12. const ServerSettingPage({super.key});
  13. @override
  14. Widget build(BuildContext context) {
  15. final state = controller.state;
  16. return Column(
  17. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  18. children: [
  19. VListFormCellGroup(
  20. children: [
  21. VListFormCell(
  22. label: "已保存地址",
  23. onTap: () async {
  24. final result = await SavedServersDialog.show();
  25. if (result != null) {
  26. //
  27. }
  28. },
  29. ),
  30. Obx(
  31. () => VListFormCell(
  32. label: "协议",
  33. contentWidget: ProtocolSwitchWidget(
  34. useSSL: state.enableSSL,
  35. onChanged: (value) {
  36. state.enableSSL = value;
  37. },
  38. ),
  39. ),
  40. ),
  41. Obx(
  42. () => VListFormCell(
  43. label: "域名/IP",
  44. content: state.host,
  45. onTap: () async {
  46. final newValue = await VDialogInput(
  47. title: "域名/IP",
  48. initialValue: state.host.toString(),
  49. ).show();
  50. if (newValue != null) {
  51. state.host = newValue;
  52. }
  53. },
  54. ),
  55. ),
  56. Obx(
  57. () => VListFormCell(
  58. label: "端口",
  59. content: state.port.toString(),
  60. onTap: () async {
  61. final newValue = await VDialogNumber(
  62. title: "端口",
  63. initialValue: state.port.toString(),
  64. ).show();
  65. if (newValue != null) {
  66. state.port = int.parse(newValue);
  67. }
  68. },
  69. ),
  70. ),
  71. ],
  72. ),
  73. Padding(
  74. padding: const EdgeInsets.only(bottom: 30),
  75. child: VButton(
  76. label: "保存",
  77. onTap: controller.submit,
  78. ),
  79. ),
  80. ],
  81. );
  82. }
  83. }