fix:参考金值,研听,研值工程通用通用工程公共能力,重点对比网络请求、登录认证、状态管理、本地存储、WebView、推送、版本更新、一键登录、主题/UI 等模块,确定后续统一整改方案
This commit is contained in:
1 parent
6997a65c96
commit
d364c6d908
46 files changed
+2060
-395
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
|
||||
import '../network/api_error_message.dart';
|
||||
import 'app_state_card.dart';
|
||||
|
||||
/// Shared loading, failure and empty-state contract for feature pages.
|
||||
@@ -37,11 +38,11 @@ class AsyncStateView<T> extends StatelessWidget {
|
||||
return state.when(
|
||||
loading: () =>
|
||||
loading ?? const Center(child: CircularProgressIndicator()),
|
||||
error: (_, _) => Center(
|
||||
error: (error, _) => Center(
|
||||
child: AppStateCard(
|
||||
icon: Icons.error_outline,
|
||||
title: errorTitle,
|
||||
subtitle: errorSubtitle,
|
||||
subtitle: ErrorMessageMapper.message(error, fallback: errorSubtitle),
|
||||
buttonLabel: onRetry == null ? null : '重试',
|
||||
onButtonPressed: onRetry,
|
||||
buttonStyle: AppStateButtonStyle.filled,
|
||||
@@ -60,3 +61,44 @@ class AsyncStateView<T> extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Sliver counterpart for CustomScrollView pages without forcing one global
|
||||
/// card layout on successful feature content.
|
||||
class SliverAsyncState<T> extends StatelessWidget {
|
||||
const SliverAsyncState({
|
||||
super.key,
|
||||
required this.state,
|
||||
required this.data,
|
||||
this.loading,
|
||||
this.onRetry,
|
||||
this.errorSubtitle = '请检查网络后重试',
|
||||
});
|
||||
|
||||
final AsyncValue<T> state;
|
||||
final Widget Function(T value) data;
|
||||
final Widget? loading;
|
||||
final VoidCallback? onRetry;
|
||||
final String errorSubtitle;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => state.when(
|
||||
data: data,
|
||||
loading: () => SliverFillRemaining(
|
||||
hasScrollBody: false,
|
||||
child: loading ?? const Center(child: CircularProgressIndicator()),
|
||||
),
|
||||
error: (error, _) => SliverFillRemaining(
|
||||
hasScrollBody: false,
|
||||
child: Center(
|
||||
child: AppStateCard(
|
||||
icon: Icons.error_outline,
|
||||
title: '加载失败',
|
||||
subtitle: ErrorMessageMapper.message(error, fallback: errorSubtitle),
|
||||
buttonLabel: onRetry == null ? null : '重试',
|
||||
onButtonPressed: onRetry,
|
||||
buttonStyle: AppStateButtonStyle.filled,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user