mirror of
				https://github.com/AppFlowy-IO/AppFlowy.git
				synced 2025-11-04 12:03:28 +00:00 
			
		
		
		
	* chore: remove use of svgWidget() * refactor: redundant code in svg * feat: add generator to generate flowy_svgs.g.dart * chore: reference new package in pubspec * chore: remove svg widget from flowy_infra * refactor: update usage in flowy_infra_ui * refactor: usage in appflowy_flutter * fix: error with script not running * fix: error with script not running * fix: use unix style file path * feat: use generation script for flowy svgs * feat: add task * fix: add required missing semicolon * fix: rebase errors * feat: update generate build script * fix: solve duplicate entries in the generated file * fix: compilation errors * fix: replace all spaces with an underscore * feat: use FlowySvgs * feat: reduce assets and simplify * refactor: do not return empty svg widget * fix: rebase errors * fix: analyzer warnings * chore: remove flowy_icons from tracking * chore: fix generate flowy icons script linux * chore: macos/linux script * chore: add rsync --------- Co-authored-by: Mathias Mogensen <mathiasrieckm@gmail.com> Co-authored-by: Mathias Mogensen <mathias@appflowy.io>
		
			
				
	
	
		
			129 lines
		
	
	
		
			3.4 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			129 lines
		
	
	
		
			3.4 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
library document_plugin;
 | 
						|
 | 
						|
import 'package:appflowy/generated/flowy_svgs.g.dart';
 | 
						|
import 'package:appflowy/generated/locale_keys.g.dart';
 | 
						|
import 'package:appflowy/plugins/document/document_page.dart';
 | 
						|
import 'package:appflowy/plugins/document/presentation/more/cubit/document_appearance_cubit.dart';
 | 
						|
import 'package:appflowy/plugins/document/presentation/more/more_button.dart';
 | 
						|
import 'package:appflowy/plugins/document/presentation/share/share_button.dart';
 | 
						|
import 'package:appflowy/plugins/util.dart';
 | 
						|
import 'package:appflowy/startup/plugin/plugin.dart';
 | 
						|
import 'package:appflowy/workspace/presentation/home/home_stack.dart';
 | 
						|
import 'package:appflowy/workspace/presentation/widgets/left_bar_item.dart';
 | 
						|
import 'package:appflowy/workspace/presentation/widgets/tab_bar_item.dart';
 | 
						|
import 'package:easy_localization/easy_localization.dart';
 | 
						|
import 'package:appflowy_backend/protobuf/flowy-folder2/view.pb.dart';
 | 
						|
import 'package:flutter/material.dart';
 | 
						|
import 'package:flutter_bloc/flutter_bloc.dart';
 | 
						|
 | 
						|
class DocumentPluginBuilder extends PluginBuilder {
 | 
						|
  @override
 | 
						|
  Plugin build(dynamic data) {
 | 
						|
    if (data is ViewPB) {
 | 
						|
      return DocumentPlugin(pluginType: pluginType, view: data);
 | 
						|
    } else {
 | 
						|
      throw FlowyPluginException.invalidData;
 | 
						|
    }
 | 
						|
  }
 | 
						|
 | 
						|
  @override
 | 
						|
  String get menuName => LocaleKeys.document_menuName.tr();
 | 
						|
 | 
						|
  @override
 | 
						|
  FlowySvgData get icon => FlowySvgs.documents_s;
 | 
						|
 | 
						|
  @override
 | 
						|
  PluginType get pluginType => PluginType.editor;
 | 
						|
 | 
						|
  @override
 | 
						|
  ViewLayoutPB? get layoutType => ViewLayoutPB.Document;
 | 
						|
}
 | 
						|
 | 
						|
class DocumentPlugin extends Plugin<int> {
 | 
						|
  late PluginType _pluginType;
 | 
						|
 | 
						|
  @override
 | 
						|
  final ViewPluginNotifier notifier;
 | 
						|
 | 
						|
  DocumentPlugin({
 | 
						|
    required PluginType pluginType,
 | 
						|
    required ViewPB view,
 | 
						|
    bool listenOnViewChanged = false,
 | 
						|
    Key? key,
 | 
						|
  }) : notifier = ViewPluginNotifier(view: view) {
 | 
						|
    _pluginType = pluginType;
 | 
						|
  }
 | 
						|
 | 
						|
  @override
 | 
						|
  PluginWidgetBuilder get widgetBuilder {
 | 
						|
    return DocumentPluginWidgetBuilder(
 | 
						|
      notifier: notifier,
 | 
						|
    );
 | 
						|
  }
 | 
						|
 | 
						|
  @override
 | 
						|
  PluginType get pluginType => _pluginType;
 | 
						|
 | 
						|
  @override
 | 
						|
  PluginId get id => notifier.view.id;
 | 
						|
}
 | 
						|
 | 
						|
class DocumentPluginWidgetBuilder extends PluginWidgetBuilder
 | 
						|
    with NavigationItem {
 | 
						|
  final ViewPluginNotifier notifier;
 | 
						|
  ViewPB get view => notifier.view;
 | 
						|
  int? deletedViewIndex;
 | 
						|
 | 
						|
  DocumentPluginWidgetBuilder({
 | 
						|
    required this.notifier,
 | 
						|
    Key? key,
 | 
						|
  });
 | 
						|
 | 
						|
  @override
 | 
						|
  EdgeInsets get contentPadding => EdgeInsets.zero;
 | 
						|
 | 
						|
  @override
 | 
						|
  Widget buildWidget({PluginContext? context, required bool shrinkWrap}) {
 | 
						|
    notifier.isDeleted.addListener(() {
 | 
						|
      notifier.isDeleted.value.fold(() => null, (deletedView) {
 | 
						|
        if (deletedView.hasIndex()) {
 | 
						|
          deletedViewIndex = deletedView.index;
 | 
						|
        }
 | 
						|
      });
 | 
						|
    });
 | 
						|
 | 
						|
    return BlocBuilder<DocumentAppearanceCubit, DocumentAppearance>(
 | 
						|
      builder: (_, state) {
 | 
						|
        return DocumentPage(
 | 
						|
          view: view,
 | 
						|
          onDeleted: () => context?.onDeleted(view, deletedViewIndex),
 | 
						|
          key: ValueKey(view.id),
 | 
						|
        );
 | 
						|
      },
 | 
						|
    );
 | 
						|
  }
 | 
						|
 | 
						|
  @override
 | 
						|
  Widget get leftBarItem => ViewLeftBarItem(view: view);
 | 
						|
 | 
						|
  @override
 | 
						|
  Widget tabBarItem(String pluginId) => ViewTabBarItem(view: notifier.view);
 | 
						|
 | 
						|
  @override
 | 
						|
  Widget? get rightBarItem {
 | 
						|
    return Row(
 | 
						|
      children: [
 | 
						|
        DocumentShareButton(
 | 
						|
          key: ValueKey(view.id),
 | 
						|
          view: view,
 | 
						|
        ),
 | 
						|
        const SizedBox(width: 10),
 | 
						|
        const DocumentMoreButton(),
 | 
						|
      ],
 | 
						|
    );
 | 
						|
  }
 | 
						|
 | 
						|
  @override
 | 
						|
  List<NavigationItem> get navigationItems => [this];
 | 
						|
}
 |