mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-07-23 17:11:23 +00:00

* chore: refactor the publish code * feat: integrate publish into database page * feat: add publish database structure * feat: add database row collab * feat: publish the database row collabs * chore: update collab * chore: improve question bubble * feat: publish the database relations * fix: rust ci * feat: select grid view to publish * feat: unable to deselect the primary database * feat: optimize the read recent views speed (#5726) * feat: optimize the read recent views speed * fix: order of recent views should be from the latest to the oldest * chore: update translations * fix: replace the unable to be selected icon * feat: remove left padding of inline database * fix: code review * chore: remove publish api err log * chore: read the database collab and document collab from disk instead of memory * chore: code cleanup * chore: revert beta.appflowy.com * chore: code cleanup * test: add database encode test * test: add publish database test * chore: refresh sidebar layout * chore: update comments
83 lines
2.6 KiB
Dart
83 lines
2.6 KiB
Dart
import 'package:appflowy/generated/locale_keys.g.dart';
|
|
import 'package:appflowy/plugins/database/application/tab_bar_bloc.dart';
|
|
import 'package:appflowy/plugins/shared/share/_shared.dart';
|
|
import 'package:appflowy/plugins/shared/share/share_bloc.dart';
|
|
import 'package:appflowy/plugins/shared/share/share_menu.dart';
|
|
import 'package:appflowy/startup/startup.dart';
|
|
import 'package:appflowy/workspace/application/view/view_ext.dart';
|
|
import 'package:appflowy/workspace/presentation/widgets/dialogs.dart';
|
|
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
|
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
|
|
class ShareButton extends StatelessWidget {
|
|
const ShareButton({
|
|
super.key,
|
|
required this.view,
|
|
});
|
|
|
|
final ViewPB view;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MultiBlocProvider(
|
|
providers: [
|
|
BlocProvider(
|
|
create: (context) =>
|
|
getIt<ShareBloc>(param1: view)..add(const ShareEvent.initial()),
|
|
),
|
|
if (view.layout.isDatabaseView)
|
|
BlocProvider(
|
|
create: (context) => DatabaseTabBarBloc(view: view)
|
|
..add(const DatabaseTabBarEvent.initial()),
|
|
),
|
|
],
|
|
child: BlocListener<ShareBloc, ShareState>(
|
|
listener: (context, state) {
|
|
if (!state.isLoading && state.exportResult != null) {
|
|
state.exportResult!.fold(
|
|
(data) => _handleExportSuccess(context, data),
|
|
(error) => _handleExportError(context, error),
|
|
);
|
|
}
|
|
},
|
|
child: BlocBuilder<ShareBloc, ShareState>(
|
|
builder: (context, state) {
|
|
final tabs = [
|
|
if (state.enablePublish) ShareMenuTab.publish,
|
|
ShareMenuTab.exportAs,
|
|
];
|
|
|
|
return ShareMenuButton(tabs: tabs);
|
|
},
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
void _handleExportSuccess(BuildContext context, ShareType shareType) {
|
|
switch (shareType) {
|
|
case ShareType.markdown:
|
|
case ShareType.html:
|
|
case ShareType.csv:
|
|
showToastNotification(
|
|
context,
|
|
message: LocaleKeys.settings_files_exportFileSuccess.tr(),
|
|
);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
void _handleExportError(BuildContext context, FlowyError error) {
|
|
showToastNotification(
|
|
context,
|
|
message:
|
|
'${LocaleKeys.settings_files_exportFileFail.tr()}: ${error.code}',
|
|
);
|
|
}
|
|
}
|