💄 Better bootstrapping
This commit is contained in:
parent
102df2ef1c
commit
6ca4aad1c4
@ -33,11 +33,18 @@ class _BootstrapperShellState extends State<BootstrapperShell> {
|
|||||||
action: () async {
|
action: () async {
|
||||||
final client = ServiceFinder.configureClient('dealer');
|
final client = ServiceFinder.configureClient('dealer');
|
||||||
final resp = await client.get('/.well-known');
|
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(() {
|
setState(() {
|
||||||
_isErrored = true;
|
_isErrored = true;
|
||||||
_subtitle = 'bsCheckingServerFail'.tr;
|
_subtitle = 'bsCheckingServerFail'.tr;
|
||||||
});
|
});
|
||||||
|
throw Exception('unable connect to server');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -90,11 +97,15 @@ class _BootstrapperShellState extends State<BootstrapperShell> {
|
|||||||
];
|
];
|
||||||
|
|
||||||
Future<void> _runPeriods() async {
|
Future<void> _runPeriods() async {
|
||||||
for (var idx = 0; idx < _periods.length; idx++) {
|
try {
|
||||||
await _periods[idx].action();
|
for (var idx = 0; idx < _periods.length; idx++) {
|
||||||
setState(() => _periodCursor++);
|
await _periods[idx].action();
|
||||||
|
if (_isErrored) break;
|
||||||
|
setState(() => _periodCursor++);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
setState(() => _isBusy = false);
|
||||||
}
|
}
|
||||||
setState(() => _isBusy = false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -119,30 +130,53 @@ class _BootstrapperShellState extends State<BootstrapperShell> {
|
|||||||
child: Image.asset('assets/logo.png', width: 80, height: 80),
|
child: Image.asset('assets/logo.png', width: 80, height: 80),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Column(
|
GestureDetector(
|
||||||
children: [
|
child: Column(
|
||||||
if (_isErrored)
|
children: [
|
||||||
const Icon(Icons.cancel, size: 24)
|
if (_isErrored)
|
||||||
else
|
const Icon(Icons.cancel, size: 24)
|
||||||
const SizedBox(
|
else
|
||||||
width: 24,
|
const SizedBox(
|
||||||
height: 24,
|
width: 24,
|
||||||
child: CircularProgressIndicator(strokeWidth: 3),
|
height: 24,
|
||||||
),
|
child: CircularProgressIndicator(strokeWidth: 3),
|
||||||
const SizedBox(height: 12),
|
),
|
||||||
CenteredContainer(
|
const SizedBox(height: 12),
|
||||||
maxWidth: 280,
|
CenteredContainer(
|
||||||
child: Text(
|
maxWidth: 280,
|
||||||
_subtitle ??
|
child: Column(
|
||||||
'${_periods[_periodCursor].label.tr} (${_periodCursor + 1}/${_periods.length})',
|
children: [
|
||||||
textAlign: TextAlign.center,
|
Text(
|
||||||
style: TextStyle(
|
_subtitle ??
|
||||||
fontSize: 13,
|
'${_periods[_periodCursor].label.tr} (${_periodCursor + 1}/${_periods.length})',
|
||||||
color: _unFocusColor,
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
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();
|
||||||
|
},
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -278,7 +278,8 @@ const messagesEnglish = {
|
|||||||
'accountStatusNeutral': 'Neutral',
|
'accountStatusNeutral': 'Neutral',
|
||||||
'accountStatusPositive': 'Positive',
|
'accountStatusPositive': 'Positive',
|
||||||
'bsCheckingServer': 'Checking Server Status',
|
'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',
|
'bsAuthorizing': 'Authorizing',
|
||||||
'bsEstablishingConn': 'Establishing Connection',
|
'bsEstablishingConn': 'Establishing Connection',
|
||||||
'bsPreparingData': 'Preparing User Data',
|
'bsPreparingData': 'Preparing User Data',
|
||||||
|
@ -257,7 +257,8 @@ const simplifiedChineseMessages = {
|
|||||||
'accountStatusNeutral': '中性',
|
'accountStatusNeutral': '中性',
|
||||||
'accountStatusPositive': '积极',
|
'accountStatusPositive': '积极',
|
||||||
'bsCheckingServer': '检查服务器状态中',
|
'bsCheckingServer': '检查服务器状态中',
|
||||||
'bsCheckingServerFail': '无法连接至服务器,请检查你的网络状态或我们服务维护状态',
|
'bsCheckingServerFail': '无法连接至服务器,请检查你的网络连接状态',
|
||||||
|
'bsCheckingServerDown': '当前服务器不可用,请稍后重试',
|
||||||
'bsAuthorizing': '正在授权中',
|
'bsAuthorizing': '正在授权中',
|
||||||
'bsEstablishingConn': '部署连接中',
|
'bsEstablishingConn': '部署连接中',
|
||||||
'bsPreparingData': '正在准备用户资料',
|
'bsPreparingData': '正在准备用户资料',
|
||||||
|
@ -82,13 +82,15 @@ class _AttachmentListFullScreenState extends State<AttachmentListFullScreen> {
|
|||||||
),
|
),
|
||||||
Align(
|
Align(
|
||||||
alignment: Alignment.bottomCenter,
|
alignment: Alignment.bottomCenter,
|
||||||
child: Container(
|
child: IgnorePointer(
|
||||||
height: 300,
|
child: Container(
|
||||||
decoration: const BoxDecoration(
|
height: 300,
|
||||||
gradient: LinearGradient(
|
decoration: const BoxDecoration(
|
||||||
begin: Alignment.bottomCenter,
|
gradient: LinearGradient(
|
||||||
end: Alignment.topCenter,
|
begin: Alignment.bottomCenter,
|
||||||
colors: [Color(0xFFFFFFFF), Color(0x00FFFFFF)],
|
end: Alignment.topCenter,
|
||||||
|
colors: [Color(0xFFFFFFFF), Color(0x00FFFFFF)],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -99,75 +101,77 @@ class _AttachmentListFullScreenState extends State<AttachmentListFullScreen> {
|
|||||||
bottom: MediaQuery.of(context).padding.bottom,
|
bottom: MediaQuery.of(context).padding.bottom,
|
||||||
left: 16,
|
left: 16,
|
||||||
right: 16,
|
right: 16,
|
||||||
child: Material(
|
child: IgnorePointer(
|
||||||
color: Colors.transparent,
|
child: Material(
|
||||||
child: Column(
|
color: Colors.transparent,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
child: Column(
|
||||||
children: [
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
if (widget.attachment.account != null)
|
children: [
|
||||||
Row(
|
if (widget.attachment.account != null)
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
AccountAvatar(
|
||||||
|
content: widget.attachment.account!.avatar,
|
||||||
|
radius: 19,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'attachmentUploadBy'.tr,
|
||||||
|
style: Theme.of(context).textTheme.bodySmall,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
widget.attachment.account!.nick,
|
||||||
|
style: Theme.of(context).textTheme.bodyMedium,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Text(
|
||||||
|
widget.attachment.alt,
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 15,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 2),
|
||||||
|
Wrap(
|
||||||
|
spacing: 6,
|
||||||
children: [
|
children: [
|
||||||
AccountAvatar(
|
if (widget.attachment.metadata?['width'] != null &&
|
||||||
content: widget.attachment.account!.avatar,
|
widget.attachment.metadata?['height'] != null)
|
||||||
radius: 19,
|
Text(
|
||||||
),
|
'${widget.attachment.metadata?['width']}x${widget.attachment.metadata?['height']}',
|
||||||
const SizedBox(width: 8),
|
style: TextStyle(
|
||||||
Column(
|
fontSize: 12,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
color: _unFocusColor,
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'attachmentUploadBy'.tr,
|
|
||||||
style: Theme.of(context).textTheme.bodySmall,
|
|
||||||
),
|
),
|
||||||
Text(
|
),
|
||||||
widget.attachment.account!.nick,
|
if (widget.attachment.metadata?['ratio'] != null)
|
||||||
style: Theme.of(context).textTheme.bodyMedium,
|
Text(
|
||||||
|
'${(widget.attachment.metadata?['ratio'] as double).toPrecision(2)}',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
color: _unFocusColor,
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
Text(
|
||||||
|
_formatBytes(widget.attachment.size),
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
color: _unFocusColor,
|
||||||
|
),
|
||||||
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 4),
|
],
|
||||||
Text(
|
),
|
||||||
widget.attachment.alt,
|
|
||||||
maxLines: 2,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 15,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 2),
|
|
||||||
Wrap(
|
|
||||||
spacing: 6,
|
|
||||||
children: [
|
|
||||||
if (widget.attachment.metadata?['width'] != null &&
|
|
||||||
widget.attachment.metadata?['height'] != null)
|
|
||||||
Text(
|
|
||||||
'${widget.attachment.metadata?['width']}x${widget.attachment.metadata?['height']}',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
color: _unFocusColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (widget.attachment.metadata?['ratio'] != null)
|
|
||||||
Text(
|
|
||||||
'${(widget.attachment.metadata?['ratio'] as double).toPrecision(2)}',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
color: _unFocusColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
_formatBytes(widget.attachment.size),
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
color: _unFocusColor,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user