Skip to content

Commit f3da704

Browse files
committed
lightbox [nfc]: Tighten and clarify docs on _LightboxHeroTag
1 parent 187a022 commit f3da704

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

lib/widgets/lightbox.dart

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,37 @@ import 'dialog.dart';
1515
import 'page.dart';
1616
import 'store.dart';
1717

18+
/// Identifies which [LightboxHero]s should match up with each other
19+
/// to produce a hero animation.
20+
///
21+
/// See [Hero.tag], the field where we use instances of this class.
22+
///
23+
/// The intended behavior is that when the user acts on an image
24+
/// in the message list to have the app expand it in the lightbox,
25+
/// a hero animation goes from the original view of the image
26+
/// to the version in the lightbox,
27+
/// and back to the original upon exiting the lightbox.
1828
class _LightboxHeroTag {
1929
_LightboxHeroTag({
2030
required this.messageImageContext,
2131
required this.src,
2232
});
2333

24-
/// The [BuildContext] of the image in the message list that's being expanded
25-
/// into the lightbox. Used to coordinate the Hero animation between this specific
26-
/// image and the lightbox view.
34+
/// The [BuildContext] for the [MessageImage] being expanded into the lightbox.
2735
///
28-
/// This helps ensure the animation only happens between the correct image instances,
29-
/// preventing unwanted animations between different message lists or between
30-
/// different images that happen to have the same URL.
36+
/// In particular this prevents hero animations between
37+
/// different message lists that happen to have the same message.
38+
/// It also distinguishes different copies of the same image
39+
/// in a given message list.
3140
// TODO: write a regression test for #44, duplicate images within a message
3241
final BuildContext messageImageContext;
3342

34-
/// The image source URL. Used to match the source and destination images
35-
/// during the Hero animation, ensuring the animation only occurs between
36-
/// images showing the same content.
43+
/// The image source URL.
44+
///
45+
/// This ensures the animation only occurs between matching images, even if
46+
/// the message was edited before navigating back to the message list
47+
/// so that the original [MessageImage] has been replaced in the tree
48+
/// by a different image.
3749
final Uri src;
3850

3951
@override

0 commit comments

Comments
 (0)