mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-23 13:17:55 +00:00
Added create a unit screen, and implemented otp screen bloc and view
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:syncrow_app/features/auth/bloc/auth_cubit.dart';
|
||||
@@ -18,6 +19,8 @@ class LoginView extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
|
||||
statusBarBrightness: Brightness.light, statusBarIconBrightness: Brightness.light));
|
||||
return BlocConsumer<AuthCubit, AuthState>(
|
||||
listener: (context, state) {
|
||||
if (state is AuthError) {
|
||||
@@ -31,9 +34,9 @@ class LoginView extends StatelessWidget {
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
body: Stack(
|
||||
return Scaffold(
|
||||
body: SafeArea(
|
||||
child: Stack(
|
||||
children: [
|
||||
Container(
|
||||
width: MediaQuery.sizeOf(context).width,
|
||||
|
||||
@@ -1,35 +1,33 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:pin_code_fields/pin_code_fields.dart';
|
||||
import 'package:syncrow_app/features/auth/bloc/auth_cubit.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_button.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/title_medium.dart';
|
||||
import 'package:syncrow_app/generated/assets.dart';
|
||||
import 'package:syncrow_app/navigation/routing_constants.dart';
|
||||
import 'package:syncrow_app/utils/context_extension.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/font_manager.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/styles_manager.dart';
|
||||
|
||||
class OtpView extends StatelessWidget {
|
||||
const OtpView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final formKey = AuthCubit.get(context).signUpFormKey;
|
||||
String maskedEmail = AuthCubit.get(context).maskEmail(AuthCubit.get(context).email);
|
||||
return BlocConsumer<AuthCubit, AuthState>(
|
||||
listener: (context, state) {
|
||||
if (state is AuthError) {
|
||||
} else if (state is AuthOtpSuccess) {
|
||||
Navigator.popAndPushNamed(context, Routes.homeRoute);
|
||||
if (state is AuthOtpSuccess) {
|
||||
Navigator.pushNamedAndRemoveUntil(context, Routes.homeRoute, (value) => false);
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
body: Stack(
|
||||
return Scaffold(
|
||||
body: SafeArea(
|
||||
child: Stack(
|
||||
children: [
|
||||
Container(
|
||||
width: MediaQuery.sizeOf(context).width,
|
||||
@@ -96,7 +94,7 @@ class OtpView extends StatelessWidget {
|
||||
),
|
||||
children: [
|
||||
TextSpan(
|
||||
text: ' ex******[email protected]',
|
||||
text: ' $maskedEmail',
|
||||
style: Theme.of(context).textTheme.titleSmall!.copyWith(
|
||||
color: Colors.black,
|
||||
fontWeight: FontsManager.bold,
|
||||
@@ -116,20 +114,19 @@ class OtpView extends StatelessWidget {
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
height: 40,
|
||||
),
|
||||
PinCodeTextField(
|
||||
key: const Key('pin_code_text_field'),
|
||||
appContext: context,
|
||||
length: 4,
|
||||
length: 6,
|
||||
obscuringCharacter: '-',
|
||||
cursorHeight: 25,
|
||||
backgroundColor: Colors.transparent,
|
||||
keyboardType: TextInputType.number,
|
||||
autoFocus: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
animationDuration: const Duration(milliseconds: 30),
|
||||
// controller: AuthCubit.get(context).emailController,
|
||||
// cursorColor: KeysperColors.primaryBase,
|
||||
beforeTextPaste: (text) {
|
||||
// Allow pasting only if all characters are numeric
|
||||
return int.tryParse(text!) != null;
|
||||
@@ -137,11 +134,11 @@ class OtpView extends StatelessWidget {
|
||||
textStyle: Theme.of(context)
|
||||
.textTheme
|
||||
.headlineMedium!
|
||||
.copyWith(color: Colors.black),
|
||||
.copyWith(color: Colors.white),
|
||||
hintStyle: Theme.of(context)
|
||||
.textTheme
|
||||
.headlineMedium!
|
||||
.copyWith(color: Colors.grey),
|
||||
.copyWith(color: Colors.white),
|
||||
enablePinAutofill: true,
|
||||
pinTheme: PinTheme(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
@@ -152,24 +149,28 @@ class OtpView extends StatelessWidget {
|
||||
errorBorderWidth: 1,
|
||||
borderWidth: 1,
|
||||
errorBorderColor: Colors.red,
|
||||
activeColor: Colors.white,
|
||||
inactiveColor: Colors.white,
|
||||
activeFillColor: Colors.white,
|
||||
inactiveFillColor: Colors.white,
|
||||
selectedFillColor: Colors.white,
|
||||
activeColor: state is AuthLoginError ? Colors.red : Colors.white,
|
||||
inactiveColor:
|
||||
state is AuthLoginError ? Colors.red : Colors.white,
|
||||
activeFillColor:
|
||||
state is AuthLoginError ? Colors.red : Colors.white,
|
||||
inactiveFillColor:
|
||||
state is AuthLoginError ? Colors.red : Colors.white,
|
||||
selectedFillColor:
|
||||
state is AuthLoginError ? Colors.red : Colors.white,
|
||||
disabledColor: Colors.white,
|
||||
fieldHeight: 50,
|
||||
fieldWidth: 50,
|
||||
fieldHeight: 56,
|
||||
fieldWidth: MediaQuery.sizeOf(context).width > 340 ? 40 : 20,
|
||||
// fieldWidth: 40,
|
||||
selectedColor: Colors.white,
|
||||
shape: PinCodeFieldShape.box,
|
||||
),
|
||||
onChanged: (value) async {
|
||||
// otpCode = value;
|
||||
// await bloc.onOTPChanged(value);
|
||||
onChanged: (value) {
|
||||
AuthCubit.get(context).setOtpCode(value);
|
||||
},
|
||||
onCompleted: (value) {},
|
||||
onSubmitted: (value) async {
|
||||
// await bloc.onOTPSubmitted();
|
||||
onSubmitted: (value) {
|
||||
// AuthCubit.get(context).setOtpCode(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 40),
|
||||
@@ -192,11 +193,35 @@ class OtpView extends StatelessWidget {
|
||||
'Verify',
|
||||
),
|
||||
onPressed: () {
|
||||
if (formKey.currentState!.validate()) {
|
||||
if ((state is! AuthLoading)) {
|
||||
AuthCubit.get(context).signUp();
|
||||
FocusScope.of(context).unfocus();
|
||||
}
|
||||
if ((state is! AuthLoading)) {
|
||||
AuthCubit.get(context).verifyOtp();
|
||||
FocusScope.of(context).unfocus();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 4,
|
||||
),
|
||||
Expanded(
|
||||
child: DefaultButton(
|
||||
isDone: state is AuthLoginSuccess,
|
||||
isLoading: state is AuthLoading,
|
||||
customButtonStyle: ButtonStyle(
|
||||
backgroundColor: MaterialStateProperty.all(
|
||||
Colors.black.withOpacity(.25),
|
||||
),
|
||||
foregroundColor: MaterialStateProperty.all(
|
||||
Colors.white,
|
||||
),
|
||||
),
|
||||
child: const Text(
|
||||
'Resend',
|
||||
),
|
||||
onPressed: () async {
|
||||
if ((state is! AuthLoading)) {
|
||||
await AuthCubit.get(context).sendOtp();
|
||||
FocusScope.of(context).unfocus();
|
||||
}
|
||||
},
|
||||
),
|
||||
|
||||
@@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:syncrow_app/features/auth/bloc/auth_cubit.dart';
|
||||
import 'package:syncrow_app/features/auth/view/widgets/login_form.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_button.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/title_medium.dart';
|
||||
@@ -26,13 +25,14 @@ class SignUpView extends StatelessWidget {
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
body: Stack(
|
||||
return Scaffold(
|
||||
body: SafeArea(
|
||||
child: Stack(
|
||||
children: [
|
||||
Container(
|
||||
width: MediaQuery.sizeOf(context).width,
|
||||
height: MediaQuery.sizeOf(context).height,
|
||||
padding: const EdgeInsets.symmetric(vertical: 24),
|
||||
decoration: const BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage(
|
||||
@@ -86,6 +86,7 @@ class SignUpView extends StatelessWidget {
|
||||
),
|
||||
Form(
|
||||
key: formKey,
|
||||
autovalidateMode: AutovalidateMode.disabled,
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -95,7 +96,7 @@ class SignUpView extends StatelessWidget {
|
||||
fontColor: Colors.white,
|
||||
),
|
||||
TextFormField(
|
||||
// autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
autovalidateMode: AutovalidateMode.disabled,
|
||||
textInputAction: TextInputAction.done,
|
||||
keyboardType: TextInputType.name,
|
||||
scrollPadding: EdgeInsets.zero,
|
||||
@@ -109,6 +110,7 @@ class SignUpView extends StatelessWidget {
|
||||
onChanged: (value) {
|
||||
AuthCubit.get(context).fullName = value;
|
||||
},
|
||||
onTap: () {},
|
||||
decoration: defaultInputDecoration(context, hint: "Full Name"),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
@@ -117,6 +119,7 @@ class SignUpView extends StatelessWidget {
|
||||
fontColor: Colors.white,
|
||||
),
|
||||
TextFormField(
|
||||
autovalidateMode: AutovalidateMode.disabled,
|
||||
textInputAction: TextInputAction.done,
|
||||
keyboardType: TextInputType.text,
|
||||
scrollPadding: EdgeInsets.zero,
|
||||
@@ -138,6 +141,7 @@ class SignUpView extends StatelessWidget {
|
||||
fontColor: Colors.white,
|
||||
),
|
||||
TextFormField(
|
||||
autovalidateMode: AutovalidateMode.disabled,
|
||||
textInputAction: TextInputAction.done,
|
||||
keyboardType: TextInputType.text,
|
||||
scrollPadding: EdgeInsets.zero,
|
||||
@@ -160,6 +164,7 @@ class SignUpView extends StatelessWidget {
|
||||
fontColor: Colors.white,
|
||||
),
|
||||
TextFormField(
|
||||
autovalidateMode: AutovalidateMode.disabled,
|
||||
textInputAction: TextInputAction.done,
|
||||
keyboardType: TextInputType.text,
|
||||
scrollPadding: EdgeInsets.zero,
|
||||
@@ -220,6 +225,5 @@ class SignUpView extends StatelessWidget {
|
||||
);
|
||||
},
|
||||
);
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user