@@ -43,6 +43,7 @@ import { getUrlWithoutParams } from '../../utils/utils';
4343export type GalleryPropsWithContext = Pick < ImageGalleryContextValue , 'imageGalleryStateStore' > &
4444 Pick <
4545 MessageContextValue ,
46+ | 'alignment'
4647 | 'images'
4748 | 'videos'
4849 | 'onLongPress'
@@ -69,6 +70,7 @@ export type GalleryPropsWithContext = Pick<ImageGalleryContextValue, 'imageGalle
6970const GalleryWithContext = ( props : GalleryPropsWithContext ) => {
7071 const {
7172 additionalPressableProps,
73+ alignment,
7274 imageGalleryStateStore,
7375 ImageLoadingFailedIndicator,
7476 ImageLoadingIndicator,
@@ -141,6 +143,7 @@ const GalleryWithContext = (props: GalleryPropsWithContext) => {
141143 styles . container ,
142144 {
143145 flexDirection : invertedDirections ? 'column' : 'row' ,
146+ alignSelf : alignment === 'right' ? 'flex-end' : 'flex-start' ,
144147 } ,
145148 images . length !== 1
146149 ? { width : gridWidth , height : gridHeight }
@@ -439,18 +442,25 @@ const GalleryImageThumbnail = ({
439442
440443const areEqual = ( prevProps : GalleryPropsWithContext , nextProps : GalleryPropsWithContext ) => {
441444 const {
445+ alignment : prevAlignment ,
442446 images : prevImages ,
443447 message : prevMessage ,
444448 myMessageTheme : prevMyMessageTheme ,
445449 videos : prevVideos ,
446450 } = prevProps ;
447451 const {
452+ alignment : nextAlignment ,
448453 images : nextImages ,
449454 message : nextMessage ,
450455 myMessageTheme : nextMyMessageTheme ,
451456 videos : nextVideos ,
452457 } = nextProps ;
453458
459+ const alignmentEqual = prevAlignment === nextAlignment ;
460+ if ( ! alignmentEqual ) {
461+ return false ;
462+ }
463+
454464 const messageEqual =
455465 prevMessage ?. id === nextMessage ?. id &&
456466 `${ prevMessage ?. updated_at } ` === `${ nextMessage ?. updated_at } ` ;
@@ -498,6 +508,7 @@ export type GalleryProps = Partial<GalleryPropsWithContext>;
498508 */
499509export const Gallery = ( props : GalleryProps ) => {
500510 const {
511+ alignment : propAlignment ,
501512 additionalPressableProps : propAdditionalPressableProps ,
502513 ImageLoadingFailedIndicator : PropImageLoadingFailedIndicator ,
503514 ImageLoadingIndicator : PropImageLoadingIndicator ,
@@ -517,6 +528,7 @@ export const Gallery = (props: GalleryProps) => {
517528
518529 const { imageGalleryStateStore } = useImageGalleryContext ( ) ;
519530 const {
531+ alignment : contextAlignment ,
520532 images : contextImages ,
521533 message : contextMessage ,
522534 onLongPress : contextOnLongPress ,
@@ -539,7 +551,7 @@ export const Gallery = (props: GalleryProps) => {
539551 const images = propImages || contextImages ;
540552 const videos = propVideos || contextVideos ;
541553 const message = propMessage || contextMessage ;
542-
554+ const alignment = propAlignment || contextAlignment ;
543555 if ( ! images . length && ! videos . length ) {
544556 return null ;
545557 }
@@ -568,6 +580,7 @@ export const Gallery = (props: GalleryProps) => {
568580 < MemoizedGallery
569581 { ...{
570582 additionalPressableProps,
583+ alignment,
571584 channelId : message ?. cid ,
572585 imageGalleryStateStore,
573586 ImageLoadingFailedIndicator,
@@ -608,7 +621,6 @@ const useStyles = () => {
608621 } ,
609622 container : {
610623 flexDirection : 'row' ,
611- justifyContent : 'center' ,
612624 gap : primitives . spacingXxs ,
613625 } ,
614626 imageContainer : { } ,
0 commit comments