fix(flutter): 放大透明播放按钮
This commit is contained in:
1 parent
02763c3dfb
commit
8013cc18ad
2 files changed
+17
-6
No files matched your search
@@ -4,6 +4,12 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
import '../../../core/theme/app_colors.dart';
|
import '../../../core/theme/app_colors.dart';
|
||||||
|
|
||||||
|
const double _toggleSize = 72;
|
||||||
|
const double _iconSize = 40;
|
||||||
|
const List<Shadow> _iconShadows = [
|
||||||
|
Shadow(color: Colors.black54, blurRadius: 12),
|
||||||
|
];
|
||||||
|
|
||||||
/// 首页沉浸流与全屏播放器共用的播放/暂停按钮。
|
/// 首页沉浸流与全屏播放器共用的播放/暂停按钮。
|
||||||
class PlayerCenterToggle extends StatelessWidget {
|
class PlayerCenterToggle extends StatelessWidget {
|
||||||
const PlayerCenterToggle({
|
const PlayerCenterToggle({
|
||||||
@@ -23,12 +29,13 @@ class PlayerCenterToggle extends StatelessWidget {
|
|||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: 52,
|
width: _toggleSize,
|
||||||
height: 52,
|
height: _toggleSize,
|
||||||
child: Icon(
|
child: Icon(
|
||||||
playing ? Icons.pause_rounded : Icons.play_arrow_rounded,
|
playing ? Icons.pause_rounded : Icons.play_arrow_rounded,
|
||||||
color: AppColors.onPrimary,
|
color: AppColors.onPrimary,
|
||||||
size: 26,
|
size: _iconSize,
|
||||||
|
shadows: _iconShadows,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ import 'package:fruitshorts/core/theme/app_colors.dart';
|
|||||||
import 'package:fruitshorts/pages/player/widgets/player_center_toggle.dart';
|
import 'package:fruitshorts/pages/player/widgets/player_center_toggle.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
testWidgets('should_use_one_shared_52px_center_toggle_style', (tester) async {
|
testWidgets('should_use_one_shared_72px_transparent_toggle_style', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
home: Scaffold(
|
home: Scaffold(
|
||||||
@@ -32,7 +34,7 @@ void main() {
|
|||||||
Key('test-center-toggle-a'),
|
Key('test-center-toggle-a'),
|
||||||
Key('player-play-toggle'),
|
Key('player-play-toggle'),
|
||||||
]) {
|
]) {
|
||||||
expect(tester.getSize(find.byKey(key)), const Size(52, 52));
|
expect(tester.getSize(find.byKey(key)), const Size(72, 72));
|
||||||
// 暂停按钮改为透明背景,容器已不再绘制任何底色或装饰。
|
// 暂停按钮改为透明背景,容器已不再绘制任何底色或装饰。
|
||||||
expect(
|
expect(
|
||||||
find.descendant(of: find.byKey(key), matching: find.byType(Container)),
|
find.descendant(of: find.byKey(key), matching: find.byType(Container)),
|
||||||
@@ -41,8 +43,10 @@ void main() {
|
|||||||
final icon = tester.widget<Icon>(
|
final icon = tester.widget<Icon>(
|
||||||
find.descendant(of: find.byKey(key), matching: find.byType(Icon)),
|
find.descendant(of: find.byKey(key), matching: find.byType(Icon)),
|
||||||
);
|
);
|
||||||
expect(icon.size, 26);
|
expect(icon.size, 40);
|
||||||
expect(icon.color, AppColors.onPrimary);
|
expect(icon.color, AppColors.onPrimary);
|
||||||
|
expect(icon.shadows, isNotNull);
|
||||||
|
expect(icon.shadows, isNotEmpty);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user