2023-12-29 23:45:33 +00:00
|
|
|
import 'package:aurcache/api/statistics.dart';
|
2024-01-01 16:11:05 +00:00
|
|
|
import 'package:aurcache/components/api/APIBuilder.dart';
|
2023-12-30 21:23:42 +00:00
|
|
|
import 'package:aurcache/providers/stats_provider.dart';
|
2023-12-29 23:45:33 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2023-12-30 21:23:42 +00:00
|
|
|
import 'package:provider/provider.dart';
|
2023-12-29 23:45:33 +00:00
|
|
|
|
|
|
|
import '../api/API.dart';
|
|
|
|
import '../components/dashboard/header.dart';
|
|
|
|
import '../constants/color_constants.dart';
|
|
|
|
import '../utils/responsive.dart';
|
|
|
|
import '../models/stats.dart';
|
|
|
|
import '../components/dashboard/quick_info_banner.dart';
|
|
|
|
import '../components/dashboard/recent_builds.dart';
|
|
|
|
import '../components/dashboard/your_packages.dart';
|
|
|
|
import '../components/dashboard/side_panel.dart';
|
|
|
|
|
2023-12-30 21:23:42 +00:00
|
|
|
class DashboardScreen extends StatefulWidget {
|
|
|
|
@override
|
|
|
|
State<DashboardScreen> createState() => _DashboardScreenState();
|
|
|
|
}
|
2023-12-29 23:45:33 +00:00
|
|
|
|
2023-12-30 21:23:42 +00:00
|
|
|
class _DashboardScreenState extends State<DashboardScreen> {
|
2023-12-29 23:45:33 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-12-30 21:23:42 +00:00
|
|
|
return APIBuilder<StatsProvider, Stats, Object>(
|
2024-01-01 22:07:52 +00:00
|
|
|
interval: const Duration(seconds: 10),
|
2023-12-30 21:23:42 +00:00
|
|
|
onData: (stats) {
|
|
|
|
return SafeArea(
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
child: Container(
|
|
|
|
padding: const EdgeInsets.all(defaultPadding),
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
const Header(),
|
|
|
|
const SizedBox(height: defaultPadding),
|
|
|
|
QuickInfoBanner(
|
|
|
|
stats: stats,
|
|
|
|
),
|
|
|
|
const SizedBox(height: defaultPadding),
|
|
|
|
Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
2023-12-29 23:45:33 +00:00
|
|
|
children: [
|
2023-12-30 21:23:42 +00:00
|
|
|
Expanded(
|
|
|
|
flex: 5,
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
const YourPackages(),
|
|
|
|
const SizedBox(height: defaultPadding),
|
|
|
|
const RecentBuilds(),
|
|
|
|
if (Responsive.isMobile(context))
|
|
|
|
const SizedBox(height: defaultPadding),
|
|
|
|
if (Responsive.isMobile(context))
|
|
|
|
SidePanel(
|
2023-12-29 23:45:33 +00:00
|
|
|
nrbuilds: stats.total_builds,
|
2023-12-30 09:43:46 +00:00
|
|
|
nrfailedbuilds: stats.failed_builds,
|
|
|
|
nrActiveBuilds: stats.active_builds),
|
2023-12-30 21:23:42 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (!Responsive.isMobile(context))
|
|
|
|
const SizedBox(width: defaultPadding),
|
|
|
|
// On Mobile means if the screen is less than 850 we dont want to show it
|
|
|
|
if (!Responsive.isMobile(context))
|
|
|
|
Expanded(
|
|
|
|
flex: 2,
|
|
|
|
child: SidePanel(
|
|
|
|
nrbuilds: stats.total_builds,
|
|
|
|
nrfailedbuilds: stats.failed_builds,
|
|
|
|
nrActiveBuilds: stats.active_builds),
|
|
|
|
),
|
2023-12-29 23:45:33 +00:00
|
|
|
],
|
2023-12-30 21:23:42 +00:00
|
|
|
)
|
|
|
|
],
|
2023-12-29 23:45:33 +00:00
|
|
|
),
|
2023-12-30 21:23:42 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
onLoad: () {
|
|
|
|
return Text("loading");
|
|
|
|
},
|
|
|
|
);
|
2023-12-29 23:45:33 +00:00
|
|
|
}
|
|
|
|
}
|