Skip to content

Commit

Permalink
feat: use EdgeInsetsDirectional instead of EdgeInsets (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
maelchiotti authored Apr 22, 2024
1 parent 35e2709 commit eb15557
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lib/pages/editor/editor_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class _EditorState extends ConsumerState<EditorPage> {
spellCheckConfiguration: SpellCheckConfiguration(
spellCheckService: DefaultSpellCheckService(),
),
padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewPadding.bottom),
padding: Paddings.custom.bottomSystemUi,
),
),
],
Expand Down
30 changes: 16 additions & 14 deletions lib/utils/constants/paddings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,35 @@ enum Paddings {
padding64(64),
;

double get bottomSystemUiPadding => MediaQuery.of(navigatorKey.currentContext!).padding.bottom;
double get _bottomSystemUiPadding => MediaQuery.of(navigatorKey.currentContext!).viewPadding.bottom;

EdgeInsets get zero => EdgeInsets.zero;
EdgeInsetsDirectional get zero => EdgeInsetsDirectional.zero;

EdgeInsets get all => EdgeInsets.all(_padding);
EdgeInsetsDirectional get all => EdgeInsetsDirectional.all(_padding);

EdgeInsets get horizontal => EdgeInsets.symmetric(horizontal: _padding);
EdgeInsetsDirectional get horizontal => EdgeInsetsDirectional.symmetric(horizontal: _padding);

EdgeInsets get vertical => EdgeInsets.symmetric(vertical: _padding);
EdgeInsetsDirectional get vertical => EdgeInsetsDirectional.symmetric(vertical: _padding);

EdgeInsets get left => EdgeInsets.only(left: _padding);
EdgeInsetsDirectional get left => EdgeInsetsDirectional.only(start: _padding);

EdgeInsets get right => EdgeInsets.only(right: _padding);
EdgeInsetsDirectional get right => EdgeInsetsDirectional.only(end: _padding);

EdgeInsets get top => EdgeInsets.only(top: _padding);
EdgeInsetsDirectional get top => EdgeInsetsDirectional.only(top: _padding);

EdgeInsets get bottom => EdgeInsets.only(bottom: _padding);
EdgeInsetsDirectional get bottom => EdgeInsetsDirectional.only(bottom: _padding);

EdgeInsets get bottomSystemUi => EdgeInsets.only(bottom: bottomSystemUiPadding);
EdgeInsetsDirectional get bottomSystemUi => EdgeInsetsDirectional.only(bottom: _bottomSystemUiPadding);

EdgeInsets get fab => EdgeInsets.only(bottom: bottomSystemUiPadding + kFloatingActionButtonMargin + 64);
EdgeInsetsDirectional get fab => EdgeInsetsDirectional.only(
bottom: _bottomSystemUiPadding + kFloatingActionButtonMargin + 64,
);

EdgeInsets get page => const EdgeInsets.all(16);
EdgeInsetsDirectional get page => const EdgeInsetsDirectional.all(16);

EdgeInsets get pageButBottom => const EdgeInsets.only(top: 16, left: 16, right: 16);
EdgeInsetsDirectional get pageButBottom => const EdgeInsetsDirectional.only(top: 16, start: 16, end: 16);

EdgeInsets get appBarActionsEnd => const EdgeInsets.only(right: 8);
EdgeInsetsDirectional get appBarActionsEnd => const EdgeInsetsDirectional.only(end: 8);

final double _padding;

Expand Down

0 comments on commit eb15557

Please sign in to comment.