Skip to content

Commit

Permalink
Merge branch 'main' into feat/chain-sync-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenj authored Sep 19, 2024
2 parents d779c5c + 8c58ecf commit c8087a6
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 98 deletions.
2 changes: 1 addition & 1 deletion catalyst_voices/Earthfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
VERSION 0.8

IMPORT ../catalyst-gateway AS catalyst-gateway
IMPORT github.com/input-output-hk/catalyst-ci/earthly/flutter:v3.2.03 AS flutter-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/flutter:v3.2.04 AS flutter-ci

# Copy all the necessary files and running bootstrap
builder:
Expand Down
79 changes: 71 additions & 8 deletions catalyst_voices/lib/pages/spaces/drawer/spaces_drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import 'package:catalyst_voices_localization/catalyst_voices_localization.dart';
import 'package:catalyst_voices_models/catalyst_voices_models.dart';
import 'package:flutter/material.dart';

class SpacesDrawer extends StatelessWidget {
class SpacesDrawer extends StatefulWidget {
final Space space;
final Map<Space, ShortcutActivator> spacesShortcutsActivators;
final bool isUnlocked;
Expand All @@ -24,18 +24,55 @@ class SpacesDrawer extends StatelessWidget {
this.isUnlocked = false,
});

@override
State<SpacesDrawer> createState() => _SpacesDrawerState();
}

