calendar.dart 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import 'package:app_flowy/generated/locale_keys.g.dart';
  2. import 'package:app_flowy/startup/plugin/plugin.dart';
  3. import 'package:app_flowy/workspace/presentation/home/home_stack.dart';
  4. import 'package:app_flowy/workspace/presentation/widgets/left_bar_item.dart';
  5. import 'package:easy_localization/easy_localization.dart';
  6. import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
  7. import 'package:flutter/material.dart';
  8. import '../util.dart';
  9. class CalendarPluginBuilder extends PluginBuilder {
  10. @override
  11. Plugin build(dynamic data) {
  12. if (data is ViewPB) {
  13. return CalendarPlugin(pluginType: pluginType, view: data);
  14. } else {
  15. throw FlowyPluginException.invalidData;
  16. }
  17. }
  18. @override
  19. String get menuName => LocaleKeys.calendar_menuName.tr();
  20. @override
  21. String get menuIcon => "editor/date";
  22. @override
  23. PluginType get pluginType => PluginType.calendar;
  24. @override
  25. ViewDataFormatPB get dataFormatType => ViewDataFormatPB.DatabaseFormat;
  26. @override
  27. ViewLayoutTypePB? get layoutType => ViewLayoutTypePB.Calendar;
  28. }
  29. class CalendarPluginConfig implements PluginConfig {
  30. @override
  31. bool get creatable => false;
  32. }
  33. class CalendarPlugin extends Plugin {
  34. @override
  35. final ViewPluginNotifier notifier;
  36. final PluginType _pluginType;
  37. CalendarPlugin({
  38. required ViewPB view,
  39. required PluginType pluginType,
  40. }) : _pluginType = pluginType,
  41. notifier = ViewPluginNotifier(view: view);
  42. @override
  43. PluginDisplay get display => CalendarPluginDisplay(notifier: notifier);
  44. @override
  45. PluginId get id => notifier.view.id;
  46. @override
  47. PluginType get ty => _pluginType;
  48. }
  49. class CalendarPluginDisplay extends PluginDisplay {
  50. final ViewPluginNotifier notifier;
  51. CalendarPluginDisplay({required this.notifier, Key? key});
  52. ViewPB get view => notifier.view;
  53. @override
  54. Widget get leftBarItem => ViewLeftBarItem(view: view);
  55. @override
  56. Widget buildWidget(PluginContext context) {
  57. notifier.isDeleted.addListener(() {
  58. notifier.isDeleted.value.fold(() => null, (deletedView) {
  59. if (deletedView.hasIndex()) {
  60. context.onDeleted(view, deletedView.index);
  61. }
  62. });
  63. });
  64. return BlankPage(key: ValueKey(view.id));
  65. // return BoardPage(key: ValueKey(view.id), view: view);
  66. }
  67. @override
  68. List<NavigationItem> get navigationItems => [this];
  69. }
  70. // mark for removal
  71. class BlankPage extends StatefulWidget {
  72. const BlankPage({Key? key}) : super(key: key);
  73. @override
  74. State<BlankPage> createState() => _BlankPageState();
  75. }
  76. class _BlankPageState extends State<BlankPage> {
  77. @override
  78. Widget build(BuildContext context) {
  79. return SizedBox.expand(
  80. child: Container(
  81. color: Theme.of(context).colorScheme.surface,
  82. child: Padding(
  83. padding: const EdgeInsets.all(10),
  84. child: Container(),
  85. ),
  86. ),
  87. );
  88. }
  89. }