Skip to content

Commit 1b5b8f1

Browse files
committed
chore: auto expand row detail page's cell
1 parent 36abd96 commit 1b5b8f1

File tree

19 files changed

+61
-54
lines changed

19 files changed

+61
-54
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,11 @@ class BlankCell extends StatelessWidget {
4747
}
4848
}
4949

50-
abstract class GridCellWidget extends HoverWidget {
50+
abstract class GridCellWidget implements FlowyHoverWidget {
5151
@override
5252
final ValueNotifier<bool> onFocus = ValueNotifier<bool>(false);
5353

5454
final GridCellRequestFocusNotifier requestFocus = GridCellRequestFocusNotifier();
55-
56-
GridCellWidget({Key? key}) : super(key: key);
5755
}
5856

5957
class GridCellRequestFocusNotifier extends ChangeNotifier {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import 'package:flutter/widgets.dart';
66
import 'package:flutter_bloc/flutter_bloc.dart';
77
import 'cell_builder.dart';
88

9-
class CheckboxCell extends GridCellWidget {
9+
class CheckboxCell extends StatefulWidget with GridCellWidget {
1010
final GridCellContextBuilder cellContextBuilder;
1111
CheckboxCell({
1212
required this.cellContextBuilder,
@@ -41,7 +41,7 @@ class _CheckboxCellState extends State<CheckboxCell> {
4141
onPressed: () => context.read<CheckboxCellBloc>().add(const CheckboxCellEvent.select()),
4242
iconPadding: EdgeInsets.zero,
4343
icon: icon,
44-
width: 23,
44+
width: 20,
4545
),
4646
);
4747
},

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
77

88
import 'cell_builder.dart';
99

10-
class NumberCell extends GridCellWidget {
10+
class NumberCell extends StatefulWidget with GridCellWidget {
1111
final GridCellContextBuilder cellContextBuilder;
1212

1313
NumberCell({

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class SelectOptionCellStyle extends GridCellStyle {
2020
});
2121
}
2222

23-
class SingleSelectCell extends GridCellWidget {
23+
class SingleSelectCell extends StatefulWidget with GridCellWidget {
2424
final GridCellContextBuilder cellContextBuilder;
2525
late final SelectOptionCellStyle? cellStyle;
2626

@@ -74,7 +74,7 @@ class _SingleSelectCellState extends State<SingleSelectCell> {
7474
}
7575

7676
//----------------------------------------------------------------
77-
class MultiSelectCell extends GridCellWidget {
77+
class MultiSelectCell extends StatefulWidget with GridCellWidget {
7878
final GridCellContextBuilder cellContextBuilder;
7979
late final SelectOptionCellStyle? cellStyle;
8080

@@ -160,7 +160,7 @@ class _SelectOptionCell extends StatelessWidget {
160160
.toList();
161161
child = Align(
162162
alignment: Alignment.centerLeft,
163-
child: Wrap(children: tags, spacing: 4, runSpacing: 4),
163+
child: Wrap(children: tags, spacing: 4, runSpacing: 2),
164164
);
165165
}
166166

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class GridTextCellStyle extends GridCellStyle {
1313
});
1414
}
1515

16-
class GridTextCell extends GridCellWidget {
16+
class GridTextCell extends StatefulWidget with GridCellWidget {
1717
final GridCellContextBuilder cellContextBuilder;
1818
late final GridTextCellStyle? cellStyle;
1919
GridTextCell({

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

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,11 @@ class _RowDetailPageState extends State<RowDetailPage> {
7171
child: Column(
7272
children: [
7373
SizedBox(
74-
height: 40,
75-
child: Row(
76-
children: const [Spacer(), _CloseButton()],
77-
)),
74+
height: 40,
75+
child: Row(
76+
children: const [Spacer(), _CloseButton()],
77+
),
78+
),
7879
Expanded(child: _PropertyList(cellCache: widget.cellCache)),
7980
],
8081
),
@@ -153,24 +154,26 @@ class _RowDetailCell extends StatelessWidget {
153154
cellCache,
154155
style: _buildCellStyle(theme, gridCell.field.fieldType),
155156
);
156-
return SizedBox(
157-
height: 36,
158-
child: Row(
159-
crossAxisAlignment: CrossAxisAlignment.stretch,
160-
mainAxisAlignment: MainAxisAlignment.center,
161-
children: [
162-
SizedBox(
163-
width: 150,
164-
child: FieldCellButton(field: gridCell.field, onTap: () => _showFieldEditor(context)),
165-
),
166-
const HSpace(10),
167-
Expanded(
168-
child: FlowyHover2(
169-
child: cell,
170-
contentPadding: const EdgeInsets.symmetric(horizontal: 6, vertical: 4),
157+
return ConstrainedBox(
158+
constraints: const BoxConstraints(minHeight: 40),
159+
child: IntrinsicHeight(
160+
child: Row(
161+
crossAxisAlignment: CrossAxisAlignment.stretch,
162+
mainAxisAlignment: MainAxisAlignment.center,
163+
children: [
164+
SizedBox(
165+
width: 150,
166+
child: FieldCellButton(field: gridCell.field, onTap: () => _showFieldEditor(context)),
171167
),
172-
),
173-
],
168+
const HSpace(10),
169+
Expanded(
170+
child: FlowyHover2(
171+
child: cell,
172+
contentPadding: const EdgeInsets.symmetric(horizontal: 10, vertical: 12),
173+
),
174+
),
175+
],
176+
),
174177
),
175178
);
176179
}

frontend/app_flowy/packages/flowy_infra_ui/lib/style_widget/hover.dart

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,14 @@ class FlowyHoverContainer extends StatelessWidget {
102102
}
103103

104104
//
105-
abstract class HoverWidget extends StatefulWidget {
106-
const HoverWidget({Key? key}) : super(key: key);
105+
abstract class FlowyHoverWidget extends Widget {
106+
const FlowyHoverWidget({Key? key}) : super(key: key);
107107

108-
ValueNotifier<bool> get onFocus;
108+
ValueNotifier<bool>? get onFocus;
109109
}
110110

111111
class FlowyHover2 extends StatefulWidget {
112-
final Widget child;
112+
final FlowyHoverWidget child;
113113
final EdgeInsets contentPadding;
114114
const FlowyHover2({
115115
required this.child,
@@ -123,24 +123,30 @@ class FlowyHover2 extends StatefulWidget {
123123

124124
class _FlowyHover2State extends State<FlowyHover2> {
125125
late FlowyHoverState _hoverState;
126+
VoidCallback? _listenerFn;
126127

127128
@override
128129
void initState() {
129130
_hoverState = FlowyHoverState();
130131

131-
if (widget.child is HoverWidget) {
132-
final hoverWidget = widget.child as HoverWidget;
133-
hoverWidget.onFocus.addListener(() {
134-
_hoverState.onFocus = hoverWidget.onFocus.value;
135-
});
132+
listener() {
133+
_hoverState.onFocus = widget.child.onFocus?.value ?? false;
136134
}
137135

136+
_listenerFn = listener;
137+
widget.child.onFocus?.addListener(listener);
138+
138139
super.initState();
139140
}
140141

141142
@override
142143
void dispose() {
143144
_hoverState.dispose();
145+
146+
if (_listenerFn != null) {
147+
widget.child.onFocus?.removeListener(_listenerFn!);
148+
_listenerFn = null;
149+
}
144150
super.dispose();
145151
}
146152

@@ -179,10 +185,7 @@ class _HoverBackground extends StatelessWidget {
179185
builder: (context, state, child) {
180186
if (state.onHover || state.onFocus) {
181187
return FlowyHoverContainer(
182-
style: HoverStyle(
183-
borderRadius: Corners.s6Border,
184-
hoverColor: theme.shader6,
185-
),
188+
style: HoverStyle(borderRadius: Corners.s6Border, hoverColor: theme.shader6),
186189
);
187190
} else {
188191
return const SizedBox();

frontend/app_flowy/packages/flowy_infra_ui/lib/widget/rounded_input_field.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,12 @@ class _RoundedInputFieldState extends State<RoundedInputField> {
132132
children.add(
133133
Align(
134134
alignment: Alignment.centerLeft,
135-
child: Text(
136-
widget.errorText,
137-
style: widget.style,
135+
child: Padding(
136+
padding: const EdgeInsets.symmetric(vertical: 4),
137+
child: Text(
138+
widget.errorText,
139+
style: widget.style,
140+
),
138141
),
139142
),
140143
);

frontend/rust-lib/flowy-grid/Flowy.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
proto_crates = [
33
"src/event_map.rs",
44
"src/services/field/type_options",
5-
"src/services/entities",
5+
"src/entities",
66
"src/dart_notification.rs"
77
]
88
event_files = ["src/event_map.rs"]

frontend/rust-lib/flowy-grid/src/services/entities/cell_entities.rs renamed to frontend/rust-lib/flowy-grid/src/entities/cell_entities.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::services::entities::{FieldIdentifier, FieldIdentifierPayload};
1+
use crate::entities::{FieldIdentifier, FieldIdentifierPayload};
22
use flowy_derive::ProtoBuf;
33
use flowy_error::ErrorCode;
44
use flowy_grid_data_model::parser::NotEmptyStr;

0 commit comments

Comments
 (0)