Skip to content

Commit

Permalink
feat: Adding basic navigation. #4
Browse files Browse the repository at this point in the history
  • Loading branch information
LuchoTurtle committed May 12, 2023
1 parent fdfec43 commit ff90bee
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/dynamic_menu.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:ui';

import 'package:app/pages.dart';
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';

Expand Down Expand Up @@ -163,6 +164,12 @@ class _MenuItemState extends State<MenuItem> {
child: ListTile(
contentPadding: EdgeInsets.only(left: widget.leftPadding),
leading: widget.info.getIcon(),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => DynamicMenuPage(menuItem: widget.info)),
);
},
title: Text(widget.info.title,
style: TextStyle(
fontSize: 25,
Expand Down
36 changes: 36 additions & 0 deletions lib/pages.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import 'package:app/settings.dart';
import 'package:flutter/material.dart';

import 'app_localization.dart';

const tourPageKey = Key("tour_page");
const settingsPageKey = Key("settings_page");
const dynamicMenuPageKey = Key("dynamic_menu_page");

class TourPage extends StatelessWidget {
const TourPage({super.key});
Expand Down Expand Up @@ -78,3 +80,37 @@ class SettingsPage extends StatelessWidget {
);
}
}

class DynamicMenuPage extends StatelessWidget {
final MenuItemInfo menuItem;

const DynamicMenuPage({super.key, required this.menuItem});

@override
Widget build(BuildContext context) {
return Scaffold(
key: dynamicMenuPageKey,
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
menuItem.title,
style: const TextStyle(fontSize: 30),
textAlign: TextAlign.center,
),
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: ElevatedButton(
onPressed: () {
Navigator.pop(context);
},
child: const Text('Go back'),
),
),
],
),
),
);
}
}

0 comments on commit ff90bee

Please sign in to comment.