import 'dart:io'; import 'package:flutter/foundation.dart'; 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 '../controllers/home_controller.dart'; class HomeView extends GetView { const HomeView({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Container( decoration: const BoxDecoration( image: DecorationImage( image: AssetImage("images/login/login.png"), fit: BoxFit.fill, ), ), child: Scaffold( backgroundColor: Colors.transparent, appBar: const SysAppBar(title: Text("登录"),), body: LoginScreen(onLogin: (username,password) { // 在这里处理登录逻辑,例如调用API print('Username: $username'); print('Password: $password'); }) ), ); } } class LoginScreen extends StatefulWidget { final Function(String username, String password) onLogin; LoginScreen({required this.onLogin}); @override _LoginScreenState createState() => _LoginScreenState(); } class _LoginScreenState extends State { final _usernameController = TextEditingController(); final _passwordController = TextEditingController(); @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, ), obscureText: true, ), const SizedBox(height: 20), SizedBox( width: 200, height: 40, child: ElevatedButton( onPressed: () { final username = _usernameController.text; final password = _passwordController.text; widget.onLogin(username, password); }, child: const Text('登录'), ), ), ], ), ), ), ); } @override void dispose() { _usernameController.dispose(); _passwordController.dispose(); super.dispose(); } }