routingmode_view.dart 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import 'package:get/get.dart';
  4. import 'package:nomo/app/base/base_view.dart';
  5. import 'package:nomo/app/widgets/click_opacity.dart';
  6. import 'package:nomo/app/widgets/ix_app_bar.dart';
  7. import 'package:nomo/config/theme/theme_extensions/theme_extension.dart';
  8. import '../controllers/routingmode_controller.dart';
  9. class RoutingmodeView extends BaseView<RoutingmodeController> {
  10. const RoutingmodeView({super.key});
  11. @override
  12. Widget buildContent(BuildContext context) {
  13. return Column(
  14. children: [
  15. IXAppBar(title: 'Routing Mode'),
  16. Padding(
  17. padding: EdgeInsets.symmetric(horizontal: 14.w, vertical: 20.h),
  18. child: Container(
  19. decoration: BoxDecoration(
  20. color: Get.reactiveTheme.highlightColor,
  21. borderRadius: BorderRadius.circular(16.r),
  22. ),
  23. child: Obx(
  24. () => Column(
  25. mainAxisSize: MainAxisSize.min,
  26. children: [
  27. _buildRoutingOption(
  28. mode: RoutingMode.smart,
  29. icon: Icons.flash_on,
  30. title: 'Smart',
  31. description:
  32. 'The local and VPN networks coexist, and the optimal route is selected intelligently.',
  33. isSelected:
  34. controller.selectedMode.value == RoutingMode.smart,
  35. onTap: () => controller.selectMode(RoutingMode.smart),
  36. ),
  37. _buildDivider(),
  38. _buildRoutingOption(
  39. mode: RoutingMode.global,
  40. icon: Icons.language,
  41. title: 'Global',
  42. description:
  43. 'All traffic is routed through the VPN server to ensure maximum privacy and security.',
  44. isSelected:
  45. controller.selectedMode.value == RoutingMode.global,
  46. onTap: () => controller.selectMode(RoutingMode.global),
  47. ),
  48. ],
  49. ),
  50. ),
  51. ),
  52. ),
  53. ],
  54. );
  55. }
  56. /// 构建路由选项
  57. Widget _buildRoutingOption({
  58. required RoutingMode mode,
  59. required IconData icon,
  60. required String title,
  61. required String description,
  62. required bool isSelected,
  63. required VoidCallback onTap,
  64. }) {
  65. return ClickOpacity(
  66. onTap: onTap,
  67. child: Padding(
  68. padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 16.h),
  69. child: Row(
  70. children: [
  71. // 图标
  72. Container(
  73. width: 40.w,
  74. height: 40.w,
  75. decoration: BoxDecoration(
  76. color: const Color(0xFF00A8E8),
  77. borderRadius: BorderRadius.circular(12.r),
  78. ),
  79. child: Icon(icon, color: Colors.white, size: 20.w),
  80. ),
  81. SizedBox(width: 12.w),
  82. // 标题和描述
  83. Expanded(
  84. child: Column(
  85. crossAxisAlignment: CrossAxisAlignment.start,
  86. children: [
  87. Text(
  88. title,
  89. style: TextStyle(
  90. fontSize: 16.sp,
  91. fontWeight: FontWeight.w500,
  92. color: Colors.white,
  93. ),
  94. ),
  95. SizedBox(height: 4.h),
  96. Text(
  97. description,
  98. style: TextStyle(
  99. fontSize: 12.sp,
  100. color: Get.reactiveTheme.hintColor,
  101. height: 1.4,
  102. ),
  103. ),
  104. ],
  105. ),
  106. ),
  107. SizedBox(width: 12.w),
  108. // 选中指示器
  109. Container(
  110. width: 24.w,
  111. height: 24.w,
  112. decoration: BoxDecoration(
  113. shape: BoxShape.circle,
  114. color: isSelected
  115. ? const Color(0xFF00A8E8)
  116. : Colors.transparent,
  117. border: Border.all(
  118. color: isSelected
  119. ? const Color(0xFF00A8E8)
  120. : Get.reactiveTheme.hintColor.withOpacity(0.5),
  121. width: 2.w,
  122. ),
  123. ),
  124. child: isSelected
  125. ? Icon(Icons.check, color: Colors.white, size: 16.w)
  126. : null,
  127. ),
  128. ],
  129. ),
  130. ),
  131. );
  132. }
  133. /// 构建分割线
  134. Widget _buildDivider() {
  135. return Padding(
  136. padding: EdgeInsets.symmetric(horizontal: 20.w),
  137. child: Divider(
  138. color: Get.reactiveTheme.hintColor.withOpacity(0.1),
  139. height: 1.h,
  140. thickness: 1.h,
  141. ),
  142. );
  143. }
  144. }