Skip to content

Commit

Permalink
Web上ColorFilter使用优化
Browse files Browse the repository at this point in the history
  • Loading branch information
simplezhli committed Feb 25, 2021
1 parent 10aed83 commit 3afb0c3
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 30 deletions.
6 changes: 6 additions & 0 deletions doc/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log:

## 1.1.5

* Web支持基本完成。
* 迁移废弃的FlatButton为TextButton。
* 添加多语言切换。

## 1.1.4

* 添加navigator示例。
Expand Down
39 changes: 20 additions & 19 deletions integration_test/login_test.dart
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
import 'package:flutter/material.dart';
import 'package:flutter_deer/login/page/login_page.dart';
import 'package:flutter_deer/login/page/register_page.dart';
import 'package:flutter_deer/main.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';

import 'test_utils.dart';

/// flutter drive --driver integration_test/integration_test.dart --target integration_test/login_test.dart
void main() {

group('登录部分:', () {

setUpAll(() async {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

});
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

group('登录部分:', () {

tearDown(() {
print('< Success');
Expand All @@ -26,54 +22,59 @@ void main() {
await tester.pumpAndSettle();

await tester.tap(find.byKey(const Key('actionName')));
await delayed();
await tester.pumpAndSettle();
await tester.tap(find.byTooltip('Back'));
await delayed();
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('forgotPassword')));
await delayed();
await tester.pumpAndSettle();
await tester.tap(find.byTooltip('Back'));
await delayed();
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('noAccountRegister')));
});

testWidgets('注册页测试',(WidgetTester tester) async {
runApp(MyApp(home: RegisterPage()));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('getVerificationCode')));/// 无法成功触发事件,需要输入手机号
final Finder textField = find.byKey(const Key('phone'));
await tester.enterText(textField, '15000000000'); // 输入内容
await delayed();
await tester.pumpAndSettle();

await tester.tap(find.byKey(const Key('getVerificationCode')));

final Finder textField2 = find.byKey(const Key('vcode'));
await tester.enterText(textField2, '123456');
await delayed();
await tester.pumpAndSettle();

final Finder textField3 = find.byKey(const Key('password'));
await tester.enterText(textField3, '111111');
await delayed();
await tester.pumpAndSettle();

await tester.tap(find.byKey(const Key('register'))); // 点击注册

// 清除输入框文字
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('password_delete')));

await delayed();
await tester.pumpAndSettle();
await tester.tap(find.byTooltip('Back'));
}, timeout: const Timeout(Duration(seconds: 30)));

testWidgets('登录页测试',(WidgetTester tester) async {
runApp(MyApp(home: LoginPage()));
await tester.pumpAndSettle();
final Finder textField = find.byKey(const Key('phone'));
await tester.enterText(textField, '15000000000');
await delayed();
await tester.pumpAndSettle();
final Finder textField2 = find.byKey(const Key('password'));
await tester.enterText(textField2, '111111');
await delayed();
await tester.pumpAndSettle();
// 点击密码可见两次
await tester.tap(find.byKey(const Key('password_showPwd')));
await delayed();
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('password_showPwd')));
await delayed();
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('login'))); // 点击登录
}, timeout: const Timeout(Duration(seconds: 30)));
});
Expand Down
7 changes: 0 additions & 7 deletions integration_test/test_utils.dart

This file was deleted.

5 changes: 3 additions & 2 deletions lib/setting/page/setting_page.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import 'package:flutter_deer/demo/demo_page.dart';
import 'package:flutter_deer/util/device_utils.dart';
import 'package:sp_util/sp_util.dart';
import 'package:flutter/material.dart';
import 'package:flutter_deer/common/common.dart';
Expand Down Expand Up @@ -62,7 +63,7 @@ class _SettingPageState extends State<SettingPage> {
title: '账号管理',
onTap: () => NavigatorUtils.push(context, SettingRouter.accountManagerPage)
),
ClickItem(
if(Device.isMobile) ClickItem(
title: '清除缓存',
content: '23.5MB',
onTap: () {}
Expand All @@ -77,7 +78,7 @@ class _SettingPageState extends State<SettingPage> {
content: localeMode,
onTap: () => NavigatorUtils.push(context, SettingRouter.localePage)
),
ClickItem(
if(Device.isMobile) ClickItem(
title: '检查更新',
onTap: _showUpdateDialog,
),
Expand Down
7 changes: 6 additions & 1 deletion lib/widgets/selected_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ class SelectedImageState extends State<SelectedImage> {

@override
Widget build(BuildContext context) {
// color为null时,Web报错NoSuchMethodError: invalid member on null: 'red' (1.27.0-8.0.pre),因此这里指定色值。
final ColorFilter _colorFilter = ColorFilter.mode(
ThemeUtils.isDark(context) ? Colours.dark_unselected_item_color : Colours.text_gray,
BlendMode.srcIn
);
return Semantics(
label: '选择图片',
hint: '跳转相册选择图片',
Expand All @@ -67,7 +72,7 @@ class SelectedImageState extends State<SelectedImage> {
image: DecorationImage(
image: _imageProvider ?? ImageUtils.getAssetImage('store/icon_zj'),
fit: BoxFit.cover,
colorFilter: _imageProvider == null ? ColorFilter.mode(ThemeUtils.getDarkColor(context, Colours.dark_unselected_item_color), BlendMode.srcIn) : null
colorFilter: _imageProvider == null ? _colorFilter : null
),
),
),
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: flutter_deer
description: Flutter Deer

version: 1.1.4+15
version: 1.1.5+16
author: 唯鹿 <[email protected]>
homepage: https://weilu.blog.csdn.net/

Expand Down

0 comments on commit 3afb0c3

Please sign in to comment.