You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
163 lines
7.5 KiB
Dart
163 lines
7.5 KiB
Dart
///todo deleted
|
|
// import 'package:flutter/material.dart';
|
|
// import 'package:fluttertoast/fluttertoast.dart';
|
|
// import 'package:provider/provider.dart';
|
|
// import 'package:test_sa/controllers/api_routes/http_status_manger.dart';
|
|
// import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
|
// import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
|
// import 'package:test_sa/controllers/validator/validator.dart';
|
|
// import 'package:test_sa/extensions/context_extension.dart';
|
|
// import 'package:test_sa/models/user.dart';
|
|
// import 'package:test_sa/new_views/pages/land_page/land_page.dart';
|
|
// import 'package:test_sa/views/app_style/sizing.dart';
|
|
// import 'package:test_sa/views/widgets/app_text_form_field.dart';
|
|
// import 'package:test_sa/views/widgets/buttons/app_button.dart';
|
|
// import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
|
//
|
|
// class Login extends StatefulWidget {
|
|
// static final String id = "/login";
|
|
//
|
|
// @override
|
|
// _LoginState createState() => _LoginState();
|
|
// }
|
|
//
|
|
// class _LoginState extends State<Login> {
|
|
// UserProvider _userProvider;
|
|
// SettingProvider _settingProvider;
|
|
// User _user = User();
|
|
// bool _obscurePassword = true;
|
|
// bool _firstTime = true;
|
|
// double _height;
|
|
// double _width;
|
|
// String _payload;
|
|
// final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
|
// final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
|
//
|
|
// @override
|
|
// Widget build(BuildContext context) {
|
|
// _userProvider = Provider.of<UserProvider>(context);
|
|
// _settingProvider = Provider.of<SettingProvider>(context);
|
|
// _height = MediaQuery.of(context).size.height;
|
|
// _width = MediaQuery.of(context).size.width;
|
|
//
|
|
// return Scaffold(
|
|
// key: _scaffoldKey,
|
|
// body: SafeArea(
|
|
// child: LoadingManager(
|
|
// isLoading: _userProvider.isLoading || !_settingProvider.isLoaded,
|
|
// isFailedLoading: false,
|
|
// stateCode: 200,
|
|
// onRefresh: () async {},
|
|
// child: Form(
|
|
// key: _formKey,
|
|
// child: SingleChildScrollView(
|
|
// //padding: EdgeInsets.symmetric(horizontal: 32),
|
|
// child: Column(
|
|
// children: [
|
|
// //AppNameBar(),
|
|
// SizedBox(
|
|
// height: MediaQuery.of(context).size.height / 7,
|
|
// ),
|
|
// Hero(
|
|
// tag: "logo",
|
|
// child: Image(
|
|
// height: _height / 6,
|
|
// fit: BoxFit.contain,
|
|
// image: AssetImage("assets/images/logo.png"),
|
|
// ),
|
|
// ),
|
|
// Padding(
|
|
// padding: EdgeInsets.symmetric(horizontal: 24 * AppStyle.getScaleFactor(context), vertical: 24 * AppStyle.getScaleFactor(context)),
|
|
// child: Column(
|
|
// children: [
|
|
// SizedBox(
|
|
// height: 24 * AppStyle.getScaleFactor(context),
|
|
// ),
|
|
// ATextFormField(
|
|
// initialValue: _user?.userName,
|
|
// hintText: context.translation.name,
|
|
// textAlign: TextAlign.left,
|
|
// style: Theme.of(context).textTheme.bodyText1,
|
|
// prefixIconData: Icons.account_circle,
|
|
// validator: (value) => Validator.hasValue(value) ? null : context.translation.nameValidateMessage,
|
|
// textInputType: TextInputType.name,
|
|
// onSaved: (value) {
|
|
// _user.userName = value;
|
|
// },
|
|
// ),
|
|
// SizedBox(height: 12),
|
|
// ATextFormField(
|
|
// initialValue: _user?.password,
|
|
// hintText: context.translation.password,
|
|
// obscureText: _obscurePassword,
|
|
// style: Theme.of(context).textTheme.bodyText1,
|
|
// prefixIconData: Icons.vpn_key_sharp,
|
|
// textAlign: TextAlign.left,
|
|
// validator: (value) => Validator.isValidPassword(value) ? null : context.translation.passwordValidateMessage,
|
|
// showPassword: () {
|
|
// _obscurePassword = !_obscurePassword;
|
|
// setState(() {});
|
|
// },
|
|
// onSaved: (value) {
|
|
// _user.password = value;
|
|
// },
|
|
// ),
|
|
// SizedBox(
|
|
// height: 32 * AppStyle.getScaleFactor(context),
|
|
// ),
|
|
// AButton(
|
|
// text: context.translation.signIn,
|
|
// onPressed: () async {
|
|
// if (!_formKey.currentState.validate()) return;
|
|
// _formKey.currentState.save();
|
|
// int status = await _userProvider.login(
|
|
// user: _user,
|
|
// );
|
|
// if (status >= 200 && status < 300) {
|
|
// if (_userProvider.user.isAuthenticated ?? false) {
|
|
// _settingProvider.setUser(_userProvider.user);
|
|
// Navigator.of(context).pushNamed(LandPage.routeName);
|
|
// } else {
|
|
// Fluttertoast.showToast(msg: _userProvider.user.message);
|
|
// }
|
|
//
|
|
// // if (_userProvider.user.isActive)
|
|
//
|
|
// // else
|
|
// // Fluttertoast.showToast(msg: context.translation.activationAlert);
|
|
// } else {
|
|
// if (status >= 400 && status < 500) return;
|
|
//
|
|
// String errorMessage = status == 400 || _userProvider.user?.userName == null
|
|
// ? context.translation.wrongEmailOrPassword
|
|
// : HttpStatusManger.getStatusMessage(status: status, subtitle: context.translation);
|
|
// ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
|
// content: Text(errorMessage),
|
|
// ));
|
|
// }
|
|
// },
|
|
// ),
|
|
// // SizedBox(
|
|
// // height: 140 * AppStyle.getScaleFactor(context),
|
|
// // ),
|
|
// // AOutLinedButton(
|
|
// // text: context.translation.signUp,
|
|
// // //color: AColors.cyan,
|
|
// // onPressed: () {
|
|
// // Navigator.of(context).pushNamed(Register.id);
|
|
// // },
|
|
// // ),
|
|
// const SizedBox(height: 32),
|
|
// ],
|
|
// ),
|
|
// ),
|
|
// ],
|
|
// ),
|
|
// ),
|
|
// ),
|
|
// ),
|
|
// ),
|
|
// );
|
|
// }
|
|
// }
|