201 lines
7.1 KiB
Dart
201 lines
7.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_svg/svg.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:tm_app/core/routes/app_routes.dart';
|
|
import 'package:tm_app/view_models/profile_view_model.dart';
|
|
|
|
import '../../../core/constants/assets.dart';
|
|
import '../../../core/constants/strings.dart';
|
|
import '../../../core/theme/colors.dart';
|
|
import '../../../core/utils/size_config.dart';
|
|
import '../../shared/desktop_navigation_widget.dart';
|
|
import '../widgets/theme_toggle.dart';
|
|
import '../widgets/title_description.dart';
|
|
|
|
class DesktopProfilePage extends StatefulWidget {
|
|
const DesktopProfilePage({super.key});
|
|
|
|
@override
|
|
State<DesktopProfilePage> createState() => _DesktopProfilePageState();
|
|
}
|
|
|
|
class _DesktopProfilePageState extends State<DesktopProfilePage> {
|
|
late ProfileViewModel viewModel;
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
viewModel = context.read<ProfileViewModel>();
|
|
viewModel.addListener(_profileListener);
|
|
}
|
|
|
|
void _profileListener() {
|
|
if (viewModel.errorMessage != null) {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(
|
|
content: Text(viewModel.errorMessage!),
|
|
backgroundColor: AppColors.red,
|
|
),
|
|
);
|
|
}
|
|
if (viewModel.loggedOut) {
|
|
Router.neglect(context, () => LoginScreenRoute().go(context));
|
|
}
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
viewModel.removeListener(_profileListener);
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: AppColors.backgroundColor,
|
|
body: Consumer<ProfileViewModel>(
|
|
builder: (context, viewModel, child) {
|
|
if (viewModel.isLoading) {
|
|
return Center(
|
|
child: CircularProgressIndicator(color: AppColors.secondary50),
|
|
);
|
|
}
|
|
if (viewModel.errorMessage != null) {
|
|
return Center(child: Text(viewModel.errorMessage!));
|
|
}
|
|
|
|
if (viewModel.companyProfileData == null) {
|
|
return Center(child: Text(AppStrings.noData));
|
|
}
|
|
|
|
return Column(
|
|
children: [
|
|
DesktopNavigationWidget(
|
|
currentIndex: 2, // Tenders index
|
|
onTabChanged: (index) {
|
|
// Navigate to different screens based on index
|
|
switch (index) {
|
|
case 0:
|
|
// Navigate to home
|
|
Router.neglect(
|
|
context,
|
|
() => HomeRouteData().go(context),
|
|
);
|
|
break;
|
|
case 1:
|
|
// Navigate to profile
|
|
Router.neglect(
|
|
context,
|
|
() => TendersRouteData().go(context),
|
|
);
|
|
break;
|
|
case 2:
|
|
// Already on profile
|
|
break;
|
|
}
|
|
},
|
|
),
|
|
SizedBox(
|
|
width: 740,
|
|
child: Column(
|
|
children: [
|
|
SizedBox(height: 36.0.h()),
|
|
TitleDescription(
|
|
title: AppStrings.companyName,
|
|
description: viewModel.companyProfileData!.name!,
|
|
),
|
|
TitleDescription(
|
|
title: AppStrings.nationalId,
|
|
description: viewModel.companyProfileData!.id!,
|
|
),
|
|
TitleDescription(
|
|
title: AppStrings.registrationNumber,
|
|
description:
|
|
viewModel.companyProfileData!.registrationNumber!,
|
|
),
|
|
TitleDescription(
|
|
title: AppStrings.businessType,
|
|
description: '-',
|
|
),
|
|
TitleDescription(
|
|
title: AppStrings.founded,
|
|
description:
|
|
viewModel.companyProfileData!.foundedYear!.toString(),
|
|
),
|
|
SizedBox(height: 24.0.h()),
|
|
// Theme Toggle
|
|
Align(
|
|
alignment: AlignmentDirectional.centerStart,
|
|
child: Text(
|
|
AppStrings.settings,
|
|
style: TextStyle(
|
|
fontSize: 20.0.sp(),
|
|
fontWeight: FontWeight.w600,
|
|
color: AppColors.grey70,
|
|
),
|
|
),
|
|
),
|
|
SizedBox(height: 36.0.h()),
|
|
Padding(
|
|
padding: EdgeInsets.symmetric(horizontal: 8.0.w()),
|
|
child: Row(
|
|
children: [
|
|
Text(
|
|
AppStrings.appTheme,
|
|
style: TextStyle(
|
|
fontSize: 16.0.sp(),
|
|
fontWeight: FontWeight.w400,
|
|
color: AppColors.grey70,
|
|
),
|
|
),
|
|
Spacer(),
|
|
SvgPicture.asset(AssetsManager.sun),
|
|
SizedBox(width: 12.0.w()),
|
|
SizedBox(
|
|
width: 52.0.w(),
|
|
height: 32.0.h(),
|
|
child: ThemeToggle(),
|
|
),
|
|
SizedBox(width: 12.0.w()),
|
|
SvgPicture.asset(AssetsManager.moon),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(height: 24.0.h()),
|
|
Divider(color: AppColors.dividerColor, thickness: 1),
|
|
SizedBox(height: 24.0.h()),
|
|
// Spacer(),
|
|
Align(
|
|
alignment: Alignment.centerRight,
|
|
child: InkWell(
|
|
onTap: () => viewModel.logout(),
|
|
borderRadius: BorderRadius.circular(100),
|
|
child: Container(
|
|
width: 156,
|
|
height: 56.0.h(),
|
|
decoration: BoxDecoration(
|
|
color: AppColors.primary20,
|
|
borderRadius: BorderRadius.circular(100),
|
|
),
|
|
alignment: Alignment.center,
|
|
child: Text(
|
|
AppStrings.logout,
|
|
style: TextStyle(
|
|
fontSize: 14.0.sp(),
|
|
fontWeight: FontWeight.w500,
|
|
color: AppColors.primaryColor,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|