mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: mobile view and field list bottom sheets (#4727)
This commit is contained in:
parent
c3e5aa29fc
commit
d861ce6227
@ -3,6 +3,25 @@ import 'package:appflowy/plugins/base/drag_handler.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';
|
||||||
|
|
||||||
|
extension BottomSheetPaddingExtension on BuildContext {
|
||||||
|
/// Calculates the total amount of space that should be added to the bottom of
|
||||||
|
/// a bottom sheet
|
||||||
|
double bottomSheetPadding({
|
||||||
|
bool ignoreViewPadding = true,
|
||||||
|
}) {
|
||||||
|
final viewPadding = MediaQuery.viewPaddingOf(this);
|
||||||
|
final viewInsets = MediaQuery.viewInsetsOf(this);
|
||||||
|
double bottom = 0.0;
|
||||||
|
if (!ignoreViewPadding) {
|
||||||
|
bottom += viewPadding.bottom;
|
||||||
|
}
|
||||||
|
// for screens with 0 view padding, add some even more space
|
||||||
|
bottom += viewPadding.bottom == 0 ? 28.0 : 16.0;
|
||||||
|
bottom += viewInsets.bottom;
|
||||||
|
return bottom;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<T?> showMobileBottomSheet<T>(
|
Future<T?> showMobileBottomSheet<T>(
|
||||||
BuildContext context, {
|
BuildContext context, {
|
||||||
required WidgetBuilder builder,
|
required WidgetBuilder builder,
|
||||||
@ -120,12 +139,11 @@ Future<T?> showMobileBottomSheet<T>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ----- content area -----
|
// ----- content area -----
|
||||||
// make sure the keyboard won't cover the content
|
// add content padding and extra bottom padding
|
||||||
children.add(
|
children.add(
|
||||||
Padding(
|
Padding(
|
||||||
padding: padding.copyWith(
|
padding:
|
||||||
bottom: padding.bottom + MediaQuery.of(context).viewInsets.bottom,
|
padding + EdgeInsets.only(bottom: context.bottomSheetPadding()),
|
||||||
),
|
|
||||||
child: child,
|
child: child,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -135,13 +153,6 @@ Future<T?> showMobileBottomSheet<T>(
|
|||||||
return children.first;
|
return children.first;
|
||||||
}
|
}
|
||||||
|
|
||||||
// add default padding
|
|
||||||
// for full screen bottom sheet, the padding should be 16.0
|
|
||||||
// for non full screen bottom sheet, the padding should be 28.0
|
|
||||||
children.add(
|
|
||||||
VSpace(MediaQuery.of(context).padding.bottom == 0 ? 28.0 : 16.0),
|
|
||||||
);
|
|
||||||
|
|
||||||
return useSafeArea
|
return useSafeArea
|
||||||
? SafeArea(
|
? SafeArea(
|
||||||
child: Column(
|
child: Column(
|
||||||
|
@ -2,6 +2,7 @@ import 'dart:ui';
|
|||||||
|
|
||||||
import 'package:appflowy/generated/flowy_svgs.g.dart';
|
import 'package:appflowy/generated/flowy_svgs.g.dart';
|
||||||
import 'package:appflowy/generated/locale_keys.g.dart';
|
import 'package:appflowy/generated/locale_keys.g.dart';
|
||||||
|
import 'package:appflowy/mobile/presentation/bottom_sheet/bottom_sheet.dart';
|
||||||
import 'package:appflowy/mobile/presentation/widgets/flowy_option_tile.dart';
|
import 'package:appflowy/mobile/presentation/widgets/flowy_option_tile.dart';
|
||||||
import 'package:appflowy/plugins/database/application/database_controller.dart';
|
import 'package:appflowy/plugins/database/application/database_controller.dart';
|
||||||
import 'package:appflowy/plugins/database/application/field/field_controller.dart';
|
import 'package:appflowy/plugins/database/application/field/field_controller.dart';
|
||||||
@ -61,6 +62,7 @@ class _MobileDatabaseFieldListBody extends StatelessWidget {
|
|||||||
if (state.fieldContexts.isEmpty) {
|
if (state.fieldContexts.isEmpty) {
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
}
|
}
|
||||||
|
|
||||||
final fields = [...state.fieldContexts];
|
final fields = [...state.fieldContexts];
|
||||||
final firstField = fields.removeAt(0);
|
final firstField = fields.removeAt(0);
|
||||||
final firstCell = DatabaseFieldListTile(
|
final firstCell = DatabaseFieldListTile(
|
||||||
@ -124,10 +126,16 @@ class _MobileDatabaseFieldListBody extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
_divider(),
|
_divider(),
|
||||||
_NewDatabaseFieldTile(viewId: viewId),
|
_NewDatabaseFieldTile(viewId: viewId),
|
||||||
const VSpace(24),
|
VSpace(
|
||||||
|
context.bottomSheetPadding(
|
||||||
|
ignoreViewPadding: false,
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
: const VSpace(24),
|
: VSpace(
|
||||||
|
context.bottomSheetPadding(ignoreViewPadding: false),
|
||||||
|
),
|
||||||
itemCount: cells.length,
|
itemCount: cells.length,
|
||||||
itemBuilder: (context, index) => cells[index],
|
itemBuilder: (context, index) => cells[index],
|
||||||
);
|
);
|
||||||
|
@ -44,8 +44,10 @@ class MobileDatabaseViewList extends StatelessWidget {
|
|||||||
useFilledDoneButton: false,
|
useFilledDoneButton: false,
|
||||||
onDone: (context) => Navigator.pop(context),
|
onDone: (context) => Navigator.pop(context),
|
||||||
),
|
),
|
||||||
SingleChildScrollView(
|
Expanded(
|
||||||
child: Column(
|
child: ListView(
|
||||||
|
shrinkWrap: true,
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
children: [
|
children: [
|
||||||
...views.mapIndexed(
|
...views.mapIndexed(
|
||||||
(index, view) => MobileDatabaseViewListButton(
|
(index, view) => MobileDatabaseViewListButton(
|
||||||
@ -55,6 +57,9 @@ class MobileDatabaseViewList extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
const VSpace(20),
|
const VSpace(20),
|
||||||
const MobileNewDatabaseViewButton(),
|
const MobileNewDatabaseViewButton(),
|
||||||
|
VSpace(
|
||||||
|
context.bottomSheetPadding(ignoreViewPadding: false),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -480,7 +480,11 @@ class _MoreOptionsState extends State<_MoreOptions> {
|
|||||||
Widget _buildDeleteButton(BuildContext context) {
|
Widget _buildDeleteButton(BuildContext context) {
|
||||||
return FlowyOptionTile.text(
|
return FlowyOptionTile.text(
|
||||||
text: LocaleKeys.button_delete.tr(),
|
text: LocaleKeys.button_delete.tr(),
|
||||||
leftIcon: const FlowySvg(FlowySvgs.m_delete_s),
|
textColor: Theme.of(context).colorScheme.error,
|
||||||
|
leftIcon: FlowySvg(
|
||||||
|
FlowySvgs.m_delete_s,
|
||||||
|
color: Theme.of(context).colorScheme.error,
|
||||||
|
),
|
||||||
onTap: widget.onDelete,
|
onTap: widget.onDelete,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user