waft-winui 0.8.2

WinUI 3 controls and Fluent styling for the Waft UI framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
//! WinUI's page navigation: a page enters as a `Frame` shows it, with
//! `NavigationThemeTransition` and its default `EntranceNavigationTransitionInfo`, and the page
//! it covers leaves and returns with the same transition's other storyboards.
//!
//! The values are the ones `ThemeTransitions.cpp` registers for each navigation trigger:
//!
//! - the entering page (`NavigatingTo`) starts 140 effective pixels lower, stays fully
//!   transparent for 150 ms, then slides up over 300 ms on the cubic `(0.1, 0.9, 0.2, 1.0)`
//!   with its opacity switched on at 150 ms;
//! - the covered page (`NavigatingAway`) fades out over 150 ms on the cubic
//!   `(0.7, 0.0, 1.0, 0.5)`;
//! - the page revealed by a back (`BackNavigatingTo`) stays invisible for 150 ms, then fades in
//!   over 300 ms on `(0.1, 0.9, 0.2, 1.0)`;
//! - the page leaving by a back (`BackNavigatingAway`) slides down 140 pixels over 150 ms on
//!   `(0.7, 0.0, 1.0, 0.5)` and is hidden at the end.

use std::any::Any;
use std::time::Duration;

use waft_animation::{AnimationRef, AnimationStatus, Cubic, Curve};
use waft_embedder::{Color, Offset};
use waft_foundation::Ref;
use waft_scheduler::TickerFuture;
use waft_widgets::{
    AnimatedBuilder, AnyModalRoute, AnyPageRoute, AnyRoute, AnyTransitionRoute, BuildContext,
    DelegatedTransitionBuilder, IntoWidget, LocalHistoryRoute, LocalHistoryRouteData, ModalRoute,
    ModalRouteData, Opacity, OverlayEntry, OverlayRoute, OverlayRouteData, PageRoute,
    PageRouteData, PredictiveBackRoute, Route, RouteData, RoutePopDisposition, RouteResult,
    RouteSettingsRef, Semantics, Transform, TransitionRoute, TransitionRouteData, WidgetBuilder,
    WidgetRef,
};

/// A page in a Fluent app, entering and leaving with WinUI's `Frame` transition.
///
/// Shaped as `MaterialPageRoute` is: a [`PageRoute`] whose
/// [`build_transitions`](ModalRoute::build_transitions) plays WinUI's entrance for its own page
/// and its other storyboards for the page it covers or reveals.
///
/// By default, when the route is replaced, the previous route remains in memory. Set
/// [`maintain_state`](Self::maintain_state) to false to free its resources.
///
/// See also:
///
///  * [`WidgetsApp::page_route_builder`](waft_widgets::WidgetsApp::page_route_builder), which a
///    Fluent app points at this route.
///  * [`FluentApp`](crate::FluentApp), which builds its pages with it.
pub struct FluentPageRoute {
    route: RouteData,
    overlay_route: OverlayRouteData,
    transition_route: TransitionRouteData,
    local_history: LocalHistoryRouteData,
    modal_route: ModalRouteData,
    page_route: PageRouteData,
    /// Builds the page's content.
    pub builder: WidgetBuilder,
    maintain_state: bool,
    include_route_semantics: bool,
}

impl FluentPageRoute {
    /// How long a page takes to enter: the 150 ms the entrance stays still, then the 300 ms it
    /// slides up.
    pub const TRANSITION_DURATION: Duration = Duration::from_millis(450);

    /// How long a page takes to leave and the one beneath to return: the leaving page's 150 ms
    /// and the revealed page's 300 ms that follows it.
    pub const REVERSE_TRANSITION_DURATION: Duration = Duration::from_millis(450);

    /// How far below its place an entering page starts, in effective pixels.
    pub const TRANSLATION_OFFSET: f64 = 140.0;

    /// The 150 ms the entering page waits, and the covered page takes to fade, out of
    /// [`TRANSITION_DURATION`](Self::TRANSITION_DURATION).
    const OUT_DURATION: Duration = Duration::from_millis(150);

    /// The curve the entering page slides up on, and the revealed page fades in on.
    const IN_CURVE: Cubic = Cubic::new(0.1, 0.9, 0.2, 1.0);

    /// The curve the leaving and covered pages move on.
    const OUT_CURVE: Cubic = Cubic::new(0.7, 0.0, 1.0, 0.5);

