Skip to content

Commit

Permalink
Merge branch 'main' into feat/account_restored_957
Browse files Browse the repository at this point in the history
  • Loading branch information
damian-molinski authored Oct 14, 2024
2 parents 5ec7dec + f7de3d2 commit ad40d5c
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 83 deletions.
102 changes: 19 additions & 83 deletions catalyst_voices/lib/pages/account/account_page.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import 'dart:async';

import 'package:catalyst_voices/common/ext/account_role_ext.dart';
import 'package:catalyst_voices/pages/account/account_page_header.dart';
import 'package:catalyst_voices/pages/account/delete_keychain_dialog.dart';
import 'package:catalyst_voices/pages/account/keychain_deleted_dialog.dart';
import 'package:catalyst_voices/widgets/buttons/voices_icon_button.dart';
Expand All @@ -12,7 +15,6 @@ import 'package:catalyst_voices_localization/catalyst_voices_localization.dart';
import 'package:catalyst_voices_models/catalyst_voices_models.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';

final class AccountPage extends StatelessWidget {
const AccountPage({super.key});
Expand All @@ -23,8 +25,9 @@ final class AccountPage extends StatelessWidget {
body: SingleChildScrollView(
padding: const EdgeInsets.all(32),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const _Header(),
const AccountPageHeader(),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column(
Expand All @@ -41,22 +44,7 @@ final class AccountPage extends StatelessWidget {
AccountRole.drep,
],
defaultRole: AccountRole.voter,
onRemoveKeychain: () async {
final confirmed =
await DeleteKeychainDialog.show(context);
if (confirmed && context.mounted) {
context
.read<SessionBloc>()
.add(const RemoveKeychainSessionEvent());

await VoicesDialog.show<void>(
context: context,
builder: (context) {
return const KeychainDeletedDialog();
},
);
}
},
onRemoveKeychain: () => unawaited(_removeKeychain(context)),
),
],
),
Expand All @@ -66,73 +54,21 @@ final class AccountPage extends StatelessWidget {
),
);
}
}

class _Header extends StatelessWidget {
const _Header();
// Note. probably should redirect somewhere.
Future<void> _removeKeychain(BuildContext context) async {
final confirmed = await DeleteKeychainDialog.show(context);

@override
Widget build(BuildContext context) {
return DecoratedBox(
decoration: BoxDecoration(
image: DecorationImage(
image: CatalystImage.asset(
VoicesAssets.images.accountBg.path,
).image,
fit: BoxFit.cover,
),
),
child: SizedBox(
width: double.infinity,
height: 350,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(
top: 24,
left: 8,
),
child: VoicesIconButton.filled(
onTap: () {
GoRouter.of(context).pop();
},
style: ButtonStyle(
backgroundColor: WidgetStateProperty.all(
Theme.of(context).colors.elevationsOnSurfaceNeutralLv1White,
),
foregroundColor: WidgetStateProperty.all(
Theme.of(context).colors.iconsForeground,
),
),
child: VoicesAssets.icons.arrowNarrowLeft.buildIcon(),
),
),
const Spacer(),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 32),
child: Text(
context.l10n.myAccountProfileKeychain,
style: Theme.of(context).textTheme.displayMedium?.copyWith(
color: Colors.white,
),
),
),
const SizedBox(height: 4),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 32),
child: Text(
context.l10n.yourCatalystKeychainAndRoleRegistration,
style: Theme.of(context).textTheme.titleMedium?.copyWith(
color: Colors.white,
),
),
),
const SizedBox(height: 48),
],
),
),
);
if (confirmed && context.mounted) {
context.read<SessionBloc>().add(const RemoveKeychainSessionEvent());

await VoicesDialog.show<void>(
context: context,
builder: (context) {
return const KeychainDeletedDialog();
},
);
}
}
}

Expand Down
99 changes: 99 additions & 0 deletions catalyst_voices/lib/pages/account/account_page_header.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import 'package:catalyst_voices/routes/routes.dart';
import 'package:catalyst_voices/widgets/widgets.dart';
import 'package:catalyst_voices_assets/catalyst_voices_assets.dart';
import 'package:catalyst_voices_brands/catalyst_voices_brands.dart';
import 'package:catalyst_voices_localization/catalyst_voices_localization.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';

class AccountPageHeader extends StatelessWidget {
const AccountPageHeader({super.key});

@override
Widget build(BuildContext context) {
return Container(
constraints: const BoxConstraints.tightFor(height: 350),
decoration: BoxDecoration(
image: DecorationImage(
image: CatalystImage.asset(VoicesAssets.images.accountBg.path).image,
fit: BoxFit.cover,
),
),
child: const Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: 24),
Padding(
padding: EdgeInsets.only(left: 8),
child: _BackArrowButton(),
),
Spacer(),
Padding(
padding: EdgeInsets.symmetric(horizontal: 32),
child: _TitleText(),
),
SizedBox(height: 4),
Padding(
padding: EdgeInsets.symmetric(horizontal: 32),
child: _SubtitleText(),
),
SizedBox(height: 48),
],
),
);
}
}

class _TitleText extends StatelessWidget {
const _TitleText();

@override
Widget build(BuildContext context) {
final theme = Theme.of(context);

return Text(
context.l10n.myAccountProfileKeychain,
style: theme.textTheme.displayMedium?.copyWith(color: Colors.white),
);
}
}

class _SubtitleText extends StatelessWidget {
const _SubtitleText();

@override
Widget build(BuildContext context) {
final theme = Theme.of(context);

return Text(
context.l10n.yourCatalystKeychainAndRoleRegistration,
style: theme.textTheme.titleMedium?.copyWith(color: Colors.white),
);
}
}

class _BackArrowButton extends StatelessWidget {
const _BackArrowButton();

@override
Widget build(BuildContext context) {
final colors = Theme.of(context).colors;

final backgroundColor = colors.elevationsOnSurfaceNeutralLv1White;
final foregroundColor = colors.iconsForeground;
return VoicesIconButton.filled(
onTap: () {
if (Navigator.of(context).canPop()) {
Navigator.of(context).pop();
} else {
GoRouter.of(context).go(Routes.initialLocation);
}
},
style: ButtonStyle(
backgroundColor: WidgetStateProperty.all(backgroundColor),
foregroundColor: WidgetStateProperty.all(foregroundColor),
),
child: VoicesAssets.icons.arrowNarrowLeft.buildIcon(),
);
}
}

0 comments on commit ad40d5c

Please sign in to comment.