Skip to content

Commit

Permalink
feat: voices treasury space (#782)
Browse files Browse the repository at this point in the history
* feat: wip

* feat: introduce TreasuryCampaignBuilder and related widgets

* feat: initially expand setup segment

* feat: localization

* refactor: Make ValueListenableBuilder unused child param underscored

* feat: CampaignControllerScope

* feat: Treasury drawer

* refactor: rename builder function
  • Loading branch information
damian-molinski authored Sep 10, 2024
1 parent aaf2a5a commit 46d6b0c
Show file tree
Hide file tree
Showing 28 changed files with 930 additions and 510 deletions.
2 changes: 2 additions & 0 deletions catalyst_voices/lib/app/view/app_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ final class AppContent extends StatelessWidget {
supportedLocales: VoicesLocalizations.supportedLocales,
localeListResolutionCallback: basicLocaleListResolution,
routerConfig: routerConfig,
// Light mode is "go to" for now.
themeMode: ThemeMode.light,
theme: ThemeBuilder.buildTheme(BrandKey.catalyst),
darkTheme: ThemeBuilder.buildDarkTheme(BrandKey.catalyst),
builder: (context, child) {
Expand Down
32 changes: 32 additions & 0 deletions catalyst_voices/lib/pages/spaces/individual_private_campaigns.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import 'package:catalyst_voices/widgets/widgets.dart';
import 'package:catalyst_voices_models/catalyst_voices_models.dart';
import 'package:flutter/material.dart';

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

@override
Widget build(BuildContext context) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
SectionHeader(
leading: SizedBox(width: 12),
title: Text('Individual private campaigns'),
),
VoicesDrawerNavItem(
name: 'Fund name 1',
status: ProposalStatus.ready,
),
VoicesDrawerNavItem(
name: 'Campaign 1',
status: ProposalStatus.draft,
),
VoicesDrawerNavItem(
name: 'What happens with a campaign title that is longer that',
status: ProposalStatus.draft,
),
],
);
}
}
102 changes: 102 additions & 0 deletions catalyst_voices/lib/pages/spaces/spaces_drawer.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import 'package:catalyst_voices/pages/spaces/individual_private_campaigns.dart';
import 'package:catalyst_voices/routes/routes.dart';
import 'package:catalyst_voices/widgets/widgets.dart';
import 'package:catalyst_voices_brands/catalyst_voices_brands.dart';
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 {
final Space space;

const SpacesDrawer({
required this.space,
});

@override
Widget build(BuildContext context) {
return VoicesDrawer(
children: [
_SpaceHeader(space),
if (space == Space.treasury) IndividualPrivateCampaigns(),
],
bottom: VoicesDrawerSpaceChooser(
currentSpace: space,
onChanged: (space) {
Scaffold.of(context).closeDrawer();
_goTo(context, space: space);
},
),
);
}

void _goTo(
BuildContext context, {
required Space space,
}) {
switch (space) {
case Space.treasury:
TreasuryRoute().go(context);
case Space.discovery:
DiscoveryRoute().go(context);
case Space.workspace:
WorkspaceRoute().go(context);
case Space.voting:
VotingRoute().go(context);
case Space.fundedProjects:
FundedProjectsRoute().go(context);
}
}
}

// Note. This should be dropdown bo at the moment we're not
// implementing it.
class _SpaceHeader extends StatelessWidget {
final Space data;

const _SpaceHeader(this.data);

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

return Container(
padding:
EdgeInsets.symmetric(vertical: 14).add(EdgeInsets.only(left: 16)),
child: Row(
children: [
SpaceAvatar(
data,
key: ObjectKey(data),
),
SizedBox(width: 12),
Expanded(
child: Text(
data.localizedName(context.l10n),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: theme.textTheme.titleMedium
?.copyWith(color: theme.colors.textPrimary),
),
),
ChevronExpandButton(
isExpanded: false,
onTap: () {},
),
],
),
);
}
}