    /// Creates a page route for `builder`'s page; Dart's optional arguments are the setters.
    ///
    /// Dart's defaults: `maintain_state` true, `fullscreen_dialog` false, `allow_snapshotting`
    /// true, `include_route_semantics` true, `barrier_dismissible` false.
    pub fn new(app: &mut waft_foundation::App, builder: WidgetBuilder) -> Ref<FluentPageRoute> {
        let route = RouteData::new(app, None, None);
        let transition_route = TransitionRouteData::new(app);
        let modal_route = ModalRouteData::new(app);
        let this = app.create(FluentPageRoute {
            route,
            overlay_route: OverlayRouteData::new(),
            transition_route,
            local_history: LocalHistoryRouteData::new(),
            modal_route,
            page_route: PageRouteData::new(),
            builder,
            maintain_state: true,
            include_route_semantics: true,
        });
        debug_assert!(TransitionRoute::opaque(this.handle(), app));
        this
    }

    /// The route `settings`, as Dart's `PageRoute` takes them.
    pub fn settings(
        self: Ref<Self>,
        app: &mut waft_foundation::App,
        settings: RouteSettingsRef,
    ) -> Ref<Self> {
        self.route_data_mut(app).set_settings(settings);
        self
    }

    /// Whether the route asks for focus when pushed, as Dart's `PageRoute` takes it.
    pub fn request_focus(
        self: Ref<Self>,
        app: &mut waft_foundation::App,
        request_focus: bool,
    ) -> Ref<Self> {
        self.route_data_mut(app)
            .set_request_focus(Some(request_focus));
        self
    }

    /// Dart `MaterialPageRoute(maintainState:)`.
    pub fn maintain_state(
        self: Ref<Self>,
        app: &mut waft_foundation::App,
        maintain_state: bool,
    ) -> Ref<Self> {
        app.get_mut(&self).maintain_state = maintain_state;
        self
    }

    /// Dart `MaterialPageRoute(fullscreenDialog:)`.
    pub fn fullscreen_dialog(
        self: Ref<Self>,
        app: &mut waft_foundation::App,
        fullscreen_dialog: bool,
    ) -> Ref<Self> {
        self.page_route_data_mut(app).fullscreen_dialog = fullscreen_dialog;
        self
    }

    /// Dart `MaterialPageRoute(allowSnapshotting:)`.
    pub fn allow_snapshotting(
        self: Ref<Self>,
        app: &mut waft_foundation::App,
        allow_snapshotting: bool,
    ) -> Ref<Self> {
        self.page_route_data_mut(app).allow_snapshotting = allow_snapshotting;
        self
    }

    /// Dart `MaterialPageRoute(includeRouteSemantics:)`.
    pub fn include_route_semantics(
        self: Ref<Self>,
        app: &mut waft_foundation::App,
        include: bool,
    ) -> Ref<Self> {
        app.get_mut(&self).include_route_semantics = include;
        self
    }

    /// Dart `MaterialPageRoute(barrierDismissible:)`.
    pub fn barrier_dismissible(
        self: Ref<Self>,
        app: &mut waft_foundation::App,
        dismissible: bool,
    ) -> Ref<Self> {
        self.page_route_data_mut(app).barrier_dismissible = dismissible;
        self
    }
}

impl Route for FluentPageRoute {
    waft_widgets::route_accessors!();

    fn as_transition_route(self: waft_foundation::Handle<Self>) -> Option<AnyTransitionRoute> {
        Some(TransitionRoute::as_transition_route(self))
    }

    fn as_modal_route(self: waft_foundation::Handle<Self>) -> Option<AnyModalRoute> {
        Some(ModalRoute::as_modal_route(self))
    }

    fn as_page_route(self: waft_foundation::Handle<Self>) -> Option<AnyPageRoute> {
        Some(PageRoute::as_page_route(self))
    }

    fn interface(
        self: waft_foundation::Handle<Self>,
        _id: std::any::TypeId,
    ) -> Option<Box<dyn Any>> {
        let _ = self;
        None
    }

    fn overlay_entries(
        self: waft_foundation::Handle<Self>,
        app: &waft_foundation::App,
    ) -> Vec<waft_foundation::Handle<OverlayEntry>> {
        OverlayRoute::overlay_entries(self, app)
    }

    fn install(self: waft_foundation::Handle<Self>, app: &mut waft_foundation::App) {
        ModalRoute::install(self, app)
    }

    fn did_push(
        self: waft_foundation::Handle<Self>,
        app: &mut waft_foundation::App,
    ) -> TickerFuture {
        ModalRoute::did_push(self, app)
    }

    fn did_add(self: waft_foundation::Handle<Self>, app: &mut waft_foundation::App) {
        ModalRoute::did_add(self, app)
    }

