Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ abstract class BaseExperienceActivity : ReactNativeActivity() {

private var onResumeTime: Long = 0

/**
* Flag to indicate that this Activity uses its own navigation handling (e.g., Compose's NavController)
* and should bypass the default `onBackPressed` behavior of this base class.
*/
protected open var usesComposeNavigation: Boolean = false

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
isInForeground = true
Expand Down Expand Up @@ -104,11 +98,6 @@ abstract class BaseExperienceActivity : ReactNativeActivity() {

@SuppressLint("MissingSuperCall")
override fun onBackPressed() {
if (usesComposeNavigation) {
super.onBackPressed()
return
}

if (!isCrashed) {
reactHost?.onBackPressed()
} else {
Expand All @@ -117,10 +106,6 @@ abstract class BaseExperienceActivity : ReactNativeActivity() {
}

override fun invokeDefaultOnBackPressed() {
if (usesComposeNavigation) {
super.invokeDefaultOnBackPressed()
return
}
moveTaskToBack(true)
}

Expand Down Expand Up @@ -200,8 +185,6 @@ abstract class BaseExperienceActivity : ReactNativeActivity() {
}

companion object {
private val TAG = BaseExperienceActivity::class.java.simpleName

// TODO: kill. just use Exponent class's activity
var visibleActivity: BaseExperienceActivity? = null
private set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,32 @@ import android.content.res.Configuration
import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.ui.platform.ComposeView
import androidx.core.view.WindowCompat
import androidx.lifecycle.lifecycleScope
import com.facebook.react.soloader.OpenSourceMergedSoMapping
import com.facebook.soloader.SoLoader
import de.greenrobot.event.EventBus
import host.exp.exponent.di.NativeModuleDepsProvider
import host.exp.exponent.home.HomeActivityEvent
import host.exp.exponent.home.HomeAppViewModel
import host.exp.exponent.home.HomeAppViewModelFactory
import host.exp.exponent.home.RootNavigation
import host.exp.exponent.home.auth.AuthActivity
import host.exp.exponent.home.auth.AuthResult
import host.exp.exponent.kernel.ExperienceKey
import host.exp.exponent.kernel.ExpoViewKernel
import host.exp.exponent.kernel.Kernel
import host.exp.exponent.services.ThemeSetting
import host.exp.exponent.utils.ExperienceRTLManager
import host.exp.exponent.utils.currentDeviceIsAPhone
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.launch
import org.json.JSONException
import javax.inject.Inject

open class HomeActivity : AppCompatActivity() {
@Inject
protected lateinit var kernel: Kernel

open class HomeActivity : BaseExperienceActivity() {
val homeActivityEvents = MutableSharedFlow<HomeActivityEvent>()

val authLauncher = registerForActivityResult(AuthActivity.Contract()) { result ->
Expand All @@ -54,7 +57,7 @@ open class HomeActivity : BaseExperienceActivity() {

//region Activity Lifecycle
override fun onCreate(savedInstanceState: Bundle?) {
usesComposeNavigation = true
NativeModuleDepsProvider.instance.inject(HomeActivity::class.java, this)

enableEdgeToEdge()

Expand All @@ -66,19 +69,8 @@ open class HomeActivity : BaseExperienceActivity() {

super.onCreate(savedInstanceState)

NativeModuleDepsProvider.instance.inject(HomeActivity::class.java, this)

manifest = exponentManifest.getKernelManifestAndAssetRequestHeaders().manifest
experienceKey = try {
ExperienceKey.fromManifest(manifest!!)
} catch (_: JSONException) {
ExperienceKey("")
}

updateStatusBarForTheme(viewModel.selectedTheme.value)

EventBus.getDefault().registerSticky(this)

ExperienceRTLManager.setRTLPreferences(this, allowRTL = false, forceRTL = false)

val contentView = ComposeView(this).apply {
Expand Down Expand Up @@ -113,11 +105,6 @@ open class HomeActivity : BaseExperienceActivity() {
}
//endregion Activity Lifecycle

override fun onError(intent: Intent) {
intent.putExtra(ErrorActivity.IS_HOME_KEY, true)
kernel.setHasError()
}

override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
enableEdgeToEdge()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package host.exp.exponent.home

import androidx.activity.compose.BackHandler
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Spacer
Expand Down Expand Up @@ -86,10 +85,6 @@ fun RootNavigation(
) {
val navController = rememberNavController()

BackHandler(enabled = true) {
navController.popBackStack()
}

val themeSetting by viewModel.selectedTheme.collectAsStateWithLifecycle()

HomeAppTheme(themeSetting = themeSetting) {
Expand Down
12 changes: 12 additions & 0 deletions apps/router-e2e/__e2e__/link-preview/app/misc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,18 @@ const HomeIndex = () => {
</Link.Trigger>
<Link.Preview />
</Link>
<Link href="/zoom-dest-list" asChild>
<Link.Trigger withAppleZoom>
<Pressable style={{ flex: 1, width: '33%', aspectRatio: width / height }}>
<Image
source={require('../../../assets/frog.jpg')}
resizeMode="cover"
style={{ width: '100%', height: '100%' }}
/>
</Pressable>
</Link.Trigger>
<Link.Preview />
</Link>
</ScrollView>
);
};
Expand Down
42 changes: 42 additions & 0 deletions apps/router-e2e/__e2e__/link-preview/app/zoom-dest-list.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Link, usePreventZoomTransitionDismissal } from 'expo-router';
import { useState } from 'react';
import { Image, ScrollView, View } from 'react-native';

export default function ZoomDestScreen() {
const [shouldPrevent, setShouldPrevent] = useState(false);
usePreventZoomTransitionDismissal(
shouldPrevent
? undefined
: {
unstable_dismissalBoundsRect: { minX: 0, minY: 0 },
}
);
return (
<ScrollView
style={{ flex: 1 }}
onScroll={(event) => {
setShouldPrevent(event.nativeEvent.contentOffset.y > 1);
}}>
<Link.AppleZoomTarget>
<View style={{ width: '100%', aspectRatio: 1 }}>
<Image
source={require('../../../assets/frog.jpg')}
style={{ width: '100%', height: '100%' }}
/>
</View>
</Link.AppleZoomTarget>
<View style={{ width: '100%', aspectRatio: 1 }}>
<Image
src="https://picsum.photos/seed/1/800/600"
style={{ width: '100%', height: '100%' }}
/>
</View>
<View style={{ width: '100%', aspectRatio: 1 }}>
<Image
src="https://picsum.photos/seed/2/800/600"
style={{ width: '100%', height: '100%' }}
/>
</View>
</ScrollView>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ appId: com.expo.routere2e
- assertVisible: "applewatch.side.right"
- assertVisible: "Index tab"
- assertVisible: "lock.applewatch"
- assertVisible: "faces"
- assertVisible: "figure.disc.sports"
- assertVisible: "Dynamic"
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ name: Native tabs minimize behavior
id: "forward-button"
- assertVisible: "applewatch.side.right"
- assertNotVisible: "lock.applewatch"
- assertNotVisible: "faces"
- assertNotVisible: "figure.disc.sports"
- assertNotVisible: "Dynamic"
# Scroll up to maximize
Expand All @@ -57,9 +56,4 @@ name: Native tabs minimize behavior
id: "pause-button"
- assertVisible:
id: "forward-button"
- assertVisible: "applewatch.side.right"
- assertVisible: "Index tab"
- assertVisible: "lock.applewatch"
- assertVisible: "faces"
- assertVisible: "figure.disc.sports"
- assertVisible: "Dynamic"
- runFlow: ../assert-all-tabs-visible.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
appId: com.expo.routere2e
name: Toolbar button press
name: Toolbar shares background
---
- stopApp: com.expo.routere2e
- openLink: router-e2e://toolbar?searchButton=true&micButton=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,13 @@ name: Toolbar hide-show
- assertVisible: "Toolbar E2E Test Screen"
- tapOn:
id: "toggle-search-button"
- tapOn: "undefined"
- tapOn: "Search"
- assertVisible: "Searching for: empty"
- tapOn: "OK"
- tapOn:
id: "toggle-mic-button"
- assertVisible: "undefined"
- assertVisible: "undefined"
- assertVisible:
text: "undefined"
index: 0
- assertVisible:
text: "undefined"
index: 1
- assertVisible: "microphone"
- assertVisible: "search"
- tapOn:
id: "toggle-custom-view"
- assertVisible:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jsEngine: graaljs
id: input-fixed-spacer-width
- tapOn: "Select All"
- inputText: "100"
- tapOn: Fixed Spacer Width (pt)
- tapOn: Toolbar E2E Test Screen
- tapOn:
point: 17%, 92%
- assertVisible: "Searching for: empty"
Expand Down
Loading
Loading