117 lines
3.7 KiB
Dart
117 lines
3.7 KiB
Dart
import 'package:flutter/material.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/common_strings.dart';
|
|
import '../../../core/theme/colors.dart';
|
|
import '../../../core/utils/app_toast.dart';
|
|
import '../../../view_models/auth_view_model.dart';
|
|
import '../../shared/desktop_navigation_widget.dart';
|
|
import '../strings/profile_strings.dart';
|
|
import '../widgets/main_data_tab.dart';
|
|
import '../widgets/members_tab.dart';
|
|
import '../widgets/profile_tab_bar.dart';
|
|
import '../widgets/subject_tab.dart';
|
|
|
|
class DesktopProfilePage extends StatefulWidget {
|
|
const DesktopProfilePage({super.key});
|
|
|
|
@override
|
|
State<DesktopProfilePage> createState() => _DesktopProfilePageState();
|
|
}
|
|
|
|
class _DesktopProfilePageState extends State<DesktopProfilePage>
|
|
with SingleTickerProviderStateMixin {
|
|
late ProfileViewModel viewModel;
|
|
late final TabController tabController;
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
viewModel = context.read<ProfileViewModel>();
|
|
tabController = TabController(length: 3, vsync: this);
|
|
viewModel.addListener(_profileListener);
|
|
}
|
|
|
|
void _profileListener() {
|
|
if (viewModel.errorMessage != null) {
|
|
AppToast.error(context, viewModel.errorMessage!);
|
|
}
|
|
if (viewModel.loggedOut) {
|
|
context.read<AuthViewModel>().clearAuthFlow();
|
|
Router.neglect(context, () => const LoginScreenRoute().go(context));
|
|
}
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
viewModel.removeListener(_profileListener);
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: AppColors.backgroundColor,
|
|
body: Column(
|
|
children: [
|
|
const DesktopNavigationWidget(
|
|
currentIndex: 4, // Tenders index
|
|
),
|
|
Expanded(
|
|
child: Consumer<ProfileViewModel>(
|
|
builder: (context, viewModel, child) {
|
|
if (viewModel.isLoading) {
|
|
return const Center(
|
|
child: CircularProgressIndicator(
|
|
color: AppColors.secondary50,
|
|
),
|
|
);
|
|
}
|
|
if (viewModel.errorMessage != null) {
|
|
return Center(child: Text(viewModel.errorMessage!));
|
|
}
|
|
|
|
if (viewModel.profileData == null) {
|
|
return const Center(child: Text(CommonStrings.noData));
|
|
}
|
|
|
|
return SizedBox(
|
|
width: 740,
|
|
height: double.infinity,
|
|
child: Column(
|
|
children: [
|
|
const SizedBox(height: 46),
|
|
ProfileTabBar(
|
|
controller: tabController,
|
|
titles: [
|
|
ProfileStrings.mainDataTab,
|
|
ProfileStrings.membersTab,
|
|
ProfileStrings.subjectTab,
|
|
],
|
|
),
|
|
Expanded(
|
|
child: TabBarView(
|
|
controller: tabController,
|
|
children: [
|
|
MainDataTab(
|
|
profileData: viewModel.profileData!,
|
|
onLogout: () => viewModel.logout(),
|
|
),
|
|
const MembersTab(),
|
|
const SubjectTab(),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|