class _SpacesDrawerState extends State<SpacesDrawer> {
late final PageController _pageController;

@override
void initState() {
super.initState();

final initialPage = Space.values.indexOf(widget.space);
_pageController = PageController(initialPage: initialPage);
}

@override
void didUpdateWidget(covariant SpacesDrawer oldWidget) {
super.didUpdateWidget(oldWidget);

if (widget.space != oldWidget.space) {
final page = Space.values.indexOf(widget.space);
unawaited(
_pageController.animateToPage(
page,
duration: const Duration(milliseconds: 150),
curve: Curves.easeIn,
),
);
}
}

@override
void dispose() {
_pageController.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
return VoicesDrawer(
bottom: VoicesDrawerSpaceChooser(
currentSpace: space,
currentSpace: widget.space,
onChanged: (space) => space.go(context),
onOverallTap: () {
Scaffold.of(context).closeDrawer();
unawaited(const OverallSpacesRoute().push<void>(context));
},
builder: (context, value, child) {
final shortcutActivator = spacesShortcutsActivators[value];
final shortcutActivator = widget.spacesShortcutsActivators[value];

return VoicesPlainTooltip(
message: value.localizedName(context.l10n),
Expand All @@ -46,15 +83,41 @@ class SpacesDrawer extends StatelessWidget {
);
},
),
children: [
_menuBuilder(),
],
child: Column(
children: [
const SizedBox(height: 12),
const BrandHeader(),
Expanded(
child: PageView.builder(
physics: const NeverScrollableScrollPhysics(),
controller: _pageController,
itemCount: Space.values.length,
itemBuilder: (context, index) {
final space = Space.values[index];

return Padding(
key: ValueKey('Drawer${space}MenuKey'),
padding: const EdgeInsets.symmetric(horizontal: 12),
child: _menuBuilder(
context,
space: space,
),
);
},
),
),
const SizedBox(height: 12),
],
),
);
}

Widget _menuBuilder() {
Widget _menuBuilder(
BuildContext context, {
required Space space,
}) {
return switch (space) {
_ when !isUnlocked => GuestMenu(space: space),
_ when !widget.isUnlocked => GuestMenu(space: space),
Space.treasury => const IndividualPrivateCampaigns(),
Space.workspace => const MyPrivateProposals(),
Space.voting => const VotingRounds(),
Expand Down
42 changes: 5 additions & 37 deletions catalyst_voices/lib/widgets/drawer/voices_drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,22 @@ import 'package:flutter/material.dart';
/// A custom [Drawer] component that implements the Voices style
/// navigation drawer.
///
/// By default it has a header with a logo and a close button.
/// To provide menu items fill in the [children] list.
/// To add a sticky bottom menu item provide [bottom] widget.
///
/// The [VoicesDrawer] is indented to be used as the [Scaffold.drawer].
/// Menu items should primarily be constructed as [VoicesListTile]s.
class VoicesDrawer extends StatelessWidget {
/// The menu items displayed from the top to the bottom in a vertical list.
final List<Widget> children;

/// The sticky menu item at the bottom.
final Widget? bottom;

/// This widget is main "body" of [VoicesDrawer].
final Widget child;

/// The default constructor for the [VoicesDrawer].
const VoicesDrawer({
super.key,
required this.children,
this.bottom,
required this.child,
});

@override
Expand All @@ -45,16 +43,7 @@ class VoicesDrawer extends StatelessWidget {
shape: const RoundedRectangleBorder(),
child: Column(
children: [
Expanded(
child: ListView(
physics: const ClampingScrollPhysics(),
padding: const EdgeInsets.all(12),
children: [
const _Header(),
...children,
],
),
),
Expanded(child: child),
if (bottom != null)
Padding(
padding: const EdgeInsets.only(
Expand All @@ -72,27 +61,6 @@ class VoicesDrawer extends StatelessWidget {
}
}

class _Header extends StatelessWidget {
const _Header();

@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Theme.of(context).brandAssets.brand.logo(context).buildPicture(),
IconButton(
onPressed: Navigator.of(context).pop,
icon: VoicesAssets.icons.x.buildIcon(size: 22),
),
],
),
);
}
}

/// A builder that builds menu items for the [VoicesDrawerChooser].
///
/// The builder might provide a completely different widget
Expand Down
29 changes: 29 additions & 0 deletions catalyst_voices/lib/widgets/headers/brand_header.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import 'package:catalyst_voices_assets/catalyst_voices_assets.dart';
import 'package:catalyst_voices_brands/catalyst_voices_brands.dart';
import 'package:flutter/material.dart';

class BrandHeader extends StatelessWidget {
final EdgeInsetsGeometry padding;

const BrandHeader({
super.key,
this.padding = const EdgeInsets.all(8),
});

@override
Widget build(BuildContext context) {
return Padding(
padding: padding,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Theme.of(context).brandAssets.brand.logo(context).buildPicture(),
IconButton(
onPressed: Navigator.of(context).pop,
icon: VoicesAssets.icons.x.buildIcon(size: 22),
),
],
),
);
}
}
1 change: 1 addition & 0 deletions catalyst_voices/lib/widgets/widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export 'drawer/voices_drawer.dart';
export 'drawer/voices_drawer_space_chooser.dart';
export 'footers/links_page_footer.dart';
export 'footers/standard_links_page_footer.dart';
export 'headers/brand_header.dart';
export 'headers/section_header.dart';
export 'headers/segment_header.dart';
export 'indicators/process_progress_indicator.dart';
Expand Down
2 changes: 1 addition & 1 deletion catalyst_voices/uikit_example/Earthfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
VERSION 0.8

IMPORT ../ AS catalyst-voices
IMPORT github.com/input-output-hk/catalyst-ci/earthly/flutter:v3.2.03 AS flutter-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/flutter:v3.2.04 AS flutter-ci

# local-build-web - build web version of UIKit example.
# Prefixed by "local" to make sure it's not auto triggered, the target was
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,56 +27,61 @@ class VoicesNavigationExample extends StatelessWidget {
body: const Center(child: Text('Content')),
drawer: VoicesDrawer(
bottom: const _DrawerChooser(),
children: [
VoicesExpandableListTile(
title: const Text('My Dashboard'),
leading: VoicesAssets.icons.home.buildIcon(),
trailing: VoicesAssets.icons.eye.buildIcon(),
expandedChildren: [
VoicesListTile(
trailing: VoicesAssets.icons.eye.buildIcon(),
title: const Text('My Catalyst Proposals'),
onTap: () {},
),
VoicesListTile(
trailing: VoicesAssets.icons.eye.buildIcon(),
title: const Text('My Actions'),
onTap: () {},
),
VoicesListTile(
trailing: VoicesAssets.icons.eye.buildIcon(),
title: const Text('Catalyst Campaign Timeline'),
onTap: () {},
),
],
),
const Divider(),
VoicesListTile(
leading: VoicesAssets.icons.user.buildIcon(),
trailing: VoicesAssets.icons.eye.buildIcon(),
title: const Text('Catalyst Roles'),
onTap: () => Navigator.pop(context),
),
VoicesListTile(
leading: VoicesAssets.icons.annotation.buildIcon(),
trailing: VoicesAssets.icons.eye.buildIcon(),
title: const Text('Feedback'),
onTap: () => Navigator.pop(context),
),
const Divider(),
VoicesListTile(
leading: VoicesAssets.icons.arrowRight.buildIcon(),
trailing: VoicesAssets.icons.eye.buildIcon(),
title: const Text('Catalyst Gitbook documentation'),
onTap: () => Navigator.pop(context),
),
VoicesListTile(
leading: VoicesAssets.icons.arrowRight.buildIcon(),
trailing: VoicesAssets.icons.eye.buildIcon(),
title: const Text('Opportunity board'),
onTap: () => Navigator.pop(context),
),
],
child: ListView(
padding: const EdgeInsets.all(12),
physics: const ClampingScrollPhysics(),
children: [
const BrandHeader(),
VoicesExpandableListTile(
title: const Text('My Dashboard'),
leading: VoicesAssets.icons.home.buildIcon(),
trailing: VoicesAssets.icons.eye.buildIcon(),
expandedChildren: [
VoicesListTile(
trailing: VoicesAssets.icons.eye.buildIcon(),
title: const Text('My Catalyst Proposals'),
onTap: () {},
),
VoicesListTile(
trailing: VoicesAssets.icons.eye.buildIcon(),
title: const Text('My Actions'),
onTap: () {},
),
VoicesListTile(
trailing: VoicesAssets.icons.eye.buildIcon(),
title: const Text('Catalyst Campaign Timeline'),
onTap: () {},
),
],
),
const Divider(),
VoicesListTile(
leading: VoicesAssets.icons.user.buildIcon(),
trailing: VoicesAssets.icons.eye.buildIcon(),
title: const Text('Catalyst Roles'),
onTap: () => Navigator.pop(context),
),
VoicesListTile(
leading: VoicesAssets.icons.annotation.buildIcon(),
trailing: VoicesAssets.icons.eye.buildIcon(),
title: const Text('Feedback'),
onTap: () => Navigator.pop(context),
),
const Divider(),
VoicesListTile(
leading: VoicesAssets.icons.arrowRight.buildIcon(),
trailing: VoicesAssets.icons.eye.buildIcon(),
title: const Text('Catalyst Gitbook documentation'),
onTap: () => Navigator.pop(context),
),
VoicesListTile(
leading: VoicesAssets.icons.arrowRight.buildIcon(),
trailing: VoicesAssets.icons.eye.buildIcon(),
title: const Text('Opportunity board'),
onTap: () => Navigator.pop(context),
),
],
),
),
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
VERSION 0.8
IMPORT github.com/input-output-hk/catalyst-ci/earthly/flutter:v3.1.25 AS flutter-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/flutter:v3.2.04 AS flutter-ci

deps:
FROM mcr.microsoft.com/playwright:v1.45.2-jammy
Expand Down

0 comments on commit c8087a6

Please sign in to comment.