profile account_screen
unknown
dart
a year ago
9.4 kB
2
Indexable
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:provider/provider.dart';
import '../../../../core/common/app/providers/user_provider.dart';
import '../../../../core/services/injection_container.dart';
import '../../../auth/presentation/bloc/auth_bloc.dart';
import '../../../auth/presentation/views/splash_screen.dart';
import '../../../auth/presentation/views/tutorial_screen.dart';
import 'reward_screen.dart';
import '../widgets/language_dialog.dart';
import 'package:flutter/material.dart';
import '../../../../core/common/widgets/app_bar_core.dart';
import '../../../../core/res/colours.dart';
import '../../../../core/res/media_res.dart';
import '../widgets/delete_account_dialog.dart';
import '../widgets/logout_dialog.dart';
import '../widgets/profile_button_item.dart';
import '../widgets/profile_subtitle.dart';
import '../widgets/user_profile_content.dart';
import 'contact_us.dart';
import 'password_manager_screen.dart';
import 'personal_info_screen.dart';
import 'terms_and_privacy_policy_screen.dart';
class AccountScreen extends StatefulWidget {
const AccountScreen({super.key});
@override
State<AccountScreen> createState() => _AccountScreenState();
}
class _AccountScreenState extends State<AccountScreen> {
@override
Widget build(BuildContext context) {
return BlocConsumer<AuthBloc, AuthState>(
listener: (context, state) {
if (state is AuthError) {
} else if (state is NotSignedIn) {
Navigator.pushNamedAndRemoveUntil(
context, SplashScreen.routeName, (route) => false);
}
},
builder: (context, state) {
return Scaffold(
appBar: const AppBarCore(
title: 'Account',
size: 24,
isBackButton: false,
),
body: Padding(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
child: Column(
children: [
Consumer<UserProvider>(
builder: (_, userProvider, __) {
return UserProfileContent(
imageProfile: userProvider.user!.profileImg!,
username: userProvider.user!.firstname,
phoneNumber: userProvider.user!.phoneNumber ??
userProvider.user!.email ??
'',
isEditable: false,
);
},
),
const SizedBox(height: 24),
const Divider(
height: 1,
color: Colours.secondaryColourDisabled,
),
const SizedBox(height: 12),
Expanded(
child: SingleChildScrollView(
child: Column(
children: [
const ProfileSubtitle(text: 'Account'),
const SizedBox(height: 12),
ProfileButtonItem(
buttonTitle: 'Personal Info',
icon: MediaRes.accountIconProfile,
needArrowBeside: true,
onPress: () {
Navigator.pushNamed(
context, PersonalInfoScreen.routeName);
}),
const SizedBox(height: 12),
ProfileButtonItem(
buttonTitle: 'Rewards',
icon: MediaRes.rewardIcon,
needArrowBeside: true,
onPress: () {
Navigator.pushNamed(
context, RewardScreen.routeName);
}),
const SizedBox(height: 12),
ProfileButtonItem(
buttonTitle: 'Password Manager',
icon: MediaRes.passwordManagerIcon,
needArrowBeside: true,
onPress: () {
Navigator.pushNamed(
context, PasswordManagerScreen.routeName);
}),
const SizedBox(height: 24),
const ProfileSubtitle(text: 'Help & Legal'),
const SizedBox(height: 12),
ProfileButtonItem(
buttonTitle: 'FAQs & Manuals',
icon: MediaRes.faqManualIcon,
needArrowBeside: true,
onPress: () {
Navigator.pushNamed(
context, TutorialScreen.routeName);
}),
const SizedBox(height: 12),
ProfileButtonItem(
buttonTitle: 'Terms & Privacy Policy',
icon: MediaRes.termPrivacyIcon,
needArrowBeside: true,
onPress: () {
Navigator.pushNamed(context,
TermsAndPrivacyPolicyScreen.routeName);
}),
const SizedBox(height: 12),
ProfileButtonItem(
buttonTitle: 'Contact Us',
icon: MediaRes.contactUsIcon,
needArrowBeside: true,
onPress: () {
Navigator.pushNamed(
context, ContactUs.routeName);
}),
const SizedBox(
height: 24,
),
const ProfileSubtitle(text: 'Settings'),
const SizedBox(height: 12),
ProfileButtonItem(
buttonTitle: 'Language',
icon: MediaRes.languageIcon,
needArrowBeside: false,
onPress: () {
showModalBottomSheet(
context: context,
builder: (_) => const LanguageDialog());
}),
const SizedBox(height: 12),
ProfileButtonItem(
buttonTitle: 'Delete Account',
icon: MediaRes.deleteAccountIcon,
needArrowBeside: false,
textColor: Colours.errorColour,
iconColor: Colours.errorColour,
onPress: () {
showModalBottomSheet(
context: context,
builder: (_) =>
const DeleteAccountDialog());
}),
const SizedBox(height: 12),
ProfileButtonItem(
buttonTitle: 'Logout',
icon: MediaRes.logoutIcon,
needArrowBeside: false,
textColor: Colours.errorColour,
iconColor: Colours.errorColour,
onPress: () {
showModalBottomSheet(
context: context,
builder: (_) => BlocProvider(
create: (context) => sl<AuthBloc>(),
child: const LogoutDialog(),
));
// navigate to logout screen
}),
const SizedBox(
height: 24,
),
const Text(
'Parking+',
style: TextStyle(
fontSize: 14,
fontFamily: 'Poppins',
color: Colours.greyDarkerColour),
),
const Text(
'Version 2.x.x',
style: TextStyle(
fontSize: 14,
fontFamily: 'Poppins',
color: Colours.greyDarkerColour),
)
],
),
),
),
],
),
));
},
);
}
}
Editor is loading...
Leave a Comment