Change desktop version to use the original style of navigation, keep using drawer for mobile devices. Flutter is so cool!! :)
This commit is contained in:
parent
cc33458457
commit
d77e732551
@ -1,5 +1,6 @@
|
||||
// Flutter
|
||||
import 'package:flutter/material.dart';
|
||||
import 'dart:io';
|
||||
|
||||
// Local
|
||||
import '/pages/expense.dart';
|
||||
@ -67,12 +68,7 @@ class _HomePageState extends State<HomePage> {
|
||||
);
|
||||
}
|
||||
|
||||
return LayoutBuilder(builder: (context, constraints) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Expense Tracker"),
|
||||
),
|
||||
drawer: NavigationRail(
|
||||
Widget navigation = NavigationRail(
|
||||
extended: true,
|
||||
destinations: [
|
||||
NavigationRailDestination(
|
||||
@ -104,14 +100,39 @@ class _HomePageState extends State<HomePage> {
|
||||
onDestinationSelected: (value) {
|
||||
setState(() {
|
||||
pageSelected = value;
|
||||
if (Platform.isAndroid || Platform.isIOS) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
body: Container(
|
||||
);
|
||||
|
||||
Widget main = Container(
|
||||
color: Theme.of(context).colorScheme.primaryContainer,
|
||||
child: Center(child: page),
|
||||
);
|
||||
|
||||
Widget? drawer, body;
|
||||
if (Platform.isAndroid || Platform.isIOS) {
|
||||
drawer = navigation;
|
||||
body = main;
|
||||
} else {
|
||||
drawer = null;
|
||||
body = Row(
|
||||
children: [
|
||||
SafeArea(child: navigation),
|
||||
Expanded(child: main),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return LayoutBuilder(builder: (context, constraints) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Expense Tracker"),
|
||||
),
|
||||
drawer: drawer,
|
||||
body: body,
|
||||
floatingActionButton: floatingButton,
|
||||
);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user