Skip to content

Commit

Permalink
fix: Get FAQs and added tests for drawer and help_center_menu #2644
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Jun 20, 2024
1 parent 1e4954c commit f29c581
Show file tree
Hide file tree
Showing 4 changed files with 733 additions and 149 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,30 @@ class HelpCenterMenu extends StatelessWidget {

@override
Widget build(BuildContext context) {
return const HelpCenterView();
return Builder(
builder: (context) {
return HelpCenterView(
profileCubit: context.read<ProfileCubit>(),
);
},
);
}
}

class HelpCenterView extends StatelessWidget {
const HelpCenterView({super.key});
const HelpCenterView({
super.key,
required this.profileCubit,
});

final ProfileCubit profileCubit;

@override
Widget build(BuildContext context) {
final l10n = context.l10n;

final helpCenterOptions = context
.read<ProfileCubit>()
.state
.model
.profileSetting
.helpCenterOptions;
final helpCenterOptions =
profileCubit.state.model.profileSetting.helpCenterOptions;

var email = AltMeStrings.appSupportMail;

Expand Down Expand Up @@ -80,11 +87,8 @@ class HelpCenterView extends StatelessWidget {
DrawerItem(
title: l10n.sendAnEmail,
onTap: () {
Navigator.of(context).push<void>(
ContactUsPage.route(
email: email,
),
);
Navigator.of(context)
.push<void>(ContactUsPage.route(email: email));
},
),
],
Expand All @@ -96,9 +100,7 @@ class HelpCenterView extends StatelessWidget {
),
DrawerItem(
onTap: () {
LaunchUrl.launch(
'https://${AltMeStrings.appContactWebsiteName}',
);
LaunchUrl.launch('https://${AltMeStrings.appContactWebsiteName}');
},
title: l10n.officialWebsite,
),
Expand Down
279 changes: 146 additions & 133 deletions lib/dashboard/drawer/src/view/drawer_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,23 @@ class DrawerPage extends StatelessWidget {

@override
Widget build(BuildContext context) {
return const DrawerView();
return Builder(
builder: (context) {
return DrawerView(
profileCubit: context.read<ProfileCubit>(),
);
},
);
}
}

class DrawerView extends StatelessWidget {
const DrawerView({super.key});
const DrawerView({
super.key,
required this.profileCubit,
});

final ProfileCubit profileCubit;

@override
Widget build(BuildContext context) {
Expand All @@ -32,163 +43,165 @@ class DrawerView extends StatelessWidget {
child: SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 15),
child: ListView(
children: <Widget>[
Align(
alignment: Alignment.topLeft,
child: BackLeadingButton(
padding: EdgeInsets.zero,
color: Theme.of(context).colorScheme.onPrimary,
child: SingleChildScrollView(
child: Column(
children: <Widget>[
Align(
alignment: Alignment.topLeft,
child: BackLeadingButton(
padding: EdgeInsets.zero,
color: Theme.of(context).colorScheme.onPrimary,
),
),
),

const DrawerLogo(),
const AppVersionDrawer(),
const SizedBox(height: Sizes.spaceLarge),
if (profileModel.profileType == ProfileType.enterprise) ...[
DrawerCategoryItem(
title: l10n.updateYourWalletConfigNow,
padding: const EdgeInsets.all(16),
onClick: () async {
Navigator.of(context).pop();
await context
.read<EnterpriseCubit>()
.updateTheConfiguration();
},
),
const SizedBox(height: Sizes.spaceSmall),
],
const DrawerLogo(),
const AppVersionDrawer(),
const SizedBox(height: Sizes.spaceLarge),
if (profileModel.profileType ==
ProfileType.enterprise) ...[
DrawerCategoryItem(
title: l10n.updateYourWalletConfigNow,
padding: const EdgeInsets.all(16),
onClick: () async {
Navigator.of(context).pop();
await context
.read<EnterpriseCubit>()
.updateTheConfiguration();
},
),
const SizedBox(height: Sizes.spaceSmall),
],

if (profileModel
.profileSetting.settingsMenu.displayProfile) ...[
DrawerCategoryItem(
title: l10n.walletProfiles,
subTitle: l10n.walletProfilesDescription,
onClick: () {
Navigator.of(context)
.push<void>(PickProfileMenu.route());
},
),
const SizedBox(height: Sizes.spaceSmall),
],

if (profileModel
.profileSetting.settingsMenu.displayProfile) ...[
DrawerCategoryItem(
title: l10n.walletProfiles,
subTitle: l10n.walletProfilesDescription,
title: l10n.walletSecurity,
subTitle: l10n.walletSecurityDescription,
onClick: () {
Navigator.of(context)
.push<void>(PickProfileMenu.route());
.push<void>(WalletSecurityMenu.route());
},
),
const SizedBox(height: Sizes.spaceSmall),
],
DrawerCategoryItem(
title: l10n.walletSecurity,
subTitle: l10n.walletSecurityDescription,
onClick: () {
Navigator.of(context)
.push<void>(WalletSecurityMenu.route());
},
),
const SizedBox(height: Sizes.spaceSmall),
DrawerCategoryItem(
title: l10n.walletSettings,
subTitle: l10n.walletSettingsDescription,
onClick: () {
Navigator.of(context)
.push<void>(WalletSettingsMenu.route());
},
),
if (Parameters.walletHandlesCrypto)
Column(
children: [
const SizedBox(height: Sizes.spaceSmall),
DrawerCategoryItem(
title: l10n.blockchainSettings,
subTitle: l10n.blockchainSettingsDescription,
onClick: () {
Navigator.of(context)
.push<void>(BlockchainSettingsMenu.route());
},
),
],
)
else
const SizedBox.shrink(),
const SizedBox(height: Sizes.spaceSmall),

if (profileModel.profileSetting.settingsMenu
.displaySelfSovereignIdentity) ...[
DrawerCategoryItem(
title: l10n.ssi,
subTitle: l10n.ssiDescription,
title: l10n.walletSettings,
subTitle: l10n.walletSettingsDescription,
onClick: () {
Navigator.of(context).push<void>(SSIMenu.route());
Navigator.of(context)
.push<void>(WalletSettingsMenu.route());
},
),
if (Parameters.walletHandlesCrypto)
Column(
children: [
const SizedBox(height: Sizes.spaceSmall),
DrawerCategoryItem(
title: l10n.blockchainSettings,
subTitle: l10n.blockchainSettingsDescription,
onClick: () {
Navigator.of(context)
.push<void>(BlockchainSettingsMenu.route());
},
),
],
)
else
const SizedBox.shrink(),
const SizedBox(height: Sizes.spaceSmall),
],

if (profileModel
.profileSetting.settingsMenu.displayDeveloperMode) ...[
DrawerCategoryItem(
title: l10n.developerMode,
subTitle: l10n.developerModeSubtitle,
trailing: SizedBox(
height: 25,
child: BlocBuilder<ProfileCubit, ProfileState>(
builder: (context, state) {
return Switch(
onChanged: (value) async {
await context
.read<ProfileCubit>()
.setDeveloperModeStatus(enabled: value);
},
value: state.model.isDeveloperMode,
activeColor:
Theme.of(context).colorScheme.primary,
);
},
if (profileModel.profileSetting.settingsMenu
.displaySelfSovereignIdentity) ...[
DrawerCategoryItem(
title: l10n.ssi,
subTitle: l10n.ssiDescription,
onClick: () {
Navigator.of(context).push<void>(SSIMenu.route());
},
),
const SizedBox(height: Sizes.spaceSmall),
],

if (profileModel.profileSetting.settingsMenu
.displayDeveloperMode) ...[
DrawerCategoryItem(
title: l10n.developerMode,
subTitle: l10n.developerModeSubtitle,
trailing: SizedBox(
height: 25,
child: BlocBuilder<ProfileCubit, ProfileState>(
builder: (context, state) {
return Switch(
key: const Key('developerMode'),
onChanged: (value) async {
await profileCubit.setDeveloperModeStatus(
enabled: value,
);
},
value: state.model.isDeveloperMode,
activeColor:
Theme.of(context).colorScheme.primary,
);
},
),
),
),
),
const SizedBox(height: Sizes.spaceSmall),
],
const SizedBox(height: Sizes.spaceSmall),
],

// DrawerCategoryItem(
// title: l10n.checkLinkedinProfile,
// subTitle: l10n.checkLinkedinProfile,
// onClick: () {
// Navigator.of(context)
// .push<void>(CheckForLinkedInProfile.route());
// },
// ),
//const SizedBox(height: Sizes.spaceSmall),
// DrawerCategoryItem(
// title: l10n.checkLinkedinProfile,
// subTitle: l10n.checkLinkedinProfile,
// onClick: () {
// Navigator.of(context)
// .push<void>(CheckForLinkedInProfile.route());
// },
// ),
//const SizedBox(height: Sizes.spaceSmall),

if (profileModel
.profileSetting.settingsMenu.displayHelpCenter) ...[
DrawerCategoryItem(
title: l10n.helpCenter,
subTitle: l10n.helpCenterDescription,
onClick: () {
Navigator.of(context)
.push<void>(HelpCenterMenu.route());
},
),
const SizedBox(height: Sizes.spaceSmall),
],

if (profileModel
.profileSetting.settingsMenu.displayHelpCenter &&
profileModel.profileType != ProfileType.defaultOne) ...[
DrawerCategoryItem(
title: l10n.helpCenter,
subTitle: l10n.helpCenterDescription,
title: l10n.about,
subTitle: l10n.aboutDescription,
onClick: () {
Navigator.of(context)
.push<void>(HelpCenterMenu.route());
.push<void>(AboutAltmeMenu.route());
},
),
const SizedBox(height: Sizes.spaceSmall),
DrawerCategoryItem(
title: l10n.resetWallet,
subTitle: l10n.resetWalletDescription,
onClick: () {
Navigator.of(context)
.push<void>(ResetWalletMenu.route());
},
),
const SizedBox(height: Sizes.spaceNormal),
],

DrawerCategoryItem(
title: l10n.about,
subTitle: l10n.aboutDescription,
onClick: () {
Navigator.of(context)
.push<void>(AboutAltmeMenu.route());
},
),
const SizedBox(height: Sizes.spaceSmall),
DrawerCategoryItem(
title: l10n.resetWallet,
subTitle: l10n.resetWalletDescription,
onClick: () {
Navigator.of(context)
.push<void>(ResetWalletMenu.route());
},
),
const SizedBox(
height: Sizes.spaceNormal,
),
],
),
),
),
),
Expand Down
Loading

0 comments on commit f29c581

Please sign in to comment.