Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: refactor snapshots when going back on Fabric #2134

Merged
merged 26 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b975b0e
feat: first look at working version on fabric
WoLewicki May 14, 2024
639b67d
feat: move listener to cpp folder
WoLewicki May 15, 2024
dae22d1
chore: dont build from sources
WoLewicki May 15, 2024
ef3baa4
chore: merge current main
WoLewicki May 15, 2024
1e2bebb
feat: rename listeners and remove code handling it in ScreenStack
WoLewicki May 15, 2024
d1af500
chore: move listeners to cpp on Android
WoLewicki May 15, 2024
99be7d1
chore: merge current main
WoLewicki May 15, 2024
ca2f34e
feat: make it work on both platforms and archs
WoLewicki May 16, 2024
3de04f5
chore: format all cpp
WoLewicki May 16, 2024
7909666
fix: indents and comment and restore init in other place
WoLewicki May 16, 2024
7cf4390
chore: merge current main
WoLewicki May 17, 2024
05dfb34
fix: clean up cmakelists
WoLewicki May 17, 2024
16f9498
fix: swipe refresh case
WoLewicki Jun 10, 2024
8fd8ae7
chore: merge current main
WoLewicki Jun 10, 2024
33a6ac5
Merge branch 'main' into @wolewicki/fix-android-fabric-goback
WoLewicki Jun 11, 2024
f467091
Merge branch 'main' into @wolewicki/fix-android-fabric-goback
WoLewicki Jun 12, 2024
b28c1c5
fix: hopefully working version
WoLewicki Jun 13, 2024
18a7aaa
feat: use ConcurrentHashMap
WoLewicki Jun 14, 2024
c8e4ba7
chore: merge current main
WoLewicki Jul 16, 2024
31c2f2e
feat: apply review comments
WoLewicki Jul 16, 2024
1019731
fix: review
WoLewicki Jul 17, 2024
d0c24ff
fix: android header buttons
WoLewicki Jul 19, 2024
bd7a30e
Merge branch 'main' into @wolewicki/fix-android-fabric-goback
WoLewicki Jul 19, 2024
8dfcdb0
chore: merge current main
WoLewicki Jul 31, 2024
e127cde
chore: format
WoLewicki Jul 31, 2024
0cfd980
fix: revert changing react-navigation
WoLewicki Jul 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion FabricTestExample/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ GEM
i18n (1.14.5)
concurrent-ruby (~> 1.0)
json (2.7.2)
minitest (5.22.3)
minitest (5.22.2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's going on here, why do we change that?

molinillo (0.8.0)
nanaimo (0.3.0)
nap (1.1.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
/* Begin PBXBuildFile section */
00E356F31AD99517003FC87E /* FabricTestExampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* FabricTestExampleTests.m */; };
0C80B921A6F3F58F76C31292 /* libPods-FabricTestExample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5DCACB8F33CDC322A6C60F78 /* libPods-FabricTestExample.a */; };
0C8DC70031F6A0EB3918E89A /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 80611F1F396BDF1BBA4C9072 /* PrivacyInfo.xcprivacy */; };
13B07FBC1A68108700A75B9A /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.mm */; };
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
7699B88040F8A987B510C191 /* libPods-FabricTestExample-FabricTestExampleTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 19F6CBCC0A4E27FBF8BF4A61 /* libPods-FabricTestExample-FabricTestExampleTests.a */; };
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; };
C96B4031A93002B8F66309BB /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = F2DBEFF9ED5BC3397C47CBFB /* PrivacyInfo.xcprivacy */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -43,10 +43,10 @@
5709B34CF0A7D63546082F79 /* Pods-FabricTestExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FabricTestExample.release.xcconfig"; path = "Target Support Files/Pods-FabricTestExample/Pods-FabricTestExample.release.xcconfig"; sourceTree = "<group>"; };
5B7EB9410499542E8C5724F5 /* Pods-FabricTestExample-FabricTestExampleTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FabricTestExample-FabricTestExampleTests.debug.xcconfig"; path = "Target Support Files/Pods-FabricTestExample-FabricTestExampleTests/Pods-FabricTestExample-FabricTestExampleTests.debug.xcconfig"; sourceTree = "<group>"; };
5DCACB8F33CDC322A6C60F78 /* libPods-FabricTestExample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-FabricTestExample.a"; sourceTree = BUILT_PRODUCTS_DIR; };
80611F1F396BDF1BBA4C9072 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; includeInIndex = 1; name = PrivacyInfo.xcprivacy; path = FabricTestExample/PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = FabricTestExample/LaunchScreen.storyboard; sourceTree = "<group>"; };
89C6BE57DB24E9ADA2F236DE /* Pods-FabricTestExample-FabricTestExampleTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FabricTestExample-FabricTestExampleTests.release.xcconfig"; path = "Target Support Files/Pods-FabricTestExample-FabricTestExampleTests/Pods-FabricTestExample-FabricTestExampleTests.release.xcconfig"; sourceTree = "<group>"; };
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
F2DBEFF9ED5BC3397C47CBFB /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; includeInIndex = 1; name = PrivacyInfo.xcprivacy; path = FabricTestExample/PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -96,7 +96,7 @@
81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */,
13B07FB71A68108700A75B9A /* main.m */,
13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */,
80611F1F396BDF1BBA4C9072 /* PrivacyInfo.xcprivacy */,
F2DBEFF9ED5BC3397C47CBFB /* PrivacyInfo.xcprivacy */,
);
name = FabricTestExample;
sourceTree = "<group>";
Expand Down Expand Up @@ -248,7 +248,7 @@
files = (
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */,
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
0C8DC70031F6A0EB3918E89A /* PrivacyInfo.xcprivacy in Resources */,
C96B4031A93002B8F66309BB /* PrivacyInfo.xcprivacy in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
2 changes: 1 addition & 1 deletion RNScreens.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package = JSON.parse(File.read(File.join(__dir__, "package.json")))

new_arch_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
platform = new_arch_enabled ? "11.0" : "9.0"
source_files = new_arch_enabled ? 'ios/**/*.{h,m,mm,cpp}' : ["ios/**/*.{h,m,mm}", "cpp/**/*.{cpp,h}"]
source_files = new_arch_enabled ? 'ios/**/*.{h,m,mm,cpp}' : ["ios/**/*.{h,m,mm}", "cpp/RNScreensTurboModule.cpp", "cpp/RNScreensTurboModule.h"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we're not scoping all .cpp and .h files right now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the new files added to the folder should not be compiled on old arch.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's worth to consider grouping the files. E.g. place screen-transition related staff in a cpp/transition / cpp/turbomodule directory & new screen listeners into cpp/mounting or sth similar.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do a cleanup of those in the follow-up PR?


folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'

Expand Down
9 changes: 5 additions & 4 deletions TestsExample/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1064,10 +1064,11 @@ PODS:
- RCT-Folly (= 2022.05.16.00)
- React-Core
- ReactCommon/turbomodule/core
- RNScreens (3.31.0-rc.1):
- RNScreens (3.31.1):
- glog
- RCT-Folly (= 2022.05.16.00)
- React-Core
- React-RCTImage
- SocketRocket (0.6.1)
- Yoga (1.14.0)

Expand Down Expand Up @@ -1243,7 +1244,7 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
boost: d3f49c53809116a5d38da093a8aa78bf551aed09
DoubleConversion: 76ab83afb40bddeeee456813d9c04f67f78771b5
DoubleConversion: fea03f2699887d960129cc54bba7e52542b6f953
FBLazyVector: 84f6edbe225f38aebd9deaf1540a4160b1f087d7
FBReactNativeSpec: d0086a479be91c44ce4687a962956a352d2dc697
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
Expand Down Expand Up @@ -1294,9 +1295,9 @@ SPEC CHECKSUMS:
ReactCommon: 840a955d37b7f3358554d819446bffcf624b2522
RNGestureHandler: 61bfdfc05db9b79dd61f894dcd29d3dcc6db3c02
RNReanimated: e7abe58f02a10c8b619db32b6bf33507420a9f86
RNScreens: 794330587bf2cc284138990677584eb7b105c188
RNScreens: 31c8bfb1d6a2500a42af751fe9d09bee8ae12131
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
Yoga: 64cd2a583ead952b0315d5135bf39e053ae9be70
Yoga: 1b901a6d6eeba4e8a2e8f308f708691cdb5db312

PODFILE CHECKSUM: e9288ec08e6f39cc345ed03cff69a6bb3749c97d

Expand Down
74 changes: 65 additions & 9 deletions android/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,27 +1,83 @@
cmake_minimum_required(VERSION 3.9.0)

project(rnscreens)
set(CMAKE_CXX_STANDARD 20)

if(${IS_NEW_ARCHITECTURE_ENABLED})
string(APPEND CMAKE_CXX_FLAGS " -DRCT_NEW_ARCH_ENABLED")
endif()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we setting this? Is that because of some unmerged changes earlier for matching RN 0.74?


if(${IS_NEW_ARCHITECTURE_ENABLED})
add_library(rnscreens
SHARED
../cpp/RNScreensTurboModule.cpp
../cpp/RNSScreenRemovalListener.cpp
./src/main/cpp/jni-adapter.cpp
./src/main/cpp/NativeProxy.cpp
./src/main/cpp/OnLoad.cpp
)
else()
add_library(rnscreens
SHARED
../cpp/RNScreensTurboModule.cpp
./src/main/cpp/jni-adapter.cpp
)
endif()

include_directories(
../cpp
)

set_target_properties(rnscreens PROPERTIES
CXX_STANDARD 20
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
POSITION_INDEPENDENT_CODE ON
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we replace setting properties on particular target with setting the non-target-scoped variable CMAKE_CXX_STANDARD? Also why do we drop standard requirement, turning off extensions and enabling -fpic explicitly?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why I removed it, reverted.

target_compile_definitions(
rnscreens
PRIVATE
-DFOLLY_NO_CONFIG=1
)

find_package(ReactAndroid REQUIRED CONFIG)

target_link_libraries(rnscreens
ReactAndroid::jsi
android
)
if(${IS_NEW_ARCHITECTURE_ENABLED})
target_include_directories(
rnscreens
PRIVATE
"${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/react/turbomodule"
"${REACT_NATIVE_DIR}/ReactCommon"
"${REACT_NATIVE_DIR}/ReactCommon/callinvoker"
"${REACT_NATIVE_DIR}/ReactCommon/react/renderer/graphics/platform/cxx"
"${REACT_NATIVE_DIR}/ReactCommon/runtimeexecutor"
"${REACT_NATIVE_DIR}/ReactCommon/yoga"
)

find_package(fbjni REQUIRED CONFIG)

target_link_libraries(
rnscreens
ReactAndroid::jsi
ReactAndroid::folly_runtime
ReactAndroid::react_nativemodule_core
ReactAndroid::react_render_uimanager
ReactAndroid::react_render_scheduler
ReactAndroid::react_utils
ReactAndroid::reactnativejni
ReactAndroid::fabricjni
ReactAndroid::react_debug
ReactAndroid::react_render_core
ReactAndroid::react_render_mounting
ReactAndroid::runtimeexecutor
ReactAndroid::react_render_graphics
ReactAndroid::rrc_view
ReactAndroid::yoga
ReactAndroid::rrc_text
ReactAndroid::rrc_textinput
ReactAndroid::react_render_textlayoutmanager
ReactAndroid::glog
ReactAndroid::react_render_componentregistry
fbjni::fbjni
android
)
WoLewicki marked this conversation as resolved.
Show resolved Hide resolved
else()
target_link_libraries(rnscreens
ReactAndroid::jsi
android
)
endif()
11 changes: 7 additions & 4 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def reactProperties = new Properties()
file("$reactNativeRootDir/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) }
def REACT_NATIVE_VERSION = reactProperties.getProperty("VERSION_NAME")
def REACT_NATIVE_MINOR_VERSION = REACT_NATIVE_VERSION.startsWith("0.0.0-") ? 1000 : REACT_NATIVE_VERSION.split("\\.")[1].toInteger()
def IS_NEW_ARCHITECTURE_ENABLED = isNewArchitectureEnabled()

android {
compileSdkVersion safeExtGet('compileSdkVersion', rnsDefaultCompileSdkVersion)
Expand All @@ -102,13 +103,14 @@ android {
targetSdkVersion safeExtGet('targetSdkVersion', rnsDefaultTargetSdkVersion)
versionCode 1
versionName "1.0"
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", IS_NEW_ARCHITECTURE_ENABLED.toString()
ndk {
abiFilters (*reactNativeArchitectures())
}
externalNativeBuild {
cmake {
arguments "-DANDROID_STL=c++_shared"
arguments "-DANDROID_STL=c++_shared",
"-DIS_NEW_ARCHITECTURE_ENABLED=${IS_NEW_ARCHITECTURE_ENABLED}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"-DIS_NEW_ARCHITECTURE_ENABLED=${IS_NEW_ARCHITECTURE_ENABLED}"
"-DRNS_NEW_ARCH_ENABLED=${IS_NEW_ARCHITECTURE_ENABLED}"

won't insist here, my only intention is to keep it consistent with iOS (I believe we even use RCT_ prefix there.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}
}
}
Expand Down Expand Up @@ -139,13 +141,14 @@ android {
"META-INF/**",
"**/libjsi.so",
"**/libc++_shared.so",
"**/libreact_render*.so"
"**/libreact_render*.so",
"**/libreactnativejni.so"
]
}
sourceSets.main {
ext.androidResDir = "src/main/res"
java {
if (isNewArchitectureEnabled()) {
if (IS_NEW_ARCHITECTURE_ENABLED) {
srcDirs += [
"src/fabric/java",
]
Expand Down
31 changes: 31 additions & 0 deletions android/src/fabric/java/com/swmansion/rnscreens/NativeProxy.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.swmansion.rnscreens

import com.facebook.jni.HybridData
import com.facebook.proguard.annotations.DoNotStrip
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.fabric.FabricUIManager
import com.facebook.react.uimanager.UIManagerHelper
import com.facebook.react.uimanager.common.UIManagerType
import com.facebook.soloader.SoLoader

class NativeProxy(private val reactContext: ReactApplicationContext) {
@DoNotStrip
@Suppress("unused")
private val mHybridData: HybridData

init {
mHybridData = initHybrid()
}

private external fun initHybrid(): HybridData
external fun nativeAddMutationsListener(fabricUIManager: FabricUIManager)

@DoNotStrip
public fun notifyScreenRemoved(screenTag: Int) {
val uiManager = UIManagerHelper.getUIManager(reactContext, UIManagerType.FABRIC)
val screen = uiManager?.resolveView(screenTag)
if (screen is Screen) {
screen.startRemovalTransition()
}
}
}
48 changes: 48 additions & 0 deletions android/src/main/cpp/NativeProxy.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include <fbjni/fbjni.h>
#include <react/fabric/Binding.h>
#include <react/renderer/scheduler/Scheduler.h>

#include <string>

#include "NativeProxy.h"


using namespace facebook;
using namespace react;

namespace rnscreens {

NativeProxy::NativeProxy(jni::alias_ref<NativeProxy::javaobject> jThis)
: javaPart_(jni::make_global(jThis)) {}

NativeProxy::~NativeProxy() {}

void NativeProxy::registerNatives() {
registerHybrid(
{makeNativeMethod("initHybrid", NativeProxy::initHybrid),
makeNativeMethod("nativeAddMutationsListener", NativeProxy::nativeAddMutationsListener)});
}

void NativeProxy::nativeAddMutationsListener(
jni::alias_ref<facebook::react::JFabricUIManager::javaobject>
fabricUIManager) {
auto uiManager = fabricUIManager->getBinding()->getScheduler()->getUIManager();
screenRemovalListener_ = std::make_shared<RNSScreenRemovalListener>(
[this](int tag) {
static const auto method = javaPart_->getClass()->getMethod<void(jint)>("notifyScreenRemoved");
method(javaPart_, tag);
});

uiManager->getShadowTreeRegistry().enumerate(
[this](const facebook::react::ShadowTree &shadowTree, bool &stop) {
shadowTree.getMountingCoordinator()->setMountingOverrideDelegate(
screenRemovalListener_);
});
}

jni::local_ref<NativeProxy::jhybriddata>
NativeProxy::initHybrid(jni::alias_ref<jhybridobject> jThis) {
return makeCxxInstance(jThis);
}

}
35 changes: 35 additions & 0 deletions android/src/main/cpp/NativeProxy.h
WoLewicki marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#pragma once

#include <fbjni/fbjni.h>
#include <react/fabric/JFabricUIManager.h>
#include "RNSScreenRemovalListener.h"

#include <string>

namespace rnscreens {
using namespace facebook;
using namespace facebook::jni;

class NativeProxy : public jni::HybridClass<NativeProxy> {
public:
std::shared_ptr<RNSScreenRemovalListener> screenRemovalListener_;
static auto constexpr kJavaDescriptor =
"Lcom/swmansion/rnscreens/NativeProxy;";
static jni::local_ref<jhybriddata>
initHybrid(jni::alias_ref<jhybridobject> jThis);
static void registerNatives();

~NativeProxy();

private:
friend HybridBase;
jni::global_ref<NativeProxy::javaobject> javaPart_;

explicit NativeProxy(jni::alias_ref<NativeProxy::javaobject> jThis);

void
nativeAddMutationsListener(jni::alias_ref<facebook::react::JFabricUIManager::javaobject>
fabricUIManager);
};

}
8 changes: 8 additions & 0 deletions android/src/main/cpp/OnLoad.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <fbjni/fbjni.h>

#include "NativeProxy.h"

JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *) {
return facebook::jni::initialize(
vm, [] { rnscreens::NativeProxy::registerNatives(); });
}
21 changes: 21 additions & 0 deletions android/src/main/java/com/swmansion/rnscreens/Screen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,27 @@ class Screen(context: ReactContext?) : FabricEnabledViewGroup(context) {

var nativeBackButtonDismissalEnabled: Boolean = true

fun startRemovalTransition() {
startTransitionRecursive(this)
}

private fun startTransitionRecursive(parent: ViewGroup?) {
parent?.let {
for (i in 0 until it.childCount) {
val child = it.getChildAt(i)
child?.let { view -> it.startViewTransition(view) }
if (child is ScreenStackHeaderConfig) {
// we want to start transition on children of the toolbar too,
// which is not a child of ScreenStackHeaderConfig
startTransitionRecursive(child.toolbar)
}
if (child is ViewGroup) {
startTransitionRecursive(child)
}
}
}
}

private fun calculateHeaderHeight(): Pair<Double, Double> {
val actionBarTv = TypedValue()
val resolvedActionBarSize = context.theme.resolveAttribute(android.R.attr.actionBarSize, actionBarTv, true)
Expand Down
Loading
Loading