    fn did_replace(
        self: waft_foundation::Handle<Self>,
        app: &mut waft_foundation::App,
        old_route: Option<AnyRoute>,
    ) {
        TransitionRoute::did_replace(self, app, old_route)
    }

    fn will_pop(
        self: waft_foundation::Handle<Self>,
        app: &mut waft_foundation::App,
    ) -> RoutePopDisposition {
        LocalHistoryRoute::will_pop(self, app)
    }

    fn pop_disposition(
        self: waft_foundation::Handle<Self>,
        app: &mut waft_foundation::App,
    ) -> RoutePopDisposition {
        ModalRoute::pop_disposition(self, app)
    }

    fn on_pop_invoked_with_result(
        self: waft_foundation::Handle<Self>,
        app: &mut waft_foundation::App,
        did_pop: bool,
        result: RouteResult,
    ) {
        ModalRoute::on_pop_invoked_with_result(self, app, did_pop, result)
    }

    fn will_handle_pop_internally(
        self: waft_foundation::Handle<Self>,
        app: &waft_foundation::App,
    ) -> bool {
        LocalHistoryRoute::will_handle_pop_internally(self, app)
    }

    fn did_pop(
        self: waft_foundation::Handle<Self>,
        app: &mut waft_foundation::App,
        result: RouteResult,
    ) -> bool {
        LocalHistoryRoute::did_pop(self, app, result)
    }

    fn did_pop_next(
        self: waft_foundation::Handle<Self>,
        app: &mut waft_foundation::App,
        next_route: AnyRoute,
    ) {
        ModalRoute::did_pop_next(self, app, next_route)
    }

    fn did_change_next(
        self: waft_foundation::Handle<Self>,
        app: &mut waft_foundation::App,
        next_route: Option<AnyRoute>,
    ) {
        ModalRoute::did_change_next(self, app, next_route)
    }

    fn did_change_previous(
        self: waft_foundation::Handle<Self>,
        app: &mut waft_foundation::App,
        previous_route: Option<AnyRoute>,
    ) {
        ModalRoute::did_change_previous(self, app, previous_route)
    }

    fn changed_internal_state(self: waft_foundation::Handle<Self>, app: &mut waft_foundation::App) {
        ModalRoute::changed_internal_state(self, app)
    }

    fn changed_external_state(self: waft_foundation::Handle<Self>, app: &mut waft_foundation::App) {
        ModalRoute::changed_external_state(self, app)
    }

    fn dispose(self: waft_foundation::Handle<Self>, app: &mut waft_foundation::App) {
        TransitionRoute::dispose(self, app)
    }
}

impl OverlayRoute for FluentPageRoute {
    waft_widgets::modal_overlay_route_overrides!();
}

impl PredictiveBackRoute for FluentPageRoute {
    waft_widgets::page_predictive_back_route_overrides!();
}

impl TransitionRoute for FluentPageRoute {
    waft_widgets::modal_transition_route_overrides!();

    fn opaque(self: waft_foundation::Handle<Self>, app: &waft_foundation::App) -> bool {
        PageRoute::opaque(self, app)
    }

    fn allow_snapshotting(self: waft_foundation::Handle<Self>, app: &waft_foundation::App) -> bool {
        PageRoute::allow_snapshotting(self, app)
    }

    fn transition_duration(
        self: waft_foundation::Handle<Self>,
        _app: &mut waft_foundation::App,
    ) -> Duration {
        let _ = self;
        FluentPageRoute::TRANSITION_DURATION
    }

    fn reverse_transition_duration(
        self: waft_foundation::Handle<Self>,
        _app: &mut waft_foundation::App,
    ) -> Duration {
        let _ = self;
        FluentPageRoute::REVERSE_TRANSITION_DURATION
    }

    /// The page beneath runs its covered animation when another page enters on top of it.
    fn can_transition_to(
        self: waft_foundation::Handle<Self>,
        app: &waft_foundation::App,
        next_route: AnyTransitionRoute,
    ) -> bool {
        let next = next_route.as_route();
        match next.as_page_route(app) {
            Some(page) => !page.as_modal_route().fullscreen_dialog(app),
            None => false,
        }
    }

    /// A page revealed by a back fades in as the page above leaves.
    fn can_transition_from(
        self: waft_foundation::Handle<Self>,
        app: &waft_foundation::App,
        previous_route: AnyTransitionRoute,
    ) -> bool {
        previous_route.as_route().as_page_route(app).is_some()
            && !PageRoute::fullscreen_dialog(self, app)
    }
}

