profile tabs added
This commit is contained in:
@@ -1,11 +1,9 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:tm_app/core/routes/app_routes.dart';
|
import 'package:tm_app/core/routes/app_routes.dart';
|
||||||
import 'package:tm_app/view_models/profile_view_model.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/constants/common_strings.dart';
|
||||||
import '../../../core/theme/colors.dart';
|
import '../../../core/theme/colors.dart';
|
||||||
import '../../../core/utils/app_toast.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 '../../../view_models/auth_view_model.dart';
|
||||||
import '../../shared/tender_app_bar.dart';
|
import '../../shared/tender_app_bar.dart';
|
||||||
import '../strings/profile_strings.dart';
|
import '../strings/profile_strings.dart';
|
||||||
import '../widgets/title_description.dart';
|
import '../widgets/profile_tab_bar.dart';
|
||||||
|
|
||||||
class MobileProfilePage extends StatefulWidget {
|
class MobileProfilePage extends StatefulWidget {
|
||||||
const MobileProfilePage({super.key});
|
const MobileProfilePage({super.key});
|
||||||
@@ -22,12 +20,15 @@ class MobileProfilePage extends StatefulWidget {
|
|||||||
State<MobileProfilePage> createState() => _MobileProfilePageState();
|
State<MobileProfilePage> createState() => _MobileProfilePageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MobileProfilePageState extends State<MobileProfilePage> {
|
class _MobileProfilePageState extends State<MobileProfilePage>
|
||||||
|
with SingleTickerProviderStateMixin {
|
||||||
late ProfileViewModel viewModel;
|
late ProfileViewModel viewModel;
|
||||||
|
late final TabController tabController;
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
viewModel = context.read<ProfileViewModel>();
|
viewModel = context.read<ProfileViewModel>();
|
||||||
|
tabController = TabController(length: 3, vsync: this);
|
||||||
viewModel.addListener(_profileListener);
|
viewModel.addListener(_profileListener);
|
||||||
// Load notification info saved in SharedPreferences
|
// Load notification info saved in SharedPreferences
|
||||||
}
|
}
|
||||||
@@ -53,137 +54,56 @@ class _MobileProfilePageState extends State<MobileProfilePage> {
|
|||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: AppColors.backgroundColor,
|
backgroundColor: AppColors.backgroundColor,
|
||||||
appBar: tenderMobileAppBar(title: ProfileStrings.profileTitle),
|
appBar: tenderMobileAppBar(title: ProfileStrings.profileTitle),
|
||||||
body: Consumer<ProfileViewModel>(
|
body: SafeArea(
|
||||||
builder: (context, viewModel, child) {
|
child: Consumer<ProfileViewModel>(
|
||||||
if (viewModel.isLoading) {
|
builder: (context, viewModel, child) {
|
||||||
return const Center(
|
if (viewModel.isLoading) {
|
||||||
child: CircularProgressIndicator(color: AppColors.secondary50),
|
return const Center(
|
||||||
);
|
child: CircularProgressIndicator(color: AppColors.secondary50),
|
||||||
}
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (viewModel.errorMessage != null) {
|
if (viewModel.errorMessage != null) {
|
||||||
return Center(child: Text(viewModel.errorMessage!));
|
return Center(child: Text(viewModel.errorMessage!));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (viewModel.profileData == null) {
|
if (viewModel.profileData == null) {
|
||||||
return const Center(child: Text(CommonStrings.noData));
|
return const Center(child: Text(CommonStrings.noData));
|
||||||
}
|
}
|
||||||
|
|
||||||
return SafeArea(
|
return Padding(
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.symmetric(
|
padding: EdgeInsets.symmetric(
|
||||||
horizontal: 24.0.w(),
|
horizontal: 24.0.w(),
|
||||||
vertical: 16.0.h(),
|
vertical: 16.0.h(),
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
SizedBox(height: 36.0.h()),
|
ProfileTabBar(
|
||||||
Align(
|
controller: tabController,
|
||||||
alignment: AlignmentDirectional.centerStart,
|
titles: [
|
||||||
child: Text(
|
ProfileStrings.mainDataTab,
|
||||||
'Last Notification',
|
ProfileStrings.membersTab,
|
||||||
style: TextStyle(
|
ProfileStrings.subjectTab,
|
||||||
fontSize: 18.0.sp(),
|
],
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
color: AppColors.grey70,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
Expanded(
|
||||||
SizedBox(height: 24.0.h()),
|
child: TabBarView(
|
||||||
TitleDescription(
|
controller: tabController,
|
||||||
title: ProfileStrings.fullname,
|
children: [
|
||||||
description: viewModel.profileData!.fullName ?? '',
|
MainDataTab(
|
||||||
),
|
profileData: viewModel.profileData!,
|
||||||
TitleDescription(
|
onLogout: () => viewModel.logout(),
|
||||||
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,
|
|
||||||
),
|
),
|
||||||
),
|
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 position = 'position';
|
||||||
static const String phone = 'phone';
|
static const String phone = 'phone';
|
||||||
static const String fullname = 'full name';
|
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]),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user