-
-
Notifications
You must be signed in to change notification settings - Fork 643
Expand file tree
/
Copy pathRNSTabsNavigationState.h
More file actions
128 lines (106 loc) · 4.15 KB
/
RNSTabsNavigationState.h
File metadata and controls
128 lines (106 loc) · 4.15 KB
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
#pragma once
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/**
* Origin (actor) that requested a tab transition. Mirrors the public `actionOrigin` event field.
*/
typedef NS_ENUM(NSInteger, RNSTabsActionOrigin) {
/**
* Direct native UI interaction (tab bar tap, drag-and-drop).
*/
RNSTabsActionOriginUser = 0,
/**
* JS-initiated request delivered via the `navStateRequest` prop.
*/
RNSTabsActionOriginProgrammaticJs,
/**
* Request initiated from the native side by some actor, e.g. a downstream
* library integrating directly against `RNSTabBarController`.
*/
RNSTabsActionOriginProgrammaticNative,
/**
* Platform side effect not attributable to an explicit actor — UIKit changed the selection
* as a side effect of another operation (e.g. More navigation controller disappearing during a
* horizontal size class transition on iPad).
*/
RNSTabsActionOriginImplicit,
};
/**
* Reason why a navigation state update was rejected by the container.
*/
typedef NS_ENUM(NSInteger, RNSTabsNavigationStateRejectionReason) {
/**
* The update's provenance is based on a stale state.
*/
RNSTabsNavigationStateRejectionReasonStale = 0,
/**
* The requested tab is already selected.
*/
RNSTabsNavigationStateRejectionReasonRepeated,
};
/**
* Describes navigation state of a tabs container.
*
* It holds information about key of a selected screen AND state provenance.
* The provenance describes *a history of the state*. Conceptually, the state with provenance `N + 1`
* MUST BE derived from state with provenance `N`.
*/
@interface RNSTabsNavigationState : NSObject
/**
* Screen key of the currently selected tab.
*/
@property (nonatomic, strong, readonly, nonnull) NSString *selectedScreenKey;
/**
* Monotonically increasing number describing the generation of this state instance.
* Used for stale update detection.
*/
@property (nonatomic, readonly) int provenance;
- (instancetype)initWithSelectedScreenKey:(nonnull NSString *)selectedScreenKey provenance:(int)provenance;
- (instancetype)cloneState;
+ (instancetype)stateWithSelectedScreenKey:(nonnull NSString *)selectedScreenKey provenance:(int)provenance;
@end
/**
* A request to change navigation state.
*
* Carries the target `selectedScreenKey`, the `baseProvenance` of the state the request was derived from,
* and the `actionOrigin` (actor) that initiated it. Mirrors the public
* `TabsHostNavStateRequest` TS type plus an `actionOrigin` carried internally.
*/
@interface RNSTabsNavigationStateUpdateRequest : NSObject
@property (nonatomic, strong, readonly, nonnull) NSString *selectedScreenKey;
@property (nonatomic, readonly) int baseProvenance;
@property (nonatomic, readonly) RNSTabsActionOrigin actionOrigin;
- (instancetype)initWithSelectedScreenKey:(nonnull NSString *)selectedScreenKey
baseProvenance:(int)baseProvenance
actionOrigin:(RNSTabsActionOrigin)actionOrigin;
- (instancetype)cloneRequest;
+ (instancetype)requestWithSelectedScreenKey:(nonnull NSString *)selectedScreenKey
baseProvenance:(int)baseProvenance
actionOrigin:(RNSTabsActionOrigin)actionOrigin;
@end
/**
* Bundles a navigation state change together with metadata about the selection context.
*/
@interface RNSTabsNavigationStateUpdateContext : NSObject
/**
* The navigation state after the change.
*/
@property (nonatomic, readonly, strong, nonnull) RNSTabsNavigationState *navState;
/**
* Whether the same tab that was already selected has been selected again.
*/
@property (nonatomic, readonly) BOOL isRepeated;
/**
* Whether a special effect (e.g. scroll-to-top) was triggered by the selection.
*/
@property (nonatomic, readonly) BOOL hasTriggeredSpecialEffect;
/**
* Origin (actor) that requested this transition.
*/
@property (nonatomic, readonly) RNSTabsActionOrigin actionOrigin;
- (instancetype)initWithNavState:(nonnull RNSTabsNavigationState *)navState
isRepeated:(BOOL)isRepeated
hasTriggeredSpecialEffect:(BOOL)hasTriggeredSpecialEffect
actionOrigin:(RNSTabsActionOrigin)actionOrigin;
@end
NS_ASSUME_NONNULL_END