|
@@ -11,6 +11,7 @@ import '../controllers/home_controller.dart';
|
|
|
|
|
|
class HomeView extends GetView<HomeController> {
|
|
|
const HomeView({Key? key}) : super(key: key);
|
|
|
+
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
return Container(
|
|
@@ -20,24 +21,29 @@ class HomeView extends GetView<HomeController> {
|
|
|
fit: BoxFit.fill,
|
|
|
),
|
|
|
),
|
|
|
- child: Scaffold(
|
|
|
- backgroundColor: Colors.transparent,
|
|
|
- appBar: const SysAppBar(title: Text("登录"),),
|
|
|
+ child: Scaffold(
|
|
|
+ backgroundColor: Colors.transparent,
|
|
|
+ appBar: const SysAppBar(title: Text("登录"),),
|
|
|
|
|
|
- body: LoginScreen(onLogin: (username,password) {
|
|
|
- controller.fetchSysConfig();
|
|
|
- // 在这里处理登录逻辑,例如调用API
|
|
|
- print('Username: $username');
|
|
|
- print('Password: $password');
|
|
|
- })
|
|
|
+ body: Obx(() {
|
|
|
+ return LoginScreen(isLoading: controller.isLoading.value,
|
|
|
+ onLogin: (username, password) {
|
|
|
+ controller.fetchSysConfig();
|
|
|
+ // 在这里处理登录逻辑,例如调用API
|
|
|
+ print('Username: $username');
|
|
|
+ print('Password: $password');
|
|
|
+ });
|
|
|
+ })
|
|
|
),
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
class LoginScreen extends StatefulWidget {
|
|
|
final Function(String username, String password) onLogin;
|
|
|
+ final bool isLoading;
|
|
|
|
|
|
- LoginScreen({required this.onLogin});
|
|
|
+ LoginScreen({required this.isLoading, required this.onLogin});
|
|
|
|
|
|
@override
|
|
|
_LoginScreenState createState() => _LoginScreenState();
|
|
@@ -82,11 +88,15 @@ class _LoginScreenState extends State<LoginScreen> {
|
|
|
height: 40,
|
|
|
child: ElevatedButton(
|
|
|
onPressed: () {
|
|
|
- final username = _usernameController.text;
|
|
|
- final password = _passwordController.text;
|
|
|
- widget.onLogin(username, password);
|
|
|
+ if (!widget.isLoading) {
|
|
|
+ final username = _usernameController.text;
|
|
|
+ final password = _passwordController.text;
|
|
|
+ widget.onLogin(username, password);
|
|
|
+ }
|
|
|
},
|
|
|
- child: const Text('登录'),
|
|
|
+ child: widget.isLoading ? const CircularProgressIndicator(
|
|
|
+ color: Colors.white,
|
|
|
+ ) : const Text('登录'),
|
|
|
),
|
|
|
),
|
|
|
],
|