cmvr-wms/mobile-app/src/AppUpdateDialog.tsx

18 lines
1.4 KiB
TypeScript
Raw Normal View History

import {Text} from './typography';
import React from 'react';
import {Modal,ScrollView,View} from 'react-native';
import {Button,Note,useTheme} from './ui';
import type {UpdateView} from './core/updates';
import {UpdateNotes} from './UpdateNotes';
export function AppUpdateDialog({view,later,restart}:{view:UpdateView;later:()=>void;restart:()=>void}){
const t=useTheme();if(!view.visible)return null;
return <Modal transparent visible animationType="fade" onRequestClose={later}><View style={{flex:1,backgroundColor:'#0008',justifyContent:'center',alignItems:'center',padding:24}}><View accessibilityViewIsModal accessibilityRole="alert" style={{width:'100%',maxWidth:380,maxHeight:'85%',borderRadius:20,backgroundColor:t.card,padding:22,gap:16}}>
<ScrollView contentContainerStyle={{gap:12}}>
<Text style={{fontSize:18,lineHeight:25,fontWeight:'700',color:t.text}}>发现新版本</Text><UpdateNotes notes={view.notes}/><Note>更新已下载,重启后生效。请先保存当前内容,未提交的内容不会保留。</Note>
{!!view.error&&<Text accessibilityRole="alert" style={{color:'#c64650',fontSize:14,lineHeight:21}}>{view.error}</Text>}
</ScrollView>
<View style={{gap:9}}><Button title={view.restarting?'正在重启…':'重启并更新'} busy={view.restarting} onPress={restart}/><Button title="稍后再说" secondary disabled={view.restarting} onPress={later}/></View>
</View></View></Modal>;
}