Skip to content

Commit b45dad1

Browse files
committed
refactor(profile): use LinearGradient instead of ImageFilter
ImageFilter not worked as expected on paddings.
1 parent b25073e commit b45dad1

File tree

1 file changed

+18
-21
lines changed

1 file changed

+18
-21
lines changed

lib/features/profile/view/profile_page.dart

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import 'dart:math' as math;
2-
import 'dart:ui';
32

43
import 'package:dart_bbcode_web_colors/dart_bbcode_web_colors.dart';
54
import 'package:easy_refresh/easy_refresh.dart';
@@ -33,6 +32,7 @@ import 'package:tsdm_client/utils/show_dialog.dart';
3332
import 'package:tsdm_client/utils/show_toast.dart';
3433
import 'package:tsdm_client/widgets/attr_block.dart';
3534
import 'package:tsdm_client/widgets/cached_image/cached_image.dart';
35+
import 'package:tsdm_client/widgets/cached_image/cached_image_provider.dart';
3636
import 'package:tsdm_client/widgets/debounce_buttons.dart';
3737
import 'package:tsdm_client/widgets/heroes.dart';
3838
import 'package:tsdm_client/widgets/icon_chip.dart';
@@ -313,35 +313,32 @@ class _ProfilePageState extends State<ProfilePage> {
313313
minRadius: _appBarAvatarHeight / 2,
314314
),
315315
);
316-
317316
if (userProfile.avatarUrl != null) {
318317
flexSpace = Stack(
319318
// Disable clip, let profile avatar show outside the stack.
320319
clipBehavior: Clip.none,
321320
children: [
322321
// Background blurred image.
323322
Positioned.fill(
324-
// Why we can not add padding here?
325-
child: Column(
326-
children: [
327-
// The height of color box is decided by the sigma in image filtered.
328-
Container(
329-
color: Theme.of(context).colorScheme.surfaceContainerLowest,
330-
height: _appBarBackgroundTopPadding,
323+
child: Container(
324+
decoration: BoxDecoration(
325+
image: DecorationImage(
326+
image: CachedImageProvider(userProfile.avatarUrl!),
327+
fit: .fitWidth,
328+
isAntiAlias: true,
331329
),
332-
Expanded(
333-
child: Row(
334-
children: [
335-
Expanded(
336-
child: ImageFiltered(
337-
imageFilter: ImageFilter.blur(sigmaX: 16, sigmaY: 16),
338-
child: CachedImage(userProfile.avatarUrl!, fit: BoxFit.cover, enableAnimation: false),
339-
),
340-
),
341-
],
342-
),
330+
),
331+
foregroundDecoration: BoxDecoration(
332+
gradient: LinearGradient(
333+
colors: [
334+
Theme.of(context).colorScheme.surfaceContainerLowest.withValues(alpha: 0.6),
335+
Theme.of(context).colorScheme.surfaceContainerLowest,
336+
],
337+
begin: .topCenter,
338+
end: .bottomCenter,
339+
stops: const [0.0, 0.55],
343340
),
344-
],
341+
),
345342
),
346343
),
347344
// Background color under avatar, height is half of avatar height.

0 commit comments

Comments
 (0)