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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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