-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
1 parent
aaf2a5a
commit 46d6b0c
Showing
28 changed files
with
930 additions
and
510 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
catalyst_voices/lib/pages/spaces/individual_private_campaigns.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
), | ||
], | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
catalyst_voices/lib/pages/treasury/campaign_builder_panel.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(), | ||
); | ||
} | ||
} |
File renamed without changes.
Oops, something went wrong.