profile tabs added

This commit is contained in:
amirrezaghabeli
2026-04-18 16:36:05 +03:30
parent 7ae5c25ebb
commit c6cb3221ab
4 changed files with 247 additions and 121 deletions
+26 -106
View File
@@ -1,11 +1,9 @@
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 'package:tm_app/views/profile/widgets/theme_toggle.dart';
import 'package:tm_app/views/profile/widgets/main_data_tab.dart';
import '../../../core/constants/assets.dart';
import '../../../core/constants/common_strings.dart';
import '../../../core/theme/colors.dart';
import '../../../core/utils/app_toast.dart';
@@ -13,7 +11,7 @@ import '../../../core/utils/size_config.dart';
import '../../../view_models/auth_view_model.dart';
import '../../shared/tender_app_bar.dart';
import '../strings/profile_strings.dart';
import '../widgets/title_description.dart';
import '../widgets/profile_tab_bar.dart';
class MobileProfilePage extends StatefulWidget {
const MobileProfilePage({super.key});
@@ -22,12 +20,15 @@ class MobileProfilePage extends StatefulWidget {
State<MobileProfilePage> createState() => _MobileProfilePageState();
}
class _MobileProfilePageState extends State<MobileProfilePage> {
class _MobileProfilePageState extends State<MobileProfilePage>
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);
// Load notification info saved in SharedPreferences
}
@@ -53,7 +54,8 @@ class _MobileProfilePageState extends State<MobileProfilePage> {
return Scaffold(
backgroundColor: AppColors.backgroundColor,
appBar: tenderMobileAppBar(title: ProfileStrings.profileTitle),
body: Consumer<ProfileViewModel>(
body: SafeArea(
child: Consumer<ProfileViewModel>(
builder: (context, viewModel, child) {
if (viewModel.isLoading) {
return const Center(
@@ -69,121 +71,39 @@ class _MobileProfilePageState extends State<MobileProfilePage> {
return const Center(child: Text(CommonStrings.noData));
}
return SafeArea(
child: Padding(
return Padding(
padding: EdgeInsets.symmetric(
horizontal: 24.0.w(),
vertical: 16.0.h(),
),
child: Column(
children: [
SizedBox(height: 36.0.h()),
Align(
alignment: AlignmentDirectional.centerStart,
child: Text(
'Last Notification',
style: TextStyle(
fontSize: 18.0.sp(),
fontWeight: FontWeight.w600,
color: AppColors.grey70,
),
),
),
SizedBox(height: 24.0.h()),
TitleDescription(
title: ProfileStrings.fullname,
description: viewModel.profileData!.fullName ?? '',
),
TitleDescription(
title: ProfileStrings.username,
description: viewModel.profileData!.username ?? '',
),
TitleDescription(
title: ProfileStrings.email,
description: viewModel.profileData!.email ?? '',
),
TitleDescription(
title: ProfileStrings.phone,
description: viewModel.profileData!.phone ?? '',
),
TitleDescription(
title: ProfileStrings.companyName,
description:
viewModel.profileData!.companies!.first.name ?? '',
),
SizedBox(height: 32.0.h()),
Align(
alignment: AlignmentDirectional.centerStart,
child: Text(
ProfileStrings.settings,
style: TextStyle(
fontSize: 20.0.sp(),
fontWeight: FontWeight.w600,
color: AppColors.grey70,
),
),
),
SizedBox(height: 36.0.h()),
_themeChangeRow(),
SizedBox(height: 24.0.h()),
Divider(color: AppColors.dividerColor, thickness: 1),
SizedBox(height: 24.0.h()),
const Spacer(),
InkWell(
onTap: () => viewModel.logout(),
borderRadius: BorderRadius.circular(100),
child: Container(
width: double.infinity,
height: 56.0.h(),
decoration: BoxDecoration(
color: AppColors.primary20,
borderRadius: BorderRadius.circular(100),
),
alignment: Alignment.center,
child: Text(
ProfileStrings.logout,
style: TextStyle(
fontSize: 14.0.sp(),
fontWeight: FontWeight.w500,
color: AppColors.primaryColor,
ProfileTabBar(
controller: tabController,
titles: [
ProfileStrings.mainDataTab,
ProfileStrings.membersTab,
ProfileStrings.subjectTab,
],
),
Expanded(
child: TabBarView(
controller: tabController,
children: [
MainDataTab(
profileData: viewModel.profileData!,
onLogout: () => viewModel.logout(),
),
const Center(child: Text('Members Tab Content')),
const Center(child: Text('Subject Tab Content')),
],
),
),
],
),
),
);
},
),
);
}
Widget _themeChangeRow() {
return Padding(
padding: EdgeInsets.symmetric(horizontal: 8.0.w()),
child: Row(
children: [
Text(
ProfileStrings.appTheme,
style: TextStyle(
fontSize: 16.0.sp(),
fontWeight: FontWeight.w400,
color: AppColors.grey70,
),
),
const Spacer(),
SvgPicture.asset(AssetsManager.sun),
SizedBox(width: 12.0.w()),
SizedBox(
width: 52.0.w(),
height: 32.0.h(),
child: const ThemeToggle(),
),
SizedBox(width: 12.0.w()),
SvgPicture.asset(AssetsManager.moon),
],
),
);
}
@@ -20,4 +20,7 @@ class ProfileStrings {
static const String position = 'position';
static const String phone = 'phone';
static const String fullname = 'full name';
static const String mainDataTab = 'Main Data';
static const String membersTab = 'Members';
static const String subjectTab = 'Subject';
}
@@ -0,0 +1,133 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:tm_app/core/utils/size_config.dart';
import '../../../core/constants/assets.dart';
import '../../../core/theme/colors.dart';
import '../../../data/services/model/profile_data/profile_data.dart';
import '../strings/profile_strings.dart';
import 'theme_toggle.dart';
import 'title_description.dart';
class MainDataTab extends StatelessWidget {
const MainDataTab({
required this.profileData,
required this.onLogout,
super.key,
});
final ProfileData profileData;
final VoidCallback onLogout;
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(height: 36.0.h()),
Align(
alignment: AlignmentDirectional.centerStart,
child: Text(
'Last Notification',
style: TextStyle(
fontSize: 18.0.sp(),
fontWeight: FontWeight.w600,
color: AppColors.grey70,
),
),
),
SizedBox(height: 24.0.h()),
TitleDescription(
title: ProfileStrings.fullname,
description: profileData.fullName ?? '',
),
TitleDescription(
title: ProfileStrings.username,
description: profileData.username ?? '',
),
TitleDescription(
title: ProfileStrings.email,
description: profileData.email ?? '',
),
TitleDescription(
title: ProfileStrings.phone,
description: profileData.phone ?? '',
),
TitleDescription(
title: ProfileStrings.companyName,
description: profileData.companies!.first.name ?? '',
),
SizedBox(height: 32.0.h()),
Align(
alignment: AlignmentDirectional.centerStart,
child: Text(
ProfileStrings.settings,
style: TextStyle(
fontSize: 20.0.sp(),
fontWeight: FontWeight.w600,
color: AppColors.grey70,
),
),
),
SizedBox(height: 36.0.h()),
_themeChangeRow(),
SizedBox(height: 24.0.h()),
Divider(color: AppColors.dividerColor, thickness: 1),
SizedBox(height: 24.0.h()),
InkWell(
onTap: onLogout,
borderRadius: BorderRadius.circular(100),
child: Container(
width: double.infinity,
height: 56.0.h(),
decoration: BoxDecoration(
color: AppColors.primary20,
borderRadius: BorderRadius.circular(100),
),
alignment: Alignment.center,
child: Text(
ProfileStrings.logout,
style: TextStyle(
fontSize: 14.0.sp(),
fontWeight: FontWeight.w500,
color: AppColors.primaryColor,
),
),
),
),
],
),
);
}
Widget _themeChangeRow() {
return Padding(
padding: EdgeInsets.symmetric(horizontal: 8.0.w()),
child: Row(
children: [
Text(
ProfileStrings.appTheme,
style: TextStyle(
fontSize: 16.0.sp(),
fontWeight: FontWeight.w400,
color: AppColors.grey70,
),
),
const Spacer(),
SvgPicture.asset(AssetsManager.sun),
SizedBox(width: 12.0.w()),
SizedBox(
width: 52.0.w(),
height: 32.0.h(),
child: const ThemeToggle(),
),
SizedBox(width: 12.0.w()),
SvgPicture.asset(AssetsManager.moon),
],
),
);
}
}
@@ -0,0 +1,70 @@
import 'package:flutter/material.dart';
import 'package:tm_app/core/utils/size_config.dart';
import '../../../core/theme/colors.dart';
class ProfileTabBar extends StatefulWidget {
const ProfileTabBar({
required this.controller,
required this.titles,
this.onTap,
super.key,
});
final TabController controller;
final List<String> titles;
final ValueChanged<int>? onTap;
@override
State<ProfileTabBar> createState() => _ProfileTabBarState();
}
class _ProfileTabBarState extends State<ProfileTabBar> {
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Container(
width: double.infinity,
height: 51.0.h(),
padding: EdgeInsets.symmetric(horizontal: 8.0.w(), vertical: 8.0.h()),
decoration: BoxDecoration(
color: AppColors.grey10,
borderRadius: BorderRadius.circular(10),
),
alignment: Alignment.center,
child: TabBar(
controller: widget.controller,
onTap: widget.onTap,
indicatorSize: TabBarIndicatorSize.tab,
dividerColor: Colors.transparent,
indicator: BoxDecoration(
color: AppColors.primary0,
borderRadius: BorderRadius.circular(10),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.12),
blurRadius: 4,
offset: const Offset(0, 2),
),
],
),
labelColor: AppColors.mainBlue,
unselectedLabelColor: AppColors.grey60,
labelStyle: TextStyle(
fontSize: 16.0.sp(),
fontWeight: FontWeight.w600,
),
unselectedLabelStyle: TextStyle(
fontSize: 16.0.sp(),
fontWeight: FontWeight.w600,
),
tabs: [
Tab(text: widget.titles[0]),
Tab(text: widget.titles[1]),
Tab(text: widget.titles[2]),
],
),
),
);
}
}