feat: make core pages local-first offline
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:miaoji_zhang/shared/api/api_client.dart';
|
||||
import 'package:miaoji_zhang/shared/theme/app_theme.dart';
|
||||
import 'package:miaoji_zhang/shared/widgets/app_icons.dart';
|
||||
|
||||
class BackendStatusIcon extends StatelessWidget {
|
||||
final Future<void> Function() onRetry;
|
||||
|
||||
const BackendStatusIcon({super.key, required this.onRetry});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ValueListenableBuilder<BackendAvailability>(
|
||||
valueListenable: ApiClient.availability,
|
||||
builder: (context, availability, _) {
|
||||
if (availability != BackendAvailability.offline) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
return IconButton(
|
||||
tooltip: '当前显示本地数据,点击重试',
|
||||
onPressed: onRetry,
|
||||
icon: AppIcons.icon(
|
||||
AppIcons.offline,
|
||||
size: 18,
|
||||
color: AppTheme.orange,
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user