From 9d32ba7c46fdfcd73ebbccfc1c5ab30b9eb30f10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emirhan=20=C3=87olak?= Date: Sat, 5 Oct 2024 23:12:29 +0300 Subject: [PATCH] =?UTF-8?q?G=C3=BCncellemeleri=20kontrol=20eden=20sistem?= =?UTF-8?q?=20eklendi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/(tabs)/index.tsx | 63 +- package-lock.json | 2259 +++++++++++++++++++++++++----------------- package.json | 2 +- 3 files changed, 1376 insertions(+), 948 deletions(-) diff --git a/app/(tabs)/index.tsx b/app/(tabs)/index.tsx index 6680918..b6eaf32 100644 --- a/app/(tabs)/index.tsx +++ b/app/(tabs)/index.tsx @@ -1,19 +1,18 @@ import React, { useEffect, useState } from "react"; -import { Image, StyleSheet, Platform, View, Text, TextInput, Button, ActivityIndicator, ScrollView, Pressable } from 'react-native'; +import { Image, StyleSheet, Platform, View, Text, TextInput, Button, ActivityIndicator, ScrollView, Pressable, Linking } from 'react-native'; import AsyncStorage from '@react-native-async-storage/async-storage'; import Modal from "react-native-modal"; import { MaskedTextInput } from "react-native-mask-text"; import { LinearGradient } from 'expo-linear-gradient'; import { - SafeAreaView, - SafeAreaProvider, - SafeAreaInsetsContext, - useSafeAreaInsets, + SafeAreaView } from 'react-native-safe-area-context'; import { router } from "expo-router"; export default function HomeScreen() { + const pkg = require('../../package.json'); + const [maskedValue, setMaskedValue] = useState(""); const [unMaskedValue, setUnmaskedValue] = useState(""); @@ -25,6 +24,8 @@ export default function HomeScreen() { const [tarifeler, setTarifeler] = useState({ "clientMeta": { "öğrenci": 0, "tam": 0 } }); const [mevcutDuyuru, setMevcutDuyuru] = useState({ "description": "", "title": "" }); + const [güncellemeNotu, setGüncellemeNotu] = useState({ "description": "", "title": "", "url": "" }); + var kullanıcıProfili = { "isim": "", "soyisim": "", @@ -36,7 +37,24 @@ export default function HomeScreen() { const [profil, setProfilDetayları] = useState(kullanıcıProfili); var apiKey = null; + // TODO: KART KAYDETME FONKSIYONUNU EKLE + async function kartKaydet(kartNumarası: string) { + kartNumarası = kartNumarası.trim().replace(" ", "").replace("-", ""); + } + async function uygulamaGüncellemeleriniDenetle() { + let response = await fetch("https://api.github.com/repos/swempish/gaziantepkart-client/releases/latest"); + let data = await response.json(); + let mevcutSürüm = data.tag_name; + let yerelSürüm = pkg.version; + + if (yerelSürüm !== null && yerelSürüm.trim().replace("v", "") !== mevcutSürüm.trim().replace("v", "")) { + setGüncellemeNotu({"title": "Uygulamanın yeni sürümü var!", "description": `Yeni sürüm: ${mevcutSürüm}\nYüklü sürüm: v${yerelSürüm}\nGüncelleme notları:\n\n${data.body}`, "url": `${data.assets[0].browser_download_url}`}); + setUpdateModalVisible(true); + } else { + } + + } async function girişBilgileriniKontrolEt() { try { @@ -144,6 +162,7 @@ export default function HomeScreen() { return response.json(); } else { alert("Geçerli bir kart numarası giriniz."); + } }) .then(data => { @@ -172,7 +191,6 @@ export default function HomeScreen() { setProcessing(false); }); } - function duyurularıGetir() { let url = "https://service.kentkart.com/rl1/api/info/announce" let params = { @@ -306,11 +324,13 @@ export default function HomeScreen() { await girişBilgileriniKontrolEt(); await duyurularıGetir(); await tarifeleriGetir(); + await uygulamaGüncellemeleriniDenetle(); } fetchData(); }, []); const [isModalVisible, setModalVisible] = useState(false); + const [isUpdateModalVisible, setUpdateModalVisible] = useState(false); const toggleModal = () => { setModalVisible(!isModalVisible); @@ -335,13 +355,27 @@ export default function HomeScreen() { - - {mevcutDuyuru?.title} - {mevcutDuyuru?.description} + + {mevcutDuyuru?.title} + + {mevcutDuyuru?.description}