/** * Fortschrittsanzeige beim App-Update: Balken mit Prozent und MB, Knopf * zum Abbrechen. Erscheint nur, waehrend ein Update laedt/installiert. */ import React, { useEffect, useState } from 'react'; import { Modal, StyleSheet, Text, TouchableOpacity, View } from 'react-native'; import updateService, { UpdateProgress as Progress } from '../services/updater'; const UpdateProgress: React.FC = () => { const [p, setP] = useState(null); useEffect(() => updateService.onProgress(setP), []); if (!p || !p.active) return null; const known = p.fraction >= 0; const pct = known ? Math.round(p.fraction * 100) : 0; return ( {}}> Update auf Version {p.version} {p.status} {known ? `${pct} % · ` : ''} {p.receivedMB > 0 ? `${p.receivedMB.toFixed(1)} von ${p.totalMB.toFixed(1)} MB` : `${p.totalMB.toFixed(1)} MB`} {p.status !== 'Installiere …' && ( updateService.cancelDownload()}> Abbrechen )} ); }; const styles = StyleSheet.create({ overlay: { flex: 1, backgroundColor: 'rgba(0,0,0,0.6)', justifyContent: 'center', padding: 24 }, box: { backgroundColor: '#1A1A2E', borderRadius: 14, padding: 20 }, title: { color: '#FFFFFF', fontSize: 17, fontWeight: '700' }, status: { color: '#C8C8D8', fontSize: 14, marginTop: 6 }, track: { height: 10, borderRadius: 5, backgroundColor: '#2A2A3E', marginTop: 14, overflow: 'hidden' }, bar: { height: 10, borderRadius: 5, backgroundColor: '#0096FF' }, barUnknown: { opacity: 0.35 }, numbers: { color: '#9090A8', fontSize: 13, marginTop: 8 }, btn: { alignSelf: 'flex-end', marginTop: 14, paddingVertical: 8, paddingHorizontal: 16, borderRadius: 8, backgroundColor: '#2A2A3E' }, btnText: { color: '#FFFFFF', fontWeight: '600' }, }); export default UpdateProgress;