Skip to content

Commit 1036521

Browse files
committed
chore: copy property to pasteboard
1 parent 9518e16 commit 1036521

File tree

9 files changed

+56
-51
lines changed

9 files changed

+56
-51
lines changed

frontend/app_flowy/assets/translations/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@
180180
"row": {
181181
"duplicate": "Duplicate",
182182
"delete": "Delete",
183-
"textPlaceholder": "Empty"
183+
"textPlaceholder": "Empty",
184+
"copyProperty": "Copied property to clipboard"
184185
},
185186
"selectOption": {
186187
"create": "Create",

frontend/app_flowy/lib/startup/deps_resolver.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import 'package:app_flowy/workspace/presentation/home/menu/menu.dart';
1616
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/app.pb.dart';
1717
import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart';
1818
import 'package:flowy_sdk/protobuf/flowy-user-data-model/user_profile.pb.dart';
19+
import 'package:fluttertoast/fluttertoast.dart';
1920
import 'package:get_it/get_it.dart';
2021

2122
class DependencyResolver {
@@ -46,6 +47,8 @@ void _resolveUserDeps(GetIt getIt) {
4647
}
4748

4849
void _resolveHomeDeps(GetIt getIt) {
50+
getIt.registerSingleton(FToast());
51+
4952
getIt.registerSingleton(MenuSharedState());
5053

5154
getIt.registerFactoryParam<UserListener, UserProfile, void>(

frontend/app_flowy/lib/startup/tasks/app_widget.dart

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -67,40 +67,42 @@ class ApplicationWidget extends StatelessWidget {
6767
}) : super(key: key);
6868

6969
@override
70-
Widget build(BuildContext context) => ChangeNotifierProvider.value(
71-
value: settingModel,
72-
builder: (context, _) {
73-
const ratio = 1.73;
74-
const minWidth = 600.0;
75-
setWindowMinSize(const Size(minWidth, minWidth / ratio));
76-
settingModel.readLocaleWhenAppLaunch(context);
77-
AppTheme theme = context.select<AppearanceSettingModel, AppTheme>(
78-
(value) => value.theme,
79-
);
80-
Locale locale = context.select<AppearanceSettingModel, Locale>(
81-
(value) => value.locale,
82-
);
70+
Widget build(BuildContext context) {
71+
return ChangeNotifierProvider.value(
72+
value: settingModel,
73+
builder: (context, _) {
74+
const ratio = 1.73;
75+
const minWidth = 600.0;
76+
setWindowMinSize(const Size(minWidth, minWidth / ratio));
77+
settingModel.readLocaleWhenAppLaunch(context);
78+
AppTheme theme = context.select<AppearanceSettingModel, AppTheme>(
79+
(value) => value.theme,
80+
);
81+
Locale locale = context.select<AppearanceSettingModel, Locale>(
82+
(value) => value.locale,
83+
);
8384

84-
return MultiProvider(
85-
providers: [
86-
Provider.value(value: theme),
87-
Provider.value(value: locale),
88-
],
89-
builder: (context, _) {
90-
return MaterialApp(
91-
builder: overlayManagerBuilder(),
92-
debugShowCheckedModeBanner: false,
93-
theme: theme.themeData,
94-
localizationsDelegates: context.localizationDelegates,
95-
supportedLocales: context.supportedLocales,
96-
locale: locale,
97-
navigatorKey: AppGlobals.rootNavKey,
98-
home: child,
99-
);
100-
},
101-
);
102-
},
103-
);
85+
return MultiProvider(
86+
providers: [
87+
Provider.value(value: theme),
88+
Provider.value(value: locale),
89+
],
90+
builder: (context, _) {
91+
return MaterialApp(
92+
builder: overlayManagerBuilder(),
93+
debugShowCheckedModeBanner: false,
94+
theme: theme.themeData,
95+
localizationsDelegates: context.localizationDelegates,
96+
supportedLocales: context.supportedLocales,
97+
locale: locale,
98+
navigatorKey: AppGlobals.rootNavKey,
99+
home: child,
100+
);
101+
},
102+
);
103+
},
104+
);
105+
}
104106
}
105107

106108
class AppGlobals {

frontend/app_flowy/lib/workspace/application/grid/cell/cell_service/context_builder.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class _GridCellContext<T, D> extends Equatable {
105105
final FieldService _fieldService;
106106

107107
late final CellListener _cellListener;
108-
late final ValueNotifier<T?> _cellDataNotifier;
108+
late final ValueNotifier<T?>? _cellDataNotifier;
109109
bool isListening = false;
110110
VoidCallback? _onFieldChangedFn;
111111
Timer? _loadDataOperation;
@@ -163,19 +163,19 @@ class _GridCellContext<T, D> extends Equatable {
163163
}
164164

165165
onCellChangedFn() {
166-
onCellChanged(_cellDataNotifier.value);
166+
onCellChanged(_cellDataNotifier?.value);
167167

168168
if (cellDataLoader.config.reloadOnCellChanged) {
169169
_loadData();
170170
}
171171
}
172172

173-
_cellDataNotifier.addListener(onCellChangedFn);
173+
_cellDataNotifier?.addListener(onCellChangedFn);
174174
return onCellChangedFn;
175175
}
176176

177177
void removeListener(VoidCallback fn) {
178-
_cellDataNotifier.removeListener(fn);
178+
_cellDataNotifier?.removeListener(fn);
179179
}
180180

181181
T? getCellData({bool loadIfNoCache = true}) {
@@ -211,7 +211,7 @@ class _GridCellContext<T, D> extends Equatable {
211211
_loadDataOperation?.cancel();
212212
_loadDataOperation = Timer(const Duration(milliseconds: 10), () {
213213
cellDataLoader.loadData().then((data) {
214-
_cellDataNotifier.value = data;
214+
_cellDataNotifier?.value = data;
215215
cellCache.insert(GridCellCacheData(key: _cacheKey, object: data));
216216
});
217217
});

frontend/app_flowy/lib/workspace/presentation/home/home_stack.dart

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@ import 'dart:io' show Platform;
22

33
import 'package:app_flowy/startup/startup.dart';
44
import 'package:app_flowy/workspace/application/home/home_bloc.dart';
5-
import 'package:app_flowy/workspace/presentation/home/home_screen.dart';
5+
import 'package:app_flowy/workspace/presentation/home/toast.dart';
66
import 'package:flowy_infra/theme.dart';
77
import 'package:flowy_sdk/log.dart';
88
import 'package:flutter/material.dart';
99
import 'package:flutter_bloc/flutter_bloc.dart';
1010
import 'package:provider/provider.dart';
1111
import 'package:time/time.dart';
12-
import 'package:fluttertoast/fluttertoast.dart';
13-
1412
import 'package:app_flowy/plugin/plugin.dart';
1513
import 'package:app_flowy/workspace/presentation/plugins/blank/blank.dart';
1614
import 'package:app_flowy/workspace/presentation/home/home_sizes.dart';
@@ -22,8 +20,6 @@ import 'package:flowy_infra/notifier.dart';
2220

2321
typedef NavigationCallback = void Function(String id);
2422

25-
late FToast fToast;
26-
2723
class HomeStack extends StatelessWidget {
2824
static GlobalKey<ScaffoldState> scaffoldKey = GlobalKey();
2925
// final Size size;
@@ -74,8 +70,7 @@ class _FadingIndexedStackState extends State<FadingIndexedStack> {
7470
@override
7571
void initState() {
7672
super.initState();
77-
fToast = FToast();
78-
fToast.init(HomeScreen.scaffoldKey.currentState!.context);
73+
initToastWithContext(context);
7974
}
8075

8176
@override

frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/url_cell/url_cell.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import 'dart:async';
2+
import 'package:app_flowy/generated/locale_keys.g.dart';
23
import 'package:app_flowy/workspace/application/grid/cell/url_cell_bloc.dart';
4+
import 'package:app_flowy/workspace/presentation/home/toast.dart';
35
import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/cell/cell_accessory.dart';
6+
import 'package:easy_localization/easy_localization.dart';
47
import 'package:flowy_infra/image.dart';
58
import 'package:flowy_infra/theme.dart';
69
import 'package:flutter/material.dart';
@@ -176,7 +179,9 @@ class _CopyURLAccessory extends StatelessWidget with GridCellAccessory {
176179

177180
@override
178181
void onTap(BuildContext context) {
179-
final content = cellContext.getCellData()?.content ?? "";
182+
final content = cellContext.getCellData(loadIfNoCache: false)?.content ?? "";
180183
Clipboard.setData(ClipboardData(text: content));
184+
185+
showMessageToast(LocaleKeys.grid_row_copyProperty.tr());
181186
}
182187
}

frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/row/row_detail.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import 'package:app_flowy/workspace/presentation/plugins/grid/src/widgets/header
1111
import 'package:flowy_infra/image.dart';
1212
import 'package:flowy_infra/theme.dart';
1313
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
14-
import 'package:flowy_infra_ui/style_widget/hover.dart';
1514
import 'package:flowy_infra_ui/style_widget/icon_button.dart';
1615
import 'package:flowy_infra_ui/style_widget/scrolling/styled_scroll_bar.dart';
1716
import 'package:flowy_infra_ui/widget/spacing.dart';

frontend/app_flowy/lib/workspace/presentation/widgets/float_bubble/question_bubble.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import 'package:app_flowy/startup/startup.dart';
12
import 'package:app_flowy/startup/tasks/rust_sdk.dart';
2-
import 'package:app_flowy/workspace/presentation/home/home_stack.dart';
33
import 'package:app_flowy/workspace/presentation/widgets/pop_up_action.dart';
44
import 'package:easy_localization/easy_localization.dart';
55
import 'package:flowy_infra/theme.dart';
@@ -115,7 +115,7 @@ class _DebugToast extends StatelessWidget {
115115
}
116116

117117
void show() {
118-
fToast.showToast(
118+
getIt<FToast>().showToast(
119119
child: this,
120120
gravity: ToastGravity.BOTTOM,
121121
toastDuration: const Duration(seconds: 3),

frontend/app_flowy/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ dependencies:
7272
# Use with the CupertinoIcons class for iOS style icons.
7373
cupertino_icons: ^1.0.2
7474
device_info_plus: ^3.2.1
75-
fluttertoast: ^8.0.8
75+
fluttertoast: ^8.0.9
7676
table_calendar: ^3.0.5
7777
reorderables: ^0.5.0
7878
linked_scroll_controller: ^0.2.0

0 commit comments

Comments
 (0)