Line data Source code
1 : // ThemeExtension has no home outside material.dart on the supported SDKs.
2 : // ignore: deprecated_member_use
3 : import 'package:flutter/material.dart' show ThemeExtension;
4 : import 'package:theme_tailor_annotation/theme_tailor_annotation.dart';
5 :
6 : part 'foss_motion.tailor.dart';
7 :
8 : /// Animation durations. Gate any token-driven animation on
9 : /// `MediaQuery.disableAnimations` so reduced-motion users get no motion.
10 : ///
11 : /// Unlike the other bundles, durations are not eased across a theme transition
12 : /// (a cycle length has no meaningful midpoint), so they switch at once.
13 : ///
14 : /// ```dart
15 : /// const m = FossMotion.standard;
16 : /// AnimatedOpacity(duration: m.caretBlink, opacity: o, child: child);
17 : /// ```
18 : @TailorMixin(themeGetter: ThemeGetter.none)
19 : class FossMotion extends ThemeExtension<FossMotion>
20 : with _$FossMotionTailorMixin {
21 : /// Creates a motion scale. Prefer [standard] unless retheming.
22 4 : const FossMotion({
23 : required this.skeleton,
24 : required this.caretBlink,
25 : required this.spinner,
26 : required this.overlay,
27 : required this.drawer,
28 : required this.toast,
29 : required this.progress,
30 : });
31 :
32 : /// Skeleton shimmer cycle.
33 : @override
34 : final Duration skeleton;
35 :
36 : /// Text caret blink cycle.
37 : @override
38 : final Duration caretBlink;
39 :
40 : /// Loading spinner rotation cycle.
41 : @override
42 : final Duration spinner;
43 :
44 : /// Enter and exit of a modal overlay (dialog scrim, fade, and scale).
45 : @override
46 : final Duration overlay;
47 :
48 : /// Enter and exit slide of an edge drawer, longer than [overlay] to read as
49 : /// a panel travelling in from the edge.
50 : @override
51 : final Duration drawer;
52 :
53 : /// Enter and exit slide of a transient toast.
54 : @override
55 : final Duration toast;
56 :
57 : /// Width transition of a determinate progress fill as its value changes.
58 : @override
59 : final Duration progress;
60 :
61 : /// The default motion scale.
62 : static const standard = FossMotion(
63 : skeleton: Duration(seconds: 2),
64 : caretBlink: Duration(seconds: 1),
65 : spinner: Duration(milliseconds: 1000),
66 : overlay: Duration(milliseconds: 200),
67 : drawer: Duration(milliseconds: 450),
68 : toast: Duration(milliseconds: 500),
69 : progress: Duration(milliseconds: 500),
70 : );
71 : }
|