mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-11-27 17:44:56 +00:00
analytics-empty-state.
This commit is contained in:
@ -27,53 +27,37 @@ class AnalyticsChartEmptyStateWidget extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Expanded(
|
||||
child: () {
|
||||
if (isLoading) {
|
||||
return const AppLoadingIndicator();
|
||||
} else if (isError) {
|
||||
return _buildState(
|
||||
context,
|
||||
message: errorMessage ?? 'Something went wrong',
|
||||
color: ColorsManager.red,
|
||||
);
|
||||
} else if (isInitial) {
|
||||
return _buildState(context, message: initialMessage);
|
||||
} else {
|
||||
return _buildState(context, message: noDataMessage);
|
||||
}
|
||||
}(),
|
||||
child: _buildWidgetBasedOnState(context),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildState(
|
||||
BuildContext context, {
|
||||
required String message,
|
||||
Color? color,
|
||||
}) {
|
||||
final disabledColor = context.theme.disabledColor;
|
||||
Widget _buildWidgetBasedOnState(BuildContext context) {
|
||||
final widgetsMap = {
|
||||
isLoading: const AppLoadingIndicator(),
|
||||
isInitial: _buildState(context, initialMessage),
|
||||
isError: _buildState(context, errorMessage ?? 'Something went wrong'),
|
||||
};
|
||||
|
||||
return widgetsMap[true] ?? _buildState(context, noDataMessage);
|
||||
}
|
||||
|
||||
Widget _buildState(BuildContext context, String message) {
|
||||
return Center(
|
||||
child: Column(
|
||||
spacing: 16,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const SizedBox(height: 16),
|
||||
Expanded(
|
||||
child: SvgPicture.asset(
|
||||
iconPath,
|
||||
fit: BoxFit.contain,
|
||||
colorFilter: ColorFilter.mode(
|
||||
color ?? disabledColor,
|
||||
BlendMode.srcIn,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(child: SvgPicture.asset(iconPath, fit: BoxFit.contain)),
|
||||
SelectableText(
|
||||
message,
|
||||
style: context.textTheme.bodyMedium?.copyWith(
|
||||
color: color ?? disabledColor,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
style: isError
|
||||
? context.textTheme.bodyMedium?.copyWith(
|
||||
color: ColorsManager.red,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w700,
|
||||
)
|
||||
: null,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
Reference in New Issue
Block a user