mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-10 02:07:57 -06:00
Fixed bugs, added serialization for documents state
This commit is contained in:
@@ -2,16 +2,17 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||
import 'package:paperless_api/paperless_api.dart';
|
||||
import 'package:paperless_mobile/core/type/types.dart';
|
||||
import 'package:paperless_mobile/features/login/bloc/authentication_cubit.dart';
|
||||
import 'package:paperless_mobile/features/login/view/widgets/client_certificate_form_field.dart';
|
||||
import 'package:paperless_mobile/features/login/view/widgets/server_address_form_field.dart';
|
||||
import 'package:paperless_mobile/features/login/view/widgets/server_connection_page.dart';
|
||||
import 'package:paperless_mobile/features/login/view/widgets/user_credentials_form_field.dart';
|
||||
import 'package:paperless_mobile/features/login/view/widgets/form_fields/client_certificate_form_field.dart';
|
||||
import 'package:paperless_mobile/features/login/view/widgets/form_fields/server_address_form_field.dart';
|
||||
import 'package:paperless_mobile/features/login/view/widgets/form_fields/user_credentials_form_field.dart';
|
||||
import 'package:paperless_mobile/features/login/view/widgets/login_pages/server_connection_page.dart';
|
||||
import 'package:paperless_mobile/generated/l10n.dart';
|
||||
import 'package:paperless_mobile/util.dart';
|
||||
|
||||
import 'widgets/never_scrollable_scroll_behavior.dart';
|
||||
import 'widgets/server_login_page.dart';
|
||||
import 'widgets/login_pages/server_login_page.dart';
|
||||
|
||||
class LoginPage extends StatefulWidget {
|
||||
const LoginPage({Key? key}) : super(key: key);
|
||||
@@ -29,14 +30,6 @@ class _LoginPageState extends State<LoginPage> {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: false, // appBar: AppBar(
|
||||
// title: Text(S.of(context).loginPageTitle),
|
||||
// bottom: _isLoginLoading
|
||||
// ? const PreferredSize(
|
||||
// preferredSize: Size(double.infinity, 4),
|
||||
// child: LinearProgressIndicator(),
|
||||
// )
|
||||
// : null,
|
||||
// ),
|
||||
body: FormBuilder(
|
||||
key: _formKey,
|
||||
child: PageView(
|
||||
@@ -47,8 +40,9 @@ class _LoginPageState extends State<LoginPage> {
|
||||
formBuilderKey: _formKey,
|
||||
onContinue: () {
|
||||
_pageController.nextPage(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
curve: Curves.easeInOut);
|
||||
duration: const Duration(milliseconds: 300),
|
||||
curve: Curves.easeInOut,
|
||||
);
|
||||
},
|
||||
),
|
||||
ServerLoginPage(
|
||||
@@ -58,58 +52,10 @@ class _LoginPageState extends State<LoginPage> {
|
||||
],
|
||||
),
|
||||
),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.all(8.0),
|
||||
// child: FormBuilder(
|
||||
// key: _formKey,
|
||||
// child: ListView(
|
||||
// children: [
|
||||
// const ServerAddressFormField().padded(),
|
||||
// const UserCredentialsFormField(),
|
||||
// Align(
|
||||
// alignment: Alignment.centerLeft,
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.only(top: 16.0),
|
||||
// child: Text(
|
||||
// S.of(context).loginPageAdvancedLabel,
|
||||
// style: Theme.of(context).textTheme.bodyLarge,
|
||||
// ).padded(),
|
||||
// ),
|
||||
// ),
|
||||
// const ClientCertificateFormField(),
|
||||
// LayoutBuilder(builder: (context, constraints) {
|
||||
// return Padding(
|
||||
// padding: const EdgeInsets.all(8.0),
|
||||
// child: SizedBox(
|
||||
// width: constraints.maxWidth,
|
||||
// child: _buildLoginButton(),
|
||||
// ),
|
||||
// );
|
||||
// }),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLoginButton() {
|
||||
return ElevatedButton(
|
||||
key: const ValueKey('login-login-button'),
|
||||
style: ButtonStyle(
|
||||
backgroundColor: MaterialStatePropertyAll(
|
||||
Theme.of(context).colorScheme.primaryContainer,
|
||||
),
|
||||
elevation: const MaterialStatePropertyAll(0),
|
||||
),
|
||||
onPressed: _login,
|
||||
child: Text(
|
||||
S.of(context).loginPageLoginButtonLabel,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _login() async {
|
||||
Future<void> _login() async {
|
||||
FocusScope.of(context).unfocus();
|
||||
if (_formKey.currentState?.saveAndValidate() ?? false) {
|
||||
final form = _formKey.currentState!.value;
|
||||
@@ -122,11 +68,15 @@ class _LoginPageState extends State<LoginPage> {
|
||||
);
|
||||
} on PaperlessServerException catch (error, stackTrace) {
|
||||
showErrorMessage(context, error, stackTrace);
|
||||
} on Map<String, dynamic> catch (error, stackTrace) {
|
||||
showGenericError(context, error.values.first, stackTrace);
|
||||
} on PaperlessValidationErrors catch (error, stackTrace) {
|
||||
if (error.hasFieldUnspecificError) {
|
||||
showLocalizedError(context, error.fieldUnspecificError!);
|
||||
} else {
|
||||
showGenericError(context, error.values.first, stackTrace);
|
||||
}
|
||||
} catch (unknownError, stackTrace) {
|
||||
showGenericError(context, unknownError.toString(), stackTrace);
|
||||
} finally {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user