mirror of
https://github.com/lifegpc/eh_downloader_flutter.git
synced 2026-07-08 01:30:28 +08:00
Allow change settings in login page
Fix layout
This commit is contained in:
@@ -36,7 +36,8 @@ Future<bool> login(String username, String password) async {
|
||||
throw re.unwrapErr();
|
||||
}
|
||||
|
||||
class _LoginPageState extends State<LoginPage> with ThemeModeWidget {
|
||||
class _LoginPageState extends State<LoginPage>
|
||||
with ThemeModeWidget, IsTopWidget2 {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
String _username = "";
|
||||
String _password = "";
|
||||
@@ -45,6 +46,10 @@ class _LoginPageState extends State<LoginPage> with ThemeModeWidget {
|
||||
bool _isLogin = false;
|
||||
bool _checkAuth = false;
|
||||
|
||||
void _onStateChanged(dynamic _) {
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -53,6 +58,13 @@ class _LoginPageState extends State<LoginPage> with ThemeModeWidget {
|
||||
_passwordVisible = false;
|
||||
_isValid = false;
|
||||
_isLogin = false;
|
||||
listener.on("user_logined", _onStateChanged);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
listener.removeEventListener("user_logined", _onStateChanged);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
static bool _checkIsValid(String username, String password) {
|
||||
@@ -82,6 +94,7 @@ class _LoginPageState extends State<LoginPage> with ThemeModeWidget {
|
||||
}
|
||||
|
||||
void _checkStatus(BuildContext build) {
|
||||
if (!isTop(context)) return;
|
||||
if (auth.isAuthed) {
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||
build.go("/");
|
||||
@@ -107,18 +120,18 @@ class _LoginPageState extends State<LoginPage> with ThemeModeWidget {
|
||||
Widget build(BuildContext context) {
|
||||
tryInitApi(context);
|
||||
_checkStatus(context);
|
||||
if (isTop(context) && auth.user != null) {
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||
context.canPop() ? context.pop() : context.go("/");
|
||||
});
|
||||
}
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: auth.user == null
|
||||
? Container()
|
||||
: IconButton(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
onPressed: () {
|
||||
context.canPop() ? context.pop() : context.go("/");
|
||||
}),
|
||||
leading: Container(),
|
||||
title: Text(AppLocalizations.of(context)!.login),
|
||||
actions: [
|
||||
buildThemeModeIcon(context),
|
||||
buildMoreVertSettingsButon(context),
|
||||
],
|
||||
),
|
||||
body: PopScope(
|
||||
|
||||
@@ -237,6 +237,7 @@ class _DisplaySettingsPage extends State<DisplaySettingsPage>
|
||||
: e.langName))
|
||||
.toList(),
|
||||
leadingIcon: const Icon(Icons.language),
|
||||
width: 250,
|
||||
)),
|
||||
Container(
|
||||
padding:
|
||||
|
||||
@@ -142,7 +142,7 @@ class _UsersPage extends State<UsersPage> with ThemeModeWidget, IsTopWidget2 {
|
||||
Widget _buildSliverGrid(BuildContext context) {
|
||||
return SliverGrid(
|
||||
gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
|
||||
maxCrossAxisExtent: 360.0,
|
||||
maxCrossAxisExtent: 370.0,
|
||||
mainAxisSpacing: 10.0,
|
||||
crossAxisSpacing: 10.0,
|
||||
mainAxisExtent: 80.0,
|
||||
|
||||
Reference in New Issue
Block a user