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 @@ -483,6 +483,7 @@ class T3ReviewDiffView(context: Context, appContext: AppContext) : ExpoView(cont
)
postInvalidateOnAnimation()
} else {
verticalScroller.forceFinished(true)
canvasView.setVerticalOffset(target)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,30 @@ import org.robolectric.annotation.Config
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [35], manifest = Config.NONE)
class ReviewDiffViewportTest {
@Test
fun immediateNavigationStopsAnActiveFling() {
val activity = Robolectric.buildActivity(Activity::class.java).setup().get()
val view = T3ReviewDiffView(activity, AppContext())
val scroller = view.javaClass.getDeclaredField("verticalScroller").apply {
isAccessible = true
}.get(view) as android.widget.OverScroller
try {
scroller.fling(0, 100, 0, 2000, 0, 0, 0, 10000)
assertTrue(!scroller.isFinished)
view.scrollToTop(false)
view.computeScroll()
val canvas = view.getChildAt(0)
val offset = canvas.javaClass.getDeclaredMethod("verticalOffset").apply {
isAccessible = true
}.invoke(canvas)
assertEquals(0, offset)
assertTrue(scroller.isFinished)
} finally {
view.cleanup()
activity.finish()
}
}

@Test
fun resetDiscardsOldRowsAndPendingDecodeBeforePublishingTheNewDestination() {
val activity = Robolectric.buildActivity(Activity::class.java).setup().get()
Expand Down
6 changes: 5 additions & 1 deletion apps/mobile/src/features/review/ReviewSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
View,
} from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { useReduceMotionEnabled } from "../../lib/appState";
import { useNativeColumnLayoutMetrics } from "../../native/native-layout-metrics";
import { NativeInspectorContent } from "../../native/NativeInspectorContent";

Expand Down Expand Up @@ -423,6 +424,7 @@ type ReviewSheetProps = StaticScreenProps<{
}>;

export function ReviewSheet(props: ReviewSheetProps) {
const reduceMotion = useReduceMotionEnabled();
const { nativeReviewDiffStyle } = useAppearanceCodeSurface();
useAdaptiveWorkspacePaneRole("inspector");
const { panes } = useAdaptiveWorkspaceLayout();
Expand Down Expand Up @@ -542,7 +544,9 @@ export function ReviewSheet(props: ReviewSheetProps) {
const nativeView = nativeReviewDiffViewRef.current;
if (!nativeView) return;
const result = await settlePromise(() =>
fileId === null ? nativeView.scrollToTop(true) : nativeView.scrollToFile(fileId, true),
fileId === null
? nativeView.scrollToTop(!reduceMotion)
: nativeView.scrollToFile(fileId, !reduceMotion),
);
if (AsyncResult.isFailure(result)) {
console.error("[review] Failed to navigate to diff file", squashAtomCommandFailure(result));
Expand Down
Loading