Skip to content

Commit

Permalink
chore: Tweak the visual effect of AxReveal
Browse files Browse the repository at this point in the history
  • Loading branch information
Losses committed Nov 25, 2024
1 parent 1f1b350 commit 03eead4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
9 changes: 7 additions & 2 deletions lib/widgets/ax_reveal/utils/reveal_config.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import 'package:fluent_ui/fluent_ui.dart';

enum AxRevealPressAnimationFillMode {
normal,
constrained,
}

class RevealConfig {
final Color borderColor;
final Color hoverLightColor;
Expand All @@ -12,7 +17,7 @@ class RevealConfig {
final bool hoverLight;
final bool diffuse;
final bool pressAnimation;
final String pressAnimationFillMode;
final AxRevealPressAnimationFillMode pressAnimationFillMode;

const RevealConfig({
this.borderColor = Colors.white,
Expand All @@ -26,6 +31,6 @@ class RevealConfig {
this.hoverLight = true,
this.diffuse = true,
this.pressAnimation = true,
this.pressAnimationFillMode = 'constrained',
this.pressAnimationFillMode = AxRevealPressAnimationFillMode.normal,
});
}
10 changes: 7 additions & 3 deletions lib/widgets/ax_reveal/utils/reveal_effect_painter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class RevealEffectPainter extends CustomPainter {
}

void _drawHoverLight(Canvas canvas, Size size, Path path) {
final radius = size.shortestSide * config.hoverLightFillRadius;
final radius = size.longestSide * config.hoverLightFillRadius;
final gradient = ui.Gradient.radial(
mousePosition!,
radius,
Expand Down Expand Up @@ -95,11 +95,15 @@ class RevealEffectPainter extends CustomPainter {
}

void _drawPressAnimation(Canvas canvas, Size size, Path path) {
final position = mouseReleased ? mouseDownPosition : mousePosition;
final position = mouseDownPosition;

if (position == null) return;

final radius = config.pressAnimationFillMode == 'constrained'
if (!mousePressed) return;
if (logicFrame == 0) return;

final radius = config.pressAnimationFillMode ==
AxRevealPressAnimationFillMode.constrained
? size.shortestSide
: size.longestSide;

Expand Down
23 changes: 16 additions & 7 deletions lib/widgets/track_list/large_screen_track_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import '../../widgets/ax_pressure.dart';
import '../../widgets/smooth_horizontal_scroll.dart';
import '../../widgets/track_list/utils/internal_media_file.dart';

import '../collection_item.dart';
import '../ax_reveal/ax_reveal.dart';
import '../navigation_bar/page_content_frame.dart';
import '../start_screen/managed_start_screen_item.dart';

Expand All @@ -30,6 +32,8 @@ class LargeScreenTrackList extends StatelessWidget {

@override
Widget build(BuildContext context) {
final brightness = FluentTheme.of(context).brightness;

return Padding(
padding: const EdgeInsets.symmetric(vertical: 12),
child: LayoutBuilder(
Expand Down Expand Up @@ -89,13 +93,18 @@ class LargeScreenTrackList extends StatelessWidget {
width: cellSize / ratio,
height: cellSize,
child: AxPressure(
child: LargeScreenTrackListItem(
index: index,
item: item,
queries: queries,
fallbackFileIds: fallbackFileIds,
coverArtPath: item.coverArtPath,
mode: mode,
child: AxReveal(
config: brightness == Brightness.dark
? defaultLightRevealConfig
: defaultDarkRevealConfig,
child: LargeScreenTrackListItem(
index: index,
item: item,
queries: queries,
fallbackFileIds: fallbackFileIds,
coverArtPath: item.coverArtPath,
mode: mode,
),
),
),
);
Expand Down

0 comments on commit 03eead4

Please sign in to comment.