Skip to content

Commit

Permalink
add tables with custom switcher
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas-Heiligenbrunner committed Dec 10, 2024
1 parent 5f10eb6 commit da25f18
Show file tree
Hide file tree
Showing 13 changed files with 192 additions and 177 deletions.
6 changes: 3 additions & 3 deletions frontend/lib/components/activity_log.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class ActivityLogItem extends StatelessWidget {
children: [
Text(
user ?? "Unknown User",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 19),
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14),
),
if (context.desktop)
SizedBox(
Expand All @@ -77,14 +77,14 @@ class ActivityLogItem extends StatelessWidget {
if (context.desktop)
Text(
text,
style: TextStyle(fontSize: 16),
style: TextStyle(fontSize: 14),
)
],
),
context.desktop
? Text(
timestamp.toString(),
style: TextStyle(fontSize: 15),
style: TextStyle(fontSize: 14),
)
: Text(
text,
Expand Down
7 changes: 3 additions & 4 deletions frontend/lib/components/build_line_chart.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:aurcache/constants/color_constants.dart';
import 'package:fl_chart/fl_chart.dart';
import 'package:flutter/material.dart';

Expand Down Expand Up @@ -28,7 +27,7 @@ class _BuildLineChartState extends State<BuildLineChart> {
Widget bottomTitleWidgets(double value, TitleMeta meta) {
const style = TextStyle(
fontWeight: FontWeight.bold,
fontSize: 16,
fontSize: 12,
);
Widget text;
switch (value) {
Expand Down Expand Up @@ -61,7 +60,7 @@ class _BuildLineChartState extends State<BuildLineChart> {
Widget leftTitleWidgets(double value, TitleMeta meta) {
const style = TextStyle(
fontWeight: FontWeight.bold,
fontSize: 15,
fontSize: 12,
);
String text;
switch (value.toInt()) {
Expand Down Expand Up @@ -114,7 +113,7 @@ class _BuildLineChartState extends State<BuildLineChart> {
showTitles: true,
interval: 1,
getTitlesWidget: leftTitleWidgets,
reservedSize: 42,
reservedSize: 30,
),
),
),
Expand Down
7 changes: 6 additions & 1 deletion frontend/lib/components/builds_table.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ class BuildsTable extends StatelessWidget {
@override
Widget build(BuildContext context) {
return DataTable(
horizontalMargin: 0,
horizontalMargin: 12,
columnSpacing: defaultPadding,
headingRowColor:
WidgetStateProperty.resolveWith<Color?>((Set<WidgetState> states) {
return Color(0xff131418);
}),
headingRowHeight: 50,
columns: const [
DataColumn(
label: Text("Build ID"),
Expand Down
115 changes: 115 additions & 0 deletions frontend/lib/components/dashboard/dashboard_tables.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import 'package:aurcache/api/builds.dart';
import 'package:aurcache/api/packages.dart';
import 'package:aurcache/components/packages_table.dart';
import 'package:aurcache/utils/responsive.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:toggle_switch/toggle_switch.dart';
import '../../api/API.dart';
import '../../constants/color_constants.dart';
import '../api/api_builder.dart';
import '../builds_table.dart';
import '../table_info.dart';

class DashboardTables extends StatefulWidget {
const DashboardTables({super.key});

@override
State<DashboardTables> createState() => _DashboardTablesState();
}

class _DashboardTablesState extends State<DashboardTables> {
int activePage = 0;

@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.stretch,
children: [
Padding(
padding: const EdgeInsets.only(left: 0, bottom: 24),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ToggleSwitch(
initialLabelIndex: activePage,
totalSwitches: 2,
labels: ['Recent Packages', 'Recent Builds'],
onToggle: (index) {
setState(() {
activePage = index!;
});
},
radiusStyle: true,
activeBgColor: [Color(0xff292E35)],
inactiveBgColor: Color(0x292E354F),
cornerRadius: 8,
customWidths: [135, 115],
),
OutlinedButton(
style: OutlinedButton.styleFrom(
backgroundColor: secondaryColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8)),
padding: EdgeInsets.symmetric(
horizontal: defaultPadding,
vertical: defaultPadding / (context.mobile ? 2 : 1),
),
),
onPressed: () {
if (activePage == 0) {
context.push("/packages");
} else {
context.push("/builds");
}
},
child: const Text(
"View All",
style: TextStyle(color: Colors.white54),
),
),
],
),
),
Expanded(
child: Builder(builder: (context) {
if (activePage == 0) {
return APIBuilder(
refreshOnComeback: true,
onData: (data) {
if (data.isEmpty) {
return const TableInfo(title: "You have no packages yet");
} else {
return PackagesTable(data: data);
}
},
onLoad: () => const CircularProgressIndicator(),
api: () => API.listPackages(limit: 10),
);
} else {
return APIBuilder(
onLoad: () => const CircularProgressIndicator(),
refreshOnComeback: true,
onData: (data) {
if (data.isEmpty) {
return const TableInfo(title: "You have no builds yet");
} else {
return BuildsTable(data: data);
}
},
api: () => API.listAllBuilds(limit: 10),
);
}
}),
),
],
),
);
}
}
3 changes: 1 addition & 2 deletions frontend/lib/components/dashboard/quick_info_tile.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:aurcache/components/dashboard/header.dart';
import 'package:aurcache/utils/responsive.dart';
import 'package:flutter/material.dart';

Expand Down Expand Up @@ -50,7 +49,7 @@ class _QuickInfoTileState extends State<QuickInfoTile> {
child: Text(
widget.value,
style: TextStyle(
fontSize: context.desktop ? 36 : 24,
fontSize: context.desktop ? 30 : 24,
fontWeight: FontWeight.bold,
color: Colors.white),
),
Expand Down
65 changes: 0 additions & 65 deletions frontend/lib/components/dashboard/recent_builds.dart

This file was deleted.

5 changes: 2 additions & 3 deletions frontend/lib/components/dashboard/side_panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class SidePanel extends StatelessWidget {
const Text(
"Recent Activity",
style: TextStyle(
fontSize: 18,
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
Expand All @@ -56,11 +56,10 @@ class SidePanel extends StatelessWidget {
const Text(
"Builds Per Month",
style: TextStyle(
fontSize: 18,
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
const SizedBox(height: defaultPadding),
BuildLineChart()
],
),
Expand Down
66 changes: 0 additions & 66 deletions frontend/lib/components/dashboard/your_packages.dart

This file was deleted.

Loading

0 comments on commit da25f18

Please sign in to comment.