mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: overflow and alignment in sort editor (#3201)
* fix: overflow and alignment in sort editor Closes: #3196 #3197 * fix: add and delete button on row
This commit is contained in:
parent
00ee4be723
commit
ee14d31194
@ -23,19 +23,17 @@ class SortChoiceButton extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final borderSide = BorderSide(
|
|
||||||
color: AFThemeExtension.of(context).toggleOffFill,
|
|
||||||
width: 1.0,
|
|
||||||
);
|
|
||||||
|
|
||||||
final decoration = BoxDecoration(
|
|
||||||
color: Colors.transparent,
|
|
||||||
border: Border.fromBorderSide(borderSide),
|
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(14)),
|
|
||||||
);
|
|
||||||
|
|
||||||
return FlowyButton(
|
return FlowyButton(
|
||||||
decoration: decoration,
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.transparent,
|
||||||
|
border: Border.fromBorderSide(
|
||||||
|
BorderSide(
|
||||||
|
color: AFThemeExtension.of(context).toggleOffFill,
|
||||||
|
width: 1.0,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
borderRadius: const BorderRadius.all(Radius.circular(14)),
|
||||||
|
),
|
||||||
useIntrinsicWidth: true,
|
useIntrinsicWidth: true,
|
||||||
text: FlowyText(
|
text: FlowyText(
|
||||||
text,
|
text,
|
||||||
|
@ -23,12 +23,13 @@ class SortEditor extends StatefulWidget {
|
|||||||
final String viewId;
|
final String viewId;
|
||||||
final List<SortInfo> sortInfos;
|
final List<SortInfo> sortInfos;
|
||||||
final FieldController fieldController;
|
final FieldController fieldController;
|
||||||
|
|
||||||
const SortEditor({
|
const SortEditor({
|
||||||
|
super.key,
|
||||||
required this.viewId,
|
required this.viewId,
|
||||||
required this.fieldController,
|
required this.fieldController,
|
||||||
required this.sortInfos,
|
required this.sortInfos,
|
||||||
Key? key,
|
});
|
||||||
}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<SortEditor> createState() => _SortEditorState();
|
State<SortEditor> createState() => _SortEditorState();
|
||||||
@ -47,20 +48,33 @@ class _SortEditorState extends State<SortEditor> {
|
|||||||
)..add(const SortEditorEvent.initial()),
|
)..add(const SortEditorEvent.initial()),
|
||||||
child: BlocBuilder<SortEditorBloc, SortEditorState>(
|
child: BlocBuilder<SortEditorBloc, SortEditorState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return IntrinsicWidth(
|
return Column(
|
||||||
child: IntrinsicHeight(
|
children: [
|
||||||
child: Column(
|
...state.sortInfos.map(
|
||||||
children: [
|
(info) => Padding(
|
||||||
_SortList(popoverMutex: popoverMutex),
|
padding: const EdgeInsets.symmetric(vertical: 6),
|
||||||
DatabaseAddSortButton(
|
child: DatabaseSortItem(
|
||||||
viewId: widget.viewId,
|
sortInfo: info,
|
||||||
fieldController: widget.fieldController,
|
|
||||||
popoverMutex: popoverMutex,
|
popoverMutex: popoverMutex,
|
||||||
),
|
),
|
||||||
DatabaseDeleteSortButton(popoverMutex: popoverMutex),
|
),
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Flexible(
|
||||||
|
child: DatabaseAddSortButton(
|
||||||
|
viewId: widget.viewId,
|
||||||
|
fieldController: widget.fieldController,
|
||||||
|
popoverMutex: popoverMutex,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const HSpace(6),
|
||||||
|
Flexible(
|
||||||
|
child: DatabaseDeleteSortButton(popoverMutex: popoverMutex),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -68,77 +82,48 @@ class _SortEditorState extends State<SortEditor> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _SortList extends StatelessWidget {
|
|
||||||
final PopoverMutex popoverMutex;
|
|
||||||
const _SortList({required this.popoverMutex, Key? key}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return BlocBuilder<SortEditorBloc, SortEditorState>(
|
|
||||||
builder: (context, state) {
|
|
||||||
final List<Widget> children = state.sortInfos
|
|
||||||
.map(
|
|
||||||
(info) => Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 6),
|
|
||||||
child: DatabaseSortItem(
|
|
||||||
sortInfo: info,
|
|
||||||
popoverMutex: popoverMutex,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
return Column(
|
|
||||||
children: children,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class DatabaseSortItem extends StatelessWidget {
|
class DatabaseSortItem extends StatelessWidget {
|
||||||
final SortInfo sortInfo;
|
final SortInfo sortInfo;
|
||||||
final PopoverMutex popoverMutex;
|
final PopoverMutex popoverMutex;
|
||||||
|
|
||||||
const DatabaseSortItem({
|
const DatabaseSortItem({
|
||||||
|
super.key,
|
||||||
required this.popoverMutex,
|
required this.popoverMutex,
|
||||||
required this.sortInfo,
|
required this.sortInfo,
|
||||||
Key? key,
|
});
|
||||||
}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final nameButton = SortChoiceButton(
|
|
||||||
text: sortInfo.fieldInfo.name,
|
|
||||||
editable: false,
|
|
||||||
onTap: () {},
|
|
||||||
);
|
|
||||||
final orderButton = DatabaseSortItemOrderButton(
|
|
||||||
sortInfo: sortInfo,
|
|
||||||
popoverMutex: popoverMutex,
|
|
||||||
);
|
|
||||||
|
|
||||||
final deleteButton = FlowyIconButton(
|
final deleteButton = FlowyIconButton(
|
||||||
width: 26,
|
width: 26,
|
||||||
onPressed: () {
|
onPressed: () => context
|
||||||
context
|
.read<SortEditorBloc>()
|
||||||
.read<SortEditorBloc>()
|
.add(SortEditorEvent.deleteSort(sortInfo)),
|
||||||
.add(SortEditorEvent.deleteSort(sortInfo));
|
|
||||||
},
|
|
||||||
iconPadding: const EdgeInsets.all(5),
|
iconPadding: const EdgeInsets.all(5),
|
||||||
hoverColor: AFThemeExtension.of(context).lightGreyHover,
|
hoverColor: AFThemeExtension.of(context).lightGreyHover,
|
||||||
icon: FlowySvg(
|
icon: svgWidget("home/close", color: Theme.of(context).iconTheme.color),
|
||||||
FlowySvgs.close_s,
|
|
||||||
color: Theme.of(context).iconTheme.color,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
SizedBox(height: 26, child: nameButton),
|
SizedBox(
|
||||||
|
height: 26,
|
||||||
|
child: SortChoiceButton(
|
||||||
|
text: sortInfo.fieldInfo.name,
|
||||||
|
editable: false,
|
||||||
|
),
|
||||||
|
),
|
||||||
const HSpace(6),
|
const HSpace(6),
|
||||||
SizedBox(height: 26, child: orderButton),
|
SizedBox(
|
||||||
const HSpace(16),
|
height: 26,
|
||||||
deleteButton
|
child: DatabaseSortItemOrderButton(
|
||||||
|
sortInfo: sortInfo,
|
||||||
|
popoverMutex: popoverMutex,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const HSpace(6),
|
||||||
|
const Spacer(),
|
||||||
|
deleteButton,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -147,12 +132,11 @@ class DatabaseSortItem extends StatelessWidget {
|
|||||||
extension SortConditionExtension on SortConditionPB {
|
extension SortConditionExtension on SortConditionPB {
|
||||||
String get title {
|
String get title {
|
||||||
switch (this) {
|
switch (this) {
|
||||||
case SortConditionPB.Ascending:
|
|
||||||
return LocaleKeys.grid_sort_ascending.tr();
|
|
||||||
case SortConditionPB.Descending:
|
case SortConditionPB.Descending:
|
||||||
return LocaleKeys.grid_sort_descending.tr();
|
return LocaleKeys.grid_sort_descending.tr();
|
||||||
|
default:
|
||||||
|
return LocaleKeys.grid_sort_ascending.tr();
|
||||||
}
|
}
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,12 +144,13 @@ class DatabaseAddSortButton extends StatefulWidget {
|
|||||||
final String viewId;
|
final String viewId;
|
||||||
final FieldController fieldController;
|
final FieldController fieldController;
|
||||||
final PopoverMutex popoverMutex;
|
final PopoverMutex popoverMutex;
|
||||||
|
|
||||||
const DatabaseAddSortButton({
|
const DatabaseAddSortButton({
|
||||||
|
super.key,
|
||||||
required this.viewId,
|
required this.viewId,
|
||||||
required this.fieldController,
|
required this.fieldController,
|
||||||
required this.popoverMutex,
|
required this.popoverMutex,
|
||||||
Key? key,
|
});
|
||||||
}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<DatabaseAddSortButton> createState() => _DatabaseAddSortButtonState();
|
State<DatabaseAddSortButton> createState() => _DatabaseAddSortButtonState();
|
||||||
@ -207,8 +192,10 @@ class _DatabaseAddSortButtonState extends State<DatabaseAddSortButton> {
|
|||||||
|
|
||||||
class DatabaseDeleteSortButton extends StatelessWidget {
|
class DatabaseDeleteSortButton extends StatelessWidget {
|
||||||
final PopoverMutex popoverMutex;
|
final PopoverMutex popoverMutex;
|
||||||
const DatabaseDeleteSortButton({required this.popoverMutex, Key? key})
|
const DatabaseDeleteSortButton({
|
||||||
: super(key: key);
|
super.key,
|
||||||
|
required this.popoverMutex,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -217,7 +204,7 @@ class DatabaseDeleteSortButton extends StatelessWidget {
|
|||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: GridSize.popoverItemHeight,
|
height: GridSize.popoverItemHeight,
|
||||||
child: FlowyButton(
|
child: FlowyButton(
|
||||||
text: FlowyText.medium(LocaleKeys.grid_sort_deleteSort.tr()),
|
text: FlowyText.medium(LocaleKeys.grid_sort_deleteAllSorts.tr()),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context
|
context
|
||||||
.read<SortEditorBloc>()
|
.read<SortEditorBloc>()
|
||||||
@ -235,10 +222,10 @@ class DatabaseSortItemOrderButton extends StatefulWidget {
|
|||||||
final SortInfo sortInfo;
|
final SortInfo sortInfo;
|
||||||
final PopoverMutex popoverMutex;
|
final PopoverMutex popoverMutex;
|
||||||
const DatabaseSortItemOrderButton({
|
const DatabaseSortItemOrderButton({
|
||||||
|
super.key,
|
||||||
required this.popoverMutex,
|
required this.popoverMutex,
|
||||||
required this.sortInfo,
|
required this.sortInfo,
|
||||||
Key? key,
|
});
|
||||||
}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<DatabaseSortItemOrderButton> createState() =>
|
State<DatabaseSortItemOrderButton> createState() =>
|
||||||
|
@ -16,10 +16,11 @@ import 'sort_info.dart';
|
|||||||
|
|
||||||
class SortMenu extends StatelessWidget {
|
class SortMenu extends StatelessWidget {
|
||||||
final FieldController fieldController;
|
final FieldController fieldController;
|
||||||
|
|
||||||
const SortMenu({
|
const SortMenu({
|
||||||
|
super.key,
|
||||||
required this.fieldController,
|
required this.fieldController,
|
||||||
Key? key,
|
});
|
||||||
}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -33,20 +34,24 @@ class SortMenu extends StatelessWidget {
|
|||||||
if (state.sortInfos.isNotEmpty) {
|
if (state.sortInfos.isNotEmpty) {
|
||||||
return AppFlowyPopover(
|
return AppFlowyPopover(
|
||||||
controller: PopoverController(),
|
controller: PopoverController(),
|
||||||
constraints: BoxConstraints.loose(const Size(340, 200)),
|
constraints: BoxConstraints.loose(const Size(320, 200)),
|
||||||
direction: PopoverDirection.bottomWithLeftAligned,
|
direction: PopoverDirection.bottomWithLeftAligned,
|
||||||
|
offset: const Offset(0, 5),
|
||||||
popupBuilder: (BuildContext popoverContext) {
|
popupBuilder: (BuildContext popoverContext) {
|
||||||
return SortEditor(
|
return SingleChildScrollView(
|
||||||
viewId: state.viewId,
|
child: SortEditor(
|
||||||
fieldController: context.read<SortMenuBloc>().fieldController,
|
viewId: state.viewId,
|
||||||
sortInfos: state.sortInfos,
|
fieldController:
|
||||||
|
context.read<SortMenuBloc>().fieldController,
|
||||||
|
sortInfos: state.sortInfos,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: SortChoiceChip(sortInfos: state.sortInfos),
|
child: SortChoiceChip(sortInfos: state.sortInfos),
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
return const SizedBox();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return const SizedBox.shrink();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -58,10 +63,10 @@ class SortChoiceChip extends StatelessWidget {
|
|||||||
final VoidCallback? onTap;
|
final VoidCallback? onTap;
|
||||||
|
|
||||||
const SortChoiceChip({
|
const SortChoiceChip({
|
||||||
Key? key,
|
super.key,
|
||||||
required this.sortInfos,
|
required this.sortInfos,
|
||||||
this.onTap,
|
this.onTap,
|
||||||
}) : super(key: key);
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -60,13 +60,9 @@ class _DatabaseViewSettingContent extends StatelessWidget {
|
|||||||
return _wrapPadding(
|
return _wrapPadding(
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
SortMenu(
|
SortMenu(fieldController: fieldController),
|
||||||
fieldController: fieldController,
|
|
||||||
),
|
|
||||||
const HSpace(6),
|
const HSpace(6),
|
||||||
FilterMenu(
|
FilterMenu(fieldController: fieldController),
|
||||||
fieldController: fieldController,
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -409,7 +409,7 @@
|
|||||||
"sort": {
|
"sort": {
|
||||||
"ascending": "Ascending",
|
"ascending": "Ascending",
|
||||||
"descending": "Descending",
|
"descending": "Descending",
|
||||||
"deleteSort": "Delete sort",
|
"deleteAllSorts": "Delete all sorts",
|
||||||
"addSort": "Add sort"
|
"addSort": "Add sort"
|
||||||
},
|
},
|
||||||
"row": {
|
"row": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user