Skip to content

Commit 3193889

Browse files
authored
feat(cat-voices): Responsive app bar (#3434)
* refactor: split into more widgets * chore: reformat code * feat: responsive appbar action buttons * feat: update button ui
1 parent e5452f8 commit 3193889

18 files changed

+234
-88
lines changed

catalyst_voices/apps/voices/lib/pages/account/delete_keychain_dialog.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ class _DeleteKeychainDialogState extends State<DeleteKeychainDialog> {
6464
children: [
6565
VoicesFilledButton(
6666
key: const Key('DeleteKeychainContinueButton'),
67-
backgroundColor: Theme.of(context).colors.iconsError,
67+
style: FilledButton.styleFrom(
68+
backgroundColor: Theme.of(context).colors.iconsError,
69+
),
6870
onTap: _removeKeychain,
6971
child: Text(context.l10n.continueText),
7072
),

catalyst_voices/apps/voices/lib/pages/discovery/sections/campaign_hero.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,10 @@ class _CampaignBrief extends StatelessWidget {
6969
onTap: () {
7070
const ProposalsRoute().go(context);
7171
},
72-
backgroundColor: ThemeBuilder.buildTheme().colorScheme.primary,
73-
foregroundColor: ThemeBuilder.buildTheme().colorScheme.onPrimary,
72+
style: FilledButton.styleFrom(
73+
backgroundColor: ThemeBuilder.buildTheme().colorScheme.primary,
74+
foregroundColor: ThemeBuilder.buildTheme().colorScheme.onPrimary,
75+
),
7476
child: Text(context.l10n.viewProposals),
7577
),
7678
const SizedBox(width: 8),

catalyst_voices/apps/voices/lib/pages/discovery/sections/most_recent_proposals.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,10 @@ class _ViewAllProposalsButton extends StatelessWidget {
214214
@override
215215
Widget build(BuildContext context) {
216216
return VoicesFilledButton(
217-
backgroundColor: ThemeBuilder.buildTheme().colorScheme.onPrimary,
218-
foregroundColor: ThemeBuilder.buildTheme().colorScheme.primary,
217+
style: FilledButton.styleFrom(
218+
backgroundColor: ThemeBuilder.buildTheme().colorScheme.onPrimary,
219+
foregroundColor: ThemeBuilder.buildTheme().colorScheme.primary,
220+
),
219221
child: Text(
220222
key: const Key('ViewAllProposalsBtn'),
221223
context.l10n.viewAllProposals,

catalyst_voices/apps/voices/lib/pages/proposal_builder/appbar/proposal_builder_back_action.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import 'package:catalyst_voices/routes/routing/routing.dart';
2-
import 'package:catalyst_voices/widgets/widgets.dart';
2+
import 'package:catalyst_voices/widgets/buttons/voices_responsive_button.dart';
33
import 'package:catalyst_voices_assets/catalyst_voices_assets.dart';
44
import 'package:catalyst_voices_localization/catalyst_voices_localization.dart';
55
import 'package:flutter/material.dart';
@@ -9,12 +9,12 @@ class ProposalBuilderBackAction extends StatelessWidget {
99

1010
@override
1111
Widget build(BuildContext context) {
12-
return VoicesOutlinedButton(
12+
return VoicesResponsiveOutlinedButton(
1313
style: OutlinedButton.styleFrom(
1414
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
1515
),
1616
onTap: () => const WorkspaceRoute().go(context),
17-
leading: VoicesAssets.icons.logout.buildIcon(),
17+
icon: VoicesAssets.icons.logout.buildIcon(),
1818
child: Text(context.l10n.proposalEditorBackToProposals),
1919
);
2020
}

catalyst_voices/apps/voices/lib/pages/proposal_builder/appbar/proposal_builder_status_action.dart

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import 'dart:async';
22

33
import 'package:catalyst_voices/common/ext/build_context_ext.dart';
44
import 'package:catalyst_voices/pages/proposal_builder/appbar/widget/proposal_builder_menu_item.dart';
5+
import 'package:catalyst_voices/widgets/buttons/voices_filled_button.dart';
6+
import 'package:catalyst_voices/widgets/buttons/voices_icon_button.dart';
57
import 'package:catalyst_voices/widgets/modals/proposals/forget_proposal_dialog.dart';
68
import 'package:catalyst_voices/widgets/modals/proposals/proposal_builder_delete_confirmation_dialog.dart';
7-
import 'package:catalyst_voices/widgets/widgets.dart';
89
import 'package:catalyst_voices_assets/catalyst_voices_assets.dart';
910
import 'package:catalyst_voices_blocs/catalyst_voices_blocs.dart';
1011
import 'package:catalyst_voices_localization/catalyst_voices_localization.dart';
@@ -42,19 +43,21 @@ class ProposalBuilderStatusAction extends StatelessWidget {
4243
}
4344
}
4445

45-
class _Button extends StatelessWidget {
46+
class _LargeButton extends StatelessWidget {
4647
final VoidCallback onTap;
4748

48-
const _Button({required this.onTap});
49+
const _LargeButton({required this.onTap});
4950

5051
@override
5152
Widget build(BuildContext context) {
5253
return VoicesFilledButton(
53-
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
54+
style: FilledButton.styleFrom(
55+
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
56+
),
5457
onTap: onTap,
58+
leading: VoicesAssets.icons.documentText.buildIcon(),
5559
child: Row(
5660
children: [
57-
VoicesAssets.icons.documentText.buildIcon(size: 16),
5861
const SizedBox(width: 8),
5962
Text(
6063
context.l10n.proposalOptions,
@@ -91,7 +94,7 @@ class _PopupMenuButtonState extends State<_PopupMenuButton> {
9194
offset: const Offset(0, 48),
9295
clipBehavior: Clip.antiAlias,
9396
constraints: const BoxConstraints(minWidth: 420),
94-
child: _Button(onTap: _showMenu),
97+
child: _ResponsiveButton(onTap: _showMenu),
9598
itemBuilder: (context) {
9699
return <PopupMenuEntry<int>>[
97100
for (final item in widget.items)
@@ -183,3 +186,34 @@ class _PopupMenuButtonState extends State<_PopupMenuButton> {
183186
_buttonKey.currentState?.showButtonMenu();
184187
}
185188
}
189+
190+
class _ResponsiveButton extends StatelessWidget {
191+
final VoidCallback onTap;
192+
193+
const _ResponsiveButton({required this.onTap});
194+
195+
@override
196+
Widget build(BuildContext context) {
197+
return ResponsiveChildBuilder(
198+
xs: (context) => _SmallButton(onTap: onTap),
199+
sm: (context) => _LargeButton(onTap: onTap),
200+
);
201+
}
202+
}
203+
204+
class _SmallButton extends StatelessWidget {
205+
final VoidCallback onTap;
206+
207+
const _SmallButton({required this.onTap});
208+
209+
@override
210+
Widget build(BuildContext context) {
211+
return VoicesIconButton.outlined(
212+
style: OutlinedButton.styleFrom(
213+
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
214+
),
215+
onTap: onTap,
216+
child: VoicesAssets.icons.documentText.buildIcon(),
217+
);
218+
}
219+
}

catalyst_voices/apps/voices/lib/pages/spaces/appbar/account_popup/session_lock_button.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import 'dart:async';
22

3-
import 'package:catalyst_voices/widgets/widgets.dart';
3+
import 'package:catalyst_voices/widgets/buttons/voices_responsive_button.dart';
44
import 'package:catalyst_voices_assets/catalyst_voices_assets.dart';
55
import 'package:catalyst_voices_blocs/catalyst_voices_blocs.dart';
66
import 'package:catalyst_voices_localization/catalyst_voices_localization.dart';
@@ -11,10 +11,10 @@ class SessionLockButton extends StatelessWidget {
1111

1212
@override
1313
Widget build(BuildContext context) {
14-
return VoicesOutlinedButton(
14+
return VoicesResponsiveOutlinedButton(
1515
key: const Key('LockButton'),
1616
onTap: () => unawaited(context.read<SessionCubit>().lock()),
17-
leading: VoicesAssets.icons.lockClosed.buildIcon(),
17+
icon: VoicesAssets.icons.lockClosed.buildIcon(),
1818
child: Text(context.l10n.lock),
1919
);
2020
}

catalyst_voices/apps/voices/lib/pages/spaces/appbar/account_popup/session_unlock_button.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'dart:async';
22

33
import 'package:catalyst_voices/pages/account/unlock_keychain_dialog.dart';
4-
import 'package:catalyst_voices/widgets/widgets.dart';
4+
import 'package:catalyst_voices/widgets/buttons/voices_responsive_button.dart';
55
import 'package:catalyst_voices_assets/catalyst_voices_assets.dart';
66
import 'package:catalyst_voices_localization/catalyst_voices_localization.dart';
77
import 'package:flutter/material.dart';
@@ -11,10 +11,10 @@ class SessionUnlockButton extends StatelessWidget {
1111

1212
@override
1313
Widget build(BuildContext context) {
14-
return VoicesOutlinedButton(
14+
return VoicesResponsiveOutlinedButton(
1515
key: const Key('UnlockButton'),
1616
onTap: () => unawaited(UnlockKeychainDialog.show(context)),
17-
trailing: VoicesAssets.icons.lockOpen.buildIcon(),
17+
icon: VoicesAssets.icons.lockOpen.buildIcon(),
1818
child: Text(context.l10n.unlock),
1919
);
2020
}

catalyst_voices/apps/voices/lib/pages/spaces/appbar/spaces_appbar/discovery_appbar.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class DiscoveryAppbar extends StatelessWidget implements PreferredSizeWidget {
2929
active: (_, __, ___) => VoicesAppBar(
3030
leading: isAppUnlock ? const DrawerToggleButton() : null,
3131
actions: [
32-
if (isProposer) const CreateProposalButton(),
32+
if (isProposer) const ResponsiveCreateProposalButton(),
3333
const SessionCtaAction(),
3434
const AccountSettingsAction(),
3535
],

catalyst_voices/apps/voices/lib/pages/spaces/appbar/voting/vote_delegation_button.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'package:catalyst_voices/widgets/buttons/voices_outlined_button.dart';
1+
import 'package:catalyst_voices/widgets/buttons/voices_responsive_button.dart';
22
import 'package:catalyst_voices_assets/catalyst_voices_assets.dart';
33
import 'package:catalyst_voices_localization/catalyst_voices_localization.dart';
44
import 'package:flutter/material.dart';
@@ -8,8 +8,8 @@ class VoteDelegationButton extends StatelessWidget {
88

99
@override
1010
Widget build(BuildContext context) {
11-
return VoicesOutlinedButton(
12-
leading: VoicesAssets.icons.vote.buildIcon(),
11+
return VoicesResponsiveOutlinedButton(
12+
icon: VoicesAssets.icons.userGroup.buildIcon(),
1313
child: Text(context.l10n.delegationButton),
1414
);
1515
}

catalyst_voices/apps/voices/lib/pages/spaces/appbar/voting/vote_list_button.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import 'package:catalyst_voices/pages/voting/widgets/voting_list/voting_list.dart';
2-
import 'package:catalyst_voices/widgets/buttons/voices_outlined_button.dart';
2+
import 'package:catalyst_voices/widgets/buttons/voices_responsive_button.dart';
33
import 'package:catalyst_voices_assets/catalyst_voices_assets.dart';
44
import 'package:catalyst_voices_blocs/catalyst_voices_blocs.dart';
55
import 'package:catalyst_voices_localization/catalyst_voices_localization.dart';
@@ -10,8 +10,8 @@ class VoteListButton extends StatelessWidget {
1010

1111
@override
1212
Widget build(BuildContext context) {
13-
return VoicesOutlinedButton(
14-
leading: VoicesAssets.icons.vote.buildIcon(),
13+
return VoicesResponsiveOutlinedButton(
14+
icon: VoicesAssets.icons.vote.buildIcon(),
1515
child: BlocSelector<VotingBallotBloc, VotingBallotState, int>(
1616
selector: (state) => state.votesCount,
1717
builder: (context, votesCount) => Text(_getText(context, votesCount)),

0 commit comments

Comments
 (0)