This commit is contained in:
mohammad
2024-09-04 16:55:46 +03:00
parent c4fc274dbf
commit c9160debd3
8 changed files with 81 additions and 64 deletions

View File

@ -13,7 +13,7 @@ import 'package:syncrow_web/utils/theme/theme.dart';
Future<void> main() async { Future<void> main() async {
try { try {
const environment = String.fromEnvironment('FLAVOR', defaultValue: 'production'); const environment = String.fromEnvironment('FLAVOR', defaultValue: 'development');
await dotenv.load(fileName: '.env.$environment'); await dotenv.load(fileName: '.env.$environment');
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
initialSetup(); initialSetup();
@ -43,6 +43,7 @@ class MyApp extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
HomeBloc.fetchUserInfo();
return MultiBlocProvider( return MultiBlocProvider(
providers: [ providers: [
BlocProvider(create: (context) => HomeBloc()), BlocProvider(create: (context) => HomeBloc()),

View File

@ -59,7 +59,6 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout {
builder: (context, state) { builder: (context, state) {
final accessBloc = BlocProvider.of<AccessBloc>(context); final accessBloc = BlocProvider.of<AccessBloc>(context);
final filteredData = accessBloc.filteredData; final filteredData = accessBloc.filteredData;
return state is AccessLoaded return state is AccessLoaded
? const Center(child: CircularProgressIndicator()) ? const Center(child: CircularProgressIndicator())
: Container( : Container(
@ -87,6 +86,7 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout {
const SizedBox(height: 20), const SizedBox(height: 20),
Expanded( Expanded(
child: DynamicTable( child: DynamicTable(
tableName: 'AccessManagement',
uuidIndex: 1, uuidIndex: 1,
withSelectAll: true, withSelectAll: true,
isEmpty: filteredData.isEmpty, isEmpty: filteredData.isEmpty,

View File

@ -132,7 +132,6 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
void _login(LoginButtonPressed event, Emitter<AuthState> emit) async { void _login(LoginButtonPressed event, Emitter<AuthState> emit) async {
emit(AuthLoading()); emit(AuthLoading());
if (isChecked) { if (isChecked) {
try { try {
if (event.username.isEmpty || event.password.isEmpty) { if (event.username.isEmpty || event.password.isEmpty) {
@ -149,7 +148,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
); );
} catch (failure) { } catch (failure) {
validate = 'Invalid Credentials!'; validate = 'Invalid Credentials!';
emit(const LoginFailure(error: 'Invalid Credentials!')); emit(LoginInitial());
return; return;
} }

View File

@ -138,15 +138,6 @@ class ForgetPasswordWebPage extends StatelessWidget {
CrossAxisAlignment.start, CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
Text(
"Country/Region",
style: Theme.of(context)
.textTheme
.bodySmall!
.copyWith(
fontSize: 14,
fontWeight: FontWeight.w400),
),
const SizedBox(height: 10), const SizedBox(height: 10),
SizedBox( SizedBox(
child: _buildDropdownField(context, forgetBloc, size) child: _buildDropdownField(context, forgetBloc, size)
@ -171,6 +162,7 @@ class ForgetPasswordWebPage extends StatelessWidget {
const SizedBox(height: 10), const SizedBox(height: 10),
SizedBox( SizedBox(
child: TextFormField( child: TextFormField(
controller:forgetBloc.forgetEmailController ,
validator: forgetBloc.validateEmail, validator: forgetBloc.validateEmail,
decoration: textBoxDecoration()! decoration: textBoxDecoration()!
.copyWith( .copyWith(

View File

@ -410,38 +410,39 @@ class _LoginWebPageState extends State<LoginWebPage>
}, },
), ),
), ),
SizedBox( Expanded(
width: 220, child: SizedBox(
child: RichText( child: RichText(
text: TextSpan( text: TextSpan(
text: 'Agree to ', text: 'Agree to ',
style: const TextStyle(color: Colors.white), style: const TextStyle(color: Colors.white),
children: [ children: [
TextSpan( TextSpan(
text: '(Terms of Service)', text: '(Terms of Service)',
style: const TextStyle(color: Colors.black), style: const TextStyle(color: Colors.black),
recognizer: TapGestureRecognizer() recognizer: TapGestureRecognizer()
..onTap = () { ..onTap = () {
loginBloc.launchURL('https://example.com/terms'); loginBloc.launchURL('https://example.com/terms');
}, },
), ),
TextSpan( TextSpan(
text: ' (Legal Statement)', text: ' (Legal Statement)',
style: const TextStyle(color: Colors.black), style: const TextStyle(color: Colors.black),
recognizer: TapGestureRecognizer() recognizer: TapGestureRecognizer()
..onTap = () { ..onTap = () {
loginBloc.launchURL('https://example.com/legal'); loginBloc.launchURL('https://example.com/legal');
}, },
), ),
TextSpan( TextSpan(
text: ' (Privacy Statement)', text: ' (Privacy Statement)',
style: const TextStyle(color: Colors.black), style: const TextStyle(color: Colors.black),
recognizer: TapGestureRecognizer() recognizer: TapGestureRecognizer()
..onTap = () { ..onTap = () {
loginBloc.launchURL('https://example.com/privacy'); loginBloc.launchURL('https://example.com/privacy');
}, },
), ),
], ],
),
), ),
), ),
), ),

View File

@ -16,7 +16,7 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
final BuchheimWalkerConfiguration builder = BuchheimWalkerConfiguration(); final BuchheimWalkerConfiguration builder = BuchheimWalkerConfiguration();
List<Node> sourcesList = []; List<Node> sourcesList = [];
List<Node> destinationsList = []; List<Node> destinationsList = [];
UserModel? user; static UserModel? user;
HomeBloc() : super((HomeInitial())) { HomeBloc() : super((HomeInitial())) {
on<CreateNewNode>(_createNode); on<CreateNewNode>(_createNode);
@ -50,6 +50,16 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
} }
} }
static Future fetchUserInfo() async {
try {
var uuid =
await const FlutterSecureStorage().read(key: UserModel.userUuidKey);
user = await HomeApi().fetchUserInfo(uuid);
} catch (e) {
return;
}
}
List<HomeItemModel> homeItems = [ List<HomeItemModel> homeItems = [
HomeItemModel( HomeItemModel(
title: 'Access', title: 'Access',

View File

@ -39,13 +39,17 @@ class AuthenticationAPI {
expectedResponseModel: (json) { expectedResponseModel: (json) {
return json['data']['cooldown']; return json['data']['cooldown'];
}); });
return response; return response;
} on DioException catch (e) { } on DioException catch (e) {
final errorData = e.response!.data;
String errorMessage = errorData['message'];
print('sendOtp=$errorMessage');
if (e.response != null) { if (e.response != null) {
if (e.response!.statusCode == 400) { if (e.response!.statusCode == 400) {
final errorData = e.response!.data; final errorData = e.response!.data;
String errorMessage = errorData['message']; String errorMessage = errorData['message'];
print('sendOtp=$errorMessage');
if (errorMessage == 'User not found') { if (errorMessage == 'User not found') {
return 1; return 1;
} else { } else {

View File

@ -5,19 +5,29 @@ import 'package:syncrow_web/pages/home/bloc/home_state.dart';
import 'package:syncrow_web/utils/color_manager.dart'; import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart'; import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
class WebAppBar extends StatelessWidget with HelperResponsiveLayout { import '../pages/auth/model/user_model.dart';
class WebAppBar extends StatefulWidget{
final Widget? title; final Widget? title;
final Widget? centerBody; final Widget? centerBody;
final Widget? rightBody; final Widget? rightBody;
const WebAppBar({super.key, this.title, this.centerBody, this.rightBody}); const WebAppBar({super.key, this.title, this.centerBody, this.rightBody});
@override
State<WebAppBar> createState() => _WebAppBarState();
}
class _WebAppBarState extends State<WebAppBar> with HelperResponsiveLayout {
@override
void initState() {
super.initState();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
bool isSmallScreen = isSmallScreenSize(context); bool isSmallScreen = isSmallScreenSize(context);
bool isHalfMediumScreen = isHafMediumScreenSize(context); bool isHalfMediumScreen = isHafMediumScreenSize(context);
return BlocBuilder<HomeBloc, HomeState>(builder: (context, state) { return BlocBuilder<HomeBloc, HomeState>(builder: (context, state) {
final user = context.read<HomeBloc>().user;
return Container( return Container(
height: (isSmallScreen || isHalfMediumScreen) ? 130 : 100, height: (isSmallScreen || isHalfMediumScreen) ? 130 : 100,
decoration: const BoxDecoration(color: ColorsManager.secondaryColor), decoration: const BoxDecoration(color: ColorsManager.secondaryColor),
@ -26,21 +36,21 @@ class WebAppBar extends StatelessWidget with HelperResponsiveLayout {
? Column( ? Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
if (title != null) if (widget.title != null)
Align( Align(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: title!, child: widget.title!,
), ),
if (centerBody != null) if (widget.centerBody != null)
Padding( Padding(
padding: const EdgeInsets.only(top: 8.0), padding: const EdgeInsets.only(top: 8.0),
child: centerBody, child: widget.centerBody,
), ),
if (rightBody != null || user != null) if (widget.rightBody != null || HomeBloc.user != null)
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
if (rightBody != null) rightBody!, if (widget.rightBody != null) widget.rightBody!,
Row( Row(
children: [ children: [
const SizedBox.square( const SizedBox.square(
@ -59,9 +69,9 @@ class WebAppBar extends StatelessWidget with HelperResponsiveLayout {
const SizedBox( const SizedBox(
width: 10, width: 10,
), ),
if (user != null) if (HomeBloc.user != null)
Text( Text(
'${user.firstName} ${user.lastName}', '${HomeBloc.user!.firstName} ${HomeBloc.user!.lastName}',
style: Theme.of(context).textTheme.bodyLarge, style: Theme.of(context).textTheme.bodyLarge,
), ),
], ],
@ -77,11 +87,11 @@ class WebAppBar extends StatelessWidget with HelperResponsiveLayout {
Expanded( Expanded(
child: Row( child: Row(
children: [ children: [
title!, widget.title!,
if (centerBody != null) if (widget.centerBody != null)
Padding( Padding(
padding: const EdgeInsets.only(left: 80), padding: const EdgeInsets.only(left: 80),
child: centerBody!, child: widget.centerBody!,
), ),
], ],
), ),
@ -89,10 +99,10 @@ class WebAppBar extends StatelessWidget with HelperResponsiveLayout {
Row( Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
if (rightBody != null) if (widget.rightBody != null)
Align( Align(
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: rightBody, child: widget.rightBody,
), ),
const SizedBox( const SizedBox(
width: 10, width: 10,
@ -113,9 +123,9 @@ class WebAppBar extends StatelessWidget with HelperResponsiveLayout {
const SizedBox( const SizedBox(
width: 10, width: 10,
), ),
if (user != null) if (HomeBloc.user != null)
Text( Text(
'${user.firstName} ${user.lastName}', '${HomeBloc.user!.firstName} ${HomeBloc.user!.lastName}',
style: Theme.of(context).textTheme.bodyLarge, style: Theme.of(context).textTheme.bodyLarge,
), ),
], ],