Skip to content

Commit 96af012

Browse files
authored
fix: grid width update (#4101)
* chore: enable checklist on mobile * fix: width of grid not updating properly * chore: fix sign-in button color and font
1 parent 7ad05fe commit 96af012

File tree

9 files changed

+120
-133
lines changed

9 files changed

+120
-133
lines changed

frontend/appflowy_flutter/lib/mobile/presentation/database/card/card_detail/widgets/_field_options.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const _supportedFieldTypes = [
1616
FieldType.MultiSelect,
1717
FieldType.DateTime,
1818
FieldType.Checkbox,
19-
// FieldType.Checklist,
19+
FieldType.Checklist,
2020
];
2121

2222
class FieldOptions extends StatelessWidget {

frontend/appflowy_flutter/lib/plugins/database_view/grid/application/grid_bloc.dart

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class GridBloc extends Bloc<GridEvent, GridState> {
5757
didReceiveFieldUpdate: (fields) {
5858
emit(
5959
state.copyWith(
60-
fields: FieldList(fields),
60+
fields: fields,
6161
),
6262
);
6363
},
@@ -176,7 +176,7 @@ class GridState with _$GridState {
176176
const factory GridState({
177177
required String viewId,
178178
required Option<DatabasePB> grid,
179-
required FieldList fields,
179+
required List<FieldInfo> fields,
180180
required List<RowInfo> rowInfos,
181181
required int rowCount,
182182
required RowMetaPB? createdRow,
@@ -188,7 +188,7 @@ class GridState with _$GridState {
188188
}) = _GridState;
189189

190190
factory GridState.initial(String viewId) => GridState(
191-
fields: FieldList([]),
191+
fields: [],
192192
rowInfos: [],
193193
rowCount: 0,
194194
createdRow: null,
@@ -201,8 +201,3 @@ class GridState with _$GridState {
201201
sorts: [],
202202
);
203203
}
204-
205-
@freezed
206-
class FieldList with _$FieldList {
207-
factory FieldList(List<FieldInfo> fields) = _FieldList;
208-
}

frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/grid_page.dart

Lines changed: 38 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -169,24 +169,16 @@ class _GridPageContentState extends State<GridPageContent> {
169169

170170
@override
171171
Widget build(BuildContext context) {
172-
return BlocBuilder<GridBloc, GridState>(
173-
buildWhen: (previous, current) => previous.fields != current.fields,
174-
builder: (context, state) {
175-
final contentWidth = GridLayout.headerWidth(state.fields.fields);
176-
177-
return Column(
178-
crossAxisAlignment: CrossAxisAlignment.start,
179-
children: [
180-
_GridHeader(headerScrollController: headerScrollController),
181-
_GridRows(
182-
viewId: state.viewId,
183-
contentWidth: contentWidth,
184-
scrollController: _scrollController,
185-
),
186-
const _GridFooter(),
187-
],
188-
);
189-
},
172+
return Column(
173+
crossAxisAlignment: CrossAxisAlignment.start,
174+
children: [
175+
_GridHeader(headerScrollController: headerScrollController),
176+
_GridRows(
177+
viewId: widget.view.id,
178+
scrollController: _scrollController,
179+
),
180+
const _GridFooter(),
181+
],
190182
);
191183
}
192184
}
@@ -210,41 +202,44 @@ class _GridHeader extends StatelessWidget {
210202

211203
class _GridRows extends StatelessWidget {
212204
final String viewId;
213-
final double contentWidth;
214205
final GridScrollController scrollController;
215206

216207
const _GridRows({
217208
required this.viewId,
218-
required this.contentWidth,
219209
required this.scrollController,
220210
});
221211

222212
@override
223213
Widget build(BuildContext context) {
224-
return Flexible(
225-
child: _WrapScrollView(
226-
scrollController: scrollController,
227-
contentWidth: contentWidth,
228-
child: BlocBuilder<GridBloc, GridState>(
229-
buildWhen: (previous, current) => current.reason.maybeWhen(
230-
reorderRows: () => true,
231-
reorderSingleRow: (reorderRow, rowInfo) => true,
232-
delete: (item) => true,
233-
insert: (item) => true,
234-
orElse: () => false,
214+
return BlocBuilder<GridBloc, GridState>(
215+
buildWhen: (previous, current) => previous.fields != current.fields,
216+
builder: (context, state) {
217+
return Flexible(
218+
child: _WrapScrollView(
219+
scrollController: scrollController,
220+
contentWidth: GridLayout.headerWidth(state.fields),
221+
child: BlocBuilder<GridBloc, GridState>(
222+
buildWhen: (previous, current) => current.reason.maybeWhen(
223+
reorderRows: () => true,
224+
reorderSingleRow: (reorderRow, rowInfo) => true,
225+
delete: (item) => true,
226+
insert: (item) => true,
227+
orElse: () => false,
228+
),
229+
builder: (context, state) {
230+
final rowInfos = state.rowInfos;
231+
final behavior = ScrollConfiguration.of(context).copyWith(
232+
scrollbars: false,
233+
);
234+
return ScrollConfiguration(
235+
behavior: behavior,
236+
child: _renderList(context, state, rowInfos),
237+
);
238+
},
239+
),
235240
),
236-
builder: (context, state) {
237-
final rowInfos = state.rowInfos;
238-
final behavior = ScrollConfiguration.of(context).copyWith(
239-
scrollbars: false,
240-
);
241-
return ScrollConfiguration(
242-
behavior: behavior,
243-
child: _renderList(context, state, rowInfos),
244-
);
245-
},
246-
),
247-
),
241+
);
242+
},
248243
);
249244
}
250245

frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/layout/layout.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
import 'package:appflowy/plugins/database_view/application/field/field_info.dart';
2+
import 'package:appflowy_backend/protobuf/flowy-database2/field_settings_entities.pbenum.dart';
23
import 'sizes.dart';
34

45
class GridLayout {
56
static double headerWidth(List<FieldInfo> fields) {
67
if (fields.isEmpty) return 0;
78

89
final fieldsWidth = fields
10+
.where(
11+
(element) =>
12+
element.visibility != null &&
13+
element.visibility != FieldVisibility.AlwaysHidden,
14+
)
915
.map((fieldInfo) => fieldInfo.fieldSettings!.width.toDouble())
1016
.reduce((value, element) => value + element);
1117

frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/mobile_grid_page.dart

Lines changed: 55 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class _GridPageContentState extends State<GridPageContent> {
148148

149149
@override
150150
Widget build(BuildContext context) {
151-
return BlocConsumer<GridBloc, GridState>(
151+
return BlocListener<GridBloc, GridState>(
152152
listenWhen: (previous, current) =>
153153
previous.createdRow != current.createdRow,
154154
listener: (context, state) {
@@ -165,37 +165,30 @@ class _GridPageContentState extends State<GridPageContent> {
165165
);
166166
bloc.add(const GridEvent.resetCreatedRow());
167167
},
168-
buildWhen: (previous, current) => previous.fields != current.fields,
169-
builder: (context, state) {
170-
final contentWidth = GridLayout.headerWidth(state.fields.fields);
171-
172-
return Stack(
173-
children: [
174-
Column(
175-
crossAxisAlignment: CrossAxisAlignment.start,
176-
children: [
177-
Padding(
178-
padding:
179-
EdgeInsets.only(right: GridSize.leadingHeaderPadding),
180-
child: _GridHeader(
181-
headerScrollController: headerScrollController,
182-
),
183-
),
184-
_GridRows(
185-
viewId: state.viewId,
186-
contentWidth: contentWidth,
187-
scrollController: _scrollController,
168+
child: Stack(
169+
children: [
170+
Column(
171+
crossAxisAlignment: CrossAxisAlignment.start,
172+
children: [
173+
Padding(
174+
padding: EdgeInsets.only(right: GridSize.leadingHeaderPadding),
175+
child: _GridHeader(
176+
headerScrollController: headerScrollController,
188177
),
189-
],
190-
),
191-
Positioned(
192-
bottom: 20,
193-
right: 20,
194-
child: getGridFabs(context),
195-
),
196-
],
197-
);
198-
},
178+
),
179+
_GridRows(
180+
viewId: widget.view.id,
181+
scrollController: _scrollController,
182+
),
183+
],
184+
),
185+
Positioned(
186+
bottom: 20,
187+
right: 20,
188+
child: getGridFabs(context),
189+
),
190+
],
191+
),
199192
);
200193
}
201194
}
@@ -219,47 +212,52 @@ class _GridHeader extends StatelessWidget {
219212

220213
class _GridRows extends StatelessWidget {
221214
final String viewId;
222-
final double contentWidth;
223215
final GridScrollController scrollController;
224216

225217
const _GridRows({
226218
required this.viewId,
227-
required this.contentWidth,
228219
required this.scrollController,
229220
});
230221

231222
@override
232223
Widget build(BuildContext context) {
233-
return Expanded(
234-
child: _WrapScrollView(
235-
scrollController: scrollController,
236-
contentWidth: contentWidth,
237-
child: BlocBuilder<GridBloc, GridState>(
238-
buildWhen: (previous, current) => current.reason.maybeWhen(
239-
reorderRows: () => true,
240-
reorderSingleRow: (reorderRow, rowInfo) => true,
241-
delete: (item) => true,
242-
insert: (item) => true,
243-
orElse: () => false,
224+
return BlocBuilder<GridBloc, GridState>(
225+
buildWhen: (previous, current) => previous.fields != current.fields,
226+
builder: (context, state) {
227+
final contentWidth = GridLayout.headerWidth(state.fields);
228+
return Expanded(
229+
child: _WrapScrollView(
230+
scrollController: scrollController,
231+
contentWidth: contentWidth,
232+
child: BlocBuilder<GridBloc, GridState>(
233+
buildWhen: (previous, current) => current.reason.maybeWhen(
234+
reorderRows: () => true,
235+
reorderSingleRow: (reorderRow, rowInfo) => true,
236+
delete: (item) => true,
237+
insert: (item) => true,
238+
orElse: () => false,
239+
),
240+
builder: (context, state) {
241+
final rowInfos = state.rowInfos;
242+
final behavior = ScrollConfiguration.of(context).copyWith(
243+
scrollbars: false,
244+
physics: const ClampingScrollPhysics(),
245+
);
246+
return ScrollConfiguration(
247+
behavior: behavior,
248+
child: _renderList(context, contentWidth, state, rowInfos),
249+
);
250+
},
251+
),
244252
),
245-
builder: (context, state) {
246-
final rowInfos = state.rowInfos;
247-
final behavior = ScrollConfiguration.of(context).copyWith(
248-
scrollbars: false,
249-
physics: const ClampingScrollPhysics(),
250-
);
251-
return ScrollConfiguration(
252-
behavior: behavior,
253-
child: _renderList(context, state, rowInfos),
254-
);
255-
},
256-
),
257-
),
253+
);
254+
},
258255
);
259256
}
260257

261258
Widget _renderList(
262259
BuildContext context,
260+
double contentWidth,
263261
GridState state,
264262
List<RowInfo> rowInfos,
265263
) {

frontend/appflowy_flutter/lib/plugins/database_view/grid/presentation/widgets/header/grid_header.dart

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,13 @@ class _GridHeaderSliverAdaptorState extends State<GridHeaderSliverAdaptor> {
4646
fieldController: fieldController,
4747
)..add(const GridHeaderEvent.initial());
4848
},
49-
child: BlocBuilder<GridHeaderBloc, GridHeaderState>(
50-
buildWhen: (previous, current) =>
51-
previous.fields.length != current.fields.length,
52-
builder: (context, state) {
53-
return SingleChildScrollView(
54-
scrollDirection: Axis.horizontal,
55-
controller: widget.anchorScrollController,
56-
child: _GridHeader(
57-
viewId: widget.viewId,
58-
fieldController: fieldController,
59-
),
60-
);
61-
},
49+
child: SingleChildScrollView(
50+
scrollDirection: Axis.horizontal,
51+
controller: widget.anchorScrollController,
52+
child: _GridHeader(
53+
viewId: widget.viewId,
54+
fieldController: fieldController,
55+
),
6256
),
6357
);
6458
}

frontend/appflowy_flutter/lib/plugins/database_view/widgets/row/cells/checklist_cell/mobile_checklist_cell_editor.dart

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,7 @@ class _MobileChecklistCellEditScreenState
4747
child: _buildHeader(context),
4848
),
4949
const Divider(),
50-
const Expanded(
51-
child: Padding(
52-
padding: EdgeInsets.symmetric(horizontal: 0.0),
53-
child: _TaskList(),
54-
),
55-
),
50+
const Expanded(child: _TaskList()),
5651
],
5752
);
5853
},
@@ -169,7 +164,7 @@ class _ChecklistItemState extends State<_ChecklistItem> {
169164
@override
170165
Widget build(BuildContext context) {
171166
return Container(
172-
padding: const EdgeInsets.only(left: 5, right: 16),
167+
padding: const EdgeInsets.symmetric(horizontal: 5),
173168
height: 44,
174169
child: Row(
175170
crossAxisAlignment: CrossAxisAlignment.center,

frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/sign_in_anonymous_button.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ class SignInAnonymousButton extends StatelessWidget {
5555
minimumSize: const Size(double.infinity, 56),
5656
),
5757
onPressed: onTap,
58-
child: Text(LocaleKeys.signIn_loginStartWithAnonymous.tr()),
58+
child: FlowyText(
59+
LocaleKeys.signIn_loginStartWithAnonymous.tr(),
60+
fontSize: 14,
61+
color: Theme.of(context).colorScheme.onPrimary,
62+
),
5963
);
6064
}
6165
// SignInAnonymousButton in desktop

0 commit comments

Comments
 (0)