241 lines
11 KiB
Dart
241 lines
11 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
|
import 'package:fluttericon/font_awesome5_icons.dart';
|
|
import 'package:form_builder_validators/form_builder_validators.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import 'package:unit2/utils/text_container.dart';
|
|
import '../../../widgets/wave.dart';
|
|
import '../../../utils/global.dart';
|
|
import '../../../theme-data.dart/colors.dart';
|
|
import '../../../theme-data.dart/form-style.dart';
|
|
import '../../../theme-data.dart/btn-style.dart';
|
|
import './components/login-via-qr-label.dart';
|
|
import './functions/press-again-to-exit.dart';
|
|
|
|
class UniT2Login extends StatefulWidget {
|
|
const UniT2Login({super.key});
|
|
|
|
@override
|
|
State<UniT2Login> createState() => _UniT2LoginState();
|
|
}
|
|
|
|
class _UniT2LoginState extends State<UniT2Login> {
|
|
final _formKey = GlobalKey<FormBuilderState>();
|
|
bool showSuffixIcon = false;
|
|
bool _showPassword = true;
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return WillPopScope(
|
|
onWillPop: pressAgainToExit,
|
|
child: Scaffold(
|
|
body: SizedBox(
|
|
child: SingleChildScrollView(
|
|
child: Stack(
|
|
children: [
|
|
Positioned(
|
|
bottom: 0,
|
|
right: 0,
|
|
child: WaveReverse(height: blockSizeVertical * 7)),
|
|
SizedBox(
|
|
height: blockSizeVertical * 100,
|
|
child: FormBuilder(
|
|
key: _formKey,
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 25),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: <Widget>[
|
|
SizedBox(height: blockSizeVertical * 7),
|
|
SvgPicture.asset(
|
|
'assets/svgs/logo.svg',
|
|
height: blockSizeVertical * 16,
|
|
allowDrawingOutsideViewBox: true,
|
|
color: primary,
|
|
),
|
|
|
|
Text(
|
|
welcome,
|
|
style: TextStyle(
|
|
fontSize: blockSizeVertical * 5,
|
|
fontWeight: FontWeight.w600),
|
|
),
|
|
Text(unitApp,
|
|
style: TextStyle(
|
|
fontSize: blockSizeVertical * 8,
|
|
fontWeight: FontWeight.w800,
|
|
letterSpacing: .2,
|
|
height: 1,
|
|
color: primary)),
|
|
Text(
|
|
loginToContinue,
|
|
style: TextStyle(
|
|
fontSize: blockSizeVertical * 2,
|
|
height: 1.5,
|
|
fontWeight: FontWeight.w600),
|
|
),
|
|
SizedBox(
|
|
height: blockSizeVertical * 1.5,
|
|
),
|
|
// USERNAME
|
|
FormBuilderTextField(
|
|
name: 'username',
|
|
validator: FormBuilderValidators.required(
|
|
errorText: "Username is required"),
|
|
autofocus: false,
|
|
style: const TextStyle(
|
|
fontWeight: FontWeight.bold,
|
|
color: Colors.black87),
|
|
decoration: loginTextFieldStyle()),
|
|
SizedBox(
|
|
height: blockSizeVertical * 1.5,
|
|
),
|
|
// PASSWORD
|
|
FormBuilderTextField(
|
|
name: 'password',
|
|
validator: FormBuilderValidators.required(
|
|
errorText: "Password is required"),
|
|
|
|
// initialValue: state.password,
|
|
onChanged: (value) {
|
|
value!.isEmpty
|
|
? setState(() {
|
|
showSuffixIcon = false;
|
|
})
|
|
: setState(() {
|
|
showSuffixIcon = true;
|
|
});
|
|
},
|
|
autofocus: false,
|
|
style: const TextStyle(
|
|
fontWeight: FontWeight.bold,
|
|
color: Colors.black87),
|
|
decoration: loginTextFieldStyle().copyWith(
|
|
suffixIcon: Visibility(
|
|
visible: showSuffixIcon,
|
|
child: _showPassword
|
|
? IconButton(
|
|
icon: Icon(FontAwesome5.eye_slash,
|
|
size: 24,
|
|
color: Theme.of(context)
|
|
.textTheme
|
|
.displayLarge
|
|
?.color),
|
|
onPressed: () {
|
|
setState(() {
|
|
_showPassword = false;
|
|
});
|
|
},
|
|
)
|
|
: IconButton(
|
|
onPressed: () {
|
|
setState(() {
|
|
_showPassword = true;
|
|
});
|
|
},
|
|
icon: Icon(FontAwesome5.eye,
|
|
size: 24,
|
|
color: Theme.of(context)
|
|
.textTheme
|
|
.displayLarge
|
|
?.color)),
|
|
),
|
|
prefixIcon: const Icon(Icons.lock),
|
|
labelText: "Password",
|
|
hintText: "Enter Password..."),
|
|
obscureText: _showPassword ? true : false,
|
|
),
|
|
SizedBox(
|
|
height: blockSizeVertical * 2,
|
|
),
|
|
SizedBox(
|
|
height: blockSizeVertical * 7,
|
|
// Login Button
|
|
child: SizedBox(
|
|
width: MediaQuery.of(context).size.width,
|
|
child: ElevatedButton(
|
|
style: mainBtnStyle(
|
|
second, Colors.transparent, Colors.white54),
|
|
child: const Text(
|
|
"LOGIN",
|
|
style: TextStyle(color: Colors.white),
|
|
),
|
|
onPressed: () {
|
|
context.go(context.namedLocation('home'));
|
|
// if (_formKey.currentState.validate()) {
|
|
// _formKey.currentState.save();
|
|
// BlocProvider.of<UserBloc>(context)
|
|
// .add(UserWebLogin(
|
|
// password: password,
|
|
// username: username));
|
|
// }
|
|
},
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: blockSizeVertical * 1.5,
|
|
),
|
|
|
|
SizedBox(
|
|
height: blockSizeVertical * 7,
|
|
child: SizedBox(
|
|
width: MediaQuery.of(context).size.width,
|
|
child: ElevatedButton.icon(
|
|
style: mainBtnStyle(Colors.white, second,
|
|
primary.withOpacity(.4)),
|
|
icon: const Icon(
|
|
Icons.qr_code,
|
|
color: second,
|
|
),
|
|
label: const Text(
|
|
loginViaQr,
|
|
style: TextStyle(color: second),
|
|
),
|
|
onPressed: () async {
|
|
// BlocProvider.of<UserBloc>(context)
|
|
// .add(QRCodelogin());
|
|
},
|
|
),
|
|
)),
|
|
SizedBox(
|
|
height: blockSizeVertical * 1,
|
|
),
|
|
const LoginViaQr(text: emergencyReponseLabel),
|
|
SizedBox(
|
|
height: blockSizeVertical * 1,
|
|
),
|
|
// REQUEST SOS
|
|
SizedBox(
|
|
height: screenHeight * .07,
|
|
width: MediaQuery.of(context).size.width,
|
|
child: ElevatedButton.icon(
|
|
icon: const Icon(
|
|
FontAwesome5.life_ring,
|
|
color: Colors.white,
|
|
),
|
|
style: mainBtnStyle(
|
|
third, Colors.transparent, Colors.white38),
|
|
onPressed: () {
|
|
context
|
|
.go(context.namedLocation('add-mobile'));
|
|
},
|
|
label: const Text(
|
|
requestSOS,
|
|
style: TextStyle(color: Colors.white),
|
|
)),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|