diff --git a/dev/a11y_assessments/lib/use_cases/app_bar.dart b/dev/a11y_assessments/lib/use_cases/app_bar.dart new file mode 100644 index 00000000000..aa7cd1d8ad9 --- /dev/null +++ b/dev/a11y_assessments/lib/use_cases/app_bar.dart @@ -0,0 +1,120 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +import 'use_cases.dart'; + +class AppBarUseCase extends UseCase { + @override + String get name => 'AppBar'; + + @override + String get route => '/app-bar'; + + @override + Widget build(BuildContext context) => const MainWidget(); +} + +class MainWidget extends StatefulWidget { + const MainWidget({super.key}); + + @override + State createState() => MainWidgetState(); +} + +class MainWidgetState extends State { + int currentIndex = 0; + + void _onChanged(int? value) { + setState(() { + currentIndex = value!; + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: [ + AppBar( + backgroundColor: Theme.of(context).colorScheme.inversePrimary, + title: Semantics(headingLevel: 1, child: const Text('AppBar')), + ), + AppBar( + backgroundColor: Theme.of(context).colorScheme.inversePrimary, + title: Semantics(headingLevel: 1, child: const Text('AppBar')), + actions: [ + IconButton( + icon: const Icon(Icons.add_alert), + tooltip: 'Show Snackbar', + onPressed: () { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('This is a snackbar'))); + }, + ), + IconButton( + icon: const Icon(Icons.navigate_next), + tooltip: 'Go to the next page', + onPressed: () { + Navigator.push(context, MaterialPageRoute( + builder: (BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: + Theme.of(context).colorScheme.inversePrimary, + title: Semantics(headingLevel: 1, child: const Text('Next Page')), + ), + body: const Center( + child: Text( + 'This is the next page', + style: TextStyle(fontSize: 24), + ), + ), + ); + }, + )); + }, + ), + ], + ), + AppBar( + backgroundColor: Theme.of(context).colorScheme.inversePrimary, + title: Semantics(headingLevel: 1, child: const Text('AppBar')), + actions: [ + TextButton( + onPressed: () {}, + child: const Text('Action 1'), + ), + TextButton( + onPressed: () {}, + child: const Text('Action 2'), + ), + ], + ), + ][currentIndex], + body: ListView( + children: [ + RadioListTile( + title: const Text('1. Simple app bar'), + value: 0, + groupValue: currentIndex, + onChanged: _onChanged, + ), + RadioListTile( + title: const Text('2. App bar with actions'), + value: 1, + groupValue: currentIndex, + onChanged: _onChanged, + ), + RadioListTile( + title: const Text('3. App bar with text buttons'), + value: 2, + groupValue: currentIndex, + onChanged: _onChanged, + ), + ], + ), + ); + } +} diff --git a/dev/a11y_assessments/lib/use_cases/tab_bar_view.dart b/dev/a11y_assessments/lib/use_cases/tab_bar_view.dart new file mode 100644 index 00000000000..ef71c0432f4 --- /dev/null +++ b/dev/a11y_assessments/lib/use_cases/tab_bar_view.dart @@ -0,0 +1,66 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +import 'use_cases.dart'; + +class TabBarViewUseCase extends UseCase { + + @override + String get name => 'TabBarView'; + + @override + String get route => '/tab-bar-view'; + + @override + Widget build(BuildContext context) => const TabBarViewExample(); +} + + +class TabBarViewExample extends StatelessWidget { + const TabBarViewExample({super.key}); + + @override + Widget build(BuildContext context) { + return DefaultTabController( + initialIndex: 1, + length: 3, + child: Scaffold( + appBar: AppBar( + title: Semantics(headingLevel: 1, child: const Text('TabBarView Sample')), + bottom: const TabBar( + tabs: [ + Tab( + icon: Icon(Icons.cloud_outlined), + text: 'Cloudy', + ), + Tab( + icon: Icon(Icons.beach_access_sharp), + text: 'Rainy', + ), + Tab( + icon: Icon(Icons.brightness_5_sharp), + text: 'Sunny', + ), + ], + ), + ), + body: const TabBarView( + children: [ + Center( + child: Text("It's cloudy here"), + ), + Center( + child: Text("It's rainy here"), + ), + Center( + child: Text("It's sunny here"), + ), + ], + ), + ), + ); + } +} diff --git a/dev/a11y_assessments/lib/use_cases/use_cases.dart b/dev/a11y_assessments/lib/use_cases/use_cases.dart index 28436d6d71a..449de4fad24 100644 --- a/dev/a11y_assessments/lib/use_cases/use_cases.dart +++ b/dev/a11y_assessments/lib/use_cases/use_cases.dart @@ -6,6 +6,7 @@ import 'package:flutter/widgets.dart'; import '../common/dynamic_title.dart'; import 'action_chip.dart'; +import 'app_bar.dart'; import 'auto_complete.dart'; import 'badge.dart'; import 'card.dart'; @@ -22,6 +23,7 @@ import 'radio_list_tile.dart'; import 'slider.dart'; import 'snack_bar.dart'; import 'switch_list_tile.dart'; +import 'tab_bar_view.dart'; import 'text_button.dart'; import 'text_field.dart'; import 'text_field_password.dart'; @@ -61,4 +63,6 @@ final List useCases = [ DrawerUseCase(), NavigationDrawerUseCase(), NavigationRailUseCase(), + AppBarUseCase(), + TabBarViewUseCase(), ]; diff --git a/dev/a11y_assessments/test/app_bar_test.dart b/dev/a11y_assessments/test/app_bar_test.dart new file mode 100644 index 00000000000..5e69b211980 --- /dev/null +++ b/dev/a11y_assessments/test/app_bar_test.dart @@ -0,0 +1,15 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:a11y_assessments/use_cases/app_bar.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'test_utils.dart'; + +void main() { + testWidgets('app bar can run', (WidgetTester tester) async { + await pumpsUseCase(tester, AppBarUseCase()); + expect(find.text('AppBar'), findsOneWidget); + }); +} diff --git a/dev/a11y_assessments/test/tab_bar_view_test.dart b/dev/a11y_assessments/test/tab_bar_view_test.dart new file mode 100644 index 00000000000..ad1f07f4aff --- /dev/null +++ b/dev/a11y_assessments/test/tab_bar_view_test.dart @@ -0,0 +1,16 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:a11y_assessments/use_cases/tab_bar_view.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'test_utils.dart'; + +void main() { + testWidgets('tab bar view can run', (WidgetTester tester) async { + await pumpsUseCase(tester, TabBarViewUseCase()); + expect(find.byType(TabBar), findsOneWidget); + }); +}