logo
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
#![allow(unused_imports)]
use std::{marker::PhantomData, future::Future, time::Duration};

use crate::ui::VoidCallback;

use super::{RouteSettings, RoutePopDisposition};

// impl FutureExtensions<T> {
//     // Completely ignores this future and its result.
//     fn ignore();
    
//     // Handles errors on this future. 
//     onError<E extends Object>(FutureOr<T> handleError(E error, StackTrace stackTrace), {bool test(E error)?}) -> Future<T>    
// }

// located in scheduler
// Implemented Future<void> 
// Available Extensions FutureExtensions 
pub struct TickerFuture {
    // A future that resolves when this future resolves or throws when the ticker is canceled.
    // or_cancel: Box<dyn Future<Output = ()>, 
}

impl TickerFuture {
    // // Creates a Stream containing the result of this future.
    // fn as_stream() -> impl Stream<Output = ()> {
    //     todo!()
    // }
    
    // // Handles errors emitted by this Future.
    // fn catch_error(on_error: impl Fn(), test: impl Fn(Object) -> Option<bool>) -> impl Future<Output = ()> {
    //     todo!()
    // }
    
    // // Register callbacks to be called when this future completes.
    // fn then<R>(on_value: impl Fn(void value) -> FutureOr<R>, onError: Option<Function>) -> Future<R> {
    //     todo!()
    // }
    
    // // Time-out the future computation after timeLimit has passed.
    // fn timeout(time_limit: Duration, on_timeout: Option<impl Fn() -> FutureOr<Ouput = ()>>) -> Future<void> {
    //     todo!()
    // }
    
    // // Registers a function to be called when this future completes.
    // fn when_complete(action: impl Fn()) -> impl Future<Output = ()> {
    //     todo!()
    // }
    
    // Calls callback either when this future resolves or when the ticker is canceled. 
    fn when_complete_or_cancel(callback: VoidCallback) {
        todo!()
    }
}

// TODO: String generic should be fixed
pub trait Route {
    // When this route is popped (see Navigator.pop) if the result isn't specified or if it's null, this value will be used instead.
    // currentResult: T?
    
    // Whether there is at least one active route underneath this route.
    // hasActiveRouteBelow: bool
    
    // Whether this route is on the navigator.
    // isActive: bool

    // Whether this route is the top-most route on the navigator.
    // isCurrent: bool
    
    // Whether this route is the bottom-most active route on the navigator.
    // isFirst: bool
    
    // The navigator that the route is in, if any.
    // navigator: NavigatorState?
    
    // The overlay entries of this route.
    // overlayEntries: List<OverlayEntry>
    
    // A future that completes when this route is popped off the navigator.
    // popped: Future<T?>
    
    // The restoration scope ID to be used for the RestorationScope surrounding this route.
    // restorationScopeId: ValueListenable<String?>
    
    // A representation of the runtime type of the object.
    // runtimeType: Type
    
    // The settings for this route.
    // settings: RouteSettings

    // Whether calling didPop would return false.
    // willHandlePopInternally: bool


    // Called whenever the Navigator has updated in some manner that might affect routes, to indicate that the route may wish to rebuild as well.
    fn changed_external_state(&self);

    // Called whenever the internal state of the route has changed.
    fn changed_internal_state(&self);

    // Called after install when the route is added to the navigator.
    fn did_add(&self);
    
    // This route's next route has changed to the given new route.
    fn did_change_next(&self, next_route: Option<Box<dyn Route>>);

    // This route's previous route has changed to the given new route.
    fn did_change_previous(&self, previous_route: Option<Box<dyn Route>>);

    // // The route was popped or is otherwise being removed somewhat gracefully.
    // fn did_complete<T>(&self, result: Option<T>);

    // // A request was made to pop this route. If the route can handle it internally 
    // // (e.g. because it has its own stack of internal state) then return false, 
    // // otherwise return true (by returning the value of calling super.didPop). 
    // // Returning false will prevent the default behavior of NavigatorState.pop.
    // fn did_pop<T>(&self, result: Option<T>) -> bool;

    // The given route, which was above this one, has been popped off the navigator.
    fn did_pop_next(&self, next_route: Box<dyn Route>);

    // Called after install when the route is pushed onto the navigator.
    fn did_push(&self) -> TickerFuture;
    
    // Called after install when the route replaced another in the navigator.
    fn did_replace(&self, old_route: Option<Box<dyn Route>>);

    // Discards any resources used by the object.
    fn dispose(&self);
    
    // Called when the route is inserted into the navigator.
    fn install(&self);
    
    // Returns whether calling Navigator.maybePop when this Route is current (isCurrent) should do anything.
    fn will_pop(&self) -> Box<dyn Future<Output = RoutePopDisposition>>;
}