integrated web and qr code login
parent
226899893f
commit
692d080e25
|
@ -14,6 +14,7 @@ part 'user_state.dart';
|
||||||
|
|
||||||
class UserBloc extends Bloc<UserEvent, UserState> {
|
class UserBloc extends Bloc<UserEvent, UserState> {
|
||||||
UserData? _userData;
|
UserData? _userData;
|
||||||
|
VersionInfo? _versionInfo;
|
||||||
UserBloc() : super(UserInitial()) {
|
UserBloc() : super(UserInitial()) {
|
||||||
// this event is called when opening the app to check if
|
// this event is called when opening the app to check if
|
||||||
// there is new app version
|
// there is new app version
|
||||||
|
@ -21,13 +22,17 @@ class UserBloc extends Bloc<UserEvent, UserState> {
|
||||||
try {
|
try {
|
||||||
emit(SplashScreen());
|
emit(SplashScreen());
|
||||||
VersionInfo versionInfo = await AuthService.instance.getVersionInfo();
|
VersionInfo versionInfo = await AuthService.instance.getVersionInfo();
|
||||||
emit(VersionLoaded(versionInfo: versionInfo));
|
_versionInfo = versionInfo;
|
||||||
|
emit(VersionLoaded(versionInfo: _versionInfo));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(UserError(
|
emit(UserError(
|
||||||
message: e.toString(),
|
message: e.toString(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
on<LoadVersion>((event, emit) {
|
||||||
|
emit(VersionLoaded(versionInfo: _versionInfo));
|
||||||
|
});
|
||||||
on<UserLogin>((event, emit) async {
|
on<UserLogin>((event, emit) async {
|
||||||
try {
|
try {
|
||||||
UserData? userData = await AuthService.instance
|
UserData? userData = await AuthService.instance
|
||||||
|
@ -38,6 +43,16 @@ class UserBloc extends Bloc<UserEvent, UserState> {
|
||||||
emit(UserError(message: e.toString()));
|
emit(UserError(message: e.toString()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
on<UuidLogin>((event, emit) async {
|
||||||
|
try {
|
||||||
|
UserData? userData = await AuthService.instance
|
||||||
|
.qrLogin(uuid: event.uuid, password: event.password);
|
||||||
|
_userData = userData;
|
||||||
|
emit(UserLoggedIn(userData: _userData));
|
||||||
|
} catch (e) {
|
||||||
|
emit(UserError(message: e.toString()));
|
||||||
|
}
|
||||||
|
});
|
||||||
on<LoadLoggedInUser>((event, emit) {
|
on<LoadLoggedInUser>((event, emit) {
|
||||||
emit(UserLoggedIn(userData: _userData));
|
emit(UserLoggedIn(userData: _userData));
|
||||||
});
|
});
|
||||||
|
|
|
@ -15,6 +15,8 @@ class UserLogin extends UserEvent {
|
||||||
final String? username;
|
final String? username;
|
||||||
final String? password;
|
final String? password;
|
||||||
UserLogin({this.username, this.password});
|
UserLogin({this.username, this.password});
|
||||||
|
@override
|
||||||
|
List<Object> get props => [username!, password!];
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadLoggedInUser extends UserEvent {
|
class LoadLoggedInUser extends UserEvent {
|
||||||
|
@ -25,3 +27,13 @@ class LoadLoggedInUser extends UserEvent {
|
||||||
class GetUuid extends UserEvent {
|
class GetUuid extends UserEvent {
|
||||||
GetUuid();
|
GetUuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class LoadVersion extends UserEvent {}
|
||||||
|
|
||||||
|
class UuidLogin extends UserEvent {
|
||||||
|
final String? uuid;
|
||||||
|
final String? password;
|
||||||
|
UuidLogin({this.uuid, this.password});
|
||||||
|
@override
|
||||||
|
List<Object> get props => [uuid!, password!];
|
||||||
|
}
|
||||||
|
|
|
@ -16,8 +16,8 @@ import '../../../theme-data.dart/colors.dart';
|
||||||
import '../../../widgets/splash_screen.dart';
|
import '../../../widgets/splash_screen.dart';
|
||||||
import './components/cover-image.dart';
|
import './components/cover-image.dart';
|
||||||
|
|
||||||
class Profile extends StatelessWidget {
|
class BasicInfo extends StatelessWidget {
|
||||||
const Profile({super.key});
|
const BasicInfo({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
|
@ -20,7 +20,6 @@ class _DrawerScreenState extends State<DrawerScreen> {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocBuilder<UserBloc, UserState>(
|
return BlocBuilder<UserBloc, UserState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
print("drawer screen" + state.toString());
|
|
||||||
if (state is UserLoggedIn) {
|
if (state is UserLoggedIn) {
|
||||||
return ZoomDrawer(
|
return ZoomDrawer(
|
||||||
controller: zoomDrawerController,
|
controller: zoomDrawerController,
|
||||||
|
|
|
@ -52,13 +52,13 @@ class _MenuScreenState extends State<MenuScreen> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
getTile(FontAwesome5.user, "Basic Info", 'profile', context,
|
getTile(FontAwesome5.user, "Basic Info", '/basic-info', context,
|
||||||
widget.userData!),
|
widget.userData!),
|
||||||
const Divider(),
|
const Divider(),
|
||||||
getTile(FontAwesome5.user_circle, "Profile",
|
getTile(FontAwesome5.user_circle, "Profile",
|
||||||
'/SelfAddressScreen', context, widget.userData!),
|
'/profile', context, widget.userData!),
|
||||||
const Divider(),
|
const Divider(),
|
||||||
getTile(FontAwesome5.life_ring, "Request SOS", 'request-sos',
|
getTile(FontAwesome5.life_ring, "Request SOS", '/request-sos',
|
||||||
context, widget.userData!),
|
context, widget.userData!),
|
||||||
const Divider(),
|
const Divider(),
|
||||||
Expanded(
|
Expanded(
|
||||||
|
|
|
@ -23,7 +23,7 @@ Widget getTile(
|
||||||
context.goNamed("login");
|
context.goNamed("login");
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
context.goNamed(route,extra: userData);
|
Navigator.pushNamed(context, route);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -44,15 +44,12 @@ class _UniT2LoginState extends State<UniT2Login> {
|
||||||
body: ProgressHUD(
|
body: ProgressHUD(
|
||||||
child: BlocConsumer<UserBloc, UserState>(listener: (context, state) {
|
child: BlocConsumer<UserBloc, UserState>(listener: (context, state) {
|
||||||
if (state is UserLoggedIn) {
|
if (state is UserLoggedIn) {
|
||||||
print("login" + state.toString());
|
|
||||||
final progress = ProgressHUD.of(context);
|
final progress = ProgressHUD.of(context);
|
||||||
progress!.dismiss();
|
progress!.dismiss();
|
||||||
Navigator.pushReplacementNamed(context, '/module-screen');
|
Navigator.pushReplacementNamed(context, '/module-screen');
|
||||||
}
|
}
|
||||||
if (state is UuidLoaded) {
|
if (state is UuidLoaded) {
|
||||||
Navigator.push(context, MaterialPageRoute(builder: (context) {
|
Navigator.pushNamed(context, '/qr-login');
|
||||||
return QRLogin();
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
}, builder: (context, state) {
|
}, builder: (context, state) {
|
||||||
if (state is VersionLoaded) {
|
if (state is VersionLoaded) {
|
||||||
|
@ -126,8 +123,6 @@ class _UniT2LoginState extends State<UniT2Login> {
|
||||||
name: 'password',
|
name: 'password',
|
||||||
validator: FormBuilderValidators.required(
|
validator: FormBuilderValidators.required(
|
||||||
errorText: passwordRequired),
|
errorText: passwordRequired),
|
||||||
|
|
||||||
// initialValue: state.password,
|
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
value!.isEmpty
|
value!.isEmpty
|
||||||
? setState(() {
|
? setState(() {
|
||||||
|
|
|
@ -4,12 +4,14 @@ import 'package:flutter/src/widgets/container.dart';
|
||||||
import 'package:flutter/src/widgets/framework.dart';
|
import 'package:flutter/src/widgets/framework.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||||
|
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:fluttericon/font_awesome5_icons.dart';
|
import 'package:fluttericon/font_awesome5_icons.dart';
|
||||||
import 'package:fluttericon/font_awesome_icons.dart';
|
import 'package:fluttericon/font_awesome_icons.dart';
|
||||||
import 'package:form_builder_validators/form_builder_validators.dart';
|
import 'package:form_builder_validators/form_builder_validators.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:unit2/theme-data.dart/btn-style.dart';
|
import 'package:unit2/theme-data.dart/btn-style.dart';
|
||||||
|
import 'package:unit2/widgets/error_state.dart';
|
||||||
import 'package:unit2/widgets/wave.dart';
|
import 'package:unit2/widgets/wave.dart';
|
||||||
|
|
||||||
import '../../../bloc/bloc/user_bloc.dart';
|
import '../../../bloc/bloc/user_bloc.dart';
|
||||||
|
@ -32,206 +34,225 @@ class _QRLoginState extends State<QRLogin> {
|
||||||
final _formKey = GlobalKey<FormBuilderState>();
|
final _formKey = GlobalKey<FormBuilderState>();
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return SafeArea(
|
return WillPopScope(
|
||||||
child: Scaffold(
|
onWillPop: ()async{
|
||||||
resizeToAvoidBottomInset: true,
|
context.read<UserBloc>().add(LoadVersion());
|
||||||
appBar: AppBar(
|
return true;
|
||||||
backgroundColor: primary,
|
},
|
||||||
elevation: 0,
|
child: SafeArea(
|
||||||
automaticallyImplyLeading: true,
|
child: Scaffold(
|
||||||
title: const Text("Login via QR"),
|
resizeToAvoidBottomInset: true,
|
||||||
centerTitle: true,
|
appBar: AppBar(
|
||||||
),
|
backgroundColor: primary,
|
||||||
body: BlocBuilder<UserBloc, UserState>(
|
elevation: 0,
|
||||||
builder: (context, state) {
|
title: const Text("Login via QR"),
|
||||||
print(state);
|
centerTitle: true,
|
||||||
if (state is UuidLoaded) {
|
),
|
||||||
return Center(
|
body: ProgressHUD(
|
||||||
child: Text(state.uuid),
|
child: BlocConsumer<UserBloc, UserState>(
|
||||||
);
|
listener: (context,state){
|
||||||
|
if (state is UserLoggedIn) {
|
||||||
|
final progress = ProgressHUD.of(context);
|
||||||
|
progress!.dismiss();
|
||||||
|
Navigator.pushReplacementNamed(context, '/module-screen');
|
||||||
}
|
}
|
||||||
return SingleChildScrollView(
|
},
|
||||||
child: Stack(
|
builder: (context, state) {
|
||||||
children: [
|
if (state is UuidLoaded) {
|
||||||
Positioned(
|
return SingleChildScrollView(
|
||||||
bottom: 0,
|
child: Stack(
|
||||||
child: WaveReverse(height: blockSizeVertical * 8)),
|
children: [
|
||||||
Container(
|
Positioned(
|
||||||
height: screenHeight * .90,
|
bottom: 0,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 15),
|
child: WaveReverse(height: blockSizeVertical * 8)),
|
||||||
child: FormBuilder(
|
Container(
|
||||||
key: _formKey,
|
height: screenHeight * .90,
|
||||||
child: Column(
|
padding: const EdgeInsets.symmetric(horizontal: 15),
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
child: FormBuilder(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
key: _formKey,
|
||||||
children: [
|
child: Column(
|
||||||
SvgPicture.asset(
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
'assets/svgs/logo.svg',
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
height: blockSizeVertical * 12,
|
children: [
|
||||||
allowDrawingOutsideViewBox: true,
|
SvgPicture.asset(
|
||||||
color: primary,
|
'assets/svgs/logo.svg',
|
||||||
),
|
height: blockSizeVertical * 12,
|
||||||
const SizedBox(
|
allowDrawingOutsideViewBox: true,
|
||||||
height: 12,
|
color: primary,
|
||||||
),
|
|
||||||
Text(unitApp,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: blockSizeVertical * 5,
|
|
||||||
fontWeight: FontWeight.w800,
|
|
||||||
letterSpacing: .2,
|
|
||||||
height: 1,
|
|
||||||
color: Colors.black87)),
|
|
||||||
const SizedBox(
|
|
||||||
height: 15,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
"Enter your password",
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: blockSizeVertical * 1.5,
|
|
||||||
height: 1.5,
|
|
||||||
fontWeight: FontWeight.w600),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 15,
|
|
||||||
),
|
|
||||||
// Password
|
|
||||||
FormBuilderTextField(
|
|
||||||
name: 'password',
|
|
||||||
validator: registerPasswordValidator,
|
|
||||||
// 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),
|
const SizedBox(
|
||||||
labelText: "Password",
|
height: 12,
|
||||||
hintText: enterPassword),
|
),
|
||||||
obscureText: _showPassword ? true : false,
|
Text(unitApp,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: blockSizeVertical * 5,
|
||||||
|
fontWeight: FontWeight.w800,
|
||||||
|
letterSpacing: .2,
|
||||||
|
height: 1,
|
||||||
|
color: Colors.black87)),
|
||||||
|
const SizedBox(
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
"Enter your password",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: blockSizeVertical * 1.5,
|
||||||
|
height: 1.5,
|
||||||
|
fontWeight: FontWeight.w600),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
// Password
|
||||||
|
FormBuilderTextField(
|
||||||
|
name: 'password',
|
||||||
|
validator: registerPasswordValidator,
|
||||||
|
// 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: enterPassword),
|
||||||
|
obscureText: _showPassword ? true : false,
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
// FormBuilderTextField(
|
||||||
|
// name: 'confirmPassword',
|
||||||
|
// validator: registerPasswordValidator,
|
||||||
|
// // 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: confirmPassword,
|
||||||
|
// hintText: enterConfirmPassword),
|
||||||
|
// obscureText: _showPassword ? true : false,
|
||||||
|
// ),
|
||||||
|
const SizedBox(
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
height: blockSizeVertical * 6,
|
||||||
|
child: ElevatedButton(
|
||||||
|
style: secondaryBtnStyle(
|
||||||
|
second, Colors.transparent, primary),
|
||||||
|
onPressed: () {
|
||||||
|
if (_formKey.currentState!
|
||||||
|
.saveAndValidate()) {
|
||||||
|
final progress =
|
||||||
|
ProgressHUD.of(context);
|
||||||
|
progress?.showWithText(
|
||||||
|
'Logging in...',
|
||||||
|
);
|
||||||
|
context.read<UserBloc>().add(UuidLogin(uuid: state.uuid,password: _formKey.currentState!.value['password']));
|
||||||
|
// BlocProvider.of<UserBloc>(context)
|
||||||
|
// .add(UserLogin(
|
||||||
|
// username: _formKey
|
||||||
|
// .currentState!.value['username'],
|
||||||
|
// password: _formKey
|
||||||
|
// .currentState!.value['password'],
|
||||||
|
// ));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: const Text(submit)),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
),
|
||||||
height: 15,
|
],
|
||||||
),
|
|
||||||
// FormBuilderTextField(
|
|
||||||
// name: 'confirmPassword',
|
|
||||||
// validator: registerPasswordValidator,
|
|
||||||
// // 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: confirmPassword,
|
|
||||||
// hintText: enterConfirmPassword),
|
|
||||||
// obscureText: _showPassword ? true : false,
|
|
||||||
// ),
|
|
||||||
const SizedBox(
|
|
||||||
height: 15,
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
width: double.infinity,
|
|
||||||
height: blockSizeVertical * 6,
|
|
||||||
child: ElevatedButton(
|
|
||||||
style: secondaryBtnStyle(
|
|
||||||
second, Colors.transparent, primary),
|
|
||||||
onPressed: () {
|
|
||||||
if (_formKey.currentState!
|
|
||||||
.saveAndValidate()) {
|
|
||||||
BlocProvider.of<UserBloc>(context)
|
|
||||||
.add(UserLogin(
|
|
||||||
username: _formKey
|
|
||||||
.currentState!.value['username'],
|
|
||||||
password: _formKey
|
|
||||||
.currentState!.value['password'],
|
|
||||||
));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: const Text(submit)),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
],
|
}if(state is UserError){
|
||||||
),
|
return ErrorState(message: state.message,);
|
||||||
);
|
}
|
||||||
},
|
return Container();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -58,4 +58,22 @@ class AuthService {
|
||||||
}
|
}
|
||||||
return userData!;
|
return userData!;
|
||||||
}
|
}
|
||||||
|
Future<UserData> qrLogin({String? uuid, String? password})async{
|
||||||
|
Map <String,String> body ={'uuid':uuid!,'password':password!};
|
||||||
|
Map<String, String> baseHeaders = {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
};
|
||||||
|
String path = Url.instance.authentication();
|
||||||
|
UserData? userData;
|
||||||
|
try{
|
||||||
|
http.Response response = await Request.instance.postRequest(path: path,param: {},headers: baseHeaders,body: body);
|
||||||
|
if(response.statusCode == 200){
|
||||||
|
Map data = jsonDecode(response.body);
|
||||||
|
userData = UserData.fromJson(data['data']);
|
||||||
|
}
|
||||||
|
}catch(e){
|
||||||
|
throw (e.toString());
|
||||||
|
}
|
||||||
|
return userData!;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:unit2/bloc/bloc/user_bloc.dart';
|
import 'package:unit2/bloc/bloc/user_bloc.dart';
|
||||||
import 'package:unit2/screens/unit2/login/login.dart';
|
import 'package:unit2/screens/unit2/login/login.dart';
|
||||||
import 'package:unit2/utils/global_context.dart';
|
import 'package:unit2/utils/global_context.dart';
|
||||||
|
import '../screens/unit2/basic-info/basic-info.dart';
|
||||||
import '../screens/unit2/homepage.dart/components/drawer-screen.dart';
|
import '../screens/unit2/homepage.dart/components/drawer-screen.dart';
|
||||||
|
import '../screens/unit2/login/qr_login.dart';
|
||||||
|
|
||||||
class AppRouter {
|
class AppRouter {
|
||||||
Route onGenerateRoute(RouteSettings routeSettings) {
|
Route onGenerateRoute(RouteSettings routeSettings) {
|
||||||
|
@ -18,11 +18,18 @@ class AppRouter {
|
||||||
return const UniT2Login();
|
return const UniT2Login();
|
||||||
});
|
});
|
||||||
case '/module-screen':
|
case '/module-screen':
|
||||||
BlocProvider.of<UserBloc>( NavigationService.navigatorKey.currentContext!).add(LoadLoggedInUser());
|
// BlocProvider.of<UserBloc>( NavigationService.navigatorKey.currentContext!).add(LoadLoggedInUser());
|
||||||
return MaterialPageRoute(builder: (_) {
|
return MaterialPageRoute(builder: (_) {
|
||||||
return const DrawerScreen();
|
return const DrawerScreen();
|
||||||
});
|
});
|
||||||
|
case '/basic-info':
|
||||||
|
return MaterialPageRoute(builder: (_){
|
||||||
|
return const BasicInfo();
|
||||||
|
});
|
||||||
|
case '/qr-login':
|
||||||
|
return MaterialPageRoute(builder: (_){
|
||||||
|
return const QRLogin();
|
||||||
|
});
|
||||||
default:
|
default:
|
||||||
return MaterialPageRoute(builder: (context) {
|
return MaterialPageRoute(builder: (context) {
|
||||||
return Container();
|
return Container();
|
||||||
|
|
Loading…
Reference in New Issue