impl LocalHistoryRoute for FluentPageRoute {
    waft_widgets::local_history_route_accessors!();
}

impl ModalRoute for FluentPageRoute {
    waft_widgets::modal_route_accessors!();

    fn barrier_dismissible(
        self: waft_foundation::Handle<Self>,
        app: &waft_foundation::App,
    ) -> bool {
        PageRoute::barrier_dismissible(self, app)
    }

    fn barrier_color(
        self: waft_foundation::Handle<Self>,
        _app: &waft_foundation::App,
    ) -> Option<Color> {
        let _ = self;
        None
    }

    fn barrier_label(
        self: waft_foundation::Handle<Self>,
        _app: &waft_foundation::App,
    ) -> Option<String> {
        let _ = self;
        None
    }

    fn delegated_transition(
        self: waft_foundation::Handle<Self>,
        _app: &waft_foundation::App,
    ) -> Option<DelegatedTransitionBuilder> {
        let _ = self;
        None
    }

    fn maintain_state(self: waft_foundation::Handle<Self>, app: &waft_foundation::App) -> bool {
        app.get(self).maintain_state
    }

    fn fullscreen_dialog(self: waft_foundation::Handle<Self>, app: &waft_foundation::App) -> bool {
        PageRoute::fullscreen_dialog(self, app)
    }

    fn build_page(
        self: waft_foundation::Handle<Self>,
        app: &mut waft_foundation::App,
        context: BuildContext,
        animation: AnimationRef<f64>,
        secondary_animation: AnimationRef<f64>,
    ) -> WidgetRef {
        let _ = (animation, secondary_animation);
        let builder = std::rc::Rc::clone(&app.get(self).builder);
        let result = builder(app, context);
        if !app.get(self).include_route_semantics {
            return result;
        }
        Semantics::new()
            .scopes_route(true)
            .explicit_child_nodes(true)
            .child(result)
            .into_widget()
    }

    fn build_transitions(
        self: waft_foundation::Handle<Self>,
        app: &mut waft_foundation::App,
        _context: BuildContext,
        animation: AnimationRef<f64>,
        secondary_animation: AnimationRef<f64>,
        child: WidgetRef,
    ) -> WidgetRef {
        let _ = self;
        fluent_transitions(app, animation, secondary_animation, child)
    }
}

impl PageRoute for FluentPageRoute {
    waft_widgets::page_route_accessors!();
}

/// The entrance on the route's own animation and the covered page's fade on its secondary one.
fn fluent_transitions(
    _app: &mut waft_foundation::App,
    animation: AnimationRef<f64>,
    secondary_animation: AnimationRef<f64>,
    child: WidgetRef,
) -> WidgetRef {
    let primary: std::rc::Rc<dyn waft_foundation::Listenable> = std::rc::Rc::new(animation.clone());
    let secondary: std::rc::Rc<dyn waft_foundation::Listenable> =
        std::rc::Rc::new(secondary_animation.clone());
    let entering = AnimatedBuilder::new(primary, move |app, _context, child| {
        let (offset, opacity) = entrance(
            animation.value(app),
            animation.status(app) == AnimationStatus::Reverse,
        );
        let child = child
            .cloned()
            .unwrap_or_else(|| waft_widgets::SizedBox::shrink().into_widget());
        Opacity::new(opacity)
            .child(Transform::translate(Offset::new(0.0, offset)).child(child))
            .into_widget()
    })
    .child(child)
    .into_widget();
    AnimatedBuilder::new(secondary, move |app, _context, child| {
        let opacity = covered(
            secondary_animation.value(app),
            secondary_animation.status(app) == AnimationStatus::Reverse,
        );
        let child = child
            .cloned()
            .unwrap_or_else(|| waft_widgets::SizedBox::shrink().into_widget());
        Opacity::new(opacity).child(child).into_widget()
    })
    .child(entering)
    .into_widget()
}

/// How far down the page is and how visible, for `value` of its own animation: the entrance
/// while it runs forward, `BackNavigatingAway` while it reverses.
fn entrance(value: f64, reversing: bool) -> (f64, f64) {
    let duration = FluentPageRoute::TRANSITION_DURATION.as_secs_f64();
    let waited = FluentPageRoute::OUT_DURATION.as_secs_f64();
    if reversing {
        // The leaving page is away after 150 ms of the 450 ms a back takes; the rest of the
        // time belongs to the page being revealed.
        let elapsed = (1.0 - value) * duration;
        let progress = if elapsed >= waited {
            1.0
        } else {
            elapsed / waited
        };
        (
            FluentPageRoute::TRANSLATION_OFFSET * FluentPageRoute::OUT_CURVE.transform(progress),
            if progress < 1.0 { 1.0 } else { 0.0 },
        )
    } else {
        let elapsed = value * duration;
        let progress = ((elapsed - waited) / (duration - waited)).clamp(0.0, 1.0);
        (
            FluentPageRoute::TRANSLATION_OFFSET
                * (1.0 - FluentPageRoute::IN_CURVE.transform(progress)),
            if elapsed >= waited { 1.0 } else { 0.0 },
        )
    }
}

