mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
81 lines
2.2 KiB
Dart
81 lines
2.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:syncrow_web/common/widgets/app_loading_indicator.dart';
|
|
import 'package:syncrow_web/utils/color_manager.dart';
|
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
|
|
|
class AnalyticsChartEmptyStateWidget extends StatelessWidget {
|
|
const AnalyticsChartEmptyStateWidget({
|
|
this.isLoading = false,
|
|
this.isError = false,
|
|
this.isInitial = false,
|
|
this.errorMessage,
|
|
this.noDataMessage = 'No data to display',
|
|
this.initialMessage = 'Please select a space to see data',
|
|
super.key,
|
|
});
|
|
|
|
final bool isLoading;
|
|
final bool isError;
|
|
final bool isInitial;
|
|
final String? errorMessage;
|
|
final String noDataMessage;
|
|
final String initialMessage;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Expanded(
|
|
child: isLoading
|
|
? const Center(
|
|
child: AppLoadingIndicator(),
|
|
)
|
|
: isError
|
|
? _buildState(
|
|
context,
|
|
icon: Icons.error_outline,
|
|
message: errorMessage ?? 'Something went wrong',
|
|
color: ColorsManager.red,
|
|
)
|
|
: isInitial
|
|
? _buildState(
|
|
context,
|
|
icon: Icons.filter_list,
|
|
message: initialMessage,
|
|
)
|
|
: _buildState(
|
|
context,
|
|
icon: Icons.bar_chart,
|
|
message: noDataMessage,
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildState(
|
|
BuildContext context, {
|
|
required IconData icon,
|
|
required String message,
|
|
Color? color,
|
|
}) {
|
|
final disabledColor = context.theme.disabledColor;
|
|
return Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Icon(
|
|
icon,
|
|
size: 48,
|
|
color: color ?? disabledColor,
|
|
),
|
|
const SizedBox(height: 16),
|
|
SelectableText(
|
|
message,
|
|
style: context.textTheme.bodyMedium?.copyWith(
|
|
color: color ?? disabledColor,
|
|
),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|