方法
#setSubFiltersFilter(subFiltersFilter)
您可以使用它来设置子筛选器函数,以在Discussion屏幕中重新排列筛选器的顺序。例如,你可以在搜索栏下的讨论屏幕上重新排列标签,如“创建日期”、“最后活动日期”等。
参数:
的名字 | 类型 | 描述 |
---|---|---|
subFiltersFilter |
TransformTopicSubFiltersFilterCallback |
例子
externalCodeSetup.topicsApi.setSubFiltersFilter((filters) => {return ["date"];//可用的过滤器包括"activity", "date", "title", "popular"})
#setTopicItemComponent(TopicItemComponent可以为空)
它在主题列表中呈现自定义主题项组件。例如,您可以在主题/讨论项中添加“更多细节”选项。
参数:
的名字 | 类型 | 属性 | 描述 |
---|---|---|---|
TopicItemComponent |
React.ComponentType。<TopicItemProps> | <空> |
例子
//在custom_code/components/TopicItem.js中import React from ' React ';import {View, Text, StyleSheet, Animated} from 'react-native';import AppTouchableOpacity from "@src/components/AppTouchableOpacity";import {getAvatar} from "@src/utils";import AppAvatar from "@src/components/AppAvatar";import AuthWrapper from "@src/components/AuthWrapper";import ActionSheetButton from "@src/components/ActionButtons/ActionSheetButton";import {GUTTER} from "@src/styles/global";const TopicItem = (props) => {const {topic, styles, actionButtons, formatDateFunc, t} = props;Const global = style .global; const colors = styles.colors; let rootStyle; if (topic.actionStates.sticky) rootStyle = [global.itemSticky]; if (!topic.actionStates.open) rootStyle = [global.itemClosed]; const Item = {topic.title} {topic.shortContent} {topic.voiceCount} {topic.replyCount} {t("topics:lastActive", { date: formatDateFunc(topic.lastActive) })} return Item; } export default TopicItem; //In custom_code/index.js... ... import TopicItem from "./components/TopicItem"; export const applyCustomCode = externalCodeSetup => { externalCodeSetup.topicsApi.setTopicItemComponent(props => { return ; }) }
#setTopicToViewModelFilter(topicToViewModelFilter)
您可以使用它来设置可以更改现有主题的视图模型对象的回调函数。
参数:
的名字 | 类型 | 描述 |
---|---|---|
topicToViewModelFilter |
TransformTopicViewModelCallback |
例子
externalCodeSetup.topicsApi。setTopicToViewModelFilter((props, topic) => { return { ...props, topicUpvotes: 30 }; })