Skip to content

Commit

Permalink
feat(GiphyGridView): add disableEmojiVariations property
Browse files Browse the repository at this point in the history
  • Loading branch information
pshoniuk committed Oct 13, 2023
1 parent 98cd776 commit abf3b95
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ class RTNGiphyGridView @JvmOverloads constructor(
}
}

fun setDisableEmojiVariations(value: Boolean?) {
if (value != null) {
// todo: implement
}
}

fun setFixedSizeCells(value: Boolean?) {
if (value != null) {
gridView.fixedSizeCells = value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ class RTNGiphyGridViewManager :
view?.setCellPadding(value)
}

@ReactProp(name = "disableEmojiVariations")
override fun setDisableEmojiVariations(view: RTNGiphyGridView?, value: Boolean) {
view?.setDisableEmojiVariations(value)
}

private fun getGridCallback(
view: RTNGiphyGridView,
context: ThemedReactContext
Expand Down
3 changes: 3 additions & 0 deletions android/src/oldarch/RTNGiphyGridViewManagerSpec.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ abstract class RTNGiphyGridViewManagerSpec<T : View> : SimpleViewManager<T>() {
@Suppress("unused")
abstract fun setContent(view: T?, value: String?)

@Suppress("unused")
abstract fun setDisableEmojiVariations(view: T?, value: Boolean)

@Suppress("unused")
abstract fun setFixedSizeCells(view: T?, value: Boolean)

Expand Down
1 change: 1 addition & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ Customizable implementation of a Giphy Grid only.
| cellPadding | Spacing between rendered GIFs. | `number`<br/><b>Note</b>: On iOS, only values between 0 and 11 inclusive are supported. | `0` |&nbsp;Android <br/> ✅&nbsp;iOS |
| clipsPreviewRenditionType | Certain renditions (cases of the [`GiphyRendition`](../src/dto/giphyRendition.ts) enum) are not available for Clips. As a result, if you set the renditionType property of the [GiphyGridView](#giphygridview) to an unsupported rendition type, clips previews may not play back correctly in the grid. To account for this limitation, we created this property specifically to work with clips. | [`GiphyClipsRendition`](../src/dto/giphyRendition.ts) | `.FixedWidth` |&nbsp;Android <br/> ✅&nbsp;iOS |
| content | A `GiphyContentRequest` object describing a content request to the Giphy API. | [`GiphyContentRequest`](../src/dto/giphyContentRequest.ts) | `None` |&nbsp;Android <br/> ✅&nbsp;iOS |
| disableEmojiVariations | If true, the emoji variations drawer is not rendered. | `boolean` | `None` |&nbsp;Android <br/> ✅&nbsp;iOS |
| fixedSizeCells | Display content in equally sized cells (for stickers only). | `boolean` | `false` |&nbsp;Android <br/> ✅&nbsp;iOS |
| onContentUpdate | A callback function that will be called when a content is updated. | `(e: NativeSyntheticEvent<{ resultCount: number }>) => void` | `None` |&nbsp;Android <br/> ✅&nbsp;iOS |
| onMediaSelect | A callback function that will be called when a media is selected. | `(e: NativeSyntheticEvent<{ media: GiphyMedia }>) => void` | `None` |&nbsp;Android <br/> ✅&nbsp;iOS |
Expand Down
3 changes: 2 additions & 1 deletion example/src/MediaGridSample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,12 @@ export function MediaGridSample(props: MediaGridSampleProps) {
})}
cellPadding={3}
clipsPreviewRenditionType={GiphyClipsRendition.FixedHeight}
disableEmojiVariations={true}
fixedSizeCells={false}
orientation={GiphyDirection.Vertical}
renditionType={GiphyRendition.FixedWidth}
spanCount={2}
showCheckeredBackground={false}
spanCount={2}
style={styles.giphyGridView}
testID="gph-grid-view"
onContentUpdate={(e) => console.log('onContentUpdate', JSON.stringify(e.nativeEvent, null, 2))}
Expand Down
1 change: 1 addition & 0 deletions ios/RTNGiphyGridView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &

REMAP_GPH_GRID_VIEW_JSON_PROP(content)
REMAP_GPH_GRID_VIEW_PROP(cellPadding)
REMAP_GPH_GRID_VIEW_PROP(disableEmojiVariations)
REMAP_GPH_GRID_VIEW_STR_PROP(clipsPreviewRenditionType)
REMAP_GPH_GRID_VIEW_STR_PROP(orientation)
REMAP_GPH_GRID_VIEW_STR_PROP(renditionType)
Expand Down
5 changes: 5 additions & 0 deletions ios/RTNGiphyGridViewImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ open class RTNGiphyGridViewImpl: UIView {
let renditionType = GPHRenditionType.fromRNValue(value: value as String)
gridController.clipsPreviewRenditionType = renditionType ?? .fixedWidth
}

@objc
public func setDisableEmojiVariations(_ value: Bool) -> Void {
// TODO: implement
}

@objc
public func setRenditionType(_ value: NSString) -> Void {
Expand Down
2 changes: 2 additions & 0 deletions ios/RTNGiphyGridViewManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ + (BOOL)requiresMainQueueSetup {

RCT_EXPORT_VIEW_PROPERTY(clipsPreviewRenditionType, NSString)

RCT_EXPORT_VIEW_PROPERTY(disableEmojiVariations, BOOL)

RCT_EXPORT_VIEW_PROPERTY(orientation, NSString)

RCT_EXPORT_VIEW_PROPERTY(renditionType, NSString)
Expand Down
3 changes: 3 additions & 0 deletions src/GiphyGridView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface GiphyGridViewProps extends ViewProps {
cellPadding?: number
clipsPreviewRenditionType?: GiphyClipsRendition
content?: GiphyContentRequest
disableEmojiVariations?: boolean
fixedSizeCells?: boolean
onContentUpdate?: DirectEventHandler<GiphyGridViewContentUpdateEvent>
onMediaSelect?: DirectEventHandler<GiphyGridViewMediaSelectEvent>
Expand Down Expand Up @@ -49,6 +50,7 @@ export class GiphyGridView extends React.Component<GiphyGridViewProps, {}> {
cellPadding = 0,
clipsPreviewRenditionType = 'fixed_width',
content,
disableEmojiVariations = false,
fixedSizeCells = false,
onMediaSelect,
orientation = 'vertical',
Expand All @@ -63,6 +65,7 @@ export class GiphyGridView extends React.Component<GiphyGridViewProps, {}> {
cellPadding={cellPadding}
clipsPreviewRenditionType={clipsPreviewRenditionType}
content={content ? JSON.stringify(content) : ''}
disableEmojiVariations={disableEmojiVariations}
fixedSizeCells={fixedSizeCells}
onMediaSelect={onMediaSelect ? this.mediaSelectHandler : undefined}
orientation={orientation}
Expand Down
1 change: 1 addition & 0 deletions src/specs/GiphyGridViewNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface NativeProps extends ViewProps {
cellPadding: Int32
clipsPreviewRenditionType: string
content?: string
disableEmojiVariations: boolean
fixedSizeCells: boolean
onContentUpdate?: DirectEventHandler<GiphyGridViewContentUpdateEvent>
onMediaSelect?: DirectEventHandler<GiphyGridViewRawMediaSelectEvent>
Expand Down

0 comments on commit abf3b95

Please sign in to comment.