|
@@ -6,10 +6,14 @@ import 'package:flutter/material.dart';
|
|
|
import 'package:get/get.dart';
|
|
|
import 'package:naiyouwl/app/component/sys_app_bar.dart';
|
|
|
import 'package:window_manager/window_manager.dart';
|
|
|
+import '../../../component/connection_status.dart';
|
|
|
+import '../../../component/connection_widget.dart';
|
|
|
|
|
|
import '../controllers/home_controller.dart';
|
|
|
|
|
|
+
|
|
|
class HomeView extends GetView<HomeController> {
|
|
|
+
|
|
|
const HomeView({Key? key}) : super(key: key);
|
|
|
|
|
|
@override
|
|
@@ -17,99 +21,143 @@ class HomeView extends GetView<HomeController> {
|
|
|
return Container(
|
|
|
decoration: const BoxDecoration(
|
|
|
image: DecorationImage(
|
|
|
- image: AssetImage("images/login/login.png"),
|
|
|
+ image: AssetImage("images/main/main.png"),
|
|
|
fit: BoxFit.fill,
|
|
|
),
|
|
|
),
|
|
|
child: Scaffold(
|
|
|
backgroundColor: Colors.transparent,
|
|
|
- appBar: const SysAppBar(title: Text("登录"),),
|
|
|
+ appBar: const SysAppBar(title: Text("首页"),),
|
|
|
|
|
|
body: Obx(() {
|
|
|
- return LoginScreen(isLoading: controller.isLoading.value,
|
|
|
- onLogin: (username, password) {
|
|
|
- controller.fetchSysConfig();
|
|
|
- // 在这里处理登录逻辑,例如调用API
|
|
|
- print('Username: $username');
|
|
|
- print('Password: $password');
|
|
|
- });
|
|
|
+ return Column(
|
|
|
+ children: [
|
|
|
+ UserStatusWidget(isActive: true,isLoading: controller.isLoading.value,username:"",expiryDate: "",userTraffic:"",onRefresh: () async {
|
|
|
+ // 这里插入刷新操作代码
|
|
|
+ //await Future.delayed(Duration(seconds: 2));
|
|
|
+ },),
|
|
|
+ Padding(
|
|
|
+ padding: const EdgeInsets.fromLTRB(20, 20, 0, 0),
|
|
|
+ child: Row(
|
|
|
+ children: controller.imageMap.entries.expand((entry) {
|
|
|
+ return [
|
|
|
+ GestureDetector(
|
|
|
+ onTap: () => controller.onImageTap(entry.key),
|
|
|
+ child: Image(
|
|
|
+ image: AssetImage(entry.value),
|
|
|
+ width: 60,
|
|
|
+ height: 60,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ //Spacer(), // 平均分配间隔
|
|
|
+ const SizedBox(width: 30),
|
|
|
+ ];
|
|
|
+ }).toList()
|
|
|
+ ..removeLast(), // 删除最后一个Spacer
|
|
|
+ )
|
|
|
+
|
|
|
+ ),
|
|
|
+ const SizedBox(height: 35,),
|
|
|
+ const Padding(
|
|
|
+ padding: EdgeInsets.fromLTRB(30, 0, 30, 0),
|
|
|
+ child: Row(
|
|
|
+ children: [
|
|
|
+
|
|
|
+ Text("http://127.0.0.1:5336"),
|
|
|
+ Spacer(),
|
|
|
+ Text("socks://127.0.0.1:5337"),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ConnectionWidget(
|
|
|
+ status: ConnectionStatus.disconnected, onStatusChange: (con) {
|
|
|
+
|
|
|
+ },)
|
|
|
+ ],
|
|
|
+ );
|
|
|
})
|
|
|
),
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-class LoginScreen extends StatefulWidget {
|
|
|
- final Function(String username, String password) onLogin;
|
|
|
- final bool isLoading;
|
|
|
+class UserStatusWidget extends StatefulWidget {
|
|
|
|
|
|
- LoginScreen({required this.isLoading, required this.onLogin});
|
|
|
+ final Future<void> Function() onRefresh; // 新增的回调
|
|
|
+ final bool isActive;
|
|
|
+ final bool isLoading; // 新增的变量
|
|
|
+ final String username;
|
|
|
+ final String userTraffic;
|
|
|
+ final String expiryDate;
|
|
|
+ const UserStatusWidget({Key? key, required this.isActive, required this.isLoading,required this.username, required this.userTraffic, required this.expiryDate, required this.onRefresh}) : super(key: key);
|
|
|
|
|
|
@override
|
|
|
- _LoginScreenState createState() => _LoginScreenState();
|
|
|
+ _UserStatusWidgetState createState() => _UserStatusWidgetState();
|
|
|
}
|
|
|
|
|
|
-class _LoginScreenState extends State<LoginScreen> {
|
|
|
- final _usernameController = TextEditingController();
|
|
|
- final _passwordController = TextEditingController();
|
|
|
-
|
|
|
+class _UserStatusWidgetState extends State<UserStatusWidget> {
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
- return Padding(
|
|
|
- padding: const EdgeInsets.only(bottom: 30),
|
|
|
- child: Center(
|
|
|
- child: Padding(
|
|
|
- padding: const EdgeInsets.fromLTRB(55, 0, 55, 0),
|
|
|
- child: Column(
|
|
|
- mainAxisAlignment: MainAxisAlignment.center,
|
|
|
- children: [
|
|
|
- TextField(
|
|
|
- controller: _usernameController,
|
|
|
- decoration: const InputDecoration(
|
|
|
- labelText: '用户名',
|
|
|
- hintText: '请输入用户名',
|
|
|
- border: InputBorder.none,
|
|
|
- ),
|
|
|
- ),
|
|
|
- const SizedBox(height: 16),
|
|
|
- TextField(
|
|
|
- controller: _passwordController,
|
|
|
- decoration: const InputDecoration(
|
|
|
- labelText: '密码',
|
|
|
- hintText: '输入密码',
|
|
|
- border: InputBorder.none,
|
|
|
+ String imagePath = widget.isActive
|
|
|
+ ? "images/main/userstatus.png"
|
|
|
+ : "images/main/userstatusoff.png";
|
|
|
+
|
|
|
+ return Align(
|
|
|
+ alignment: Alignment.topCenter,
|
|
|
+ child: Padding(
|
|
|
+ padding: const EdgeInsets.fromLTRB(10.0, 0, 10.0, 10.0),
|
|
|
+ child:
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ const SizedBox(
|
|
|
+ width: 80,
|
|
|
+ height: 20,
|
|
|
+ ),
|
|
|
+ Column(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start, // 这将使子组件从左边开始对齐
|
|
|
+ children: [
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ Text(widget.username),
|
|
|
+ const SizedBox(width: 10,),
|
|
|
+ Image(
|
|
|
+ image: AssetImage(imagePath),
|
|
|
+ width: 100,
|
|
|
+ height: 30,
|
|
|
+ ),
|
|
|
+ const SizedBox(width: 10,),
|
|
|
+ IconButton(
|
|
|
+ icon: widget.isLoading ? const CircularProgressIndicator() : Image.asset("images/main/refresh.png"),
|
|
|
+ onPressed: () {
|
|
|
+ // 刷新操作
|
|
|
+ if(!widget.isLoading){
|
|
|
+ widget.onRefresh();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ )
|
|
|
+ ],
|
|
|
),
|
|
|
- obscureText: true,
|
|
|
-
|
|
|
- ),
|
|
|
- const SizedBox(height: 20),
|
|
|
- SizedBox(
|
|
|
- width: 200,
|
|
|
- height: 40,
|
|
|
- child: ElevatedButton(
|
|
|
- onPressed: () {
|
|
|
- if (!widget.isLoading) {
|
|
|
- final username = _usernameController.text;
|
|
|
- final password = _passwordController.text;
|
|
|
- widget.onLogin(username, password);
|
|
|
- }
|
|
|
- },
|
|
|
- child: widget.isLoading ? const CircularProgressIndicator(
|
|
|
- color: Colors.white,
|
|
|
- ) : const Text('登录'),
|
|
|
+ Text(
|
|
|
+ widget.expiryDate,
|
|
|
+ style: const TextStyle(
|
|
|
+ fontSize: 8.0, // 设置字体大小为20像素
|
|
|
+ ),
|
|
|
),
|
|
|
- ),
|
|
|
- ],
|
|
|
- ),
|
|
|
+ Text(
|
|
|
+ widget.userTraffic,
|
|
|
+ style: const TextStyle(
|
|
|
+ fontSize: 8.0, // 设置字体大小为20像素
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ],
|
|
|
),
|
|
|
+ // const SizedBox(height: 10,), // 可调整间隔
|
|
|
),
|
|
|
);
|
|
|
}
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- @override
|
|
|
- void dispose() {
|
|
|
- _usernameController.dispose();
|
|
|
- _passwordController.dispose();
|
|
|
- super.dispose();
|
|
|
- }
|
|
|
-}
|