|
| 1 | +/// Sample page - Demonstrates AppBar-only navigation pattern. |
| 2 | +/// |
| 3 | +/// Copyright (C) 2026, Software Innovation Institute, ANU. |
| 4 | +/// |
| 5 | +/// Licensed under the MIT License (the "License"). |
| 6 | +/// |
| 7 | +/// License: https://choosealicense.com/licenses/mit/. |
| 8 | +// |
| 9 | +// Permission is hereby granted, free of charge, to any person obtaining a copy |
| 10 | +// of this software and associated documentation files (the "Software"), to deal |
| 11 | +// in the Software without restriction, including without limitation the rights |
| 12 | +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 13 | +// copies of the Software, and to permit persons to whom the Software is |
| 14 | +// furnished to do so, subject to the following conditions: |
| 15 | +// |
| 16 | +// The above copyright notice and this permission notice shall be included in |
| 17 | +// all copies or substantial portions of the Software. |
| 18 | +// |
| 19 | +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 20 | +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 21 | +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 22 | +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 23 | +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 24 | +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 25 | +// SOFTWARE. |
| 26 | +/// |
| 27 | +/// Authors: Tony Chen |
| 28 | +
|
| 29 | +library; |
| 30 | + |
| 31 | +import 'package:flutter/material.dart'; |
| 32 | + |
| 33 | +/// Sample page widget demonstrating AppBar-only navigation. |
| 34 | +
|
| 35 | +class SamplePage extends StatelessWidget { |
| 36 | + const SamplePage({super.key}); |
| 37 | + |
| 38 | + @override |
| 39 | + Widget build(BuildContext context) { |
| 40 | + final theme = Theme.of(context); |
| 41 | + |
| 42 | + return Center( |
| 43 | + child: Card( |
| 44 | + margin: const EdgeInsets.all(32.0), |
| 45 | + child: Padding( |
| 46 | + padding: const EdgeInsets.all(32.0), |
| 47 | + child: Column( |
| 48 | + mainAxisSize: MainAxisSize.min, |
| 49 | + children: [ |
| 50 | + Icon( |
| 51 | + Icons.article_outlined, |
| 52 | + size: 64, |
| 53 | + color: theme.colorScheme.primary, |
| 54 | + ), |
| 55 | + const SizedBox(height: 24), |
| 56 | + Text( |
| 57 | + 'Sample Page', |
| 58 | + style: theme.textTheme.headlineMedium?.copyWith( |
| 59 | + fontWeight: FontWeight.bold, |
| 60 | + ), |
| 61 | + ), |
| 62 | + const SizedBox(height: 16), |
| 63 | + Text( |
| 64 | + 'AppBar-Only Navigation Demo', |
| 65 | + style: theme.textTheme.titleMedium?.copyWith( |
| 66 | + color: theme.colorScheme.primary, |
| 67 | + ), |
| 68 | + ), |
| 69 | + const SizedBox(height: 32), |
| 70 | + Container( |
| 71 | + constraints: const BoxConstraints(maxWidth: 500), |
| 72 | + child: Text( |
| 73 | + 'The navigation buttons for this page are only placed on ' |
| 74 | + 'the app bar, so no buttons on the navigation rail will be ' |
| 75 | + 'highlighted when entering this page. In contrast, when ' |
| 76 | + 'the Files button on the app bar is clicked, the ' |
| 77 | + 'Files button on the navigation rail will be highlighted ' |
| 78 | + 'as well, since it is laid out in both places. This button ' |
| 79 | + 'also demonstrates the usage of the navigateToSubpage() ' |
| 80 | + 'function.', |
| 81 | + style: theme.textTheme.bodyLarge, |
| 82 | + textAlign: TextAlign.left, |
| 83 | + ), |
| 84 | + ), |
| 85 | + ], |
| 86 | + ), |
| 87 | + ), |
| 88 | + ), |
| 89 | + ); |
| 90 | + } |
| 91 | +} |
0 commit comments