Skip to content

Commit 61727ac

Browse files
committed
fix: refactor grid row count UI layout
1 parent db78457 commit 61727ac

File tree

5 files changed

+40
-33
lines changed

5 files changed

+40
-33
lines changed

frontend/app_flowy/assets/translations/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@
197197
"duplicate": "Duplicate",
198198
"delete": "Delete",
199199
"textPlaceholder": "Empty",
200-
"copyProperty": "Copied property to clipboard"
200+
"copyProperty": "Copied property to clipboard",
201+
"count": "Count"
201202
},
202203
"selectOption": {
203204
"create": "Create",

frontend/app_flowy/lib/plugins/grid/application/grid_bloc.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class GridBloc extends Bloc<GridEvent, GridState> {
4141
didReceiveRowUpdate: (newRowInfos, reason) {
4242
emit(state.copyWith(
4343
rowInfos: newRowInfos,
44+
rowCount: newRowInfos.length,
4445
reason: reason,
4546
));
4647
},
@@ -117,13 +118,15 @@ class GridState with _$GridState {
117118
required Option<GridPB> grid,
118119
required GridFieldEquatable fields,
119120
required List<RowInfo> rowInfos,
121+
required int rowCount,
120122
required GridLoadingState loadingState,
121123
required RowsChangedReason reason,
122124
}) = _GridState;
123125

124126
factory GridState.initial(String gridId) => GridState(
125127
fields: GridFieldEquatable(UnmodifiableListView([])),
126128
rowInfos: [],
129+
rowCount: 0,
127130
grid: none(),
128131
gridId: gridId,
129132
loadingState: const _Loading(),

frontend/app_flowy/lib/plugins/grid/presentation/grid_page.dart

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import 'package:app_flowy/generated/locale_keys.g.dart';
12
import 'package:app_flowy/plugins/grid/application/field/field_controller.dart';
23
import 'package:app_flowy/plugins/grid/application/row/row_data_controller.dart';
34
import 'package:app_flowy/startup/startup.dart';
45
import 'package:app_flowy/plugins/grid/application/grid_bloc.dart';
6+
import 'package:easy_localization/easy_localization.dart';
57
import 'package:flowy_infra/theme.dart';
68
import 'package:flowy_infra_ui/style_widget/scrolling/styled_list.dart';
79
import 'package:flowy_infra_ui/style_widget/scrolling/styled_scroll_bar.dart';
@@ -118,6 +120,7 @@ class _FlowyGridState extends State<FlowyGrid> {
118120
const _GridToolbarAdaptor(),
119121
_gridHeader(context, state.gridId),
120122
Flexible(child: child),
123+
const RowCountBadge(),
121124
],
122125
);
123126
},
@@ -302,48 +305,48 @@ class _GridFooter extends StatelessWidget {
302305

303306
@override
304307
Widget build(BuildContext context) {
305-
final rowCount = context.watch<GridBloc>().state.rowInfos.length;
306-
final theme = context.watch<AppTheme>();
307308
return SliverPadding(
308309
padding: const EdgeInsets.only(bottom: 200),
309310
sliver: SliverToBoxAdapter(
310311
child: SizedBox(
311312
height: GridSize.footerHeight,
312313
child: Padding(
313-
padding: GridSize.headerContentInsets,
314-
child: Row(
315-
children: [
316-
SizedBox(width: GridSize.leadingHeaderPadding),
317-
Column(
318-
crossAxisAlignment: CrossAxisAlignment.start,
319-
children: [
320-
const SizedBox(width: 120, child: GridAddRowButton()),
321-
const SizedBox(height: 30),
322-
_rowCountTextWidget(theme: theme, count: rowCount)
323-
],
324-
),
325-
],
314+
padding: GridSize.footerContentInsets,
315+
child: const Expanded(
316+
child: SizedBox(height: 40, child: GridAddRowButton()),
326317
),
327318
),
328319
),
329320
),
330321
);
331322
}
323+
}
332324

333-
Widget _rowCountTextWidget({required AppTheme theme, required int count}) {
334-
return Row(
335-
mainAxisAlignment: MainAxisAlignment.start,
336-
children: [
337-
FlowyText.regular(
338-
'Count : ',
339-
fontSize: 13,
340-
color: theme.shader3,
341-
),
342-
FlowyText.regular(
343-
count.toString(),
344-
fontSize: 13,
345-
),
346-
],
325+
class RowCountBadge extends StatelessWidget {
326+
const RowCountBadge({Key? key}) : super(key: key);
327+
328+
@override
329+
Widget build(BuildContext context) {
330+
final theme = context.watch<AppTheme>();
331+
332+
return BlocSelector<GridBloc, GridState, int>(
333+
selector: (state) => state.rowCount,
334+
builder: (context, rowCount) {
335+
return Padding(
336+
padding: GridSize.footerContentInsets,
337+
child: Row(
338+
mainAxisAlignment: MainAxisAlignment.start,
339+
children: [
340+
FlowyText.regular(
341+
'${LocaleKeys.grid_row_count.tr()} : ',
342+
fontSize: 13,
343+
color: theme.shader3,
344+
),
345+
FlowyText.regular(rowCount.toString(), fontSize: 13),
346+
],
347+
),
348+
);
349+
},
347350
);
348351
}
349352
}

frontend/app_flowy/lib/plugins/grid/presentation/layout/sizes.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class GridSize {
55

66
static double get scrollBarSize => 12 * scale;
77
static double get headerHeight => 40 * scale;
8-
static double get footerHeight => 100 * scale;
8+
static double get footerHeight => 40 * scale;
99
static double get leadingHeaderPadding => 50 * scale;
1010
static double get trailHeaderPadding => 140 * scale;
1111
static double get headerContainerPadding => 0 * scale;
@@ -35,7 +35,7 @@ class GridSize {
3535
);
3636

3737
static EdgeInsets get footerContentInsets => EdgeInsets.fromLTRB(
38-
0,
38+
GridSize.leadingHeaderPadding,
3939
GridSize.headerContainerPadding,
4040
GridSize.headerContainerPadding,
4141
GridSize.headerContainerPadding,

frontend/app_flowy/lib/plugins/grid/presentation/widgets/footer/grid_footer.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class GridAddRowButton extends StatelessWidget {
1616
text: const FlowyText.medium('New row', fontSize: 12),
1717
hoverColor: theme.shader6,
1818
onTap: () => context.read<GridBloc>().add(const GridEvent.createRow()),
19-
leftIcon: svgWidget("home/add"),
19+
leftIcon: svgWidget("home/add", color: theme.iconColor),
2020
);
2121
}
2222
}

0 commit comments

Comments
 (0)