瀏覽代碼

Fix

master
Lazar Kostic 2 年之前
父節點
當前提交
6562e750ac
共有 2 個文件被更改,包括 62 次插入50 次删除
  1. 13
    4
      navigation/RootNavigation.js
  2. 49
    46
      screens/HomeScreen.jsx

+ 13
- 4
navigation/RootNavigation.js 查看文件

@@ -1,25 +1,26 @@
import React from "react";
import AppStack from "./AppStack";
import AuthStack from "./AuthStack";
import { SafeAreaView } from "react-native-safe-area-context";
import { SafeAreaView as SafeArea } from "react-native-safe-area-context";
import { useSelector } from "react-redux";
import { selectCurrentToken } from "@features/auth/authSlice";
import { StatusBar } from "expo-status-bar";
import { useTheme } from "@styles";
import { Platform, SafeAreaView } from "react-native";

const RootNavigation = () => {
const { isDark, colors } = useTheme();
const tokens = useSelector(selectCurrentToken);

return !tokens ? (
<SafeAreaView style={{ flex: 1, backgroundColor: colors.background }}>
<>
<StatusBar
backgroundColor={colors.background}
style={isDark ? "light" : "dark"}
/>
<AuthStack />
</SafeAreaView>
) : (
</>
) : Platform.OS === "ios" ? (
<SafeAreaView style={{ flex: 1, backgroundColor: colors.background }}>
<StatusBar
backgroundColor={colors.background}
@@ -27,6 +28,14 @@ const RootNavigation = () => {
/>
<AppStack />
</SafeAreaView>
) : (
<SafeArea style={{ flex: 1 }} edges={["top"]}>
<StatusBar
backgroundColor={colors.background}
style={isDark ? "light" : "dark"}
/>
<AppStack />
</SafeArea>
);
};


+ 49
- 46
screens/HomeScreen.jsx 查看文件

@@ -87,54 +87,57 @@ const HomeScreen = ({ navigation }) => {
style={{ flex: 1, color: colors.textPrimary }}
/>
</View>
<Text>
{filteredData?.length === 0 && (
<View style={{paddingHorizontal: 18}}>
<Text
style={[globalStyles.boldText, { color: colors.textPrimary }]}
>
{t('common.noResults')}
</Text>
</View>
)}
{!isLoading && (
<ScrollView style={{ flex: 1, paddingHorizontal: 18 }}>
{query.length === 0
? posts?.map((post) => (
<ListItem
key={post?.id}
title={post?.attributes?.title}
photo={
post?.attributes?.profileImage?.data?.attributes?.formats
}
publishedAt={post?.attributes?.publishedAt}
onPress={() =>
navigation.navigate("PostDetails", {
title: post?.attributes?.title,
id: post?.id,
})
}
/>
))
: filteredData.map((post) => (
<ListItem
key={post?.id}
title={post?.attributes?.title}
photo={
post?.attributes?.profileImage?.data?.attributes?.formats
}
publishedAt={post?.attributes?.publishedAt}
onPress={() =>
navigation.navigate("PostDetails", {
title: post?.attributes?.title,
id: post?.id,
})
}
/>
))}
</ScrollView>
<View style={{ paddingHorizontal: 18 }}>
<Text
style={[globalStyles.boldText, { color: colors.textPrimary }]}
>
{t("common.noResults")}
</Text>
</View>
)}
</Text>
{!isLoading && (
<ScrollView
style={{ flex: 1, paddingHorizontal: 18 }}
showsVerticalScrollIndicator={false}
>
{query.length === 0
? posts?.map((post) => (
<ListItem
key={post?.id}
title={post?.attributes?.title}
photo={
post?.attributes?.profileImage?.data?.attributes?.formats
}
publishedAt={post?.attributes?.publishedAt}
onPress={() =>
navigation.navigate("PostDetails", {
title: post?.attributes?.title,
id: post?.id,
})
}
/>
))
: filteredData.map((post) => (
<ListItem
key={post?.id}
title={post?.attributes?.title}
photo={
post?.attributes?.profileImage?.data?.attributes?.formats
}
publishedAt={post?.attributes?.publishedAt}
onPress={() =>
navigation.navigate("PostDetails", {
title: post?.attributes?.title,
id: post?.id,
})
}
/>
))}
</ScrollView>
)}
</Layout>
);
};

Loading…
取消
儲存