65 lines
1.9 KiB
Dart
65 lines
1.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../models/tracker.dart';
|
|
import '../services/progress.dart';
|
|
import 'progress_bar.dart';
|
|
import 'theme.dart';
|
|
|
|
class TrackerTile extends StatelessWidget {
|
|
const TrackerTile({
|
|
super.key,
|
|
required this.tracker,
|
|
required this.onTap,
|
|
this.onLongPress,
|
|
});
|
|
|
|
final Tracker tracker;
|
|
final VoidCallback onTap;
|
|
final VoidCallback? onLongPress;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final Color color = Color(tracker.colorValue);
|
|
final double fraction = TrackerProgress(tracker).overall;
|
|
return Card(
|
|
clipBehavior: Clip.antiAlias,
|
|
child: InkWell(
|
|
onTap: onTap,
|
|
onLongPress: onLongPress,
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(AppTokens.spaceL),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: <Widget>[
|
|
Row(
|
|
children: <Widget>[
|
|
Container(
|
|
width: 12,
|
|
height: 12,
|
|
decoration: BoxDecoration(
|
|
color: color,
|
|
shape: BoxShape.circle,
|
|
),
|
|
),
|
|
const SizedBox(width: AppTokens.spaceM),
|
|
Expanded(
|
|
child: Text(
|
|
tracker.name,
|
|
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
),
|
|
ProgressPill(fraction: fraction, color: color),
|
|
],
|
|
),
|
|
const SizedBox(height: AppTokens.spaceM),
|
|
ProgressBar(value: fraction, color: color),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|