/// How visible the page is when it is covered, for `value` of its secondary animation: fading
/// out over 150 ms as a page enters, and from 150 ms into a back, fading in over 300 ms.
fn covered(value: f64, reversing: bool) -> f64 {
    let duration = FluentPageRoute::TRANSITION_DURATION.as_secs_f64();
    let waited = FluentPageRoute::OUT_DURATION.as_secs_f64();
    if reversing {
        let elapsed = (1.0 - value) * duration;
        if elapsed < waited {
            0.0
        } else if elapsed >= duration {
            1.0
        } else {
            FluentPageRoute::IN_CURVE.transform((elapsed - waited) / (duration - waited))
        }
    } else {
        let elapsed = (value * duration).min(waited);
        let progress = (elapsed / waited).clamp(0.0, 1.0);
        1.0 - FluentPageRoute::OUT_CURVE.transform(progress)
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn the_entrance_waits_150_ms_invisible_140_pixels_low_then_slides_up() {
        let at = |ms: f64| entrance(ms / 450.0, false);
        assert_eq!(at(0.0), (140.0, 0.0));
        assert_eq!(at(149.0), (140.0, 0.0), "still waiting");
        assert_eq!(at(150.0), (140.0, 1.0), "the opacity keyframe at 150 ms");
        let (offset, opacity) = at(300.0);
        assert!(opacity == 1.0, "visible once the slide starts");
        assert!(
            offset > 0.0 && offset < 140.0,
            "already moving up: {offset}"
        );
        assert_eq!(at(450.0), (0.0, 1.0));
    }

    #[test]
    fn leaving_slides_down_over_150_ms_and_the_rest_of_the_back_belongs_to_the_page_below() {
        let at = |ms: f64| entrance(1.0 - ms / 450.0, true);
        assert_eq!(at(0.0), (0.0, 1.0));
        let (offset, opacity) = at(75.0);
        assert!(offset > 0.0 && offset < 140.0, "moving down: {offset}");
        assert_eq!(opacity, 1.0);
        assert_eq!(at(151.0), (140.0, 0.0));
        assert_eq!(at(450.0), (140.0, 0.0), "away while the page below returns");
    }

    #[test]
    fn a_covered_page_fades_out_in_150_ms() {
        assert_eq!(covered(0.0, false), 1.0);
        assert!(covered(75.0 / 450.0, false) > 0.0);
        assert_eq!(covered(150.0 / 450.0, false), 0.0);
        assert_eq!(covered(1.0, false), 0.0);
    }

    #[test]
    fn a_page_revealed_by_a_back_fades_in_after_150_ms() {
        let at = |ms: f64| covered(1.0 - ms / 450.0, true);
        assert_eq!(at(0.0), 0.0, "still covered at the start");
        assert_eq!(at(150.0), 0.0, "invisible until 150 ms");
        let middle = at(300.0);
        assert!(middle > 0.0 && middle < 1.0, "fading in: {middle}");
        assert_eq!(at(450.0), 1.0);
    }

    #[test]
    fn the_route_is_a_page_route_with_its_data() {
        let cell = waft_foundation::AppCell::new();
        let mut app = cell.borrow_mut();
        let route = FluentPageRoute::new(
            &mut app,
            std::rc::Rc::new(|_app, _context| waft_widgets::SizedBox::shrink().into_widget()),
        );
        let erased: waft_widgets::RouteRef = route.into_erased();
        assert!(erased.as_page_route(&app).is_some());
        assert!(erased.as_modal_route(&app).is_some());
        assert!(erased.as_transition_route(&app).is_some());
    }

    #[test]
    fn the_route_uses_winuis_durations() {
        assert_eq!(FluentPageRoute::TRANSITION_DURATION.as_millis(), 450);
        assert_eq!(
            FluentPageRoute::REVERSE_TRANSITION_DURATION.as_millis(),
            450
        );
        assert_eq!(FluentPageRoute::TRANSLATION_OFFSET, 140.0);
    }
}