-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5f10eb6
commit da25f18
Showing
13 changed files
with
192 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
frontend/lib/components/dashboard/dashboard_tables.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), | ||
); | ||
} | ||
}), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.