mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
27dd719aa8
* chore: create orphan view handler * feat: save icon url and cover url in view * feat: implement emoji picker UI * chore: config ui * chore: config ui again * chore: replace RowPB with RowMetaPB to exposing more row information * fix: compile error * feat: show emoji in row * chore: update * test: insert emoji test * test: add update emoji test * test: add remove emoji test * test: add create field tests * test: add create row and delete row integration tests * test: add create row from row menu * test: document in row detail page * test: delete, duplicate row in row detail page * test: check the row count displayed in grid page * test: rename existing field in grid page * test: update field type of exisiting field in grid page * test: delete field test * test: add duplicate field test * test: add hide field test * test: add edit text cell test * test: add insert text to text cell test * test: add edit number cell test * test: add edit multiple number cells * test: add edit checkbox cell test * feat: integrate editor into database row * test: add edit create time and last edit time cell test * test: add edit date cell by selecting a date test * chore: remove unused code * chore: update checklist bg color * test: add update database layout test --------- Co-authored-by: Lucas.Xu <lucas.xu@appflowy.io>
142 lines
3.8 KiB
Dart
142 lines
3.8 KiB
Dart
library document_plugin;
|
|
|
|
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: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
|
|
String get menuIcon => "editor/documents";
|
|
|
|
@override
|
|
PluginType get pluginType => PluginType.editor;
|
|
|
|
@override
|
|
ViewLayoutPB? get layoutType => ViewLayoutPB.Document;
|
|
}
|
|
|
|
class DocumentPlugin extends Plugin<int> {
|
|
late PluginType _pluginType;
|
|
final DocumentAppearanceCubit _documentAppearanceCubit =
|
|
DocumentAppearanceCubit();
|
|
|
|
@override
|
|
final ViewPluginNotifier notifier;
|
|
|
|
DocumentPlugin({
|
|
required PluginType pluginType,
|
|
required ViewPB view,
|
|
bool listenOnViewChanged = false,
|
|
Key? key,
|
|
}) : notifier = ViewPluginNotifier(
|
|
view: view,
|
|
listenOnViewChanged: listenOnViewChanged,
|
|
) {
|
|
_pluginType = pluginType;
|
|
_documentAppearanceCubit.fetch();
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_documentAppearanceCubit.close();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
PluginWidgetBuilder get widgetBuilder {
|
|
return DocumentPluginWidgetBuilder(
|
|
notifier: notifier,
|
|
documentAppearanceCubit: _documentAppearanceCubit,
|
|
);
|
|
}
|
|
|
|
@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;
|
|
DocumentAppearanceCubit documentAppearanceCubit;
|
|
|
|
DocumentPluginWidgetBuilder({
|
|
required this.notifier,
|
|
required this.documentAppearanceCubit,
|
|
Key? key,
|
|
});
|
|
|
|
@override
|
|
EdgeInsets get contentPadding => EdgeInsets.zero;
|
|
|
|
@override
|
|
Widget buildWidget({PluginContext? context}) {
|
|
notifier.isDeleted.addListener(() {
|
|
notifier.isDeleted.value.fold(() => null, (deletedView) {
|
|
if (deletedView.hasIndex()) {
|
|
deletedViewIndex = deletedView.index;
|
|
}
|
|
});
|
|
});
|
|
|
|
return BlocProvider.value(
|
|
value: documentAppearanceCubit,
|
|
child: 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? get rightBarItem {
|
|
return Row(
|
|
children: [
|
|
DocumentShareButton(view: view),
|
|
const SizedBox(width: 10),
|
|
BlocProvider.value(
|
|
value: documentAppearanceCubit,
|
|
child: const DocumentMoreButton(),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
@override
|
|
List<NavigationItem> get navigationItems => [this];
|
|
}
|