💄 Better bootstrapping

This commit is contained in:
LittleSheep 2024-07-27 14:16:49 +08:00
parent 102df2ef1c
commit 6ca4aad1c4
4 changed files with 140 additions and 100 deletions

View File

@ -33,11 +33,18 @@ class _BootstrapperShellState extends State<BootstrapperShell> {
action: () async {
final client = ServiceFinder.configureClient('dealer');
final resp = await client.get('/.well-known');
if (resp.statusCode != 200) {
if (resp.statusCode != null && resp.statusCode != 200) {
setState(() {
_isErrored = true;
_subtitle = 'bsCheckingServerDown'.tr;
});
throw Exception('unable connect to server');
} else if (resp.statusCode == null) {
setState(() {
_isErrored = true;
_subtitle = 'bsCheckingServerFail'.tr;
});
throw Exception('unable connect to server');
}
},
),
@ -90,12 +97,16 @@ class _BootstrapperShellState extends State<BootstrapperShell> {
];
Future<void> _runPeriods() async {
try {
for (var idx = 0; idx < _periods.length; idx++) {
await _periods[idx].action();
if (_isErrored) break;
setState(() => _periodCursor++);
}
} finally {
setState(() => _isBusy = false);
}
}
@override
void initState() {
@ -119,7 +130,8 @@ class _BootstrapperShellState extends State<BootstrapperShell> {
child: Image.asset('assets/logo.png', width: 80, height: 80),
),
),
Column(
GestureDetector(
child: Column(
children: [
if (_isErrored)
const Icon(Icons.cancel, size: 24)
@ -132,7 +144,9 @@ class _BootstrapperShellState extends State<BootstrapperShell> {
const SizedBox(height: 12),
CenteredContainer(
maxWidth: 280,
child: Text(
child: Column(
children: [
Text(
_subtitle ??
'${_periods[_periodCursor].label.tr} (${_periodCursor + 1}/${_periods.length})',
textAlign: TextAlign.center,
@ -141,8 +155,28 @@ class _BootstrapperShellState extends State<BootstrapperShell> {
color: _unFocusColor,
),
),
Text(
'2024 © Solsynth LLC',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 11,
color: _unFocusColor,
),
),
],
),
),
],
),
onTap: () {
if (_isBusy) return;
setState(() {
_isBusy = true;
_isErrored = false;
_periodCursor = 0;
});
_runPeriods();
},
)
],
),

View File

@ -278,7 +278,8 @@ const messagesEnglish = {
'accountStatusNeutral': 'Neutral',
'accountStatusPositive': 'Positive',
'bsCheckingServer': 'Checking Server Status',
'bsCheckingServerFail': 'Unable connect to server, check your network connection or follow our service maintenance status',
'bsCheckingServerFail': 'Unable connect to server, check your network connection',
'bsCheckingServerDown': 'Server currently unavailable, please retry later',
'bsAuthorizing': 'Authorizing',
'bsEstablishingConn': 'Establishing Connection',
'bsPreparingData': 'Preparing User Data',

View File

@ -257,7 +257,8 @@ const simplifiedChineseMessages = {
'accountStatusNeutral': '中性',
'accountStatusPositive': '积极',
'bsCheckingServer': '检查服务器状态中',
'bsCheckingServerFail': '无法连接至服务器,请检查你的网络状态或我们服务维护状态',
'bsCheckingServerFail': '无法连接至服务器,请检查你的网络连接状态',
'bsCheckingServerDown': '当前服务器不可用,请稍后重试',
'bsAuthorizing': '正在授权中',
'bsEstablishingConn': '部署连接中',
'bsPreparingData': '正在准备用户资料',

View File

@ -82,6 +82,7 @@ class _AttachmentListFullScreenState extends State<AttachmentListFullScreen> {
),
Align(
alignment: Alignment.bottomCenter,
child: IgnorePointer(
child: Container(
height: 300,
decoration: const BoxDecoration(
@ -92,6 +93,7 @@ class _AttachmentListFullScreenState extends State<AttachmentListFullScreen> {
),
),
),
),
)
.animate(target: _showDetails ? 1 : 0)
.fadeIn(curve: Curves.fastEaseInToSlowEaseOut),
@ -99,6 +101,7 @@ class _AttachmentListFullScreenState extends State<AttachmentListFullScreen> {
bottom: MediaQuery.of(context).padding.bottom,
left: 16,
right: 16,
child: IgnorePointer(
child: Material(
color: Colors.transparent,
child: Column(
@ -170,6 +173,7 @@ class _AttachmentListFullScreenState extends State<AttachmentListFullScreen> {
],
),
),
),
)
.animate(target: _showDetails ? 1 : 0)
.fadeIn(curve: Curves.fastEaseInToSlowEaseOut),