From b5576afef8ca69566f638016fb84112b1fc7613e Mon Sep 17 00:00:00 2001 From: Niranjan Dorage Date: Fri, 2 Aug 2024 00:40:23 +0530 Subject: [PATCH] feat: new profile updated --- lib/theme/app_font.dart | 5 +- .../profile/preferences/preferences_view.dart | 2 +- .../preferences_view_components.dart | 29 +- lib/ui/views/profile/profile_view.dart | 15 +- .../views/profile/profile_view_component.dart | 250 ++++++++++-------- lib/ui/views/profile/profile_view_model.dart | 2 + 6 files changed, 168 insertions(+), 135 deletions(-) diff --git a/lib/theme/app_font.dart b/lib/theme/app_font.dart index c68f96bd..1994251c 100644 --- a/lib/theme/app_font.dart +++ b/lib/theme/app_font.dart @@ -57,9 +57,10 @@ class FontThemeClass { ); } - TextStyle body(BuildContext ctx, {Color? color, FontWeight? fontWeight}) { + TextStyle body(BuildContext ctx, + {Color? color, FontWeight? fontWeight, double? fontSize}) { return TextStyle( - fontSize: 16.sp, + fontSize: fontSize ?? 16.sp, fontFamily: 'Outfit', fontWeight: fontWeight ?? FontWeight.w400, color: color ?? ctx.colorScheme.primaryText, diff --git a/lib/ui/views/profile/preferences/preferences_view.dart b/lib/ui/views/profile/preferences/preferences_view.dart index 77fce652..e4d8d014 100644 --- a/lib/ui/views/profile/preferences/preferences_view.dart +++ b/lib/ui/views/profile/preferences/preferences_view.dart @@ -51,7 +51,7 @@ class PreferencesView extends StatelessWidget { ), body: SafeArea( child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 20).r, + padding: const EdgeInsets.symmetric(horizontal: 25).r, child: SingleChildScrollView( child: Column( children: [ diff --git a/lib/ui/views/profile/preferences/preferences_view_components.dart b/lib/ui/views/profile/preferences/preferences_view_components.dart index 819e22a8..8bed2a58 100644 --- a/lib/ui/views/profile/preferences/preferences_view_components.dart +++ b/lib/ui/views/profile/preferences/preferences_view_components.dart @@ -16,6 +16,7 @@ class LogoutButton extends ViewModelWidget { context, color: Colors.red.withOpacity(0.8), fontWeight: FontWeight.w700, + fontSize: 18.sp, ), ), ), @@ -41,11 +42,10 @@ class PasswordChangeTile extends ViewModelWidget { borderRadius: BorderRadius.circular(20).r, ), leading: SizedBox( - width: 60.w, child: Icon( Icons.lock_outline_rounded, - size: 30.r, - color: context.colorScheme.accentColor, + size: 35.r, + color: context.colorScheme.secondary.withOpacity(0.6), ), ), subtitle: Text( @@ -70,7 +70,8 @@ class PasswordChangeTile extends ViewModelWidget { }, child: Icon( Icons.arrow_forward_ios_rounded, - color: context.colorScheme.primaryText, + size: 25.r, + color: context.colorScheme.primaryText.withOpacity(0.6), ), ), ), @@ -91,14 +92,13 @@ class MisNumberTile extends ViewModelWidget { minVerticalPadding: 15.r, tileColor: context.colorScheme.card, shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(20).r, + borderRadius: BorderRadius.circular(12).r, ), leading: SizedBox( - width: 60.w, child: Icon( Icons.school_outlined, - size: 30.r, - color: context.colorScheme.accentColor, + size: 35.r, + color: context.colorScheme.secondary.withOpacity(0.6), ), ), trailing: GestureDetector( @@ -107,7 +107,8 @@ class MisNumberTile extends ViewModelWidget { }, child: Icon( Icons.copy_outlined, - color: context.colorScheme.primaryText, + color: context.colorScheme.primaryText.withOpacity(0.6), + size: 25.r, ), ), title: Column( @@ -148,14 +149,13 @@ class EmailAdressTile extends ViewModelWidget { minVerticalPadding: 15.r, tileColor: context.colorScheme.card, shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(20).r, + borderRadius: BorderRadius.circular(12).r, ), leading: SizedBox( - width: 60.w, child: Icon( Icons.email_outlined, - size: 30.r, - color: context.colorScheme.accentColor, + size: 35.r, + color: context.colorScheme.secondary.withOpacity(0.6), ), ), trailing: GestureDetector( @@ -164,7 +164,8 @@ class EmailAdressTile extends ViewModelWidget { }, child: Icon( Icons.copy_outlined, - color: context.colorScheme.primaryText, + color: context.colorScheme.primaryText.withOpacity(0.6), + size: 25.r, ), ), title: Column( diff --git a/lib/ui/views/profile/profile_view.dart b/lib/ui/views/profile/profile_view.dart index 39f6e085..7f12a42f 100644 --- a/lib/ui/views/profile/profile_view.dart +++ b/lib/ui/views/profile/profile_view.dart @@ -1,7 +1,7 @@ import 'package:abhiyaan/ui/common/circular_loading_indicator.dart'; -import 'package:cached_network_image/cached_network_image.dart'; import 'package:abhiyaan/file_exporter.dart'; import 'package:abhiyaan/ui/common/url_launcher.dart'; +import 'package:cached_network_image/cached_network_image.dart'; part 'profile_view_model.dart'; part "profile_view_component.dart"; @@ -24,7 +24,7 @@ class ProfileView extends StatelessWidget { ), ); return ViewModelBuilder.reactive( - viewModelBuilder: () => locator(), + viewModelBuilder: () => locator(), onViewModelReady: (viewModel) => viewModel.init(), disposeViewModel: false, builder: (context, model, child) { @@ -34,18 +34,17 @@ class ProfileView extends StatelessWidget { ? const CircularLoadingIndicator() : SafeArea( child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 20).r, + padding: const EdgeInsets.symmetric(horizontal: 33).r, child: Column( children: [ - const AppBarWidget(), + const ProfileImageWidget(), + const ProfileSectionText(title: 'Settings'), 16.verticalSpace, const ProfileCard(), 16.verticalSpace, const DarkModeTile(), - // 16.verticalSpace, - // model.localStorageService.read('userProfile') == "Explorer" || model.localStorageService.read('userProfile') == "Faculty" - // ? const SizedBox() - // : const Cerificatation(), + 16.verticalSpace, + const ProfileSectionText(title: 'Others'), 16.verticalSpace, const HelpSupportTile(), 16.verticalSpace, diff --git a/lib/ui/views/profile/profile_view_component.dart b/lib/ui/views/profile/profile_view_component.dart index d5460b30..f3ccd052 100644 --- a/lib/ui/views/profile/profile_view_component.dart +++ b/lib/ui/views/profile/profile_view_component.dart @@ -41,17 +41,15 @@ class Cerificatation extends StatelessWidget { return GestureDetector( onTap: () {}, child: ListTile( - minVerticalPadding: 15.r, tileColor: context.colorScheme.card, shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(20.r), + borderRadius: BorderRadius.circular(12.r), ), leading: SizedBox( - width: 60.w, child: Icon( Icons.credit_card_outlined, size: 30.r, - color: context.colorScheme.accentColor, + color: context.colorScheme.secondary.withOpacity(0.6), ), ), title: Text( @@ -59,7 +57,7 @@ class Cerificatation extends StatelessWidget { style: FontThemeClass().body( context, color: context.colorScheme.primaryText, - fontWeight: FontWeight.w600, + fontWeight: FontWeight.w500, ), ), subtitle: Text( @@ -73,8 +71,8 @@ class Cerificatation extends StatelessWidget { ), trailing: Icon( Icons.arrow_forward_ios_rounded, - size: 25.r, - color: context.colorScheme.primaryText, + size: 20.r, + color: context.colorScheme.primaryText.withOpacity(0.5), ), ), ); @@ -103,6 +101,80 @@ class AppBarWidget extends ViewModelWidget { } } +class ProfileImageWidget extends ViewModelWidget { + const ProfileImageWidget({ + super.key, + }); + + @override + Widget build(BuildContext context, ProfileViewModel viewModel) { + return Padding( + padding: EdgeInsets.symmetric(vertical: 30.r), + child: Column( + children: [ + InkWell( + splashColor: Colors.transparent, + child: ClipOval( + child: CachedNetworkImage( + width: 100.r, + height: 100.r, + fit: BoxFit.cover, + imageUrl: AssetUrls.profileImageUrl == '' || + AssetUrls.profileImageUrl == 'Not Available' + ? AssetUrls.dummyImageUrl + : AssetUrls.profileImageUrl, + placeholder: (context, url) => + const CircularLoadingIndicator(), + errorWidget: (context, url, error) { + return const Icon(Icons.error); + }, + ), + ), + ), + Text( + viewModel.localStorageService.read('userName'), + style: viewModel.fontTheme.title2( + context, + color: context.colorScheme.primaryText, + fontWeight: FontWeight.w600, + ), + ), + Text( + viewModel.localStorageService.read('userProfile'), + style: viewModel.fontTheme.body( + context, + color: context.colorScheme.secondarySectionColor, + fontWeight: FontWeight.w500, + ), + ), + ], + ), + ); + } +} + +class ProfileSectionText extends ViewModelWidget { + final String title; + const ProfileSectionText({ + required this.title, + super.key, + }); + + @override + Widget build(BuildContext context, ProfileViewModel viewModel) { + return Container( + alignment: Alignment.centerLeft, + child: Text(title, + style: FontThemeClass().body( + context, + color: context.colorScheme.primaryText, + fontWeight: FontWeight.w700, + fontSize: 18.sp, + )), + ); + } +} + class ProfileCard extends ViewModelWidget { const ProfileCard({ super.key, @@ -113,68 +185,29 @@ class ProfileCard extends ViewModelWidget { return GestureDetector( onTap: () => viewModel._navigationService.navigateToPreferencesView(), child: ListTile( + tileColor: context.colorScheme.card, shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(20.r), + borderRadius: BorderRadius.circular(12.r), ), - tileColor: context.colorScheme.card, - minVerticalPadding: 10.r, - title: Row( - children: [ - Hero( - tag: "profileImage", - child: ClipOval( - clipBehavior: Clip.hardEdge, - child: CachedNetworkImage( - imageUrl: AssetUrls.profileImageUrl==''||AssetUrls.profileImageUrl=='Not Available'?AssetUrls.dummyImageUrl:AssetUrls.profileImageUrl, - width: 50.w, - height: 50.w, - fit: BoxFit.cover, - ), - ), - ), - 12.horizontalSpace, - Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - viewModel.localStorageService.read('userName'), - style: FontThemeClass().title2( - context, - color: context.colorScheme.primaryText, - fontWeight: FontWeight.w500, - ), - ), - Text( - "View Profile Information", - style: FontThemeClass().caption( - context, - color: context.colorScheme.secondaryText, - fontWeight: FontWeight.w500, - ), - ), - ], - ), - const Spacer(), - Row( - children: [ - Text( - "View", - style: FontThemeClass().body( - context, - color: context.colorScheme.secondaryText, - fontWeight: FontWeight.w600, - ), - ), - 4.horizontalSpace, - Icon( - Icons.arrow_forward_ios_sharp, - color: context.colorScheme.secondaryText, - size: 15.r, - ), - ], - ), - ], + leading: SizedBox( + child: Icon( + Icons.person_2_outlined, + size: 30.r, + color: context.colorScheme.secondary.withOpacity(0.6), + ), + ), + title: Text( + "Personal Info", + style: FontThemeClass().body( + context, + color: context.colorScheme.primaryText, + fontWeight: FontWeight.w500, + ), + ), + trailing: Icon( + Icons.arrow_forward_ios_rounded, + size: 20.r, + color: context.colorScheme.primaryText.withOpacity(0.5), ), ), ); @@ -193,17 +226,15 @@ class HelpSupportTile extends ViewModelWidget { viewModel.navigateToHelpSupport(); }, child: ListTile( - minVerticalPadding: 25.r, tileColor: context.colorScheme.card, shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(20.r), + borderRadius: BorderRadius.circular(12.r), ), leading: SizedBox( - width: 60.w, child: Icon( Icons.warning_amber_rounded, size: 30.r, - color: context.colorScheme.accentColor, + color: context.colorScheme.secondary.withOpacity(0.6), ), ), title: Text( @@ -211,13 +242,13 @@ class HelpSupportTile extends ViewModelWidget { style: FontThemeClass().body( context, color: context.colorScheme.primaryText, - fontWeight: FontWeight.w600, + fontWeight: FontWeight.w500, ), ), trailing: Icon( Icons.arrow_forward_ios_rounded, - size: 25.r, - color: context.colorScheme.primaryText, + size: 20.r, + color: context.colorScheme.primaryText.withOpacity(0.5), ), ), ); @@ -236,17 +267,15 @@ class PrivacyPolicyTile extends ViewModelWidget { viewModel.navigateToPrivacyPolicy(); }, child: ListTile( - minVerticalPadding: 25.r, tileColor: context.colorScheme.card, shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(20.r), + borderRadius: BorderRadius.circular(12.r), ), leading: SizedBox( - width: 60.w, child: Icon( Icons.privacy_tip_outlined, size: 30.r, - color: context.colorScheme.accentColor, + color: context.colorScheme.secondary.withOpacity(0.6), ), ), title: Text( @@ -254,13 +283,13 @@ class PrivacyPolicyTile extends ViewModelWidget { style: FontThemeClass().body( context, color: context.colorScheme.primaryText, - fontWeight: FontWeight.w600, + fontWeight: FontWeight.w500, ), ), trailing: Icon( Icons.arrow_forward_ios_rounded, - size: 25.r, - color: context.colorScheme.primaryText, + size: 20.r, + color: context.colorScheme.primaryText.withOpacity(0.5), ), ), ); @@ -275,37 +304,38 @@ class DarkModeTile extends ViewModelWidget { @override Widget build(BuildContext context, ProfileViewModel viewModel) { return ListTile( - minVerticalPadding: 25.r, - tileColor: context.colorScheme.card, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(20.r), - ), - leading: SizedBox( - width: 60.w, - child: Icon( - Icons.dark_mode_outlined, - size: 30.r, - color: context.colorScheme.accentColor, + tileColor: context.colorScheme.card, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12.r), ), - ), - title: Text( - "Dark Mode", - style: FontThemeClass().body( - context, - color: context.colorScheme.primaryText, - fontWeight: FontWeight.w600, + leading: SizedBox( + child: Icon( + Icons.dark_mode_outlined, + size: 30.r, + color: context.colorScheme.secondary.withOpacity(0.6), + ), ), - ), - trailing: Switch.adaptive( - activeColor: context.colorScheme.accentColor, - inactiveThumbColor: context.colorScheme.accentColor, - inactiveTrackColor: context.colorScheme.lightScaffold, - trackOutlineColor: WidgetStateColor.resolveWith( - (states) => context.colorScheme.accentColor, + title: Text( + "Dark Mode", + style: FontThemeClass().body( + context, + color: context.colorScheme.primaryText, + fontWeight: FontWeight.w500, + ), ), - value: viewModel._themeService.valueListenable.value, - onChanged: (val) => viewModel.changeTheme(context), - ), - ); + contentPadding: EdgeInsets.only(left: 16.r,right: 10.r), + trailing: Transform.scale( + scale: 0.85, // Adjust the scale factor as needed + child: Switch.adaptive( + activeColor: context.colorScheme.accentColor, + inactiveThumbColor: context.colorScheme.secondary.withOpacity(0.7), + inactiveTrackColor: context.colorScheme.lightScaffold, + trackOutlineColor: WidgetStateColor.resolveWith( + (states) => context.colorScheme.secondary.withOpacity(0.7), + ), + value: viewModel._themeService.valueListenable.value, + onChanged: (val) => viewModel.changeTheme(context), + ))); + } } diff --git a/lib/ui/views/profile/profile_view_model.dart b/lib/ui/views/profile/profile_view_model.dart index 77875414..dd569ffa 100644 --- a/lib/ui/views/profile/profile_view_model.dart +++ b/lib/ui/views/profile/profile_view_model.dart @@ -6,6 +6,8 @@ class ProfileViewModel extends BaseViewModel { final _navigationService = locator(); final localStorageService = locator(); final _themeService = locator(); + final fontTheme = FontThemeClass(); + navigateToHelpSupport() { _analyticsService.logEvent(