122 lines
3.9 KiB
Dart
122 lines
3.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:hl_lieferservice/feature/authentication/bloc/auth_event.dart';
|
|
import 'package:hl_lieferservice/widget/operations/bloc/operation_bloc.dart';
|
|
import 'package:hl_lieferservice/widget/operations/bloc/operation_event.dart';
|
|
import 'package:hl_lieferservice/widget/operations/presentation/operation_view_enforcer.dart';
|
|
|
|
import '../bloc/auth_bloc.dart';
|
|
|
|
class LoginPage extends StatefulWidget {
|
|
const LoginPage({super.key});
|
|
|
|
@override
|
|
State<StatefulWidget> createState() => _LoginPageState();
|
|
}
|
|
|
|
class _LoginPageState extends State<LoginPage> {
|
|
final _loginFormKey = GlobalKey<FormState>();
|
|
final TextEditingController _passwordEditingController =
|
|
TextEditingController();
|
|
final TextEditingController _userIdEditingController =
|
|
TextEditingController();
|
|
|
|
bool _isEmpty = false;
|
|
|
|
void onChanged(String value) {
|
|
setState(() {
|
|
_isEmpty = value.isEmpty;
|
|
});
|
|
}
|
|
|
|
void _onPressLogin(BuildContext context) async {
|
|
if (context.mounted) {
|
|
context.read<AuthBloc>().add(
|
|
Authenticate(
|
|
username: _userIdEditingController.text,
|
|
password: _passwordEditingController.text,
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(),
|
|
body: Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.all(50),
|
|
child: Column(
|
|
children: [
|
|
Image.asset(
|
|
"assets/holzleitner_Logo_2017_RZ_transparent.png",
|
|
),
|
|
const Padding(
|
|
padding: EdgeInsets.only(top: 20),
|
|
child: Text(
|
|
"Auslieferservice",
|
|
style: TextStyle(
|
|
fontWeight: FontWeight.w400,
|
|
fontSize: 20,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Form(
|
|
key: _loginFormKey,
|
|
child: FractionallySizedBox(
|
|
widthFactor: 0.8,
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.only(bottom: 20),
|
|
child: TextFormField(
|
|
decoration: const InputDecoration(
|
|
labelText: "Personalnummer",
|
|
border: OutlineInputBorder(
|
|
borderRadius: BorderRadius.all(
|
|
Radius.circular(10.0),
|
|
),
|
|
),
|
|
),
|
|
controller: _userIdEditingController,
|
|
onChanged: onChanged,
|
|
),
|
|
),
|
|
TextFormField(
|
|
decoration: const InputDecoration(
|
|
labelText: "Passwort",
|
|
border: OutlineInputBorder(
|
|
borderRadius: BorderRadius.all(Radius.circular(10.0)),
|
|
),
|
|
),
|
|
controller: _passwordEditingController,
|
|
obscureText: true,
|
|
onChanged: onChanged,
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 15, bottom: 15),
|
|
child: OutlinedButton(
|
|
onPressed:
|
|
!_isEmpty ? () => _onPressLogin(context) : null,
|
|
child: const Text("Anmelden"),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|