mirror of
https://github.com/qinglong-app/qinglong_app.git
synced 2025-10-09 16:48:19 +08:00
add login
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import 'package:dio_log/dio_log.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:qinglong_app/base/common_dialog.dart';
|
||||
import 'package:qinglong_app/base/routes.dart';
|
||||
import 'package:qinglong_app/main.dart';
|
||||
import 'package:qinglong_app/module/login/login_viewmodel.dart';
|
||||
import 'package:qinglong_app/utils/utils.dart';
|
||||
|
||||
@@ -14,9 +15,16 @@ class LoginPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _LoginPageState extends State<LoginPage> {
|
||||
final TextEditingController _hostController = TextEditingController(text: userInfoViewModel.host);
|
||||
final TextEditingController _userNameController = TextEditingController();
|
||||
final TextEditingController _passwordController = TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
showDebugBtn(context, btnColor: Colors.blue);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -39,6 +47,41 @@ class _LoginPageState extends State<LoginPage> {
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height / 3,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 15,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const SizedBox(
|
||||
child: Text(
|
||||
"域名:",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
width: 60,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 15,
|
||||
),
|
||||
Expanded(
|
||||
child: TextField(
|
||||
onChanged: (_) {
|
||||
setState(() {});
|
||||
},
|
||||
controller: _hostController,
|
||||
decoration: const InputDecoration(
|
||||
contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5),
|
||||
hintText: "http://1.1.1.1:5700",
|
||||
),
|
||||
autofocus: false,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 15,
|
||||
@@ -60,6 +103,7 @@ class _LoginPageState extends State<LoginPage> {
|
||||
),
|
||||
Expanded(
|
||||
child: TextField(
|
||||
|
||||
onChanged: (_) {
|
||||
setState(() {});
|
||||
},
|
||||
@@ -117,7 +161,7 @@ class _LoginPageState extends State<LoginPage> {
|
||||
SizedBox(
|
||||
width: MediaQuery.of(context).size.width - 30,
|
||||
child: CupertinoButton(
|
||||
color: (_userNameController.text.isNotEmpty && _passwordController.text.isNotEmpty && !model.isLoading)
|
||||
color: (_hostController.text.isNotEmpty && _userNameController.text.isNotEmpty && _passwordController.text.isNotEmpty && !model.isLoading)
|
||||
? Theme.of(context).primaryColor
|
||||
: Theme.of(context).primaryColor.withOpacity(0.3),
|
||||
child: model.isLoading
|
||||
@@ -131,6 +175,7 @@ class _LoginPageState extends State<LoginPage> {
|
||||
onPressed: () {
|
||||
if (model.isLoading) return;
|
||||
Utils.hideKeyBoard(context);
|
||||
userInfoViewModel.updateHost(_hostController.text);
|
||||
model.login(_userNameController.text, _passwordController.text);
|
||||
}),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user