Skip to content

Commit

Permalink
move fab in container
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewwong525 committed Jun 18, 2023
1 parent dca3948 commit ba66ae8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion lib/screens/main/components/fn_bottom_app_bar.dart
@@ -1,3 +1,5 @@
import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

Expand All @@ -19,7 +21,7 @@ class FNBottomAppBar extends StatelessWidget {

@override
Widget build(BuildContext context) {
const height = (kIsWeb) ? 80.0 : 100.0;
var height = (!kIsWeb && Platform.isIOS) ? 100.0 : 80.0;
return AnimatedContainer(
duration: const Duration(milliseconds: 200),
height: isVisible ? height : 0,
Expand Down
3 changes: 3 additions & 0 deletions lib/screens/main/components/note_fab.dart
Expand Up @@ -4,15 +4,18 @@ class NoteFAB extends StatelessWidget {
const NoteFAB({
super.key,
required this.onPressed,
required this.isElevated,
});

final VoidCallback onPressed;
final bool isElevated;

@override
Widget build(BuildContext context) {
return FloatingActionButton(
child: const Icon(Icons.add),
onPressed: onPressed,
elevation: (isElevated) ? null : 0,
);
}
}
9 changes: 5 additions & 4 deletions lib/screens/main/main_screen.dart
Expand Up @@ -31,7 +31,7 @@ class _MainScreenState extends ConsumerState<MainScreen> {
final imagePicker = ImagePicker();
bool bottomAppBarVisible = true;
FloatingActionButtonLocation get _fabLocation => bottomAppBarVisible
? FloatingActionButtonLocation.endDocked
? FloatingActionButtonLocation.endContained
: FloatingActionButtonLocation.endFloat;
FocusNode searchFocusNode = FocusNode();
Widget? desktopSideWidget;
Expand Down Expand Up @@ -189,7 +189,7 @@ class _MainScreenState extends ConsumerState<MainScreen> {
closeDrawer: db.closeDrawer,
),
bottomNavigationBar: FNBottomAppBar(
isElevated: true,
isElevated: !bottomAppBarVisible,
isVisible: isMobile && bottomAppBarVisible,
onRecord: recordNote,
onAddChecklist: () {
Expand All @@ -198,8 +198,9 @@ class _MainScreenState extends ConsumerState<MainScreen> {
onImagePicker: onPickImageOption,
),
floatingActionButtonLocation: _fabLocation,
floatingActionButton:
(isMobile) ? NoteFAB(onPressed: addNote) : null,
floatingActionButton: (isMobile)
? NoteFAB(onPressed: addNote, isElevated: !bottomAppBarVisible)
: null,
body: SafeArea(
child: Responsive(
mobile: SearchScreen(
Expand Down

0 comments on commit ba66ae8

Please sign in to comment.