From 511a19397427039d5b3fac3df361dfca48f64743 Mon Sep 17 00:00:00 2001 From: weilu Date: Tue, 21 Nov 2023 22:40:40 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8Dflutter=203.16.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/goods/page/goods_size_page.dart | 2 +- lib/order/page/order_track_page.dart | 3 --- lib/setting/provider/theme_provider.dart | 1 + lib/shop/page/freight_config_page.dart | 4 ++-- test/goods/goods_accessibility_test.dart | 7 +++++-- test/shop/shop_accessibility_test.dart | 7 +++++-- test/statistics/statistic_accessibility_test.dart | 7 +++++-- test_driver/setting/setting_test.dart | 4 ++-- 8 files changed, 21 insertions(+), 14 deletions(-) diff --git a/lib/goods/page/goods_size_page.dart b/lib/goods/page/goods_size_page.dart index 5c17a8553..3586ec453 100644 --- a/lib/goods/page/goods_size_page.dart +++ b/lib/goods/page/goods_size_page.dart @@ -187,7 +187,7 @@ class _GoodsSizePageState extends State { ) ], ), - Gaps.vGap16, + const Spacer(), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ diff --git a/lib/order/page/order_track_page.dart b/lib/order/page/order_track_page.dart index fdc03dc10..e662ca57e 100644 --- a/lib/order/page/order_track_page.dart +++ b/lib/order/page/order_track_page.dart @@ -39,8 +39,6 @@ class _OrderTrackPageState extends State { Stepper( physics: const BouncingScrollPhysics(), currentStep: 4 - 1, - // flutter 2.8.0以下使用: - // controlsBuilder: (_, {onStepContinue, onStepCancel}) { controlsBuilder: (_, __) { return Gaps.empty; //操作按钮置空 }, @@ -70,7 +68,6 @@ class _OrderTrackPageState extends State { ) : Theme.of(context).textTheme.titleSmall), content: const Text(''), isActive: index == 0, - // TODO(weilu): 这里的状态图标无法修改,暂时使用原生的。应该可以复制Step代码修改一下。 state: index == 0 ? StepState.complete : StepState.indexed, ); } diff --git a/lib/setting/provider/theme_provider.dart b/lib/setting/provider/theme_provider.dart index e53c1ba3e..83ec6f014 100644 --- a/lib/setting/provider/theme_provider.dart +++ b/lib/setting/provider/theme_provider.dart @@ -38,6 +38,7 @@ class ThemeProvider extends ChangeNotifier { ThemeData getTheme({bool isDarkMode = false}) { return ThemeData( + useMaterial3: false, primaryColor: isDarkMode ? Colours.dark_app_main : Colours.app_main, colorScheme: ColorScheme.fromSwatch().copyWith( brightness: isDarkMode ? Brightness.dark : Brightness.light, diff --git a/lib/shop/page/freight_config_page.dart b/lib/shop/page/freight_config_page.dart index 8830ea571..488753924 100644 --- a/lib/shop/page/freight_config_page.dart +++ b/lib/shop/page/freight_config_page.dart @@ -145,9 +145,9 @@ class _FreightConfigPageState extends State { const Text('元'), ], ), - Gaps.vGap15, + const Spacer(), Gaps.line, - Gaps.vGap15, + const Spacer(), Row( children: [ Semantics( diff --git a/test/goods/goods_accessibility_test.dart b/test/goods/goods_accessibility_test.dart index c34fc9eb6..74274a09d 100644 --- a/test/goods/goods_accessibility_test.dart +++ b/test/goods/goods_accessibility_test.dart @@ -4,6 +4,7 @@ import 'package:flutter_deer/goods/page/goods_page.dart'; import 'package:flutter_deer/goods/page/goods_search_page.dart'; import 'package:flutter_deer/goods/page/goods_size_edit_page.dart'; import 'package:flutter_deer/goods/page/goods_size_page.dart'; +import 'package:flutter_deer/setting/provider/theme_provider.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { @@ -16,11 +17,12 @@ void main() { map['goods_size_edit_page'] = const GoodsSizeEditPage(); group('goods => 检测页面可点击目标大小是否大于44 * 44', () { + final ThemeData themeData = ThemeProvider().getTheme(); map.forEach((name, page) { testWidgets(name, (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(MaterialApp(home: page)); + await tester.pumpWidget(MaterialApp(home: page, theme: themeData,)); if (name == 'goods_page') { // GoodsListPage 内有一个2秒的延时 await tester.pumpAndSettle(const Duration(seconds: 2)); @@ -32,11 +34,12 @@ void main() { }); group('goods => 检测页面可点击目标是否都有语义', () { + final ThemeData themeData = ThemeProvider().getTheme(); map.forEach((name, page) { testWidgets(name, (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(MaterialApp(home: page)); + await tester.pumpWidget(MaterialApp(home: page, theme: themeData,)); if (name == 'goods_page') { await tester.pumpAndSettle(const Duration(seconds: 2)); } diff --git a/test/shop/shop_accessibility_test.dart b/test/shop/shop_accessibility_test.dart index 30665853a..ce2886333 100644 --- a/test/shop/shop_accessibility_test.dart +++ b/test/shop/shop_accessibility_test.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter_deer/setting/provider/theme_provider.dart'; import 'package:flutter_deer/shop/page/freight_config_page.dart'; import 'package:flutter_deer/shop/page/input_text_page.dart'; import 'package:flutter_deer/shop/page/message_page.dart'; @@ -18,10 +19,11 @@ void main() { map['freight_config_page'] = const FreightConfigPage(); group('shop => 检测页面可点击目标大小是否大于44 * 44', () { + final ThemeData themeData = ThemeProvider().getTheme(); map.forEach((name, page) { testWidgets(name, (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(MaterialApp(home: page)); + await tester.pumpWidget(MaterialApp(home: page, theme: themeData,)); await expectLater(tester, meetsGuideline(iOSTapTargetGuideline)); handle.dispose(); }, skip: name == 'select_address_page' || name == 'freight_config_page'); @@ -29,10 +31,11 @@ void main() { }); group('shop => 检测页面可点击目标是否都有语义', () { + final ThemeData themeData = ThemeProvider().getTheme(); map.forEach((name, page) { testWidgets(name, (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(MaterialApp(home: page)); + await tester.pumpWidget(MaterialApp(home: page, theme: themeData,)); await expectLater(tester, meetsGuideline(labeledTapTargetGuideline)); handle.dispose(); }); diff --git a/test/statistics/statistic_accessibility_test.dart b/test/statistics/statistic_accessibility_test.dart index d98cf7ea0..c2b51fed4 100644 --- a/test/statistics/statistic_accessibility_test.dart +++ b/test/statistics/statistic_accessibility_test.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter_deer/setting/provider/theme_provider.dart'; import 'package:flutter_deer/statistics/page/goods_statistics_page.dart'; import 'package:flutter_deer/statistics/page/order_statistics_page.dart'; import 'package:flutter_deer/statistics/page/statistics_page.dart'; @@ -12,10 +13,11 @@ void main() { map['goods_statistics_page'] = const GoodsStatisticsPage(); group('statistics => 检测页面可点击目标大小是否大于44 * 44', () { + final ThemeData themeData = ThemeProvider().getTheme(); map.forEach((name, page) { testWidgets(name, (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(MaterialApp(home: page)); + await tester.pumpWidget(MaterialApp(home: page, theme: themeData,)); await expectLater(tester, meetsGuideline(iOSTapTargetGuideline)); handle.dispose(); }, skip: name == 'order_statistics_page'); @@ -23,10 +25,11 @@ void main() { }); group('statistics => 检测页面可点击目标是否都有语义', () { + final ThemeData themeData = ThemeProvider().getTheme(); map.forEach((name, page) { testWidgets(name, (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(MaterialApp(home: page)); + await tester.pumpWidget(MaterialApp(home: page, theme: themeData,)); await expectLater(tester, meetsGuideline(labeledTapTargetGuideline)); handle.dispose(); }); diff --git a/test_driver/setting/setting_test.dart b/test_driver/setting/setting_test.dart index 812c48c9e..206a04cfb 100644 --- a/test_driver/setting/setting_test.dart +++ b/test_driver/setting/setting_test.dart @@ -52,7 +52,7 @@ void main([List args = const []]) { await driver.tap(find.text('夜间模式')); await delayed(); await driver.tap(find.text('开启')); - await Future.delayed(const Duration(seconds: 2)); + await Future.delayed(const Duration(seconds: 4)); await driver.tap(find.byTooltip('Back')); await delayed(); // 查看效果 @@ -76,7 +76,7 @@ void main([List args = const []]) { await driver.tap(find.text('多语言')); await delayed(); await driver.tap(find.text('English')); - await Future.delayed(const Duration(seconds: 1)); + await Future.delayed(const Duration(seconds: 2)); await driver.tap(find.byTooltip('Back')); await delayed();