|
|
@@ -33,9 +33,11 @@ import shareTitle from "./moment_unit";
|
|
|
|
|
|
let useRoute;
|
|
|
let useNavigation;
|
|
|
+let FlatList;
|
|
|
if (process.env.TARO_ENV == 'rn') {
|
|
|
useRoute = require("@react-navigation/native").useRoute
|
|
|
useNavigation = require("@react-navigation/native").useNavigation
|
|
|
+ FlatList = require('react-native').FlatList
|
|
|
}
|
|
|
|
|
|
let timer;
|
|
|
@@ -87,7 +89,7 @@ export default function MomentMain() {
|
|
|
const [showGuide, setShowGuide] = useState(false)
|
|
|
const [showShareGuide, setShowShareGuide] = useState(false)
|
|
|
const [shareInfo, setShareInfo] = useState<any>(null)
|
|
|
- const query = Taro.createSelectorQuery()
|
|
|
+ const query: any = process.env.TARO_ENV == 'weapp' ? Taro.createSelectorQuery() : null
|
|
|
|
|
|
const dispatch = useDispatch()
|
|
|
const { t } = useTranslation()
|
|
|
@@ -213,6 +215,7 @@ export default function MomentMain() {
|
|
|
}, [endSignal])
|
|
|
|
|
|
function measureItemLayouts() {
|
|
|
+ if (process.env.TARO_ENV == 'rn') return
|
|
|
if (moments.length <= 10) {
|
|
|
moments.forEach((item, index) => {
|
|
|
query.select(`#history2-${index}`).boundingClientRect()
|
|
|
@@ -468,6 +471,98 @@ export default function MomentMain() {
|
|
|
</Block>
|
|
|
}
|
|
|
|
|
|
+ function wxList() {
|
|
|
+ return <ScrollView style={{
|
|
|
+ marginTop: navigationBarHeight,
|
|
|
+ height: '90vh'
|
|
|
+ }}
|
|
|
+ enableBackToTop
|
|
|
+ ref={scrollRef}
|
|
|
+ id="myscrollview"
|
|
|
+ scrollY={showShareGuide ? false : true}
|
|
|
+ refresherEnabled={true}
|
|
|
+ upperThreshold={70}
|
|
|
+ // scrollTop={showShareGuide ? pageTop : undefined}
|
|
|
+ // lowerThreshold={140}
|
|
|
+ refresherBackground={MainColorType.g05}
|
|
|
+ onRefresherRefresh={onRefresh}
|
|
|
+ refresherTriggered={isPulling}
|
|
|
+ onScroll={onScroll}
|
|
|
+ onScrollToUpper={() => {
|
|
|
+ // setPage(1)
|
|
|
+ // if (moments.length > 10) {
|
|
|
+ // setMoments(moments.slice(0, 10))
|
|
|
+ // setItemHeights(itemHeights.slice(0, 10))
|
|
|
+ // setItemLayouts(itemLayouts.slice(0, 10))
|
|
|
+ // }
|
|
|
+
|
|
|
+ }}
|
|
|
+ // onScrollToLower={props.loadMore}
|
|
|
+ >
|
|
|
+ <View style={{ backgroundColor: '#fff', minHeight: '100vh', paddingTop: rpxToPx(30), paddingBottom: 100 }}>
|
|
|
+ {
|
|
|
+ dashBoard && dashBoard.new_message && <View className="new_message_bg">
|
|
|
+
|
|
|
+ <View className="new_message" onClick={() => {
|
|
|
+ jumpPage('/_moment/pages/message')
|
|
|
+ }}>
|
|
|
+ {
|
|
|
+ dashBoard.new_message.avatars.map((item, index) => {
|
|
|
+ return <Image className="message_avatar" src={item} key={index} style={{ zIndex: 9 - index, marginLeft: index == 0 ? rpxToPx(8) : -15 }} />
|
|
|
+ })
|
|
|
+ }
|
|
|
+ <View className="h26 bold" style={{ color: '#fff', minWidth: rpxToPx(260), textAlign: 'center' }}>{dashBoard.new_message.message_tip}</View>
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ }
|
|
|
+ {
|
|
|
+ moments.map((item, index) => {
|
|
|
+ if (itemLayouts.length >= index + 1 && pageTop > 0 && index > 5) {
|
|
|
+ if (Math.abs(itemLayouts[index] - pageTop) > 2500) {
|
|
|
+ return <View style={{ height: itemHeights[index] }} id={`history—temp-${index}`}>
|
|
|
+ </View>
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return <View key={index} id={`history2-${index}`}>
|
|
|
+ <MomentItem data={item} del={
|
|
|
+ () => {
|
|
|
+ var list = JSON.parse(JSON.stringify(moments))
|
|
|
+ list.splice(index, 1)
|
|
|
+ setMoments(list)
|
|
|
+ }
|
|
|
+ } />
|
|
|
+ </View>
|
|
|
+ })
|
|
|
+ }
|
|
|
+ {
|
|
|
+ moments.length == 0 && <NoRecord style={{ marginTop: rpxToPx(160) }} />
|
|
|
+ }
|
|
|
+
|
|
|
+ <ListFooter noMore={noMore} loading={loading} />
|
|
|
+ <View id="footer" style={{ width: 1, height: 1 }}></View>
|
|
|
+ </View>
|
|
|
+ </ScrollView>
|
|
|
+ }
|
|
|
+
|
|
|
+ function rnList() {
|
|
|
+ return <FlatList
|
|
|
+ style={{
|
|
|
+ marginTop: navigationBarHeight,
|
|
|
+ height: screenHeight-navigationBarHeight
|
|
|
+ }}
|
|
|
+ data={moments}
|
|
|
+ keyExtractor={item => item.link.event_id}
|
|
|
+ renderItem={({ item, index }) => <MomentItem data={item} del={
|
|
|
+ () => {
|
|
|
+ var list = JSON.parse(JSON.stringify(moments))
|
|
|
+ list.splice(index, 1)
|
|
|
+ setMoments(list)
|
|
|
+ }
|
|
|
+ } />}
|
|
|
+ />
|
|
|
+ }
|
|
|
+
|
|
|
function listDetail() {
|
|
|
return <View >
|
|
|
<View style={{
|
|
|
@@ -491,77 +586,9 @@ export default function MomentMain() {
|
|
|
</View>
|
|
|
</View>
|
|
|
</View>
|
|
|
- <ScrollView style={{
|
|
|
- marginTop: navigationBarHeight,
|
|
|
- height: '90vh'
|
|
|
- }}
|
|
|
- enableBackToTop
|
|
|
- ref={scrollRef}
|
|
|
- id="myscrollview"
|
|
|
- scrollY={showShareGuide ? false : true}
|
|
|
- refresherEnabled={true}
|
|
|
- upperThreshold={70}
|
|
|
- // scrollTop={showShareGuide ? pageTop : undefined}
|
|
|
- // lowerThreshold={140}
|
|
|
- refresherBackground={MainColorType.g05}
|
|
|
- onRefresherRefresh={onRefresh}
|
|
|
- refresherTriggered={isPulling}
|
|
|
- onScroll={onScroll}
|
|
|
- onScrollToUpper={() => {
|
|
|
- // setPage(1)
|
|
|
- // if (moments.length > 10) {
|
|
|
- // setMoments(moments.slice(0, 10))
|
|
|
- // setItemHeights(itemHeights.slice(0, 10))
|
|
|
- // setItemLayouts(itemLayouts.slice(0, 10))
|
|
|
- // }
|
|
|
-
|
|
|
- }}
|
|
|
- // onScrollToLower={props.loadMore}
|
|
|
- >
|
|
|
- <View style={{ backgroundColor: '#fff', minHeight: '100vh', paddingTop: rpxToPx(30), paddingBottom: 100 }}>
|
|
|
- {
|
|
|
- dashBoard && dashBoard.new_message && <View className="new_message_bg">
|
|
|
-
|
|
|
- <View className="new_message" onClick={() => {
|
|
|
- jumpPage('/_moment/pages/message')
|
|
|
- }}>
|
|
|
- {
|
|
|
- dashBoard.new_message.avatars.map((item, index) => {
|
|
|
- return <Image className="message_avatar" src={item} key={index} style={{ zIndex: 9 - index, marginLeft: index == 0 ? rpxToPx(8) : -15 }} />
|
|
|
- })
|
|
|
- }
|
|
|
- <View className="h26 bold" style={{ color: '#fff', minWidth: rpxToPx(260), textAlign: 'center' }}>{dashBoard.new_message.message_tip}</View>
|
|
|
- </View>
|
|
|
- </View>
|
|
|
- }
|
|
|
- {
|
|
|
- moments.map((item, index) => {
|
|
|
- if (itemLayouts.length >= index + 1 && pageTop > 0 && index > 5) {
|
|
|
- if (Math.abs(itemLayouts[index] - pageTop) > 2500) {
|
|
|
- return <View style={{ height: itemHeights[index] }} id={`history—temp-${index}`}>
|
|
|
- </View>
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- return <View key={index} id={`history2-${index}`}>
|
|
|
- <MomentItem data={item} del={
|
|
|
- () => {
|
|
|
- var list = JSON.parse(JSON.stringify(moments))
|
|
|
- list.splice(index, 1)
|
|
|
- setMoments(list)
|
|
|
- }
|
|
|
- } />
|
|
|
- </View>
|
|
|
- })
|
|
|
- }
|
|
|
- {
|
|
|
- moments.length == 0 && <NoRecord style={{ marginTop: rpxToPx(160) }} />
|
|
|
- }
|
|
|
-
|
|
|
- <ListFooter noMore={noMore} loading={loading} />
|
|
|
- <View id="footer" style={{ width: 1, height: 1 }}></View>
|
|
|
- </View>
|
|
|
- </ScrollView>
|
|
|
+ {
|
|
|
+ process.env.TARO_ENV == 'weapp' ? wxList() : rnList()
|
|
|
+ }
|
|
|
<Block>
|
|
|
{
|
|
|
showShareGuide && <MomentDetailShare user={shareInfo.join.user} btnColor={getThemeColor(shareInfo.join.window)}
|