112 lines
3.0 KiB
Dart
112 lines
3.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../../../core/l10n/l10n.dart';
|
|
import '../../../../core/theme/design_tokens.dart';
|
|
import '../../../../shared/widgets/app_loading_indicator.dart';
|
|
|
|
class HomeWaitingIndicator extends StatelessWidget {
|
|
const HomeWaitingIndicator({super.key, required this.label});
|
|
|
|
final String label;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final colorScheme = Theme.of(context).colorScheme;
|
|
|
|
return Padding(
|
|
padding: const EdgeInsets.fromLTRB(20, 0, 20, 20),
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
SizedBox(
|
|
width: 18,
|
|
height: 18,
|
|
child: AppLoadingIndicator(
|
|
variant: AppLoadingVariant.inline,
|
|
size: 18,
|
|
strokeWidth: 2,
|
|
color: colorScheme.primary,
|
|
trackColor: colorScheme.primaryContainer,
|
|
),
|
|
),
|
|
SizedBox(width: AppSpacing.sm),
|
|
Text(
|
|
label,
|
|
style: TextStyle(fontSize: 14, color: colorScheme.onSurfaceVariant),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class HomeDateDivider extends StatelessWidget {
|
|
const HomeDateDivider({super.key, required this.date});
|
|
|
|
final DateTime date;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final colorScheme = Theme.of(context).colorScheme;
|
|
final now = DateTime.now();
|
|
const weekdays = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
|
|
final weekday = weekdays[date.weekday - 1];
|
|
final label = date.year == now.year
|
|
? context.l10n.homeDateLabelNoYear(date.month, date.day, weekday)
|
|
: context.l10n.homeDateLabelWithYear(
|
|
date.year,
|
|
date.month,
|
|
date.day,
|
|
weekday,
|
|
);
|
|
|
|
return Container(
|
|
padding: const EdgeInsets.symmetric(vertical: 12),
|
|
alignment: Alignment.center,
|
|
child: Text(
|
|
label,
|
|
style: TextStyle(fontSize: 12, color: colorScheme.onSurfaceVariant),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class HomeLoadMoreButton extends StatelessWidget {
|
|
const HomeLoadMoreButton({
|
|
super.key,
|
|
required this.isLoading,
|
|
required this.onTap,
|
|
});
|
|
|
|
final bool isLoading;
|
|
final VoidCallback? onTap;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final colorScheme = Theme.of(context).colorScheme;
|
|
|
|
return GestureDetector(
|
|
onTap: isLoading ? null : onTap,
|
|
child: Container(
|
|
padding: const EdgeInsets.symmetric(vertical: 8),
|
|
alignment: Alignment.center,
|
|
child: isLoading
|
|
? AppLoadingIndicator(
|
|
variant: AppLoadingVariant.inline,
|
|
size: 14,
|
|
strokeWidth: 1.5,
|
|
color: colorScheme.onSurfaceVariant,
|
|
trackColor: colorScheme.surfaceContainerHighest,
|
|
)
|
|
: Text(
|
|
context.l10n.homeViewHistory,
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
color: colorScheme.onSurfaceVariant,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|