chore: auto expand row detail page's cell

This commit is contained in:
appflowy 2022-05-22 13:08:38 +08:00
parent 36abd969ac
commit 1b5b8f19d7
19 changed files with 61 additions and 54 deletions

View File

@ -47,13 +47,11 @@ class BlankCell extends StatelessWidget {
}
}
abstract class GridCellWidget extends HoverWidget {
abstract class GridCellWidget implements FlowyHoverWidget {
@override
final ValueNotifier<bool> onFocus = ValueNotifier<bool>(false);
final GridCellRequestFocusNotifier requestFocus = GridCellRequestFocusNotifier();
GridCellWidget({Key? key}) : super(key: key);
}
class GridCellRequestFocusNotifier extends ChangeNotifier {

View File

@ -6,7 +6,7 @@ import 'package:flutter/widgets.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'cell_builder.dart';
class CheckboxCell extends GridCellWidget {
class CheckboxCell extends StatefulWidget with GridCellWidget {
final GridCellContextBuilder cellContextBuilder;
CheckboxCell({
required this.cellContextBuilder,
@ -41,7 +41,7 @@ class _CheckboxCellState extends State<CheckboxCell> {
onPressed: () => context.read<CheckboxCellBloc>().add(const CheckboxCellEvent.select()),
iconPadding: EdgeInsets.zero,
icon: icon,
width: 23,
width: 20,
),
);
},

View File

@ -7,7 +7,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'cell_builder.dart';
class NumberCell extends GridCellWidget {
class NumberCell extends StatefulWidget with GridCellWidget {
final GridCellContextBuilder cellContextBuilder;
NumberCell({

View File

@ -20,7 +20,7 @@ class SelectOptionCellStyle extends GridCellStyle {
});
}
class SingleSelectCell extends GridCellWidget {
class SingleSelectCell extends StatefulWidget with GridCellWidget {
final GridCellContextBuilder cellContextBuilder;
late final SelectOptionCellStyle? cellStyle;
@ -74,7 +74,7 @@ class _SingleSelectCellState extends State<SingleSelectCell> {
}
//----------------------------------------------------------------
class MultiSelectCell extends GridCellWidget {
class MultiSelectCell extends StatefulWidget with GridCellWidget {
final GridCellContextBuilder cellContextBuilder;
late final SelectOptionCellStyle? cellStyle;
@ -160,7 +160,7 @@ class _SelectOptionCell extends StatelessWidget {
.toList();
child = Align(
alignment: Alignment.centerLeft,
child: Wrap(children: tags, spacing: 4, runSpacing: 4),
child: Wrap(children: tags, spacing: 4, runSpacing: 2),
);
}

View File

@ -13,7 +13,7 @@ class GridTextCellStyle extends GridCellStyle {
});
}
class GridTextCell extends GridCellWidget {
class GridTextCell extends StatefulWidget with GridCellWidget {
final GridCellContextBuilder cellContextBuilder;
late final GridTextCellStyle? cellStyle;
GridTextCell({

View File

@ -71,10 +71,11 @@ class _RowDetailPageState extends State<RowDetailPage> {
child: Column(
children: [
SizedBox(
height: 40,
child: Row(
children: const [Spacer(), _CloseButton()],
)),
height: 40,
child: Row(
children: const [Spacer(), _CloseButton()],
),
),
Expanded(child: _PropertyList(cellCache: widget.cellCache)),
],
),
@ -153,24 +154,26 @@ class _RowDetailCell extends StatelessWidget {
cellCache,
style: _buildCellStyle(theme, gridCell.field.fieldType),
);
return SizedBox(
height: 36,
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width: 150,
child: FieldCellButton(field: gridCell.field, onTap: () => _showFieldEditor(context)),
),
const HSpace(10),
Expanded(
child: FlowyHover2(
child: cell,
contentPadding: const EdgeInsets.symmetric(horizontal: 6, vertical: 4),
return ConstrainedBox(
constraints: const BoxConstraints(minHeight: 40),
child: IntrinsicHeight(
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width: 150,
child: FieldCellButton(field: gridCell.field, onTap: () => _showFieldEditor(context)),
),
),
],
const HSpace(10),
Expanded(
child: FlowyHover2(
child: cell,
contentPadding: const EdgeInsets.symmetric(horizontal: 10, vertical: 12),
),
),
],
),
),
);
}

View File

@ -102,14 +102,14 @@ class FlowyHoverContainer extends StatelessWidget {
}
//
abstract class HoverWidget extends StatefulWidget {
const HoverWidget({Key? key}) : super(key: key);
abstract class FlowyHoverWidget extends Widget {
const FlowyHoverWidget({Key? key}) : super(key: key);
ValueNotifier<bool> get onFocus;
ValueNotifier<bool>? get onFocus;
}
class FlowyHover2 extends StatefulWidget {
final Widget child;
final FlowyHoverWidget child;
final EdgeInsets contentPadding;
const FlowyHover2({
required this.child,
@ -123,24 +123,30 @@ class FlowyHover2 extends StatefulWidget {
class _FlowyHover2State extends State<FlowyHover2> {
late FlowyHoverState _hoverState;
VoidCallback? _listenerFn;
@override
void initState() {
_hoverState = FlowyHoverState();
if (widget.child is HoverWidget) {
final hoverWidget = widget.child as HoverWidget;
hoverWidget.onFocus.addListener(() {
_hoverState.onFocus = hoverWidget.onFocus.value;
});
listener() {
_hoverState.onFocus = widget.child.onFocus?.value ?? false;
}
_listenerFn = listener;
widget.child.onFocus?.addListener(listener);
super.initState();
}
@override
void dispose() {
_hoverState.dispose();
if (_listenerFn != null) {
widget.child.onFocus?.removeListener(_listenerFn!);
_listenerFn = null;
}
super.dispose();
}
@ -179,10 +185,7 @@ class _HoverBackground extends StatelessWidget {
builder: (context, state, child) {
if (state.onHover || state.onFocus) {
return FlowyHoverContainer(
style: HoverStyle(
borderRadius: Corners.s6Border,
hoverColor: theme.shader6,
),
style: HoverStyle(borderRadius: Corners.s6Border, hoverColor: theme.shader6),
);
} else {
return const SizedBox();

View File

@ -132,9 +132,12 @@ class _RoundedInputFieldState extends State<RoundedInputField> {
children.add(
Align(
alignment: Alignment.centerLeft,
child: Text(
widget.errorText,
style: widget.style,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 4),
child: Text(
widget.errorText,
style: widget.style,
),
),
),
);

View File

@ -2,7 +2,7 @@
proto_crates = [
"src/event_map.rs",
"src/services/field/type_options",
"src/services/entities",
"src/entities",
"src/dart_notification.rs"
]
event_files = ["src/event_map.rs"]

View File

@ -1,4 +1,4 @@
use crate::services::entities::{FieldIdentifier, FieldIdentifierPayload};
use crate::entities::{FieldIdentifier, FieldIdentifierPayload};
use flowy_derive::ProtoBuf;
use flowy_error::ErrorCode;
use flowy_grid_data_model::parser::NotEmptyStr;

View File

@ -1,5 +1,5 @@
use crate::entities::*;
use crate::manager::GridManager;
use crate::services::entities::*;
use crate::services::field::type_options::*;
use crate::services::field::{default_type_option_builder_from_type, type_option_builder_from_json_str};
use flowy_error::{ErrorCode, FlowyError, FlowyResult};

View File

@ -6,6 +6,7 @@ pub mod event_map;
pub mod manager;
mod dart_notification;
pub mod entities;
mod protobuf;
pub mod services;
pub mod util;

View File

@ -1,5 +1,5 @@
use crate::entities::{CellIdentifier, CellIdentifierPayload};
use crate::impl_type_option;
use crate::services::entities::{CellIdentifier, CellIdentifierPayload};
use crate::services::field::{BoxTypeOptionBuilder, TypeOptionBuilder};
use crate::services::row::{CellContentChangeset, CellDataOperation, DecodedCellData, TypeOptionCellData};
use bytes::Bytes;

View File

@ -1,5 +1,5 @@
use crate::entities::{CellIdentifier, CellIdentifierPayload};
use crate::impl_type_option;
use crate::services::entities::{CellIdentifier, CellIdentifierPayload};
use crate::services::field::type_options::util::get_cell_data;
use crate::services::field::{BoxTypeOptionBuilder, TypeOptionBuilder};
use crate::services::row::{CellContentChangeset, CellDataOperation, DecodedCellData, TypeOptionCellData};

View File

@ -1,7 +1,7 @@
use crate::dart_notification::{send_dart_notification, GridNotification};
use crate::entities::CellIdentifier;
use crate::manager::GridUser;
use crate::services::block_meta_manager::GridBlockMetaEditorManager;
use crate::services::entities::CellIdentifier;
use crate::services::field::{default_type_option_builder_from_type, type_option_builder_from_bytes, FieldBuilder};
use crate::services::persistence::block_index::BlockIndexPersistence;
use crate::services::row::*;

View File

@ -2,7 +2,6 @@ mod util;
pub mod block_meta_editor;
mod block_meta_manager;
pub mod entities;
pub mod field;
pub mod grid_editor;
pub mod persistence;