chore: copy property to pasteboard

This commit is contained in:
appflowy 2022-06-01 15:22:18 +08:00
parent 9518e164b5
commit 10365217ca
9 changed files with 56 additions and 51 deletions

View File

@ -180,7 +180,8 @@
"row": { "row": {
"duplicate": "Duplicate", "duplicate": "Duplicate",
"delete": "Delete", "delete": "Delete",
"textPlaceholder": "Empty" "textPlaceholder": "Empty",
"copyProperty": "Copied property to clipboard"
}, },
"selectOption": { "selectOption": {
"create": "Create", "create": "Create",

View File

@ -16,6 +16,7 @@ import 'package:app_flowy/workspace/presentation/home/menu/menu.dart';
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/app.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-folder-data-model/app.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-user-data-model/user_profile.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-user-data-model/user_profile.pb.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:get_it/get_it.dart'; import 'package:get_it/get_it.dart';
class DependencyResolver { class DependencyResolver {
@ -46,6 +47,8 @@ void _resolveUserDeps(GetIt getIt) {
} }
void _resolveHomeDeps(GetIt getIt) { void _resolveHomeDeps(GetIt getIt) {
getIt.registerSingleton(FToast());
getIt.registerSingleton(MenuSharedState()); getIt.registerSingleton(MenuSharedState());
getIt.registerFactoryParam<UserListener, UserProfile, void>( getIt.registerFactoryParam<UserListener, UserProfile, void>(

View File

@ -67,7 +67,8 @@ class ApplicationWidget extends StatelessWidget {
}) : super(key: key); }) : super(key: key);
@override @override
Widget build(BuildContext context) => ChangeNotifierProvider.value( Widget build(BuildContext context) {
return ChangeNotifierProvider.value(
value: settingModel, value: settingModel,
builder: (context, _) { builder: (context, _) {
const ratio = 1.73; const ratio = 1.73;
@ -101,6 +102,7 @@ class ApplicationWidget extends StatelessWidget {
); );
}, },
); );
}
} }
class AppGlobals { class AppGlobals {

View File

@ -105,7 +105,7 @@ class _GridCellContext<T, D> extends Equatable {
final FieldService _fieldService; final FieldService _fieldService;
late final CellListener _cellListener; late final CellListener _cellListener;
late final ValueNotifier<T?> _cellDataNotifier; late final ValueNotifier<T?>? _cellDataNotifier;
bool isListening = false; bool isListening = false;
VoidCallback? _onFieldChangedFn; VoidCallback? _onFieldChangedFn;
Timer? _loadDataOperation; Timer? _loadDataOperation;
@ -163,19 +163,19 @@ class _GridCellContext<T, D> extends Equatable {
} }
onCellChangedFn() { onCellChangedFn() {
onCellChanged(_cellDataNotifier.value); onCellChanged(_cellDataNotifier?.value);
if (cellDataLoader.config.reloadOnCellChanged) { if (cellDataLoader.config.reloadOnCellChanged) {
_loadData(); _loadData();
} }
} }
_cellDataNotifier.addListener(onCellChangedFn); _cellDataNotifier?.addListener(onCellChangedFn);
return onCellChangedFn; return onCellChangedFn;
} }
void removeListener(VoidCallback fn) { void removeListener(VoidCallback fn) {
_cellDataNotifier.removeListener(fn); _cellDataNotifier?.removeListener(fn);
} }
T? getCellData({bool loadIfNoCache = true}) { T? getCellData({bool loadIfNoCache = true}) {
@ -211,7 +211,7 @@ class _GridCellContext<T, D> extends Equatable {
_loadDataOperation?.cancel(); _loadDataOperation?.cancel();
_loadDataOperation = Timer(const Duration(milliseconds: 10), () { _loadDataOperation = Timer(const Duration(milliseconds: 10), () {
cellDataLoader.loadData().then((data) { cellDataLoader.loadData().then((data) {
_cellDataNotifier.value = data; _cellDataNotifier?.value = data;
cellCache.insert(GridCellCacheData(key: _cacheKey, object: data)); cellCache.insert(GridCellCacheData(key: _cacheKey, object: data));
}); });
}); });

View File

@ -2,15 +2,13 @@ import 'dart:io' show Platform;
import 'package:app_flowy/startup/startup.dart'; import 'package:app_flowy/startup/startup.dart';
import 'package:app_flowy/workspace/application/home/home_bloc.dart'; import 'package:app_flowy/workspace/application/home/home_bloc.dart';
import 'package:app_flowy/workspace/presentation/home/home_screen.dart'; import 'package:app_flowy/workspace/presentation/home/toast.dart';
import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra/theme.dart';
import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/log.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:time/time.dart'; import 'package:time/time.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:app_flowy/plugin/plugin.dart'; import 'package:app_flowy/plugin/plugin.dart';
import 'package:app_flowy/workspace/presentation/plugins/blank/blank.dart'; import 'package:app_flowy/workspace/presentation/plugins/blank/blank.dart';
import 'package:app_flowy/workspace/presentation/home/home_sizes.dart'; import 'package:app_flowy/workspace/presentation/home/home_sizes.dart';
@ -22,8 +20,6 @@ import 'package:flowy_infra/notifier.dart';
typedef NavigationCallback = void Function(String id); typedef NavigationCallback = void Function(String id);
late FToast fToast;
class HomeStack extends StatelessWidget { class HomeStack extends StatelessWidget {
static GlobalKey<ScaffoldState> scaffoldKey = GlobalKey(); static GlobalKey<ScaffoldState> scaffoldKey = GlobalKey();
// final Size size; // final Size size;
@ -74,8 +70,7 @@ class _FadingIndexedStackState extends State<FadingIndexedStack> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
fToast = FToast(); initToastWithContext(context);
fToast.init(HomeScreen.scaffoldKey.currentState!.context);
} }
@override @override

View File

@ -1,6 +1,9 @@
import 'dart:async'; import 'dart:async';
import 'package:app_flowy/generated/locale_keys.g.dart';
import 'package:app_flowy/workspace/application/grid/cell/url_cell_bloc.dart'; import 'package:app_flowy/workspace/application/grid/cell/url_cell_bloc.dart';
import 'package:app_flowy/workspace/presentation/home/toast.dart';
import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/cell/cell_accessory.dart'; import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/cell/cell_accessory.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/image.dart';
import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra/theme.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -176,7 +179,9 @@ class _CopyURLAccessory extends StatelessWidget with GridCellAccessory {
@override @override
void onTap(BuildContext context) { void onTap(BuildContext context) {
final content = cellContext.getCellData()?.content ?? ""; final content = cellContext.getCellData(loadIfNoCache: false)?.content ?? "";
Clipboard.setData(ClipboardData(text: content)); Clipboard.setData(ClipboardData(text: content));
showMessageToast(LocaleKeys.grid_row_copyProperty.tr());
} }
} }

View File

@ -11,7 +11,6 @@ import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/header
import 'package:flowy_infra/image.dart'; import 'package:flowy_infra/image.dart';
import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra/theme.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flowy_infra_ui/style_widget/hover.dart';
import 'package:flowy_infra_ui/style_widget/icon_button.dart'; import 'package:flowy_infra_ui/style_widget/icon_button.dart';
import 'package:flowy_infra_ui/style_widget/scrolling/styled_scroll_bar.dart'; import 'package:flowy_infra_ui/style_widget/scrolling/styled_scroll_bar.dart';
import 'package:flowy_infra_ui/widget/spacing.dart'; import 'package:flowy_infra_ui/widget/spacing.dart';

View File

@ -1,5 +1,5 @@
import 'package:app_flowy/startup/startup.dart';
import 'package:app_flowy/startup/tasks/rust_sdk.dart'; import 'package:app_flowy/startup/tasks/rust_sdk.dart';
import 'package:app_flowy/workspace/presentation/home/home_stack.dart';
import 'package:app_flowy/workspace/presentation/widgets/pop_up_action.dart'; import 'package:app_flowy/workspace/presentation/widgets/pop_up_action.dart';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra/theme.dart';
@ -115,7 +115,7 @@ class _DebugToast extends StatelessWidget {
} }
void show() { void show() {
fToast.showToast( getIt<FToast>().showToast(
child: this, child: this,
gravity: ToastGravity.BOTTOM, gravity: ToastGravity.BOTTOM,
toastDuration: const Duration(seconds: 3), toastDuration: const Duration(seconds: 3),

View File

@ -72,7 +72,7 @@ dependencies:
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2 cupertino_icons: ^1.0.2
device_info_plus: ^3.2.1 device_info_plus: ^3.2.1
fluttertoast: ^8.0.8 fluttertoast: ^8.0.9
table_calendar: ^3.0.5 table_calendar: ^3.0.5
reorderables: ^0.5.0 reorderables: ^0.5.0
linked_scroll_controller: ^0.2.0 linked_scroll_controller: ^0.2.0