Skip to content

Commit

Permalink
maybe this will fix
Browse files Browse the repository at this point in the history
  • Loading branch information
orl0pl committed Nov 24, 2023
1 parent 67c5a1a commit b0d3558
Showing 1 changed file with 64 additions and 66 deletions.
130 changes: 64 additions & 66 deletions lib/pages/home_page.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

// ignore-for-file: deprecated_member_use
import 'dart:io';

import 'package:flutter/material.dart';
Expand Down Expand Up @@ -48,74 +48,72 @@ class HomePage extends HookWidget {
return null;
}, [accStore.defaultInstanceHost]);

onWillPopHandler() {
if (currentTab.value == 0 && !snackBarShowing.value) {
// show snackbar warning
snackBarShowing.value = true;
ScaffoldMessenger.of(context)
.showSnackBar(const SnackBar(
content: Text('Tap back again to leave'),
))
.closed
.then(
(SnackBarClosedReason reason) => snackBarShowing.value = false);

return Future(() => false);
}
if (currentTab.value != 0) {
currentTab.value = 0;
return Future(() => false);
}

return Scaffold(
extendBody: true,
body: AppLinkHandler(Column(
children: [
Expanded(
child: WillPopScope(
onWillPop: () {
if (currentTab.value == 0 && !snackBarShowing.value) {
// show snackbar warning
snackBarShowing.value = true;
ScaffoldMessenger.of(context)
.showSnackBar(const SnackBar(
content: Text('Tap back again to leave'),
))
.closed
.then((SnackBarClosedReason reason) =>
snackBarShowing.value = false);
return Future(() => true);
}

return Future(() => false);
}
if (currentTab.value != 0) {
currentTab.value = 0;
return Future(() => false);
}
return Scaffold(
extendBody: true,
body: AppLinkHandler(Column(
children: [
Expanded(
child: WillPopScope(
onWillPop: onWillPopHandler,
child: IndexedStack(
index: currentTab.value,
children: pages,
)),
),
const SizedBox(height: kMinInteractiveDimension / 2),
],
)),
floatingActionButton: Platform.isAndroid ? const CreatePostFab() : null,
floatingActionButtonLocation: Platform.isAndroid
? FloatingActionButtonLocation.centerDocked
: null,
bottomNavigationBar: NavigationBar(
destinations: const [
NavigationDestination(icon: Icon(Icons.home), label: 'Home'),
NavigationDestination(icon: Icon(Icons.list), label: 'List'),
NavigationDestination(icon: Icon(Icons.search), label: 'Search'),
NavigationDestination(icon: Icon(Icons.person), label: 'Profile')
],
selectedIndex: currentTab.value,
onDestinationSelected: (int index) => {currentTab.value = index})

return Future(() => true);
},
child: IndexedStack(
index: currentTab.value,
children: pages,
)),
),
const SizedBox(height: kMinInteractiveDimension / 2),
],
)),
floatingActionButton: Platform.isAndroid ? const CreatePostFab() : null,
floatingActionButtonLocation:
Platform.isAndroid ? FloatingActionButtonLocation.centerDocked : null,
bottomNavigationBar: NavigationBar(destinations: const [
NavigationDestination(icon: Icon(Icons.home), label: 'Home'),
NavigationDestination(icon: Icon(Icons.list), label: 'List'),
NavigationDestination(icon: Icon(Icons.search), label: 'Search'),
NavigationDestination(icon: Icon(Icons.person), label: 'Profile')
],
selectedIndex: currentTab.value,
onDestinationSelected: (int index) => {
currentTab.value = index
}

)

// BottomAppBar(
// child: SizedBox(
// height: 60,
// child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceAround,
// children: [
// tabButton(Icons.home),
// tabButton(Icons.list),
// tabButton(Icons.add),
// tabButton(Icons.search),
// tabButton(Icons.person),
// ],
// ),
// ),
// ),
);
// BottomAppBar(
// child: SizedBox(
// height: 60,
// child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceAround,
// children: [
// tabButton(Icons.home),
// tabButton(Icons.list),
// tabButton(Icons.add),
// tabButton(Icons.search),
// tabButton(Icons.person),
// ],
// ),
// ),
// ),
);
}
}

0 comments on commit b0d3558

Please sign in to comment.