import * as WebBrowser from "expo-web-browser";
import * as React from "react";
import {
Image,
StyleSheet,
TouchableOpacity,
ImageBackground,
View,
} from "react-native";
import { ScrollView } from "react-native-gesture-handler";
import { useModel } from "flooks";
import {
Layout,
Text,
useTheme,
Button,
Card,
Icon,
MenuItem,
OverflowMenu,
TopNavigation,
TopNavigationAction,
} from "@ui-kitten/components";
import { createMaterialTopTabNavigator } from "@react-navigation/material-top-tabs";
import { useFocusEffect } from "@react-navigation/native";
import Badge from "../components/Badge";
import HomePage1 from "./HomeScreenPage1";
import HomePage2 from "./Comment";
import HomePage3 from "./HomeScreenPage3";
import * as RootNavigation from "../navigation/RootNavigation";
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#F0F0F0",
},
touch: {
width: 53,
height: 53,
position: "absolute",
left: 10,
top: 10,
zIndex: 2,
},
icon: {
width: 53,
height: 53,
backgroundColor: "#E5E5E5",
borderRadius: 3,
},
text: {
fontWeight: "500",
marginBottom: 7,
},
button: {
marginTop: 19,
},
banner: {
height: 100,
backgroundColor: "#E5E5E5",
position: "absolute",
left: 0,
right: 0,
top: 0,
zIndex: 1,
},
FlexRow: {
flexDirection: "row",
alignItems: "center",
marginTop: 2,
},
zanImg: {
width: 12,
height: 12,
marginRight: 3,
},
layItem: {
width: 40,
marginRight: 10,
},
cardMain: {
alignItems: "center",
zIndex: 1,
},
cardTop: {
minHeight: 53,
alignItems: "center",
justifyContent: "center",
paddingBottom: 10,
},
allBadges1: {
marginHorizontal: 10,
},
allBadges: {
overflow: "hidden",
height: 20,
marginHorizontal: 10,
},
more: {
position: "absolute",
right: 5,
top: 57,
},
badges: {
flexDirection: "row",
flexWrap: "wrap",
alignSelf: "center",
backgroundColor: "rgba(0,0,0,0)",
},
badge: {
marginRight: 15,
marginTop: 3,
},
labelText: {
textAlign: "left",
fontSize: 13,
paddingHorizontal: 10,
minWidth: 120,
maxWidth: "100%",
},
homeCard: {
zIndex: 2,
marginHorizontal: 15,
marginTop: 80,
},
mainContent: {
marginTop: 0,
backgroundColor: "transparent",
},
tab: {
backgroundColor: "#eee",
},
tabContainer: {
backgroundColor: "transparent",
},
tabIndicator: {
backgroundColor: "#FFC21C",
},
btn: {
maxWidth: "100%",
overflow: "hidden",
paddingLeft: 30,
},
});
const Tab = createMaterialTopTabNavigator();
const labelText = (focused, title) => (
{title}
);
const NextIcon = props => ;
const SearchIcon = props => ;
const MailIcon = props => ;
const ShareIcon = props => ;
const MenuIcon = props => ;
const LogoutIcon = props => ;
const img1 = require("../assets/images/zan.png");
const img2 = require("../assets/images/cai.png");
export default function HomeScreen({ navigation, route }) {
const theme = useTheme();
const { changeBackground } = useModel("barModel");
const {
showName,
logo,
proclamation,
updateMerchant,
banner,
userLogout,
monthSales,
goodNum,
badNum,
firstOrder,
} = useModel("userModel");
const {
homeBar,
homeTip1,
homeTitle3,
homeTip2,
homeTip3,
homeTab1,
homeTab2,
homeTab3,
fullReduction2,
fullReduction1,
ABSYHA,
HXRNYH,
MPSFFU,
changeLocal,
local,
} = useModel("wordsModel");
const [fullReductions, changeFllReduction] = React.useState([]);
const { showDialog } = useModel("dialogModel", true);
const { httpGet } = useModel("httpModel", true);
const { getPlaf } = useModel("couponModel", true);
const [showMore, changeShow] = React.useState(false);
const [couponList, setCouponList] = React.useState([]);
// const couponTips = React.useMemo(() => {
// if (couponList.length > 0) {
// return couponList
// .map(item => {
// return item.name;
// })
// .join(",");
// }
// return "";
// }, [couponList]);
useFocusEffect(
React.useCallback(() => {
changeBackground(theme["color-primary-500"]);
httpGet("/fullReduction/my").then(res => {
changeFllReduction(res);
});
getPlaf().then(res => {
setCouponList(res);
});
}, [])
);
const [menuVisible, setMenuVisible] = React.useState(false);
const toggleMenu = () => {
setMenuVisible(!menuVisible);
};
const renderMenuAction = () => (
);
const renderRightActions = () => (
<>
{
RootNavigation.navigate("Search");
}}
/>
{
RootNavigation.navigate("SystemEmail");
}}
/>
>
);
const renderBackAction = () => {homeBar};
const badgeList = list => {
return list.map(item => {
return (
{fullReduction1}
{item.fullAmount}
{fullReduction2}
{item.minusAmount}
);
});
};
const CoupnbadgeList = list => {
return list.map((item, index) => {
return (
{item.name}
);
});
};
const [scrollRef, setScroll] = React.useState();
React.useEffect(() => {
const unsubscribe = navigation.addListener("tabPress", () => {
if (route.name === "Home") {
navigation.jumpTo("homeTab1");
if (scrollRef) {
scrollRef.scrollTo({ x: 0, y: 0, animated: true });
}
}
});
return unsubscribe;
}, [navigation]);
return (
<>
RootNavigation.navigate("EditBanner", {
type: "logo",
})
}
>
{showName}
{goodNum || 0}
{badNum || 0}
{`${homeTip2} :`}
{monthSales || 0}
{
changeShow(!showMore);
}}
>
{badgeList(fullReductions)}
{firstOrder !== 0 &&
firstOrder !== null &&
firstOrder !== "" && (
{HXRNYH}
{firstOrder}
)}
{CoupnbadgeList(couponList)}
labelText(focused, homeTab1),
}}
/>
labelText(focused, homeTab2),
}}
/>
labelText(focused, homeTab3),
}}
/>
>
);
}