extension _SpaceExt on Space {
String localizedName(VoicesLocalizations localizations) {
return switch (this) {
Space.treasury => localizations.drawerSpaceTreasury,
Space.discovery => localizations.drawerSpaceDiscovery,
Space.workspace => localizations.drawerSpaceWorkspace,
Space.voting => localizations.drawerSpaceVoting,
Space.fundedProjects => localizations.drawerSpaceFundedProjects,
};
}
}
44 changes: 2 additions & 42 deletions catalyst_voices/lib/pages/spaces/spaces_shell_page.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:catalyst_voices/routes/routes.dart';
import 'package:catalyst_voices/pages/spaces/spaces_drawer.dart';
import 'package:catalyst_voices/widgets/widgets.dart';
import 'package:catalyst_voices_models/catalyst_voices_models.dart';
import 'package:flutter/material.dart';
Expand All @@ -17,48 +17,8 @@ class SpacesShellPage extends StatelessWidget {
Widget build(BuildContext context) {
return Scaffold(
appBar: VoicesAppBar(),
drawer: _SpacesDrawer(space: space),
drawer: SpacesDrawer(space: space),
body: child,
);
}
}

class _SpacesDrawer extends StatelessWidget {
final Space space;

const _SpacesDrawer({
required this.space,
});

@override
Widget build(BuildContext context) {
return VoicesDrawer(
children: [],
bottom: VoicesDrawerSpaceChooser(
currentSpace: space,
onChanged: (space) {
Scaffold.of(context).closeDrawer();
_goTo(context, space: space);
},
),
);
}

void _goTo(
BuildContext context, {
required Space space,
}) {
switch (space) {
case Space.treasury:
TreasuryRoute().go(context);
case Space.discovery:
DiscoveryRoute().go(context);
case Space.workspace:
WorkspaceRoute().go(context);
case Space.voting:
VotingRoute().go(context);
case Space.fundedProjects:
FundedProjectsRoute().go(context);
}
}
}
72 changes: 72 additions & 0 deletions catalyst_voices/lib/pages/treasury/campaign_builder_panel.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import 'package:catalyst_voices/pages/treasury/campaign_segment_controller.dart';
import 'package:catalyst_voices/pages/treasury/treasury_campaign_builder_ext.dart';
import 'package:catalyst_voices/widgets/widgets.dart';
import 'package:catalyst_voices_localization/catalyst_voices_localization.dart';
import 'package:catalyst_voices_models/catalyst_voices_models.dart';
import 'package:flutter/material.dart';

class CampaignBuilderPanel extends StatelessWidget {
final TreasuryCampaignBuilder builder;

const CampaignBuilderPanel({
required this.builder,
});

@override
Widget build(BuildContext context) {
return SpaceSidePanel(
isLeft: true,
name: context.l10n.treasuryCampaignBuilder,
onCollapseTap: () {},
tabs: [
if (builder.segments.isNotEmpty)
SpaceSidePanelTab(
name: context.l10n.treasuryCampaignBuilderSegments,
body: Column(
children: builder.segments.map(
(segment) {
return _CampaignSegmentBody(
key: ValueKey('CampaignSegment${segment.id}Key'),
segment: segment,
controller: CampaignControllerScope.of(
context,
id: segment.id,
),
);
},
).toList(),
),
),
],
);
}
}

class _CampaignSegmentBody extends StatelessWidget {
final TreasuryCampaignSegment segment;
final VoicesNodeMenuController? controller;

const _CampaignSegmentBody({
super.key,
required this.segment,
this.controller,
});

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

return VoicesNodeMenu(
name: segment.localizedName(l10n),
controller: controller,
items: segment.steps.map(
(step) {
return VoicesNodeMenuItem(
id: step.id,
label: step.localizedName(l10n),
);
},
).toList(),
);
}
}
Loading

0 comments on commit 46d6b0c

Please sign in to comment.