@apexnative/navigation 1.0.0-alpha.4 → 1.0.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -0
- package/README.md +1 -1
- package/android/CLAUDE.md +23 -14
- package/android/CORE.md +32 -19
- package/android/src/main/java/dev/apexnative/navigation/NavigationActivity.kt +60 -13
- package/android/src/main/java/dev/apexnative/navigation/options/AnimationsOptions.kt +2 -2
- package/android/src/main/java/dev/apexnative/navigation/options/BottomTabsOptions.kt +13 -8
- package/android/src/main/java/dev/apexnative/navigation/options/HardwareBackButtonOptions.kt +9 -1
- package/android/src/main/java/dev/apexnative/navigation/options/StackAnimationOptions.kt +40 -2
- package/android/src/main/java/dev/apexnative/navigation/react/CommandAnswer.kt +28 -13
- package/android/src/main/java/dev/apexnative/navigation/react/Hinge.kt +7 -4
- package/android/src/main/java/dev/apexnative/navigation/react/NavigationTurboModule.kt +3 -3
- package/android/src/main/java/dev/apexnative/navigation/react/ReactView.kt +39 -20
- package/android/src/main/java/dev/apexnative/navigation/react/ReloadCoordinator.kt +7 -6
- package/android/src/main/java/dev/apexnative/navigation/react/ScreenEnvironment.kt +177 -0
- package/android/src/main/java/dev/apexnative/navigation/react/ScreenRegions.kt +19 -51
- package/android/src/main/java/dev/apexnative/navigation/react/ScrollEvents.kt +49 -128
- package/android/src/main/java/dev/apexnative/navigation/react/events/AppearanceDispatcher.kt +30 -39
- package/android/src/main/java/dev/apexnative/navigation/react/events/EventEmitter.kt +34 -7
- package/android/src/main/java/dev/apexnative/navigation/react/events/NavigationState.kt +154 -0
- package/android/src/main/java/dev/apexnative/navigation/safearea/SafeAreaView.kt +12 -10
- package/android/src/main/java/dev/apexnative/navigation/slots/SlotScreenView.kt +12 -12
- package/android/src/main/java/dev/apexnative/navigation/utils/ViewExtensions.kt +0 -13
- package/android/src/main/java/dev/apexnative/navigation/viewcontrollers/arrangement/ArrangementController.kt +10 -7
- package/android/src/main/java/dev/apexnative/navigation/viewcontrollers/bottomtabs/BottomTabsCollapseBehavior.kt +5 -3
- package/android/src/main/java/dev/apexnative/navigation/viewcontrollers/bottomtabs/BottomTabsController.kt +22 -21
- package/android/src/main/java/dev/apexnative/navigation/viewcontrollers/bottomtabs/CustomTabRowGeometry.kt +22 -0
- package/android/src/main/java/dev/apexnative/navigation/viewcontrollers/bottomtabs/TabsRoom.kt +0 -5
- package/android/src/main/java/dev/apexnative/navigation/viewcontrollers/component/ComponentViewController.kt +12 -9
- package/android/src/main/java/dev/apexnative/navigation/viewcontrollers/component/ContentReadiness.kt +1 -1
- package/android/src/main/java/dev/apexnative/navigation/viewcontrollers/component/ScreenReadiness.kt +103 -56
- package/android/src/main/java/dev/apexnative/navigation/viewcontrollers/component/ScreenSafeArea.kt +29 -11
- package/android/src/main/java/dev/apexnative/navigation/viewcontrollers/externalcomponent/ExternalComponentViewController.kt +2 -6
- package/android/src/main/java/dev/apexnative/navigation/viewcontrollers/modal/ModalCoordinator.kt +20 -2
- package/android/src/main/java/dev/apexnative/navigation/viewcontrollers/modal/ModalSheet.kt +119 -8
- package/android/src/main/java/dev/apexnative/navigation/viewcontrollers/modal/ModalViews.kt +7 -0
- package/android/src/main/java/dev/apexnative/navigation/viewcontrollers/modal/SheetBack.kt +42 -0
- package/android/src/main/java/dev/apexnative/navigation/viewcontrollers/navigator/BackCallbackCheck.kt +50 -0
- package/android/src/main/java/dev/apexnative/navigation/viewcontrollers/navigator/BackCallbackState.kt +45 -14
- package/android/src/main/java/dev/apexnative/navigation/viewcontrollers/navigator/Navigator.kt +25 -5
- package/android/src/main/java/dev/apexnative/navigation/viewcontrollers/navigator/RootCoordinator.kt +2 -2
- package/android/src/main/java/dev/apexnative/navigation/viewcontrollers/parent/ParentController.kt +3 -6
- package/android/src/main/java/dev/apexnative/navigation/viewcontrollers/splitview/SplitViewController.kt +3 -0
- package/android/src/main/java/dev/apexnative/navigation/viewcontrollers/stack/PreparedFrame.kt +3 -3
- package/android/src/main/java/dev/apexnative/navigation/viewcontrollers/stack/StackCommands.kt +2 -2
- package/android/src/main/java/dev/apexnative/navigation/viewcontrollers/stack/StackController.kt +13 -5
- package/android/src/main/java/dev/apexnative/navigation/viewcontrollers/stack/StackViews.kt +3 -0
- package/android/src/main/java/dev/apexnative/navigation/viewcontrollers/stack/search/ScreenSearch.kt +3 -5
- package/android/src/main/java/dev/apexnative/navigation/viewcontrollers/stack/search/StackSearchPresenter.kt +2 -5
- package/android/src/main/java/dev/apexnative/navigation/viewcontrollers/stack/topbar/BarComponents.kt +5 -51
- package/android/src/main/java/dev/apexnative/navigation/viewcontrollers/stack/topbar/TopBarPresenter.kt +4 -9
- package/android/src/main/java/dev/apexnative/navigation/viewcontrollers/viewcontroller/ScrollEventListener.kt +6 -9
- package/android/src/main/java/dev/apexnative/navigation/views/animations/AnimationLayer.kt +73 -0
- package/android/src/main/java/dev/apexnative/navigation/views/animations/ValueInterpolation.kt +14 -0
- package/android/src/main/java/dev/apexnative/navigation/views/bottomtabs/BottomTabsLayout.kt +61 -2
- package/android/src/main/java/dev/apexnative/navigation/views/bottomtabs/CustomBottomTabItemView.kt +0 -5
- package/android/src/main/java/dev/apexnative/navigation/views/bottomtabs/CustomTabRow.kt +72 -10
- package/android/src/main/java/dev/apexnative/navigation/views/element/ElementTransitions.kt +9 -2
- package/android/src/main/java/dev/apexnative/navigation/views/element/animators/ElementPictures.kt +11 -0
- package/android/src/main/java/dev/apexnative/navigation/views/element/animators/FlightGeometry.kt +318 -25
- package/android/src/main/java/dev/apexnative/navigation/views/element/animators/ImageMatrixAnimator.kt +18 -20
- package/android/src/main/java/dev/apexnative/navigation/views/element/animators/PlainViewAnimator.kt +17 -25
- package/android/src/main/java/dev/apexnative/navigation/views/element/animators/ReactImageAnimator.kt +15 -22
- package/android/src/main/java/dev/apexnative/navigation/views/element/animators/SharedAnimatorFactory.kt +12 -9
- package/android/src/main/java/dev/apexnative/navigation/views/element/animators/TextChangeAnimator.kt +84 -35
- package/android/src/main/java/dev/apexnative/navigation/views/element/animators/ViewChangeAnimator.kt +49 -40
- package/cli/doctor/checks/splash.js +4 -22
- package/cli/splash/index.js +3 -1
- package/docs-md/architecture/transitions.md +4 -2
- package/docs-md/containers/modals.md +4 -2
- package/docs-md/containers/overlays.md +1 -1
- package/docs-md/containers/side-menu.md +1 -1
- package/docs-md/containers/tabs.md +2 -0
- package/docs-md/flows/bottom-sheets.md +1 -1
- package/docs-md/fundamentals/starting-the-app.md +1 -1
- package/docs-md/guides/cli.md +1 -2
- package/docs-md/help/glossary.md +2 -2
- package/docs-md/help/troubleshooting.md +23 -2
- package/docs-md/index.json +12 -0
- package/docs-md/migration/from-expo-router.md +1 -1
- package/docs-md/migration/from-react-native-navigation.md +1 -1
- package/docs-md/migration/from-react-navigation.md +2 -2
- package/docs-md/screen-ui/back-and-gestures.md +36 -0
- package/docs-md/screen-ui/bar-buttons.md +4 -4
- package/docs-md/screen-ui/search.md +1 -1
- package/docs-md/screen-ui/system-ui.md +16 -11
- package/docs-md/screen-ui/toolbar-and-fab.md +2 -2
- package/docs-md/screen-ui/top-bar.md +8 -4
- package/docs-md/start/installation.md +1 -1
- package/ios/Animations/ANNFrameDriver.mm +2 -0
- package/ios/Animations/Elements/ANNSharedElementFlight.mm +70 -4
- package/ios/Animations/Interpolators/ANNInterpolate.h +2 -30
- package/ios/Animations/Interpolators/ANNTransformParts.h +48 -0
- package/ios/Animations/Interpolators/ANNTransformParts.mm +507 -0
- package/ios/Animations/Interpolators/ANNViewTracks.h +6 -4
- package/ios/Animations/Interpolators/ANNViewTracks.mm +49 -9
- package/ios/CLAUDE.md +17 -15
- package/ios/CORE.md +30 -26
- package/ios/Contract/ANNCommandAnswer.h +9 -2
- package/ios/Contract/ANNCommandAnswer.mm +25 -12
- package/ios/Contract/ANNCommandRunner.h +8 -7
- package/ios/Contract/ANNCommandRunner.mm +21 -27
- package/ios/Contract/ANNLayoutNode.h +3 -3
- package/ios/Contract/ANNLayoutReader.h +3 -3
- package/ios/Core/ANNAppearanceDispatcher.h +5 -4
- package/ios/Core/ANNAppearanceDispatcher.mm +12 -1
- package/ios/Core/ANNJavaScriptCalls.h +11 -12
- package/ios/Core/ANNJavaScriptCalls.mm +7 -16
- package/ios/Core/ANNNavigationState.h +4 -6
- package/ios/Core/ANNNavigationState.mm +0 -4
- package/ios/Core/ANNReloadCoordinator.mm +4 -8
- package/ios/Core/ApexNavigation+Internal.h +1 -1
- package/ios/Layouts/Arrangement/ANNArrangementState.h +2 -17
- package/ios/Layouts/Arrangement/ANNArrangementState.mm +0 -38
- package/ios/Layouts/Arrangement/ANNArrangementViewController.mm +4 -4
- package/ios/Layouts/Root/ANNSplashViewController.h +5 -3
- package/ios/Layouts/Root/ANNSplashViewController.mm +147 -0
- package/ios/Layouts/Screen/ANNComponentViewController.h +2 -2
- package/ios/Layouts/Screen/ANNComponentViewController.mm +9 -22
- package/ios/Layouts/Screen/ANNPreviewInteraction.h +7 -4
- package/ios/Layouts/Screen/ANNPreviewInteraction.mm +72 -10
- package/ios/Layouts/Screen/ANNScreenEnvironment.h +63 -0
- package/ios/Layouts/Screen/ANNScreenEnvironment.mm +181 -0
- package/ios/Layouts/Screen/ANNScreenRegions.h +3 -18
- package/ios/Layouts/Screen/ANNScreenRegions.mm +0 -38
- package/ios/Layouts/Screen/ANNScreenSafeArea.h +4 -9
- package/ios/Layouts/Screen/ANNScreenSafeArea.mm +14 -16
- package/ios/Layouts/Stack/ANNPreviewPush.h +7 -6
- package/ios/Layouts/Stack/ANNPreviewPush.mm +142 -27
- package/ios/Layouts/Tabs/ANNBottomTabsAccessoryView.h +12 -1
- package/ios/Layouts/Tabs/ANNBottomTabsAccessoryView.mm +23 -0
- package/ios/Layouts/Tabs/ANNBottomTabsController.mm +2 -1
- package/ios/Layouts/Tabs/ANNBottomTabsCustomRow.mm +8 -3
- package/ios/Layouts/Tabs/ANNBottomTabsPresenter.h +4 -0
- package/ios/Layouts/Tabs/ANNBottomTabsPresenter.mm +123 -36
- package/ios/Layouts/Tabs/ANNTabsDesign.h +6 -5
- package/ios/Layouts/Tabs/ANNTabsDesign.mm +9 -1
- package/ios/Layouts/Tabs/UITabBar+utils.h +5 -5
- package/ios/Layouts/Tabs/UITabBar+utils.mm +32 -13
- package/ios/Options/ANNBottomTabsOptions.h +2 -0
- package/ios/Options/ANNBottomTabsOptions.mm +1 -0
- package/ios/Options/ANNOptions.h +18 -0
- package/ios/Options/ANNOptions.mm +112 -1
- package/ios/Options/ANNOptionsReader.mm +110 -0
- package/ios/Options/Params/ANNParam.h +15 -0
- package/ios/Options/Params/ANNParam.mm +61 -0
- package/ios/Options/Params/Color.h +3 -0
- package/ios/Options/Params/Color.mm +21 -0
- package/ios/Options/Params/Image.h +4 -0
- package/ios/Options/Params/Image.mm +20 -0
- package/ios/React/ANNReactView.mm +6 -25
- package/ios/React/ANNSafeAreaViewComponentView.mm +26 -15
- package/ios/React/ANNSurfaceHostingView.h +6 -0
- package/ios/React/ANNSurfaceHostingView.mm +116 -0
- package/ios/TopBar/ANNBackButtonPresenter.mm +6 -5
- package/ios/TopBar/ANNBarAppearance.h +2 -1
- package/ios/TopBar/ANNBarAppearance.mm +111 -30
- package/ios/TopBar/ANNBarBackgroundComponent.mm +16 -0
- package/ios/TopBar/ANNBarButtonComponentView.h +4 -4
- package/ios/TopBar/ANNBarButtonComponentView.mm +1 -1
- package/ios/TopBar/ANNBarButtons.h +5 -3
- package/ios/TopBar/ANNBarButtons.mm +186 -17
- package/ios/TopBar/ANNLargeTitlePresenter.mm +24 -4
- package/ios/TopBar/ANNMainList.h +3 -0
- package/ios/TopBar/ANNMainList.mm +4 -0
- package/ios/TopBar/ANNScrollEdgeEffects.h +22 -6
- package/ios/TopBar/ANNScrollEdgeEffects.mm +123 -16
- package/ios/TopBar/ANNSearchPresenter.mm +2 -2
- package/ios/TopBar/ANNSearchResultsViewController.mm +5 -5
- package/ios/TopBar/ANNTopBarPresenter.h +3 -2
- package/ios/TopBar/ANNTopBarPresenter.mm +95 -22
- package/ios/TurboModules/ANNTurboModule.mm +20 -16
- package/lib/module/ARCHITECTURE.md +8 -4
- package/lib/module/api/commands/commands.js +54 -6
- package/lib/module/api/commands/commands.js.map +1 -1
- package/lib/module/api/hooks/useSafeAreaInsets.js +4 -3
- package/lib/module/api/hooks/useSafeAreaInsets.js.map +1 -1
- package/lib/module/api/options/OptionsChain.js +2 -2
- package/lib/module/engine/commands.js +21 -1
- package/lib/module/engine/commands.js.map +1 -1
- package/lib/module/engine/places.js +8 -0
- package/lib/module/engine/places.js.map +1 -1
- package/lib/module/engine/screens.js +29 -4
- package/lib/module/engine/screens.js.map +1 -1
- package/lib/typescript/api/app/createNavigation.d.ts +3 -3
- package/lib/typescript/api/commands/commands.d.ts.map +1 -1
- package/lib/typescript/api/commands/presentation.d.ts +4 -3
- package/lib/typescript/api/commands/presentation.d.ts.map +1 -1
- package/lib/typescript/api/hooks/useSafeAreaInsets.d.ts +4 -3
- package/lib/typescript/api/hooks/useSafeAreaInsets.d.ts.map +1 -1
- package/lib/typescript/api/options/OptionsChain.d.ts +2 -2
- package/lib/typescript/engine/commands.d.ts.map +1 -1
- package/lib/typescript/engine/places.d.ts +2 -0
- package/lib/typescript/engine/places.d.ts.map +1 -1
- package/lib/typescript/engine/screens.d.ts +20 -6
- package/lib/typescript/engine/screens.d.ts.map +1 -1
- package/lib/typescript/interfaces/Options.d.ts +1 -1
- package/lib/typescript/interfaces/Options.d.ts.map +1 -1
- package/lib/typescript/interfaces/options/animations.d.ts +30 -9
- package/lib/typescript/interfaces/options/animations.d.ts.map +1 -1
- package/lib/typescript/interfaces/options/bottomTabs.d.ts +18 -5
- package/lib/typescript/interfaces/options/bottomTabs.d.ts.map +1 -1
- package/lib/typescript/interfaces/options/buttons.d.ts +8 -8
- package/lib/typescript/interfaces/options/stack.d.ts +9 -0
- package/lib/typescript/interfaces/options/stack.d.ts.map +1 -1
- package/lib/typescript/interfaces/options/system.d.ts +8 -5
- package/lib/typescript/interfaces/options/system.d.ts.map +1 -1
- package/lib/typescript/interfaces/options/toolbar.d.ts +2 -2
- package/lib/typescript/interfaces/options/topBar.d.ts +32 -29
- package/lib/typescript/interfaces/options/topBar.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/ARCHITECTURE.md +8 -4
- package/src/api/app/createNavigation.ts +3 -3
- package/src/api/commands/commands.ts +48 -7
- package/src/api/commands/presentation.ts +4 -3
- package/src/api/hooks/useSafeAreaInsets.ts +4 -3
- package/src/api/options/OptionsChain.ts +2 -2
- package/src/engine/commands.ts +30 -6
- package/src/engine/places.ts +9 -0
- package/src/engine/screens.tsx +29 -8
- package/src/interfaces/Options.ts +1 -0
- package/src/interfaces/options/animations.ts +31 -9
- package/src/interfaces/options/bottomTabs.ts +18 -5
- package/src/interfaces/options/buttons.ts +8 -8
- package/src/interfaces/options/stack.ts +9 -0
- package/src/interfaces/options/system.ts +8 -5
- package/src/interfaces/options/toolbar.ts +2 -2
- package/src/interfaces/options/topBar.ts +32 -29
- package/android/src/main/java/dev/apexnative/navigation/react/ArrangementStates.kt +0 -42
- package/android/src/main/java/dev/apexnative/navigation/react/ScreenInsets.kt +0 -70
- package/android/src/main/java/dev/apexnative/navigation/react/events/NavigationStateReporter.kt +0 -62
- package/android/src/main/java/dev/apexnative/navigation/react/events/StateHold.kt +0 -62
- package/android/src/main/java/dev/apexnative/navigation/viewcontrollers/bottomtabs/CustomTabRowPlacer.kt +0 -223
- package/ios/Layouts/Screen/ANNScreenInsets.h +0 -30
- package/ios/Layouts/Screen/ANNScreenInsets.mm +0 -70
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
#import "ANNBarAppearance.h"
|
|
2
2
|
#import "ANNBackButtonPresenter.h"
|
|
3
|
+
#import "ANNTabsDesign.h"
|
|
4
|
+
#import <objc/runtime.h>
|
|
5
|
+
|
|
6
|
+
// The icon an indicator was tinted from: an entry found by the icon's address counts only for that icon. An indicator
|
|
7
|
+
// that is the icon itself (already an original image) carries nothing: the icon must not hold itself, and it may be
|
|
8
|
+
// the image the options' cache keeps.
|
|
9
|
+
static const void *ANNIndicatorIconKey = &ANNIndicatorIconKey;
|
|
3
10
|
|
|
4
11
|
// UIKit's fonts of the places the options build over: the title of the row, the large title, the text of the back
|
|
5
12
|
// button.
|
|
@@ -28,6 +35,27 @@ static BOOL ANNIsClear(UIColor *color, UITraitCollection *traits) {
|
|
|
28
35
|
return CGColorGetAlpha([color resolvedColorWithTraitCollection:traits].CGColor) == 0;
|
|
29
36
|
}
|
|
30
37
|
|
|
38
|
+
// The images the looks are made of, by what they are drawn from, so a look filled again from the same options is
|
|
39
|
+
// equal to the one before (UIKit compares appearances by value, images by identity) and nothing is set again. Main
|
|
40
|
+
// queue; a memory warning empties it.
|
|
41
|
+
static NSCache<id, UIImage *> *ANNLookImages(void) {
|
|
42
|
+
static NSCache<id, UIImage *> *images;
|
|
43
|
+
static dispatch_once_t once;
|
|
44
|
+
dispatch_once(&once, ^{
|
|
45
|
+
images = [NSCache new];
|
|
46
|
+
images.countLimit = 64;
|
|
47
|
+
});
|
|
48
|
+
return images;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// A color of the options as a key: a pair by its sides (its dynamic color is made anew), else its value.
|
|
52
|
+
static NSArray *ANNColorKeyOf(Color *color) {
|
|
53
|
+
if (color.light || color.dark) {
|
|
54
|
+
return @[ color.light ?: NSNull.null, color.dark ?: NSNull.null ];
|
|
55
|
+
}
|
|
56
|
+
return @[ color.value ?: NSNull.null ];
|
|
57
|
+
}
|
|
58
|
+
|
|
31
59
|
static NSDictionary<NSAttributedStringKey, id> *ANNTextAttributes(ANNFontOptions *font,
|
|
32
60
|
Color *color,
|
|
33
61
|
UIFont *placeFont) {
|
|
@@ -104,16 +132,14 @@ static NSDictionary<NSAttributedStringKey, id> *ANNTextAttributes(ANNFontOptions
|
|
|
104
132
|
return resolved && !ANNIsClear(resolved, traits) ? resolved : nil;
|
|
105
133
|
}
|
|
106
134
|
|
|
135
|
+
// The glass bar is translucent by default; the design before iOS 26 (and its compatibility mode) opaque.
|
|
107
136
|
+ (BOOL)translucentByDefault {
|
|
108
|
-
|
|
109
|
-
return YES;
|
|
110
|
-
}
|
|
111
|
-
return NO;
|
|
137
|
+
return ANNTabsDesign.isGlass;
|
|
112
138
|
}
|
|
113
139
|
|
|
114
|
-
// `color` beats `blur` and `translucent`; a clear color is a clear bar. On iOS 26 a color is a solid
|
|
115
|
-
// with the color and a 1×1 image of it, without the system effect. `blur` is the system's chrome
|
|
116
|
-
// base, with no view of its own in the bar.
|
|
140
|
+
// `color` beats `blur` and `translucent`; a clear color is a clear bar. On the glass of iOS 26 a color is a solid
|
|
141
|
+
// bar: a clear base with the color and a 1×1 image of it, without the system effect. `blur` is the system's chrome
|
|
142
|
+
// material on a clear base, with no view of its own in the bar.
|
|
117
143
|
+ (void)configure:(UINavigationBarAppearance *)appearance
|
|
118
144
|
color:(UIColor *)color
|
|
119
145
|
blur:(BOOL)blur
|
|
@@ -124,7 +150,7 @@ static NSDictionary<NSAttributedStringKey, id> *ANNTextAttributes(ANNFontOptions
|
|
|
124
150
|
[appearance configureWithTransparentBackground];
|
|
125
151
|
return;
|
|
126
152
|
}
|
|
127
|
-
if (
|
|
153
|
+
if (ANNTabsDesign.isGlass) {
|
|
128
154
|
[appearance configureWithTransparentBackground];
|
|
129
155
|
appearance.backgroundEffect = nil;
|
|
130
156
|
appearance.backgroundColor = color;
|
|
@@ -219,23 +245,51 @@ static NSDictionary<NSAttributedStringKey, id> *ANNTextAttributes(ANNFontOptions
|
|
|
219
245
|
if (!color) {
|
|
220
246
|
return nil;
|
|
221
247
|
}
|
|
222
|
-
|
|
248
|
+
symbol = @"chevron.backward";
|
|
249
|
+
icon = [UIImage systemImageNamed:symbol];
|
|
223
250
|
isSymbol = YES;
|
|
224
251
|
}
|
|
252
|
+
// A symbol by its name; an image by its object, which the entry keeps, so its address is never another's.
|
|
253
|
+
id iconKey = isSymbol ? symbol : [NSValue valueWithNonretainedObject:icon];
|
|
254
|
+
NSArray *key = @[
|
|
255
|
+
@"back", iconKey, color ? ANNColorKeyOf(backButton.color) : NSNull.null
|
|
256
|
+
];
|
|
257
|
+
NSCache<id, UIImage *> *images = ANNLookImages();
|
|
258
|
+
UIImage *cached = [images objectForKey:key];
|
|
259
|
+
if (cached && (isSymbol || cached == icon ||
|
|
260
|
+
objc_getAssociatedObject(cached, ANNIndicatorIconKey) == icon)) {
|
|
261
|
+
return cached;
|
|
262
|
+
}
|
|
263
|
+
UIImage *indicator = nil;
|
|
225
264
|
if (color) {
|
|
226
|
-
|
|
265
|
+
indicator = [icon imageWithTintColor:color
|
|
266
|
+
renderingMode:UIImageRenderingModeAlwaysOriginal];
|
|
267
|
+
} else {
|
|
268
|
+
indicator =
|
|
269
|
+
isSymbol ? icon : [icon imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
|
|
270
|
+
}
|
|
271
|
+
if (!isSymbol && indicator != icon) {
|
|
272
|
+
objc_setAssociatedObject(indicator, ANNIndicatorIconKey, icon,
|
|
273
|
+
OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
|
227
274
|
}
|
|
228
|
-
|
|
275
|
+
[images setObject:indicator forKey:key];
|
|
276
|
+
return indicator;
|
|
229
277
|
}
|
|
230
278
|
|
|
279
|
+
// One for the app: every look that hides the arrow holds the same image.
|
|
231
280
|
+ (UIImage *)emptyIndicator {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
281
|
+
static UIImage *empty;
|
|
282
|
+
static dispatch_once_t once;
|
|
283
|
+
dispatch_once(&once, ^{
|
|
284
|
+
UIGraphicsImageRendererFormat *format = [UIGraphicsImageRendererFormat preferredFormat];
|
|
285
|
+
format.opaque = NO;
|
|
286
|
+
UIGraphicsImageRenderer *renderer =
|
|
287
|
+
[[UIGraphicsImageRenderer alloc] initWithSize:CGSizeMake(1, 1) format:format];
|
|
288
|
+
UIImage *drawn = [renderer imageWithActions:^(UIGraphicsImageRendererContext *context){
|
|
289
|
+
}];
|
|
290
|
+
empty = [drawn imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
|
|
291
|
+
});
|
|
292
|
+
return empty;
|
|
239
293
|
}
|
|
240
294
|
|
|
241
295
|
+ (UIColor *)pinnedTitleColor:(Color *)color traits:(UITraitCollection *)traits {
|
|
@@ -244,8 +298,44 @@ static NSDictionary<NSAttributedStringKey, id> *ANNTextAttributes(ANNFontOptions
|
|
|
244
298
|
}
|
|
245
299
|
|
|
246
300
|
// The 1×1 picture of the color in both styles: the bar's image view picks the variant of its own style, so a `{ light,
|
|
247
|
-
// dark }` color follows a switch of the style without a new appearance.
|
|
301
|
+
// dark }` color follows a switch of the style without a new appearance. Made once for the two resolved colors and the
|
|
302
|
+
// style picked.
|
|
248
303
|
+ (UIImage *)imageOfColor:(UIColor *)color traits:(UITraitCollection *)traits {
|
|
304
|
+
UITraitCollection *light =
|
|
305
|
+
[UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleLight];
|
|
306
|
+
UITraitCollection *dark =
|
|
307
|
+
[UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleDark];
|
|
308
|
+
// Each variant is drawn with the window's other traits (contrast, elevation) and registered by its style only.
|
|
309
|
+
NSArray<UITraitCollection *> *base = traits ? @[ traits ] : @[];
|
|
310
|
+
UITraitCollection *lightTraits = [UITraitCollection
|
|
311
|
+
traitCollectionWithTraitsFromCollections:[base arrayByAddingObject:light]];
|
|
312
|
+
UITraitCollection *darkTraits = [UITraitCollection
|
|
313
|
+
traitCollectionWithTraitsFromCollections:[base arrayByAddingObject:dark]];
|
|
314
|
+
UIColor *lightColor = [color resolvedColorWithTraitCollection:lightTraits];
|
|
315
|
+
UIColor *darkColor = [color resolvedColorWithTraitCollection:darkTraits];
|
|
316
|
+
BOOL isDark = traits.userInterfaceStyle == UIUserInterfaceStyleDark;
|
|
317
|
+
NSArray *key = @[ @"color", lightColor, darkColor, @(isDark) ];
|
|
318
|
+
NSCache<id, UIImage *> *images = ANNLookImages();
|
|
319
|
+
UIImage *cached = [images objectForKey:key];
|
|
320
|
+
if (cached) {
|
|
321
|
+
return cached;
|
|
322
|
+
}
|
|
323
|
+
UIImage *image = [self drawImageOf:color
|
|
324
|
+
light:light
|
|
325
|
+
dark:dark
|
|
326
|
+
lightTraits:lightTraits
|
|
327
|
+
darkTraits:darkTraits
|
|
328
|
+
isDark:isDark];
|
|
329
|
+
[images setObject:image forKey:key];
|
|
330
|
+
return image;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
+ (UIImage *)drawImageOf:(UIColor *)color
|
|
334
|
+
light:(UITraitCollection *)light
|
|
335
|
+
dark:(UITraitCollection *)dark
|
|
336
|
+
lightTraits:(UITraitCollection *)lightTraits
|
|
337
|
+
darkTraits:(UITraitCollection *)darkTraits
|
|
338
|
+
isDark:(BOOL)isDark {
|
|
249
339
|
UIImage * (^draw)(UITraitCollection *) = ^UIImage *(UITraitCollection *variant) {
|
|
250
340
|
UIColor *resolved = [color resolvedColorWithTraitCollection:variant];
|
|
251
341
|
UIGraphicsImageRendererFormat *format = [UIGraphicsImageRendererFormat preferredFormat];
|
|
@@ -257,20 +347,11 @@ static NSDictionary<NSAttributedStringKey, id> *ANNTextAttributes(ANNFontOptions
|
|
|
257
347
|
[context fillRect:CGRectMake(0, 0, 1, 1)];
|
|
258
348
|
}];
|
|
259
349
|
};
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
UITraitCollection *dark =
|
|
263
|
-
[UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleDark];
|
|
264
|
-
// Each variant is drawn with the window's other traits (contrast, elevation) and registered by its style only.
|
|
265
|
-
NSArray<UITraitCollection *> *base = traits ? @[ traits ] : @[];
|
|
266
|
-
UIImage *lightImage =
|
|
267
|
-
draw([UITraitCollection traitCollectionWithTraitsFromCollections:[base arrayByAddingObject:light]]);
|
|
268
|
-
UIImage *darkImage =
|
|
269
|
-
draw([UITraitCollection traitCollectionWithTraitsFromCollections:[base arrayByAddingObject:dark]]);
|
|
350
|
+
UIImage *lightImage = draw(lightTraits);
|
|
351
|
+
UIImage *darkImage = draw(darkTraits);
|
|
270
352
|
UIImageAsset *asset = [UIImageAsset new];
|
|
271
353
|
[asset registerImage:lightImage withTraitCollection:light];
|
|
272
354
|
[asset registerImage:darkImage withTraitCollection:dark];
|
|
273
|
-
BOOL isDark = traits.userInterfaceStyle == UIUserInterfaceStyleDark;
|
|
274
355
|
UIImage *picked = [asset imageWithTraitCollection:isDark ? dark : light];
|
|
275
356
|
return picked ?: (isDark ? darkImage : lightImage);
|
|
276
357
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#import "ANNBarBackgroundComponent.h"
|
|
2
|
+
#import <React/RCTLog.h>
|
|
2
3
|
#import <objc/runtime.h>
|
|
3
4
|
|
|
4
5
|
// The background a bar shows now.
|
|
@@ -13,6 +14,21 @@ static UIView *ANNBackgroundHostOf(UINavigationBar *bar) {
|
|
|
13
14
|
return subview;
|
|
14
15
|
}
|
|
15
16
|
}
|
|
17
|
+
#if DEBUG
|
|
18
|
+
// The name is UIKit's private one: a system that renames the view puts the components on the bar itself. Told
|
|
19
|
+
// once, in development, and only for a bar that has its views already (one not laid out yet has none).
|
|
20
|
+
static BOOL told = NO;
|
|
21
|
+
if (!told && bar.subviews.count > 0) {
|
|
22
|
+
told = YES;
|
|
23
|
+
NSMutableArray<NSString *> *names = [NSMutableArray new];
|
|
24
|
+
for (UIView *subview in bar.subviews) {
|
|
25
|
+
[names addObject:NSStringFromClass(subview.class)];
|
|
26
|
+
}
|
|
27
|
+
RCTLogWarn(@"[ApexNavigation] the bar has no view named …BarBackground, so a background "
|
|
28
|
+
@"component goes on the bar itself at index 1; its views: %@",
|
|
29
|
+
[names componentsJoinedByString:@", "]);
|
|
30
|
+
}
|
|
31
|
+
#endif
|
|
16
32
|
return bar;
|
|
17
33
|
}
|
|
18
34
|
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
NS_ASSUME_NONNULL_BEGIN
|
|
5
5
|
|
|
6
6
|
/// The slot of a React button (`topBar.leftButtons[].component`) as the custom view of its bar item. It takes a content
|
|
7
|
-
/// view (`UIView<ANNComponentProtocol>`), never a class of the roots.
|
|
8
|
-
///
|
|
9
|
-
///
|
|
10
|
-
///
|
|
7
|
+
/// view (`UIView<ANNComponentProtocol>`), never a class of the roots. In the glass design of iOS 26 (`ANNTabsDesign`)
|
|
8
|
+
/// the slot is 44 pt high and as wide as the content, at least 44 pt; the width follows the content both ways
|
|
9
|
+
/// (measured after every mount; a change over 0.5 pt only), and the slot's constraints live with the view, so a new
|
|
10
|
+
/// item built around it reuses them. In the compatibility mode and before iOS 26: the content's size, no
|
|
11
11
|
/// constraints. A button rendered before the screen shows enters at its width. The core measures only the surface and
|
|
12
12
|
/// never moves the views inside it: the JS wrapper centres them.
|
|
13
13
|
@interface ANNBarButtonComponentView : UIView
|
|
@@ -7,7 +7,7 @@ static const CGFloat ANNBarButtonSlotHeight = 44;
|
|
|
7
7
|
static const CGFloat ANNBarButtonSlotMinimumWidth = 44;
|
|
8
8
|
static const CGFloat ANNBarButtonWidthTolerance = 0.5;
|
|
9
9
|
|
|
10
|
-
// The slot of iOS 26's bar: unless
|
|
10
|
+
// The slot of iOS 26's bar: unless UIKit keeps the earlier design for the app (`ANNTabsDesign`).
|
|
11
11
|
static BOOL ANNUsesSlotConstraints(void) {
|
|
12
12
|
return ANNTabsDesign.isGlass;
|
|
13
13
|
}
|
|
@@ -14,8 +14,9 @@ typedef NS_ENUM(NSInteger, ANNBarButtonsSide) {
|
|
|
14
14
|
|
|
15
15
|
/// The buttons of one screen's bar and toolbar (`topBar.leftButtons[].*`, the side options, `overflowMenu`,
|
|
16
16
|
/// `toolbar.buttons`): built from the resolved options, whole, at the screen's creation, at each appearance and at a
|
|
17
|
-
/// merge of a side
|
|
18
|
-
///
|
|
17
|
+
/// merge of a side, when anything the side's build reads changed or the item no longer holds what it put there.
|
|
18
|
+
/// Each button is an `ANNUIBarButtonItem` of the first kind its fields give (React view → icon and text → image
|
|
19
|
+
/// button → SF Symbol → image → text → system item); a button without `id` is not placed. Side colors go
|
|
19
20
|
/// onto what is built, never into the options; what the user chose (a toggle, a menu's check) goes into the screen's
|
|
20
21
|
/// user layer. The React buttons' slots are kept by component id, so a button built again reuses its slot. Main queue.
|
|
21
22
|
@interface ANNBarButtons : NSObject
|
|
@@ -27,7 +28,8 @@ typedef NS_ENUM(NSInteger, ANNBarButtonsSide) {
|
|
|
27
28
|
+ (instancetype)new NS_UNAVAILABLE;
|
|
28
29
|
|
|
29
30
|
/// Sets `side` of the screen's item (left, right, center) from `options`; `animated` fades new buttons in (a side set
|
|
30
|
-
/// as groups changes at once).
|
|
31
|
+
/// as groups changes at once). Nothing when the side's buttons, colors, loaded images, React roots and traits are the
|
|
32
|
+
/// same as at its last build and the item still holds what that build set: iOS 26 animates even equal new items.
|
|
31
33
|
- (void)applySide:(ANNBarButtonsSide)side
|
|
32
34
|
options:(ANNNavigationOptions *)options
|
|
33
35
|
animated:(BOOL)animated;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
#import "ANNBarButtonComponentView.h"
|
|
3
3
|
#import "ANNIconButtonImage.h"
|
|
4
4
|
#import "ANNShowTextButton.h"
|
|
5
|
+
#import "ANNTabsDesign.h"
|
|
5
6
|
#import "ANNUIBarButtonItem.h"
|
|
6
7
|
#import "ANNUserChoice.h"
|
|
7
8
|
#import "UIViewController+LayoutProtocol.h"
|
|
@@ -301,6 +302,27 @@ static BOOL ANNHasComponent(ANNButtonOptions *button) {
|
|
|
301
302
|
[button.component.componentId withDefault:nil].length > 0;
|
|
302
303
|
}
|
|
303
304
|
|
|
305
|
+
// The image an icon loads, for telling builds apart (NSNull without one): a source of a file, data or Metro's server
|
|
306
|
+
// loads through the shared cache, which gives the same image until the file at its path changes or a failed load
|
|
307
|
+
// succeeds. An SF Symbol is the system's: its name in the options says it all.
|
|
308
|
+
static id ANNLoadedImageOf(Image *icon) {
|
|
309
|
+
ANNImageSource *source = icon.source;
|
|
310
|
+
if (!icon.hasValue || (source && source.kind == ANNImageSourceKindSymbol)) {
|
|
311
|
+
return NSNull.null;
|
|
312
|
+
}
|
|
313
|
+
return [icon withDefault:nil] ?: NSNull.null;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// The images the items of a menu load (an item with `sfSymbol` shows the symbol), at any depth.
|
|
317
|
+
static void ANNAddMenuImages(NSArray<ANNMenuItemOptions *> *items, NSMutableArray *loaded) {
|
|
318
|
+
for (ANNMenuItemOptions *item in items) {
|
|
319
|
+
if (!item.sfSymbol.hasValue) {
|
|
320
|
+
[loaded addObject:ANNLoadedImageOf(item.icon)];
|
|
321
|
+
}
|
|
322
|
+
ANNAddMenuImages(item.items, loaded);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
304
326
|
// The image button's background: its own `iconBackground.color`, else (only for an image icon) the side's.
|
|
305
327
|
static UIColor *ANNIconBackgroundOf(ANNButtonOptions *button, Color *sideBackground) {
|
|
306
328
|
UIColor *own = ANNColorOf(button.iconBackground.color);
|
|
@@ -394,6 +416,60 @@ static UIBarButtonSystemItem ANNSystemItemOf(NSString *name) {
|
|
|
394
416
|
@implementation ANNButtonPress
|
|
395
417
|
@end
|
|
396
418
|
|
|
419
|
+
// The same objects, one by one: what a build read by identity (a loaded image, a React button's slot) and what it put
|
|
420
|
+
// on the navigation item. A string (the item's customization id) by its value.
|
|
421
|
+
static BOOL ANNSameObjects(NSArray *a, NSArray *b) {
|
|
422
|
+
if (a.count != b.count) {
|
|
423
|
+
return NO;
|
|
424
|
+
}
|
|
425
|
+
for (NSUInteger index = 0; index < a.count; index++) {
|
|
426
|
+
id mine = a[index];
|
|
427
|
+
id theirs = b[index];
|
|
428
|
+
if (mine != theirs && !([mine isKindOfClass:NSString.class] && [mine isEqual:theirs])) {
|
|
429
|
+
return NO;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
return YES;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
// Everything the build of one side reads: the side's buttons, its colors and the customization id of the middle by
|
|
436
|
+
// value; the images it loads and the slots of its React buttons by identity (a file written again at its path loads as
|
|
437
|
+
// another image, a reload gives other roots); the traits it builds under (a text button's font follows the text size,
|
|
438
|
+
// a drawn image the scale and the style).
|
|
439
|
+
@interface ANNSideInputs : NSObject
|
|
440
|
+
@property(nonatomic, strong, nullable) NSArray<ANNButtonOptions *> *buttons;
|
|
441
|
+
@property(nonatomic, strong, nullable) Color *color;
|
|
442
|
+
@property(nonatomic, strong, nullable) Color *disabledColor;
|
|
443
|
+
@property(nonatomic, strong, nullable) Color *background;
|
|
444
|
+
@property(nonatomic, strong, nullable) Text *customizationId;
|
|
445
|
+
@property(nonatomic, copy) NSArray *loaded;
|
|
446
|
+
@property(nonatomic, copy) NSArray *traits;
|
|
447
|
+
@end
|
|
448
|
+
|
|
449
|
+
@implementation ANNSideInputs
|
|
450
|
+
|
|
451
|
+
- (BOOL)isSameAs:(ANNSideInputs *)other {
|
|
452
|
+
return ANNOptionValuesSame(_buttons, other.buttons) &&
|
|
453
|
+
ANNOptionValuesSame(_color, other.color) &&
|
|
454
|
+
ANNOptionValuesSame(_disabledColor, other.disabledColor) &&
|
|
455
|
+
ANNOptionValuesSame(_background, other.background) &&
|
|
456
|
+
ANNOptionValuesSame(_customizationId, other.customizationId) &&
|
|
457
|
+
ANNSameObjects(_loaded, other.loaded) && [_traits isEqualToArray:other.traits];
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
@end
|
|
461
|
+
|
|
462
|
+
// The last build of one side: what it read and what the navigation item held right after it.
|
|
463
|
+
@interface ANNSideBuild : NSObject
|
|
464
|
+
@property(nonatomic, strong) ANNSideInputs *inputs;
|
|
465
|
+
// The side went in as groups (`leadingItemGroups`, …), not as a list of items.
|
|
466
|
+
@property(nonatomic) BOOL grouped;
|
|
467
|
+
@property(nonatomic, copy) NSArray *placed;
|
|
468
|
+
@end
|
|
469
|
+
|
|
470
|
+
@implementation ANNSideBuild
|
|
471
|
+
@end
|
|
472
|
+
|
|
397
473
|
@implementation ANNBarButtons {
|
|
398
474
|
__weak UIViewController *_screen;
|
|
399
475
|
ANNReactComponentRegistry *_registry;
|
|
@@ -402,6 +478,8 @@ static UIBarButtonSystemItem ANNSystemItemOf(NSString *name) {
|
|
|
402
478
|
NSMutableDictionary<NSString *, NSNumber *> *_selected;
|
|
403
479
|
// What a press of each sender (an item, a button of an item) means.
|
|
404
480
|
NSMapTable<id, ANNButtonPress *> *_presses;
|
|
481
|
+
// The last build of each side, by the side.
|
|
482
|
+
NSMutableDictionary<NSNumber *, ANNSideBuild *> *_builds;
|
|
405
483
|
}
|
|
406
484
|
|
|
407
485
|
- (instancetype)initWithScreen:(UIViewController *)screen
|
|
@@ -412,12 +490,16 @@ static UIBarButtonSystemItem ANNSystemItemOf(NSString *name) {
|
|
|
412
490
|
_slots = [NSMutableDictionary new];
|
|
413
491
|
_selected = [NSMutableDictionary new];
|
|
414
492
|
_presses = [NSMapTable weakToStrongObjectsMapTable];
|
|
493
|
+
_builds = [NSMutableDictionary new];
|
|
415
494
|
}
|
|
416
495
|
return self;
|
|
417
496
|
}
|
|
418
497
|
|
|
419
498
|
#pragma mark - The sides
|
|
420
499
|
|
|
500
|
+
// From iOS 26 UIKit animates any change of the bar's items, also to equal ones and with `animated:NO`: new items on
|
|
501
|
+
// each appearance would morph, close an open menu and drop a pressed state. So a side is built again only when what
|
|
502
|
+
// its build reads changed, or when the item no longer holds what the last build put there.
|
|
421
503
|
- (void)applySide:(ANNBarButtonsSide)side
|
|
422
504
|
options:(ANNNavigationOptions *)options
|
|
423
505
|
animated:(BOOL)animated {
|
|
@@ -426,12 +508,92 @@ static UIBarButtonSystemItem ANNSystemItemOf(NSString *name) {
|
|
|
426
508
|
return;
|
|
427
509
|
}
|
|
428
510
|
UINavigationItem *navigationItem = screen.navigationItem;
|
|
511
|
+
ANNSideInputs *inputs = [self inputsOfSide:side options:options];
|
|
512
|
+
ANNSideBuild *last = _builds[@(side)];
|
|
513
|
+
if (last && [last.inputs isSameAs:inputs]) {
|
|
514
|
+
NSArray *placed = [self placedOf:side grouped:last.grouped item:navigationItem];
|
|
515
|
+
if (ANNSameObjects(last.placed, placed)) {
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
ANNSideBuild *build = [ANNSideBuild new];
|
|
520
|
+
build.inputs = inputs;
|
|
521
|
+
build.grouped = [self placeSide:side options:options item:navigationItem animated:animated];
|
|
522
|
+
build.placed = [self placedOf:side grouped:build.grouped item:navigationItem];
|
|
523
|
+
_builds[@(side)] = build;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
- (ANNSideInputs *)inputsOfSide:(ANNBarButtonsSide)side options:(ANNNavigationOptions *)options {
|
|
527
|
+
ANNTopBarOptions *topBar = options.topBar;
|
|
528
|
+
ANNSideInputs *inputs = [ANNSideInputs new];
|
|
529
|
+
inputs.buttons = ANNButtonsOfSide(options, side);
|
|
530
|
+
inputs.color = ANNSideColor(topBar, side);
|
|
531
|
+
inputs.disabledColor = ANNSideDisabledColor(topBar, side);
|
|
532
|
+
inputs.background = ANNSideBackgroundColor(topBar, side);
|
|
533
|
+
inputs.customizationId = side == ANNBarButtonsSideCenter ? topBar.customizationId : nil;
|
|
534
|
+
NSMutableArray *loaded = [NSMutableArray new];
|
|
535
|
+
for (ANNButtonOptions *button in inputs.buttons ?: @[]) {
|
|
536
|
+
if (ANNHasComponent(button)) {
|
|
537
|
+
[loaded addObject:[self slotFor:button] ?: NSNull.null];
|
|
538
|
+
}
|
|
539
|
+
[loaded addObject:ANNLoadedImageOf(button.icon)];
|
|
540
|
+
ANNAddMenuImages(button.menu.items, loaded);
|
|
541
|
+
}
|
|
542
|
+
inputs.loaded = loaded;
|
|
543
|
+
UITraitCollection *traits = UITraitCollection.currentTraitCollection;
|
|
544
|
+
inputs.traits = @[
|
|
545
|
+
@(traits.userInterfaceStyle), @(traits.displayScale),
|
|
546
|
+
traits.preferredContentSizeCategory ?: @"", @(traits.legibilityWeight)
|
|
547
|
+
];
|
|
548
|
+
return inputs;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
// What the navigation item holds of `side` now, as the side's build put it there.
|
|
552
|
+
- (NSArray *)placedOf:(ANNBarButtonsSide)side
|
|
553
|
+
grouped:(BOOL)grouped
|
|
554
|
+
item:(UINavigationItem *)navigationItem {
|
|
555
|
+
NSMutableArray *placed = [NSMutableArray new];
|
|
556
|
+
BOOL left = side == ANNBarButtonsSideLeft;
|
|
557
|
+
switch (side) {
|
|
558
|
+
case ANNBarButtonsSideLeft:
|
|
559
|
+
case ANNBarButtonsSideRight: {
|
|
560
|
+
NSArray *shown =
|
|
561
|
+
left ? navigationItem.leftBarButtonItems : navigationItem.rightBarButtonItems;
|
|
562
|
+
if (@available(iOS 16.0, *)) {
|
|
563
|
+
if (grouped) {
|
|
564
|
+
shown = left ? navigationItem.leadingItemGroups
|
|
565
|
+
: navigationItem.trailingItemGroups;
|
|
566
|
+
}
|
|
567
|
+
if (!left) {
|
|
568
|
+
[placed addObject:navigationItem.pinnedTrailingGroup ?: NSNull.null];
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
[placed addObjectsFromArray:shown ?: @[]];
|
|
572
|
+
break;
|
|
573
|
+
}
|
|
574
|
+
case ANNBarButtonsSideCenter:
|
|
575
|
+
if (@available(iOS 16.0, *)) {
|
|
576
|
+
[placed addObjectsFromArray:navigationItem.centerItemGroups ?: @[]];
|
|
577
|
+
[placed addObject:navigationItem.customizationIdentifier ?: NSNull.null];
|
|
578
|
+
}
|
|
579
|
+
break;
|
|
580
|
+
case ANNBarButtonsSideToolbar:
|
|
581
|
+
break;
|
|
582
|
+
}
|
|
583
|
+
return placed;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
// Builds `side` whole and puts it on the item; YES when it went in as groups.
|
|
587
|
+
- (BOOL)placeSide:(ANNBarButtonsSide)side
|
|
588
|
+
options:(ANNNavigationOptions *)options
|
|
589
|
+
item:(UINavigationItem *)navigationItem
|
|
590
|
+
animated:(BOOL)animated {
|
|
429
591
|
NSArray<ANNBuiltButton *> *built = [self buildSide:side options:options];
|
|
430
592
|
if (side == ANNBarButtonsSideCenter) {
|
|
431
593
|
if (@available(iOS 16.0, *)) {
|
|
432
594
|
[self setCenter:built options:options item:navigationItem];
|
|
433
595
|
}
|
|
434
|
-
return;
|
|
596
|
+
return YES;
|
|
435
597
|
}
|
|
436
598
|
NSMutableArray<ANNBuiltButton *> *placed = [built mutableCopy];
|
|
437
599
|
if (side == ANNBarButtonsSideRight) {
|
|
@@ -440,26 +602,28 @@ static UIBarButtonSystemItem ANNSystemItemOf(NSString *name) {
|
|
|
440
602
|
}
|
|
441
603
|
}
|
|
442
604
|
if (@available(iOS 26.0, *)) {
|
|
443
|
-
if ([self hasGroupOfSeveral:placed]) {
|
|
605
|
+
if (ANNTabsDesign.isGlass && [self hasGroupOfSeveral:placed]) {
|
|
444
606
|
NSArray<UIBarButtonItemGroup *> *groups = [self groupsOf:placed];
|
|
445
607
|
if (side == ANNBarButtonsSideLeft) {
|
|
446
608
|
navigationItem.leadingItemGroups = groups;
|
|
447
609
|
} else {
|
|
448
610
|
navigationItem.trailingItemGroups = groups.reverseObjectEnumerator.allObjects;
|
|
449
611
|
}
|
|
450
|
-
return;
|
|
612
|
+
return YES;
|
|
451
613
|
}
|
|
452
614
|
}
|
|
453
615
|
NSMutableArray<UIBarButtonItem *> *items = [NSMutableArray new];
|
|
454
616
|
for (ANNBuiltButton *button in placed) {
|
|
455
617
|
if (@available(iOS 26.0, *)) {
|
|
456
618
|
// Each button its own capsule: a zero-width space between neighbours, and the right ones never share the
|
|
457
|
-
// capsule of "•••".
|
|
458
|
-
if (
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
619
|
+
// capsule of "•••". The compatibility mode has no capsules.
|
|
620
|
+
if (ANNTabsDesign.isGlass) {
|
|
621
|
+
if (items.count > 0) {
|
|
622
|
+
[items addObject:[UIBarButtonItem fixedSpaceItemOfWidth:0]];
|
|
623
|
+
}
|
|
624
|
+
if (side == ANNBarButtonsSideRight) {
|
|
625
|
+
button.item.sharesBackground = NO;
|
|
626
|
+
}
|
|
463
627
|
}
|
|
464
628
|
}
|
|
465
629
|
[items addObject:button.item];
|
|
@@ -469,6 +633,7 @@ static UIBarButtonSystemItem ANNSystemItemOf(NSString *name) {
|
|
|
469
633
|
} else {
|
|
470
634
|
[navigationItem setRightBarButtonItems:items animated:animated];
|
|
471
635
|
}
|
|
636
|
+
return NO;
|
|
472
637
|
}
|
|
473
638
|
|
|
474
639
|
- (NSArray<ANNBuiltButton *> *)buildSide:(ANNBarButtonsSide)side
|
|
@@ -559,7 +724,7 @@ static UIBarButtonSystemItem ANNSystemItemOf(NSString *name) {
|
|
|
559
724
|
NSMutableArray<UIBarButtonItem *> *items = [NSMutableArray new];
|
|
560
725
|
for (ANNBuiltButton *button in run) {
|
|
561
726
|
if (@available(iOS 26.0, *)) {
|
|
562
|
-
if (run.count == 1) {
|
|
727
|
+
if (run.count == 1 && ANNTabsDesign.isGlass) {
|
|
563
728
|
button.item.sharesBackground = NO;
|
|
564
729
|
}
|
|
565
730
|
}
|
|
@@ -667,7 +832,7 @@ static UIBarButtonSystemItem ANNSystemItemOf(NSString *name) {
|
|
|
667
832
|
BOOL icon = kind == ANNBarButtonKindSymbol || kind == ANNBarButtonKindImage ||
|
|
668
833
|
kind == ANNBarButtonKindImageButton || kind == ANNBarButtonKindShowText;
|
|
669
834
|
NSString *group = icon ? [button.group withDefault:nil] : nil;
|
|
670
|
-
if (
|
|
835
|
+
if (ANNTabsDesign.isGlass) {
|
|
671
836
|
// Only icons of one group share a capsule (the toolbar has no groups): any other neighbours get a
|
|
672
837
|
// zero-width space, unless a space of the options is there already.
|
|
673
838
|
BOOL sameGroup = group.length > 0 && [group isEqualToString:previousIconGroup];
|
|
@@ -835,10 +1000,12 @@ static UIBarButtonSystemItem ANNSystemItemOf(NSString *name) {
|
|
|
835
1000
|
}
|
|
836
1001
|
BOOL prominent = [[button.style withDefault:nil] isEqualToString:@"prominent"];
|
|
837
1002
|
if (prominent) {
|
|
1003
|
+
// The capsule of the glass; the design before it (and its compatibility mode) has the bold `done` style.
|
|
1004
|
+
item.style = UIBarButtonItemStyleDone;
|
|
838
1005
|
if (@available(iOS 26.0, *)) {
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
1006
|
+
if (ANNTabsDesign.isGlass) {
|
|
1007
|
+
item.style = UIBarButtonItemStyleProminent;
|
|
1008
|
+
}
|
|
842
1009
|
}
|
|
843
1010
|
}
|
|
844
1011
|
// The color: the tint, and for a plain button also the text's; `prominent` takes it only into the tint, and a font
|
|
@@ -1021,9 +1188,11 @@ static UIBarButtonSystemItem ANNSystemItemOf(NSString *name) {
|
|
|
1021
1188
|
kind:(ANNBarButtonKind)kind
|
|
1022
1189
|
to:(UIBarButtonItem *)item {
|
|
1023
1190
|
if (@available(iOS 26.0, *)) {
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1191
|
+
if (ANNTabsDesign.isGlass) {
|
|
1192
|
+
BOOL ownBackground =
|
|
1193
|
+
kind == ANNBarButtonKindComponent || kind == ANNBarButtonKindImageButton;
|
|
1194
|
+
item.hidesSharedBackground = [button.hideSharedBackground withDefault:ownBackground];
|
|
1195
|
+
}
|
|
1027
1196
|
}
|
|
1028
1197
|
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 270000
|
|
1029
1198
|
if (@available(iOS 27.0, *)) {
|
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
#import "ANNBarAppearance.h"
|
|
4
4
|
#import "ANNMainList.h"
|
|
5
5
|
#import "ANNScreenBars.h"
|
|
6
|
+
#import "ANNTabsDesign.h"
|
|
7
|
+
|
|
8
|
+
// The glass design of iOS 26 draws the large title inside the list the bar follows: the places, fills and bands of
|
|
9
|
+
// this file are for it. The compatibility mode keeps the title in the bar, as before iOS 26 (`ANNTabsDesign`).
|
|
10
|
+
static BOOL ANNTitleInList(void) {
|
|
11
|
+
return ANNTabsDesign.isGlass;
|
|
12
|
+
}
|
|
6
13
|
|
|
7
14
|
// How far the color reaches above the list's content: as far as a pull can show.
|
|
8
15
|
static const CGFloat ANNListFillHeight = 2000;
|
|
@@ -58,10 +65,8 @@ static UINavigationItemLargeTitleDisplayMode ANNItemModeOf(NSString *mode) {
|
|
|
58
65
|
![options.topBar.largeTitle.collapseOnScroll withDefault:YES]) {
|
|
59
66
|
return NO;
|
|
60
67
|
}
|
|
61
|
-
if (
|
|
62
|
-
|
|
63
|
-
return NO;
|
|
64
|
-
}
|
|
68
|
+
if (ANNTitleInList() && ANNAppDirection.reactNativeIsRightToLeft) {
|
|
69
|
+
return NO;
|
|
65
70
|
}
|
|
66
71
|
return YES;
|
|
67
72
|
}
|
|
@@ -132,6 +137,9 @@ static UINavigationItemLargeTitleDisplayMode ANNItemModeOf(NSString *mode) {
|
|
|
132
137
|
- (void)screenInPop:(ANNNavigationOptions *)options
|
|
133
138
|
list:(UIScrollView *)list
|
|
134
139
|
inlineInRow:(BOOL)inlineInRow {
|
|
140
|
+
if (!ANNTitleInList()) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
135
143
|
if (@available(iOS 26.0, *)) {
|
|
136
144
|
UIViewController *screen = _screen;
|
|
137
145
|
UIView *screenView = screen.viewIfLoaded;
|
|
@@ -168,6 +176,9 @@ static UINavigationItemLargeTitleDisplayMode ANNItemModeOf(NSString *mode) {
|
|
|
168
176
|
inlineInRow:(BOOL)inlineInRow
|
|
169
177
|
top:(CGFloat)top
|
|
170
178
|
stackTop:(CGFloat)stackTop {
|
|
179
|
+
if (!ANNTitleInList()) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
171
182
|
if (@available(iOS 26.0, *)) {
|
|
172
183
|
UIView *screenView = _screen.viewIfLoaded;
|
|
173
184
|
if (!screenView || inlineInRow || !ANNLargeTitleCanShow(options) || top - stackTop <= 0) {
|
|
@@ -282,6 +293,9 @@ static UINavigationItemLargeTitleDisplayMode ANNItemModeOf(NSString *mode) {
|
|
|
282
293
|
list:(UIScrollView *)list
|
|
283
294
|
inlineInRow:(BOOL)inlineInRow
|
|
284
295
|
backgroundComponent:(BOOL)backgroundComponent {
|
|
296
|
+
if (!ANNTitleInList()) {
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
285
299
|
if (@available(iOS 26.0, *)) {
|
|
286
300
|
UIViewController *screen = _screen;
|
|
287
301
|
UIColor *fill = [ANNBarAppearance solidColorOf:options.topBar.background.color
|
|
@@ -320,6 +334,9 @@ static UINavigationItemLargeTitleDisplayMode ANNItemModeOf(NSString *mode) {
|
|
|
320
334
|
- (void)fillTitlePlaceFrom:(CGFloat)oldBarBottom
|
|
321
335
|
list:(UIScrollView *)list
|
|
322
336
|
options:(ANNNavigationOptions *)options {
|
|
337
|
+
if (!ANNTitleInList()) {
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
323
340
|
if (@available(iOS 26.0, *)) {
|
|
324
341
|
[self removeTitlePlaceFill];
|
|
325
342
|
if (!ANNLargeTitleCanShow(options) || [ANNLargeTitlePresenter collapsesIntoList:options]) {
|
|
@@ -334,6 +351,9 @@ static UINavigationItemLargeTitleDisplayMode ANNItemModeOf(NSString *mode) {
|
|
|
334
351
|
// The pushed screen's content may render only during the push, so its list mounts later than the push starts: the
|
|
335
352
|
// fill is placed again at each mount and layout until the screen appeared.
|
|
336
353
|
- (void)updateTitlePlaceFill:(ANNNavigationOptions *)options list:(UIScrollView *)list {
|
|
354
|
+
if (!ANNTitleInList()) {
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
337
357
|
if (@available(iOS 26.0, *)) {
|
|
338
358
|
UIViewController *screen = _screen;
|
|
339
359
|
UIView *screenView = screen.viewIfLoaded;
|