mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
85 lines
2.3 KiB
Dart
85 lines
2.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_svg/svg.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({
|
|
required this.iconPath,
|
|
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;
|
|
final String iconPath;
|
|
|
|
@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);
|
|
}
|
|
}(),
|
|
);
|
|
}
|
|
|
|
Widget _buildState(
|
|
BuildContext context, {
|
|
required String message,
|
|
Color? color,
|
|
}) {
|
|
final disabledColor = context.theme.disabledColor;
|
|
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,
|
|
),
|
|
),
|
|
),
|
|
SelectableText(
|
|
message,
|
|
style: context.textTheme.bodyMedium?.copyWith(
|
|
color: color ?? disabledColor,
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w700,
|
|
),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
const SizedBox(height: 16),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|