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