Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cat-voices): proposal editor template data flow #1335

Merged
merged 20 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions catalyst_voices/apps/voices/lib/app/view/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ class _AppState extends State<App> {
BlocProvider<CampaignBuilderCubit>(
create: (_) => Dependencies.instance.get<CampaignBuilderCubit>(),
),
BlocProvider<WorkspaceBloc>(
create: (context) => Dependencies.instance.get<WorkspaceBloc>(),
),
];
}
}
60 changes: 60 additions & 0 deletions catalyst_voices/apps/voices/lib/common/codecs/markdown_codec.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import 'dart:convert';

import 'package:catalyst_voices_models/catalyst_voices_models.dart';
import 'package:flutter_quill/quill_delta.dart';
import 'package:markdown/markdown.dart' as md;
import 'package:markdown_quill/markdown_quill.dart';

// Note.
// This codec is here because it depends on flutter_quill which is heavy
// package with lots different dependencies which we don't want to have in
// other packages.
//
// If we could have just Delta package it would be preferred to live in
// models/shared package
const markdown = MarkdownCodec();

final _mdDocument = md.Document();
final _mdToDelta = MarkdownToDelta(markdownDocument: _mdDocument);
final _deltaToMd = DeltaToMarkdown(
customContentHandler: DeltaToMarkdown.escapeSpecialCharactersRelaxed,
);

final class MarkdownCodec extends Codec<MarkdownData, Delta> {
const MarkdownCodec();

@override
Converter<Delta, MarkdownData> get decoder => const MarkdownEncoder();

@override
Converter<MarkdownData, Delta> get encoder => const MarkdownDecoder();
}

class MarkdownDecoder extends Converter<MarkdownData, Delta> {
const MarkdownDecoder();

@override
Delta convert(MarkdownData input) {
if (input.data.isEmpty) {
return Delta();
}

return _mdToDelta.convert(input.data);
}
}

class MarkdownEncoder extends Converter<Delta, MarkdownData> {
const MarkdownEncoder();

@override
MarkdownData convert(Delta input) {
if (input.isEmpty) {
return const MarkdownData('');
}

final data = _deltaToMd.convert(input);
final trimmed = data.trim();

return MarkdownData(trimmed);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:catalyst_voices_assets/catalyst_voices_assets.dart';
import 'package:catalyst_voices_localization/generated/catalyst_voices_localizations.dart';
import 'package:catalyst_voices_view_models/catalyst_voices_view_models.dart';
import 'package:catalyst_voices_models/catalyst_voices_models.dart';

extension GuidanceExt on GuidanceType {
String localizedType(VoicesLocalizations localizations) => switch (this) {
Expand Down
15 changes: 11 additions & 4 deletions catalyst_voices/apps/voices/lib/dependency/dependencies.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ final class Dependencies extends DependencyProvider {
// TODO(ryszard-schossler): add repository for campaign management
..registerLazySingleton<CampaignBuilderCubit>(
CampaignBuilderCubit.new,
);
)
..registerFactory<WorkspaceBloc>(() {
return WorkspaceBloc(
get<CampaignService>(),
);
});
}

void _registerRepositories() {
Expand Down Expand Up @@ -116,8 +121,10 @@ final class Dependencies extends DependencyProvider {
dispose: (service) => unawaited(service.dispose()),
);
registerLazySingleton<AccessControl>(AccessControl.new);
registerLazySingleton<CampaignService>(
() => CampaignService(get<CampaignRepository>()),
);
registerLazySingleton<CampaignService>(() {
return CampaignService(
get<CampaignRepository>(),
);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,15 @@ class MyPrivateProposals extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Column(
return const Column(
mainAxisSize: MainAxisSize.min,
children: [
const SpaceHeader(Space.workspace),
const SectionHeader(
SpaceHeader(Space.workspace),
SectionHeader(
leading: SizedBox(width: 12),
title: Text('My private proposals (3/5)'),
),
VoicesNavTile(
name: 'My first proposal',
status: ProposalStatus.draft,
trailing: const MoreOptionsButton(),
onTap: () => Scaffold.of(context).closeDrawer(),
),
VoicesNavTile(
name: 'My second proposal',
status: ProposalStatus.inProgress,
trailing: const MoreOptionsButton(),
onTap: () => Scaffold.of(context).closeDrawer(),
),
VoicesNavTile(
name: 'My third proposal',
status: ProposalStatus.inProgress,
trailing: const MoreOptionsButton(),
onTap: () => Scaffold.of(context).closeDrawer(),
),
// TODO(damian-molinski): watch workspace bloc
],
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';

const sections = [
CampaignSetup(
id: 0,
id: '0',
steps: [
DummyTopicStep(
id: 0,
sectionId: 0,
id: '0',
sectionId: '0',
isEditable: false,
),
DummyTopicStep(id: 1, sectionId: 0),
DummyTopicStep(id: 2, sectionId: 0),
DummyTopicStep(id: 3, sectionId: 0),
DummyTopicStep(id: '1', sectionId: '0'),
DummyTopicStep(id: '2', sectionId: '0'),
DummyTopicStep(id: '3', sectionId: '0'),
],
),
];
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading