Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 5 additions & 23 deletions app/(pages)/about/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ import * as Clipboard from "expo-clipboard";
import Constants from "expo-constants";
import { Image } from "expo-image";
import { Stack } from "expo-router";
import * as Updates from "expo-updates";
import { useCallback } from "react";
import {
ActivityIndicator,
Linking,
Platform,
ScrollView,
Text,
View,
Expand All @@ -34,6 +32,7 @@ export default function AboutScreen() {
const latestVersion = useUpdateStore((s) => s.latestVersion);
const checking = useUpdateStore((s) => s.checking);
const check = useUpdateStore((s) => s.check);
const openUpdateModal = useUpdateStore((s) => s.openModal);

const copyToClipboard = useCallback(
async (label: string, value: string) => {
Expand All @@ -48,35 +47,18 @@ export default function AboutScreen() {
);

const handleCheckUpdate = useCallback(async () => {
await check();
const { hasUpdate: updated, latestVersion: latest } =
useUpdateStore.getState();
await check({ force: true });
const { hasUpdate: updated } = useUpdateStore.getState();
if (updated) {
Toast.show({
type: "info",
text1: t("about.newVersionFound"),
text2: t("about.newVersionTip", { v: latest ?? "" }),
position: "bottom",
onPress: () => {
if (Platform.OS === "ios") {
Linking.openURL("itms-apps://apps.apple.com/cn/app/id6761684977");
} else {
const channel = Updates.channel || "production";
Linking.openURL(
`https://download.tokenteam.dev/iwut/${latest}/${channel}.apk`,
);
}
Toast.hide();
},
});
openUpdateModal();
} else {
Toast.show({
type: "success",
text1: t("about.upToDate"),
position: "bottom",
});
}
}, [check, t]);
}, [check, openUpdateModal, t]);

return (
<>
Expand Down
8 changes: 5 additions & 3 deletions app/(tabs)/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Ionicons } from "@expo/vector-icons";
import { useRouter } from "expo-router";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import {
LayoutChangeEvent,
Expand Down Expand Up @@ -131,12 +130,12 @@ export default function HomeScreen() {
const t = useT();
const colorScheme = useColorScheme();
const isDark = colorScheme === "dark";
const router = useRouter();
const haptic = useHaptics();
const { width: screenWidth } = useWindowDimensions();
const courses = useCourseStore((s) => s.courses);
const termStart = useCourseStore((s) => s.termStart);
const hasUpdate = useUpdateStore((s) => s.hasUpdate);
const openUpdateModal = useUpdateStore((s) => s.openModal);
const colorPalette = useScheduleStore((s) => s.colorPalette);
const courseColorOverrides = useScheduleStore((s) => s.courseColorOverrides);
const announcements = useAnnouncementStore((s) => s.announcements);
Expand Down Expand Up @@ -351,7 +350,10 @@ export default function HomeScreen() {
{hasUpdate && (
<Pressable
className="relative p-1 active:opacity-60"
onPress={() => router.push("/about" as any)}
onPress={() => {
haptic();
openUpdateModal();
}}
>
<Ionicons
name="arrow-up-circle-outline"
Expand Down
2 changes: 2 additions & 0 deletions app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
} from "react-native-safe-area-context";
import Toast from "react-native-toast-message";

import { UpdateModal } from "@/components/ui/update-modal";
import { Themes } from "@/constants/theme";
import { useColorScheme } from "@/hooks/use-color-scheme";
import { refreshSystemLocale } from "@/lib/i18n";
Expand Down Expand Up @@ -156,6 +157,7 @@ function RootLayout() {
</Stack>
<StatusBar style="auto" />
<Toast />
<UpdateModal />
</ThemeProvider>
</View>
</SafeAreaProvider>
Expand Down
15 changes: 15 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading