feat: add bottom navigation shell with study/manage/stats/account tabs

This commit is contained in:
pluv committed 2026-10-24 01:06:49 +08:00
1 parent 500c69bf33
commit 277ead9fe7
8 files changed
+247 -125

No files matched your search

+33 -19
View File
@@ -1,30 +1,44 @@
// This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility in the flutter_test package. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mobile/main.dart';
/// 在导航栏内按标签定位,避免和页面标题的相同文字混淆。
Finder navLabel(String label) {
return find.descendant(
of: find.byType(NavigationBar),
matching: find.text(label),
);
}
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const MyApp());
testWidgets('底部导航提供学习 / 管理 / 统计 / 账户四个入口', (WidgetTester tester) async {
await tester.pumpWidget(const KiriMemoApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
expect(find.byType(NavigationBar), findsOneWidget);
expect(find.byType(NavigationDestination), findsNWidgets(4));
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
for (final String label in <String>['学习', '管理', '统计', '账户']) {
expect(navLabel(label), findsOneWidget);
}
});
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
testWidgets('默认停留在学习页,点击其它入口会切换', (WidgetTester tester) async {
await tester.pumpWidget(const KiriMemoApp());
NavigationBar bar = tester.widget<NavigationBar>(find.byType(NavigationBar));
expect(bar.selectedIndex, 0);
await tester.tap(navLabel('统计'));
await tester.pumpAndSettle();
bar = tester.widget<NavigationBar>(find.byType(NavigationBar));
expect(bar.selectedIndex, 2);
await tester.tap(navLabel('账户'));
await tester.pumpAndSettle();
bar = tester.widget<NavigationBar>(find.byType(NavigationBar));
expect(bar.selectedIndex, 3);
});
}