mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-07-16 14:46:44 +02:00
Back button switches to apps + more haptics
This commit is contained in:
@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:obtainium/pages/add_app.dart';
|
import 'package:obtainium/pages/add_app.dart';
|
||||||
import 'package:obtainium/pages/apps.dart';
|
import 'package:obtainium/pages/apps.dart';
|
||||||
import 'package:obtainium/pages/settings.dart';
|
import 'package:obtainium/pages/settings.dart';
|
||||||
@ -20,22 +21,34 @@ class _HomePageState extends State<HomePage> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return WillPopScope(
|
||||||
appBar: AppBar(title: const Text('Obtainium')),
|
child: Scaffold(
|
||||||
body: pages.elementAt(selectedIndex),
|
appBar: AppBar(title: const Text('Obtainium')),
|
||||||
bottomNavigationBar: NavigationBar(
|
body: pages.elementAt(selectedIndex),
|
||||||
destinations: const [
|
bottomNavigationBar: NavigationBar(
|
||||||
NavigationDestination(icon: Icon(Icons.settings), label: 'Settings'),
|
destinations: const [
|
||||||
NavigationDestination(icon: Icon(Icons.apps), label: 'Apps'),
|
NavigationDestination(
|
||||||
NavigationDestination(icon: Icon(Icons.add), label: 'Add App'),
|
icon: Icon(Icons.settings), label: 'Settings'),
|
||||||
],
|
NavigationDestination(icon: Icon(Icons.apps), label: 'Apps'),
|
||||||
onDestinationSelected: (int index) {
|
NavigationDestination(icon: Icon(Icons.add), label: 'Add App'),
|
||||||
setState(() {
|
],
|
||||||
selectedIndex = index;
|
onDestinationSelected: (int index) {
|
||||||
});
|
HapticFeedback.lightImpact();
|
||||||
},
|
setState(() {
|
||||||
selectedIndex: selectedIndex,
|
selectedIndex = index;
|
||||||
),
|
});
|
||||||
);
|
},
|
||||||
|
selectedIndex: selectedIndex,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onWillPop: () async {
|
||||||
|
if (selectedIndex != 1) {
|
||||||
|
setState(() {
|
||||||
|
selectedIndex = 1;
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user