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 {
try {
const environment = String.fromEnvironment('FLAVOR', defaultValue: 'production');
const environment = String.fromEnvironment('FLAVOR', defaultValue: 'development');
await dotenv.load(fileName: '.env.$environment');
WidgetsFlutterBinding.ensureInitialized();
initialSetup();
@ -43,6 +43,7 @@ class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
HomeBloc.fetchUserInfo();
return MultiBlocProvider(
providers: [
BlocProvider(create: (context) => HomeBloc()),

View File

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

View File

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

View File

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

View File

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

View File

@ -16,7 +16,7 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
final BuchheimWalkerConfiguration builder = BuchheimWalkerConfiguration();
List<Node> sourcesList = [];
List<Node> destinationsList = [];
UserModel? user;
static UserModel? user;
HomeBloc() : super((HomeInitial())) {
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 = [
HomeItemModel(
title: 'Access',

View File

@ -39,13 +39,17 @@ class AuthenticationAPI {
expectedResponseModel: (json) {
return json['data']['cooldown'];
});
return response;
} on DioException catch (e) {
final errorData = e.response!.data;
String errorMessage = errorData['message'];
print('sendOtp=$errorMessage');
if (e.response != null) {
if (e.response!.statusCode == 400) {
final errorData = e.response!.data;
String errorMessage = errorData['message'];
print('sendOtp=$errorMessage');
if (errorMessage == 'User not found') {
return 1;
} 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/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? centerBody;
final Widget? 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
Widget build(BuildContext context) {
bool isSmallScreen = isSmallScreenSize(context);
bool isHalfMediumScreen = isHafMediumScreenSize(context);
return BlocBuilder<HomeBloc, HomeState>(builder: (context, state) {
final user = context.read<HomeBloc>().user;
return Container(
height: (isSmallScreen || isHalfMediumScreen) ? 130 : 100,
decoration: const BoxDecoration(color: ColorsManager.secondaryColor),
@ -26,21 +36,21 @@ class WebAppBar extends StatelessWidget with HelperResponsiveLayout {
? Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (title != null)
if (widget.title != null)
Align(
alignment: Alignment.centerLeft,
child: title!,
child: widget.title!,
),
if (centerBody != null)
if (widget.centerBody != null)
Padding(
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(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
if (rightBody != null) rightBody!,
if (widget.rightBody != null) widget.rightBody!,
Row(
children: [
const SizedBox.square(
@ -59,9 +69,9 @@ class WebAppBar extends StatelessWidget with HelperResponsiveLayout {
const SizedBox(
width: 10,
),
if (user != null)
if (HomeBloc.user != null)
Text(
'${user.firstName} ${user.lastName}',
'${HomeBloc.user!.firstName} ${HomeBloc.user!.lastName}',
style: Theme.of(context).textTheme.bodyLarge,
),
],
@ -77,11 +87,11 @@ class WebAppBar extends StatelessWidget with HelperResponsiveLayout {
Expanded(
child: Row(
children: [
title!,
if (centerBody != null)
widget.title!,
if (widget.centerBody != null)
Padding(
padding: const EdgeInsets.only(left: 80),
child: centerBody!,
child: widget.centerBody!,
),
],
),
@ -89,10 +99,10 @@ class WebAppBar extends StatelessWidget with HelperResponsiveLayout {
Row(
mainAxisSize: MainAxisSize.min,
children: [
if (rightBody != null)
if (widget.rightBody != null)
Align(
alignment: Alignment.centerRight,
child: rightBody,
child: widget.rightBody,
),
const SizedBox(
width: 10,
@ -113,9 +123,9 @@ class WebAppBar extends StatelessWidget with HelperResponsiveLayout {
const SizedBox(
width: 10,
),
if (user != null)
if (HomeBloc.user != null)
Text(
'${user.firstName} ${user.lastName}',
'${HomeBloc.user!.firstName} ${HomeBloc.user!.lastName}',
style: Theme.of(context).textTheme.bodyLarge,
),
],