Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

fix: alignment in date cell

appflowy6c2c3b066623
diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/cell_builder.dart b/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/cell_builder.dart
index 0b13aab846..8efdffdb32 100755
--- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/cell_builder.dart
+++ b/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/cell_builder.dart
@@ -23,7 +23,7 @@ GridCellWidget buildGridCellWidget(GridCell gridCell, GridCellCache cellCache, {
case FieldType.Checkbox:
return CheckboxCell(cellContextBuilder: cellContextBuilder, key: key);
case FieldType.DateTime:
- return DateCell(cellContextBuilder: cellContextBuilder, key: key);
+ return DateCell(cellContextBuilder: cellContextBuilder, key: key, style: style);
case FieldType.SingleSelect:
return SingleSelectCell(cellContextBuilder: cellContextBuilder, style: style, key: key);
case FieldType.MultiSelect:
diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/date_cell.dart b/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/date_cell.dart
index a68bfcb4bc..194e5adf6a 100644
--- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/date_cell.dart
+++ b/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/cell/date_cell.dart
@@ -8,6 +8,12 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:table_calendar/table_calendar.dart';
import 'cell_builder.dart';
+class DateCellStyle extends GridCellStyle {
+ Alignment alignment;
+
+ DateCellStyle({this.alignment = Alignment.center});
+}
+
abstract class GridCellDelegate {
void onFocus(bool isFocus);
GridCellDelegate get delegate;
@@ -15,11 +21,19 @@ abstract class GridCellDelegate {
class DateCell extends GridCellWidget {
final GridCellContextBuilder cellContextBuilder;
+ late final DateCellStyle? cellStyle;
DateCell({
+ GridCellStyle? style,
required this.cellContextBuilder,
Key? key,
- }) : super(key: key);
+ }) : super(key: key) {
+ if (style != null) {
+ cellStyle = (style as DateCellStyle);
+ } else {
+ cellStyle = null;
+ }
+ }
@override
State<DateCell> createState() => _DateCellState();
@@ -37,6 +51,7 @@ class _DateCellState extends State<DateCell> {
@override
Widget build(BuildContext context) {
+ final alignment = widget.cellStyle != null ? widget.cellStyle!.alignment : Alignment.center;
return BlocProvider.value(
value: _cellBloc,
child: BlocBuilder<DateCellBloc, DateCellState>(
@@ -57,7 +72,7 @@ class _DateCellState extends State<DateCell> {
child: MouseRegion(
opaque: false,
cursor: SystemMouseCursors.click,
- child: Center(child: FlowyText.medium(state.content, fontSize: 12)),
+ child: Align(alignment: alignment, child: FlowyText.medium(state.content, fontSize: 12)),
),
),
);
diff --git a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/row/row_detail.dart b/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/row/row_detail.dart
index ae82033320..7e2ece2cf5 100644
--- a/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/row/row_detail.dart
+++ b/frontend/app_flowy/lib/workspace/presentation/plugins/grid/src/widgets/row/row_detail.dart
@@ -165,7 +165,9 @@ GridCellStyle? _buildCellStyle(AppTheme theme, FieldType fieldType) {
case FieldType.Checkbox:
return null;
case FieldType.DateTime:
- return null;
+ return DateCellStyle(
+ alignment: Alignment.centerLeft,
+ );
case FieldType.MultiSelect:
return SelectOptionCellStyle(
placeholder: LocaleKeys.grid_row_textPlaceholder.tr(),
diff --git a/frontend/rust-lib/flowy-grid/src/services/field/type_options/number_type_option.rs b/frontend/rust-lib/flowy-grid/src/services/field/type_options/number_type_option.rs
index f403a28272..2d03a0ab33 100644
--- a/frontend/rust-lib/flowy-grid/src/services/field/type_options/number_type_option.rs
+++ b/frontend/rust-lib/flowy-grid/src/services/field/type_options/number_type_option.rs
@@ -110,11 +110,13 @@ impl CellDataOperation for NumberTypeOption {
_cell_meta: Option<CellMeta>,
) -> Result<String, FlowyError> {
let changeset = changeset.into();
- let data = changeset.to_string();
- let data = self.strip_symbol(data.trim());
+ let mut data = changeset.trim().to_string();
- if !data.chars().all(char::is_numeric) {
- return Err(FlowyError::invalid_data().context("Should only contain numbers"));
+ if self.format != NumberFormat::Number {
+ data = self.strip_symbol(data);
+ if !data.chars().all(char::is_numeric) {
+ return Err(FlowyError::invalid_data().context("Should only contain numbers"));
+ }
}
Ok(TypeOptionCellData::new(&data, self.field_type()).json())
@@ -168,7 +170,7 @@ impl NumberTypeOption {
}
}
-#[derive(Clone, Copy, Debug, EnumIter, Serialize, Deserialize, ProtoBuf_Enum)]
+#[derive(Clone, Copy, Debug, PartialEq, Eq, EnumIter, Serialize, Deserialize, ProtoBuf_Enum)]
pub enum NumberFormat {
Number = 0,
USD = 1,
diff --git a/frontend/rust-lib/flowy-grid/src/services/grid_editor.rs b/frontend/rust-lib/flowy-grid/src/services/grid_editor.rs
index d8d909cabe..5962386352 100644
--- a/frontend/rust-lib/flowy-grid/src/services/grid_editor.rs
+++ b/frontend/rust-lib/flowy-grid/src/services/grid_editor.rs
@@ -316,7 +316,11 @@ impl ClientGridEditor {
let cell_data_changeset = changeset.data.unwrap();
let cell_meta = self.get_cell_meta(&changeset.row_id, &changeset.field_id).await?;
- tracing::trace!("{}: {:?}", &changeset.field_id, cell_meta);
+ tracing::trace!(
+ "field changeset: id:{} / value:{}",
+ &changeset.field_id,
+ cell_data_changeset
+ );
match self.grid_pad.read().await.get_field_meta(&changeset.field_id) {
None => {
let msg = format!("Field not found with id: {}", &changeset.field_id);