2023-12-30 21:23:42 +00:00
|
|
|
import 'package:aurcache/components/builds_table.dart';
|
2023-12-29 23:45:33 +00:00
|
|
|
import 'package:aurcache/models/build.dart';
|
2024-01-01 16:11:05 +00:00
|
|
|
import 'package:aurcache/components/api/APIBuilder.dart';
|
2024-02-16 21:37:35 +00:00
|
|
|
import 'package:aurcache/providers/api/builds_provider.dart';
|
2023-12-27 15:45:55 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2023-12-30 15:46:13 +00:00
|
|
|
import 'package:go_router/go_router.dart';
|
2023-12-29 23:45:33 +00:00
|
|
|
import '../../constants/color_constants.dart';
|
2024-02-25 18:40:21 +00:00
|
|
|
import '../table_info.dart';
|
2023-12-27 15:45:55 +00:00
|
|
|
|
2024-02-25 18:40:21 +00:00
|
|
|
class RecentBuilds extends StatelessWidget {
|
|
|
|
const RecentBuilds({super.key});
|
2023-12-27 15:45:55 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Container(
|
2023-12-30 09:43:46 +00:00
|
|
|
padding: const EdgeInsets.all(defaultPadding),
|
|
|
|
decoration: const BoxDecoration(
|
2023-12-27 15:45:55 +00:00
|
|
|
color: secondaryColor,
|
2023-12-30 09:43:46 +00:00
|
|
|
borderRadius: BorderRadius.all(Radius.circular(10)),
|
2023-12-27 15:45:55 +00:00
|
|
|
),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"Recent Builds",
|
|
|
|
style: Theme.of(context).textTheme.subtitle1,
|
|
|
|
),
|
2024-02-25 18:40:21 +00:00
|
|
|
APIBuilder<BuildsProvider, List<Build>, BuildsDTO>(
|
|
|
|
key: const Key("Builds on dashboard"),
|
|
|
|
dto: BuildsDTO(limit: 10),
|
|
|
|
interval: const Duration(seconds: 10),
|
|
|
|
onLoad: () => const Text("no data"),
|
|
|
|
onData: (t) {
|
|
|
|
if (t.isEmpty) {
|
|
|
|
return const TableInfo(title: "You have no builds yet");
|
|
|
|
} else {
|
|
|
|
return Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
SizedBox(
|
|
|
|
width: double.infinity, child: BuildsTable(data: t)),
|
|
|
|
ElevatedButton(
|
|
|
|
onPressed: () {
|
|
|
|
context.push("/builds");
|
|
|
|
},
|
|
|
|
child: Text(
|
|
|
|
"List all Builds",
|
|
|
|
style: TextStyle(color: Colors.white.withOpacity(0.8)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
2023-12-30 21:23:42 +00:00
|
|
|
},
|
2024-02-25 18:40:21 +00:00
|
|
|
),
|
2023-12-27 15:45:55 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|