chore: adjust show mobile bottom sheet (#4689)

This commit is contained in:
Richard Shiue 2024-02-21 21:06:46 +08:00 committed by GitHub
parent 34fb1bcfa4
commit 6f173c2ada
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
19 changed files with 19 additions and 47 deletions

View File

@ -1,6 +1,5 @@
import 'package:appflowy/mobile/presentation/base/app_bar_actions.dart';
import 'package:appflowy/plugins/base/drag_handler.dart';
import 'package:flowy_infra/size.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart' hide WidgetBuilder;
import 'package:flutter/material.dart';
@ -16,7 +15,6 @@ Future<T?> showMobileBottomSheet<T>(
bool showCloseButton = false,
// this field is only used if showHeader is true
String title = '',
bool resizeToAvoidBottomInset = true,
bool isScrollControlled = true,
bool showDivider = true,
bool useRootNavigator = false,
@ -42,7 +40,7 @@ Future<T?> showMobileBottomSheet<T>(
shape ??= const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
top: Corners.s12Radius,
top: Radius.circular(16),
),
);
@ -68,17 +66,14 @@ Future<T?> showMobileBottomSheet<T>(
final Widget child = builder(context);
// if the children is only one, we don't need to wrap it with a column
if (!showDragHandle &&
!showHeader &&
!showDivider &&
!resizeToAvoidBottomInset) {
if (!showDragHandle && !showHeader && !showDivider) {
return child;
}
// ----- header area -----
if (showDragHandle) {
children.add(
const DragHandler(),
const DragHandle(),
);
}
@ -125,21 +120,12 @@ Future<T?> showMobileBottomSheet<T>(
}
// ----- content area -----
if (resizeToAvoidBottomInset) {
children.add(
Padding(
padding: EdgeInsets.only(
top: padding.top,
left: padding.left,
right: padding.right,
bottom: padding.bottom + MediaQuery.of(context).viewInsets.bottom,
),
child: child,
),
);
} else {
children.add(child);
}
children.add(
Padding(
padding: padding,
child: child,
),
);
// ----- content area -----
if (children.length == 1) {

View File

@ -61,7 +61,7 @@ class _MobileDateCellEditScreenState extends State<MobileDateCellEditScreen> {
children: [
ColoredBox(
color: Theme.of(context).colorScheme.surface,
child: const Center(child: DragHandler()),
child: const Center(child: DragHandle()),
),
const MobileDateHeader(),
_buildDatePicker(),

View File

@ -38,7 +38,6 @@ void showCreateFieldBottomSheet(
}) {
showMobileBottomSheet(
context,
padding: EdgeInsets.zero,
showHeader: true,
showDragHandle: true,
showCloseButton: true,
@ -110,9 +109,7 @@ void showQuickEditField(
) {
showMobileBottomSheet(
context,
padding: EdgeInsets.zero,
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
resizeToAvoidBottomInset: true,
showDragHandle: true,
builder: (context) {
return SingleChildScrollView(

View File

@ -47,7 +47,7 @@ class _MobileFieldPickerListState extends State<MobileFieldPickerList> {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
const DragHandler(),
const DragHandle(),
_Header(
title: widget.title,
onDone: (context) => context.pop(newFieldId),

View File

@ -711,7 +711,7 @@ class _NumberFormatListState extends State<_NumberFormatList> {
controller: widget.scrollController,
children: [
const Center(
child: DragHandler(),
child: DragHandle(),
),
Container(
margin: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),

View File

@ -40,7 +40,7 @@ class MobileDatabaseViewList extends StatelessWidget {
return Column(
children: [
const DragHandler(),
const DragHandle(),
_Header(
title: LocaleKeys.grid_settings_viewList.plural(
context.watch<DatabaseTabBarBloc>().state.tabBars.length,

View File

@ -231,7 +231,6 @@ class DatabaseViewSettingTile extends StatelessWidget {
await showMobileBottomSheet(
context,
useSafeArea: false,
resizeToAvoidBottomInset: false,
showDragHandle: true,
showHeader: true,
showBackButton: true,
@ -257,7 +256,6 @@ class DatabaseViewSettingTile extends StatelessWidget {
if (setting == DatabaseViewSettings.board) {
await showMobileBottomSheet<DatabaseLayoutPB>(
context,
resizeToAvoidBottomInset: false,
builder: (context) {
return Padding(
padding: const EdgeInsets.only(top: 24, bottom: 46),

View File

@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
class DragHandler extends StatelessWidget {
const DragHandler({
class DragHandle extends StatelessWidget {
const DragHandle({
super.key,
});

View File

@ -39,7 +39,6 @@ class MobileGridChecklistCellSkin extends IEditableChecklistCellSkin {
),
onTap: () => showMobileBottomSheet(
context,
padding: EdgeInsets.zero,
backgroundColor: Theme.of(context).colorScheme.background,
builder: (context) {
return BlocProvider.value(

View File

@ -44,7 +44,6 @@ class MobileGridDateCellSkin extends IEditableDateCellSkin {
onTap: () {
showMobileBottomSheet(
context,
padding: EdgeInsets.zero,
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
builder: (context) {
return MobileDateCellEditScreen(

View File

@ -33,7 +33,6 @@ class MobileGridSelectOptionCellSkin extends IEditableSelectOptionCellSkin {
onTap: () {
showMobileBottomSheet(
context,
padding: EdgeInsets.zero,
builder: (context) {
return MobileSelectOptionEditor(
cellController: bloc.cellController,

View File

@ -25,7 +25,6 @@ class MobileRowDetailChecklistCellSkin extends IEditableChecklistCellSkin {
borderRadius: const BorderRadius.all(Radius.circular(14)),
onTap: () => showMobileBottomSheet(
context,
padding: EdgeInsets.zero,
backgroundColor: Theme.of(context).colorScheme.background,
builder: (context) {
return BlocProvider.value(

View File

@ -27,7 +27,6 @@ class MobileRowDetailDateCellSkin extends IEditableDateCellSkin {
borderRadius: const BorderRadius.all(Radius.circular(14)),
onTap: () => showMobileBottomSheet(
context,
padding: EdgeInsets.zero,
builder: (context) {
return MobileDateCellEditScreen(
controller: bloc.cellController,

View File

@ -27,7 +27,6 @@ class MobileRowDetailSelectOptionCellSkin
borderRadius: const BorderRadius.all(Radius.circular(14)),
onTap: () => showMobileBottomSheet(
context,
padding: EdgeInsets.zero,
builder: (context) {
return MobileSelectOptionEditor(
cellController: bloc.cellController,

View File

@ -33,7 +33,7 @@ class _MobileChecklistCellEditScreenState
return Column(
mainAxisSize: MainAxisSize.min,
children: [
const DragHandler(),
const DragHandle(),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: _buildHeader(context),

View File

@ -61,7 +61,7 @@ class _MobileSelectOptionEditorState extends State<MobileSelectOptionEditor> {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
const DragHandler(),
const DragHandle(),
_buildHeader(context),
const Divider(height: 0.5),
Expanded(

View File

@ -60,7 +60,6 @@ class MobileDatabaseControls extends StatelessWidget {
icon: FlowySvgs.m_field_hide_s,
onTap: () => showMobileBottomSheet(
context,
resizeToAvoidBottomInset: false,
showDragHandle: true,
showHeader: true,
showBackButton: true,

View File

@ -163,7 +163,6 @@ class _MentionDateBlockState extends State<MentionDateBlock> {
if (PlatformExtension.isMobile) {
showMobileBottomSheet(
context,
resizeToAvoidBottomInset: false,
builder: (_) => DraggableScrollableSheet(
expand: false,
snap: true,
@ -178,7 +177,7 @@ class _MentionDateBlockState extends State<MentionDateBlock> {
children: [
ColoredBox(
color: Theme.of(context).colorScheme.surface,
child: const Center(child: DragHandler()),
child: const Center(child: DragHandle()),
),
const MobileDateHeader(),
MobileAppFlowyDatePicker(

View File

@ -214,7 +214,6 @@ class _ReminderSelector extends StatelessWidget {
),
onTap: () => showMobileBottomSheet(
context,
padding: EdgeInsets.zero,
builder: (_) => DraggableScrollableSheet(
expand: false,
snap: true,
@ -224,7 +223,7 @@ class _ReminderSelector extends StatelessWidget {
children: [
ColoredBox(
color: Theme.of(context).colorScheme.surface,
child: const Center(child: DragHandler()),
child: const Center(child: DragHandle()),
),
const _ReminderSelectHeader(),
Flexible(