add endpoint for general stats
load build data to graph redesign top info tiles place add button on header folder restructure
This commit is contained in:
@ -1,64 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/constants/color_constants.dart';
|
||||
|
||||
class UserDetailsMiniCard extends StatelessWidget {
|
||||
const UserDetailsMiniCard({
|
||||
Key? key,
|
||||
required this.title,
|
||||
required this.color,
|
||||
required this.amountOfFiles,
|
||||
required this.numberOfIncrease,
|
||||
}) : super(key: key);
|
||||
|
||||
final Color color;
|
||||
final String title, amountOfFiles;
|
||||
final int numberOfIncrease;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: EdgeInsets.only(top: defaultPadding),
|
||||
padding: EdgeInsets.all(defaultPadding),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(width: 2, color: primaryColor.withOpacity(0.15)),
|
||||
borderRadius: const BorderRadius.all(
|
||||
Radius.circular(defaultPadding),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: Container(
|
||||
color: color,
|
||||
)),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: defaultPadding),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
Text(
|
||||
"$numberOfIncrease",
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.caption!
|
||||
.copyWith(color: Colors.white70),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(amountOfFiles)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,96 +0,0 @@
|
||||
import 'package:fl_chart/fl_chart.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class Chart extends StatefulWidget {
|
||||
const Chart({
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
_ChartState createState() => _ChartState();
|
||||
}
|
||||
|
||||
class _ChartState extends State<Chart> {
|
||||
int touchedIndex = -1;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
height: 300,
|
||||
child: AspectRatio(
|
||||
aspectRatio: 1.3,
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
const SizedBox(
|
||||
height: 18,
|
||||
),
|
||||
Expanded(
|
||||
child: AspectRatio(
|
||||
aspectRatio: 1,
|
||||
child: PieChart(
|
||||
PieChartData(
|
||||
pieTouchData: PieTouchData(
|
||||
touchCallback: (pieTouchResponse, touchresponse) {
|
||||
setState(() {
|
||||
// final desiredTouch = pieTouchResponse.touchInput
|
||||
// is! PointerExitEvent &&
|
||||
// pieTouchResponse.touchInput is! PointerUpEvent;
|
||||
if (touchresponse?.touchedSection != null) {
|
||||
touchedIndex = touchresponse!
|
||||
.touchedSection!.touchedSectionIndex;
|
||||
} else {
|
||||
touchedIndex = -1;
|
||||
}
|
||||
});
|
||||
}),
|
||||
borderData: FlBorderData(
|
||||
show: false,
|
||||
),
|
||||
sectionsSpace: 0,
|
||||
centerSpaceRadius: 40,
|
||||
sections: showingSections()),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 28,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<PieChartSectionData> showingSections() {
|
||||
return List.generate(2, (i) {
|
||||
final isTouched = i == touchedIndex;
|
||||
final fontSize = isTouched ? 25.0 : 16.0;
|
||||
final radius = isTouched ? 60.0 : 50.0;
|
||||
switch (i) {
|
||||
case 0:
|
||||
return PieChartSectionData(
|
||||
color: const Color(0xff760707),
|
||||
value: 40,
|
||||
title: '28.3%',
|
||||
radius: radius,
|
||||
titleStyle: TextStyle(
|
||||
fontSize: fontSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: const Color(0xffffffff)),
|
||||
);
|
||||
case 1:
|
||||
return PieChartSectionData(
|
||||
color: const Color(0xff0a7005),
|
||||
value: 30,
|
||||
title: '16.7%',
|
||||
radius: radius,
|
||||
titleStyle: TextStyle(
|
||||
fontSize: fontSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: const Color(0xffffffff)),
|
||||
);
|
||||
default:
|
||||
throw Error();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -1,125 +0,0 @@
|
||||
import 'package:aurcache/api/packages.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
|
||||
import '../../../api/API.dart';
|
||||
import '../../../core/constants/color_constants.dart';
|
||||
import '../../../responsive.dart';
|
||||
|
||||
class Header extends StatelessWidget {
|
||||
const Header({
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
if (!Responsive.isDesktop(context))
|
||||
IconButton(
|
||||
icon: Icon(Icons.menu),
|
||||
onPressed: () {},
|
||||
),
|
||||
if (!Responsive.isMobile(context))
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Hello, Arch User 👋",
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
),
|
||||
SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
Text(
|
||||
"Welcome to your Build server",
|
||||
style: Theme.of(context).textTheme.subtitle2,
|
||||
),
|
||||
],
|
||||
),
|
||||
if (!Responsive.isMobile(context))
|
||||
Spacer(flex: Responsive.isDesktop(context) ? 2 : 1),
|
||||
Expanded(child: SearchField()),
|
||||
//ProfileCard()
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ProfileCard extends StatelessWidget {
|
||||
const ProfileCard({
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: EdgeInsets.only(left: defaultPadding),
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: defaultPadding,
|
||||
vertical: defaultPadding / 2,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: secondaryColor,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
||||
border: Border.all(color: Colors.white10),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
backgroundImage: AssetImage("assets/images/profile_pic.png"),
|
||||
),
|
||||
if (!Responsive.isMobile(context))
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: defaultPadding / 2),
|
||||
child: Text("Deniz Çolak"),
|
||||
),
|
||||
Icon(Icons.keyboard_arrow_down),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SearchField extends StatelessWidget {
|
||||
SearchField({
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
final controller = TextEditingController();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TextField(
|
||||
controller: controller,
|
||||
decoration: InputDecoration(
|
||||
hintText: "Search",
|
||||
fillColor: secondaryColor,
|
||||
filled: true,
|
||||
border: const OutlineInputBorder(
|
||||
borderSide: BorderSide.none,
|
||||
borderRadius: BorderRadius.all(Radius.circular(10)),
|
||||
),
|
||||
suffixIcon: InkWell(
|
||||
onTap: () {
|
||||
// todo this is only temporary -> add this to a proper page
|
||||
API.addPackage(name: controller.text);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(defaultPadding * 0.75),
|
||||
margin: EdgeInsets.symmetric(horizontal: defaultPadding / 2),
|
||||
decoration: const BoxDecoration(
|
||||
color: greenColor,
|
||||
borderRadius: BorderRadius.all(Radius.circular(10)),
|
||||
),
|
||||
child: SvgPicture.asset(
|
||||
"assets/icons/Search.svg",
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/constants/color_constants.dart';
|
||||
import '../../../models/daily_info_model.dart';
|
||||
import '../../../responsive.dart';
|
||||
import 'mini_information_widget.dart';
|
||||
|
||||
class MiniInformation extends StatelessWidget {
|
||||
const MiniInformation({
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Size _size = MediaQuery.of(context).size;
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
ElevatedButton.icon(
|
||||
style: TextButton.styleFrom(
|
||||
backgroundColor: Colors.green,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: defaultPadding * 1.5,
|
||||
vertical:
|
||||
defaultPadding / (Responsive.isMobile(context) ? 2 : 1),
|
||||
),
|
||||
),
|
||||
onPressed: () {},
|
||||
icon: Icon(Icons.add),
|
||||
label: Text(
|
||||
"Add New",
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: defaultPadding),
|
||||
Responsive(
|
||||
mobile: InformationCard(
|
||||
crossAxisCount: _size.width < 650 ? 2 : 4,
|
||||
childAspectRatio: _size.width < 650 ? 1.2 : 1,
|
||||
),
|
||||
tablet: InformationCard(),
|
||||
desktop: InformationCard(
|
||||
childAspectRatio: _size.width < 1400 ? 1.2 : 1.4,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class InformationCard extends StatelessWidget {
|
||||
const InformationCard({
|
||||
Key? key,
|
||||
this.crossAxisCount = 5,
|
||||
this.childAspectRatio = 1,
|
||||
}) : super(key: key);
|
||||
|
||||
final int crossAxisCount;
|
||||
final double childAspectRatio;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GridView.builder(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
itemCount: dailyDatas.length,
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: crossAxisCount,
|
||||
crossAxisSpacing: defaultPadding,
|
||||
mainAxisSpacing: defaultPadding,
|
||||
childAspectRatio: childAspectRatio,
|
||||
),
|
||||
itemBuilder: (context, index) =>
|
||||
MiniInformationWidget(dailyData: dailyDatas[index]),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,206 +0,0 @@
|
||||
import 'package:fl_chart/fl_chart.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/constants/color_constants.dart';
|
||||
import '../../../models/daily_info_model.dart';
|
||||
|
||||
class MiniInformationWidget extends StatefulWidget {
|
||||
const MiniInformationWidget({
|
||||
Key? key,
|
||||
required this.dailyData,
|
||||
}) : super(key: key);
|
||||
final DailyInfoModel dailyData;
|
||||
|
||||
@override
|
||||
_MiniInformationWidgetState createState() => _MiniInformationWidgetState();
|
||||
}
|
||||
|
||||
int _value = 1;
|
||||
|
||||
class _MiniInformationWidgetState extends State<MiniInformationWidget> {
|
||||
@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,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(defaultPadding * 0.75),
|
||||
height: 40,
|
||||
width: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: widget.dailyData.color!.withOpacity(0.1),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
||||
),
|
||||
child: Icon(
|
||||
widget.dailyData.icon,
|
||||
color: widget.dailyData.color,
|
||||
size: 18,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(right: 12.0),
|
||||
child: DropdownButton(
|
||||
icon: Icon(Icons.more_vert, size: 18),
|
||||
underline: SizedBox(),
|
||||
style: Theme.of(context).textTheme.button,
|
||||
value: _value,
|
||||
items: [
|
||||
DropdownMenuItem(
|
||||
child: Text("Daily"),
|
||||
value: 1,
|
||||
),
|
||||
DropdownMenuItem(
|
||||
child: Text("Weekly"),
|
||||
value: 2,
|
||||
),
|
||||
DropdownMenuItem(
|
||||
child: Text("Monthly"),
|
||||
value: 3,
|
||||
),
|
||||
],
|
||||
onChanged: (int? value) {
|
||||
setState(() {
|
||||
_value = value!;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
widget.dailyData.title!,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
Container(
|
||||
child: LineChartWidget(
|
||||
colors: widget.dailyData.colors,
|
||||
spotsData: widget.dailyData.spots,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
ProgressLine(
|
||||
color: widget.dailyData.color!,
|
||||
percentage: widget.dailyData.percentage!,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"${widget.dailyData.volumeData}",
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.caption!
|
||||
.copyWith(color: Colors.white70),
|
||||
),
|
||||
Text(
|
||||
widget.dailyData.totalStorage!,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.caption!
|
||||
.copyWith(color: Colors.white),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class LineChartWidget extends StatelessWidget {
|
||||
const LineChartWidget({
|
||||
Key? key,
|
||||
required this.colors,
|
||||
required this.spotsData,
|
||||
}) : super(key: key);
|
||||
final List<Color>? colors;
|
||||
final List<FlSpot>? spotsData;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Stack(
|
||||
children: [
|
||||
Container(
|
||||
width: 80,
|
||||
height: 30,
|
||||
child: LineChart(
|
||||
LineChartData(
|
||||
lineBarsData: [
|
||||
LineChartBarData(
|
||||
spots: spotsData!,
|
||||
belowBarData: BarAreaData(show: false),
|
||||
aboveBarData: BarAreaData(show: false),
|
||||
isCurved: true,
|
||||
dotData: FlDotData(show: false),
|
||||
//colors: colors,
|
||||
barWidth: 3),
|
||||
],
|
||||
lineTouchData: LineTouchData(enabled: false),
|
||||
titlesData: FlTitlesData(show: false),
|
||||
//axisTitleData: FlAxisTitleData(show: false),
|
||||
gridData: FlGridData(show: false),
|
||||
borderData: FlBorderData(show: false)),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ProgressLine extends StatelessWidget {
|
||||
const ProgressLine({
|
||||
Key? key,
|
||||
this.color = primaryColor,
|
||||
required this.percentage,
|
||||
}) : super(key: key);
|
||||
|
||||
final Color color;
|
||||
final int percentage;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Stack(
|
||||
children: [
|
||||
Container(
|
||||
width: double.infinity,
|
||||
height: 5,
|
||||
decoration: BoxDecoration(
|
||||
color: color.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.all(Radius.circular(10)),
|
||||
),
|
||||
),
|
||||
LayoutBuilder(
|
||||
builder: (context, constraints) => Container(
|
||||
width: constraints.maxWidth * (percentage / 100),
|
||||
height: 5,
|
||||
decoration: BoxDecoration(
|
||||
color: color,
|
||||
borderRadius: BorderRadius.all(Radius.circular(10)),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
@ -1,106 +0,0 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:aurcache/api/builds.dart';
|
||||
import 'package:aurcache/core/models/build.dart';
|
||||
import 'package:aurcache/screens/dashboard/components/your_packages.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../api/API.dart';
|
||||
import '../../../core/constants/color_constants.dart';
|
||||
import '../../../core/models/package.dart';
|
||||
|
||||
class RecentBuilds extends StatefulWidget {
|
||||
const RecentBuilds({
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<RecentBuilds> createState() => _RecentBuildsState();
|
||||
}
|
||||
|
||||
class _RecentBuildsState extends State<RecentBuilds> {
|
||||
late Future<List<Build>> dataFuture;
|
||||
Timer? timer;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
dataFuture = API.listAllBuilds();
|
||||
|
||||
timer = Timer.periodic(
|
||||
const Duration(seconds: 10),
|
||||
(Timer t) => setState(() {
|
||||
dataFuture = API.listAllBuilds();
|
||||
}));
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
timer?.cancel();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(defaultPadding),
|
||||
decoration: BoxDecoration(
|
||||
color: secondaryColor,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Recent Builds",
|
||||
style: Theme.of(context).textTheme.subtitle1,
|
||||
),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: FutureBuilder(
|
||||
future: dataFuture,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
return DataTable(
|
||||
horizontalMargin: 0,
|
||||
columnSpacing: defaultPadding,
|
||||
columns: const [
|
||||
DataColumn(
|
||||
label: Text("Build ID"),
|
||||
),
|
||||
DataColumn(
|
||||
label: Text("Package Name"),
|
||||
),
|
||||
DataColumn(
|
||||
label: Text("Version"),
|
||||
),
|
||||
DataColumn(
|
||||
label: Text("Status"),
|
||||
),
|
||||
],
|
||||
rows: snapshot.data!.map((e) => recentUserDataRow(e)).toList(),
|
||||
);
|
||||
} else {
|
||||
return Text("no data");
|
||||
}
|
||||
}),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
DataRow recentUserDataRow(Build build) {
|
||||
return DataRow(
|
||||
cells: [
|
||||
DataCell(Text(build.id.toString())),
|
||||
DataCell(Text(build.pkg_name)),
|
||||
DataCell(Text(build.version)),
|
||||
DataCell(Icon(
|
||||
switchSuccessIcon(build.status),
|
||||
color: switchSuccessColor(build.status),
|
||||
)),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
import 'package:aurcache/screens/dashboard/components/chart_card.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/constants/color_constants.dart';
|
||||
import 'charts.dart';
|
||||
|
||||
class UserDetailsWidget extends StatelessWidget {
|
||||
const UserDetailsWidget({
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(defaultPadding),
|
||||
decoration: BoxDecoration(
|
||||
color: secondaryColor,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Package build success",
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
SizedBox(height: defaultPadding),
|
||||
Chart(),
|
||||
UserDetailsMiniCard(
|
||||
color: const Color(0xff0a7005),
|
||||
title: "Successful Builds",
|
||||
amountOfFiles: "%16.7",
|
||||
numberOfIncrease: 1328,
|
||||
),
|
||||
UserDetailsMiniCard(
|
||||
color: const Color(0xff760707),
|
||||
title: "Failed Builds",
|
||||
amountOfFiles: "%28.3",
|
||||
numberOfIncrease: 1328,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,162 +0,0 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:aurcache/api/packages.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../api/API.dart';
|
||||
import '../../../core/constants/color_constants.dart';
|
||||
import '../../../core/models/package.dart';
|
||||
|
||||
class YourPackages extends StatefulWidget {
|
||||
const YourPackages({
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<YourPackages> createState() => _YourPackagesState();
|
||||
}
|
||||
|
||||
class _YourPackagesState extends State<YourPackages> {
|
||||
late Future<List<Package>> dataFuture;
|
||||
Timer? timer;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
dataFuture = API.listPackages();
|
||||
|
||||
timer = Timer.periodic(
|
||||
const Duration(seconds: 10),
|
||||
(Timer t) => setState(() {
|
||||
dataFuture = API.listPackages();
|
||||
}));
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
timer?.cancel();
|
||||
}
|
||||
|
||||
@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,
|
||||
),
|
||||
SingleChildScrollView(
|
||||
//scrollDirection: Axis.horizontal,
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
child: FutureBuilder(
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
return DataTable(
|
||||
horizontalMargin: 0,
|
||||
columnSpacing: defaultPadding,
|
||||
columns: const [
|
||||
DataColumn(
|
||||
label: Text("Package ID"),
|
||||
),
|
||||
DataColumn(
|
||||
label: Text("Package Name"),
|
||||
),
|
||||
DataColumn(
|
||||
label: Text("Number of versions"),
|
||||
),
|
||||
DataColumn(
|
||||
label: Text("Status"),
|
||||
),
|
||||
DataColumn(
|
||||
label: Text("Action"),
|
||||
),
|
||||
],
|
||||
rows: snapshot.data!
|
||||
.map((e) => buildDataRow(e))
|
||||
.toList(growable: false),
|
||||
);
|
||||
} else {
|
||||
return const Text("No data");
|
||||
}
|
||||
},
|
||||
future: dataFuture,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
DataRow buildDataRow(Package package) {
|
||||
return DataRow(
|
||||
cells: [
|
||||
DataCell(Text(package.id.toString())),
|
||||
DataCell(Text(package.name)),
|
||||
DataCell(Text(package.count.toString())),
|
||||
DataCell(IconButton(
|
||||
icon: Icon(
|
||||
switchSuccessIcon(package.status),
|
||||
color: switchSuccessColor(package.status),
|
||||
),
|
||||
onPressed: () {
|
||||
// todo open build info with logs
|
||||
},
|
||||
)),
|
||||
DataCell(
|
||||
Row(
|
||||
children: [
|
||||
TextButton(
|
||||
child: const Text('View', style: TextStyle(color: greenColor)),
|
||||
onPressed: () {},
|
||||
),
|
||||
const SizedBox(
|
||||
width: 6,
|
||||
),
|
||||
TextButton(
|
||||
child: const Text("Delete",
|
||||
style: TextStyle(color: Colors.redAccent)),
|
||||
onPressed: () {},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
IconData switchSuccessIcon(int status) {
|
||||
switch (status) {
|
||||
case 0:
|
||||
return Icons.watch_later_outlined;
|
||||
case 1:
|
||||
return Icons.check_circle_outline;
|
||||
case 2:
|
||||
return Icons.cancel_outlined;
|
||||
default:
|
||||
return Icons.question_mark_outlined;
|
||||
}
|
||||
}
|
||||
|
||||
Color switchSuccessColor(int status) {
|
||||
switch (status) {
|
||||
case 0:
|
||||
return const Color(0xFF9D8D00);
|
||||
case 1:
|
||||
return const Color(0xFF0A6900);
|
||||
case 2:
|
||||
return const Color(0xff760707);
|
||||
default:
|
||||
return const Color(0xFF9D8D00);
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../core/constants/color_constants.dart';
|
||||
import '../../responsive.dart';
|
||||
import 'components/header.dart';
|
||||
import 'components/mini_information_card.dart';
|
||||
import 'components/recent_builds.dart';
|
||||
import 'components/your_packages.dart';
|
||||
import 'components/user_details_widget.dart';
|
||||
|
||||
class DashboardScreen extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SafeArea(
|
||||
child: SingleChildScrollView(
|
||||
//padding: EdgeInsets.all(defaultPadding),
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(defaultPadding),
|
||||
child: Column(
|
||||
children: [
|
||||
Header(),
|
||||
SizedBox(height: defaultPadding),
|
||||
MiniInformation(),
|
||||
SizedBox(height: defaultPadding),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 5,
|
||||
child: Column(
|
||||
children: [
|
||||
YourPackages(),
|
||||
SizedBox(height: defaultPadding),
|
||||
RecentBuilds(),
|
||||
if (Responsive.isMobile(context))
|
||||
SizedBox(height: defaultPadding),
|
||||
if (Responsive.isMobile(context)) UserDetailsWidget(),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (!Responsive.isMobile(context))
|
||||
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: UserDetailsWidget(),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
78
frontend/lib/screens/dashboard_screen.dart
Normal file
78
frontend/lib/screens/dashboard_screen.dart
Normal file
@ -0,0 +1,78 @@
|
||||
import 'package:aurcache/api/statistics.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
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';
|
||||
|
||||
class DashboardScreen extends StatelessWidget {
|
||||
final stats = API.listStats();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder(
|
||||
future: stats,
|
||||
builder: (BuildContext context, AsyncSnapshot<dynamic> snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
final Stats stats = snapshot.data!;
|
||||
|
||||
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,
|
||||
children: [
|
||||
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(
|
||||
nrbuilds: stats.total_builds,
|
||||
nrfailedbuilds: stats.failed_builds),
|
||||
],
|
||||
),
|
||||
),
|
||||
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),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return const Text("loading");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
|
||||
import '../../../core/constants/color_constants.dart';
|
||||
|
||||
class SideMenu extends StatelessWidget {
|
||||
const SideMenu({
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Drawer(
|
||||
child: SingleChildScrollView(
|
||||
// it enables scrolling
|
||||
child: Column(
|
||||
children: [
|
||||
const DrawerHeader(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
// SizedBox(
|
||||
// height: defaultPadding * 3,
|
||||
// ),
|
||||
// Image.asset(
|
||||
// "assets/logo/logo_icon.png",
|
||||
// scale: 5,
|
||||
// ),
|
||||
SizedBox(
|
||||
height: defaultPadding,
|
||||
),
|
||||
Text("AURCache")
|
||||
],
|
||||
)),
|
||||
DrawerListTile(
|
||||
title: "Dashboard",
|
||||
svgSrc: "assets/icons/menu_dashbord.svg",
|
||||
press: () {},
|
||||
),
|
||||
DrawerListTile(
|
||||
title: "Builds",
|
||||
svgSrc: "assets/icons/menu_tran.svg",
|
||||
press: () {},
|
||||
),
|
||||
DrawerListTile(
|
||||
title: "AUR",
|
||||
svgSrc: "assets/icons/menu_task.svg",
|
||||
press: () {},
|
||||
),
|
||||
DrawerListTile(
|
||||
title: "Settings",
|
||||
svgSrc: "assets/icons/menu_setting.svg",
|
||||
press: () {},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class DrawerListTile extends StatelessWidget {
|
||||
const DrawerListTile({
|
||||
Key? key,
|
||||
// For selecting those three line once press "Command+D"
|
||||
required this.title,
|
||||
required this.svgSrc,
|
||||
required this.press,
|
||||
}) : super(key: key);
|
||||
|
||||
final String title, svgSrc;
|
||||
final VoidCallback press;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListTile(
|
||||
onTap: press,
|
||||
horizontalTitleGap: 0.0,
|
||||
leading: SvgPicture.asset(
|
||||
svgSrc,
|
||||
color: Colors.white54,
|
||||
height: 16,
|
||||
),
|
||||
title: Text(
|
||||
title,
|
||||
style: TextStyle(color: Colors.white54),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../responsive.dart';
|
||||
import '../dashboard/dashboard_screen.dart';
|
||||
import 'components/side_menu.dart';
|
||||
import '../utils/responsive.dart';
|
||||
import 'dashboard_screen.dart';
|
||||
import '../components/side_menu.dart';
|
||||
|
||||
class HomeScreen extends StatelessWidget {
|
||||
const HomeScreen({super.key});
|
Reference in New Issue
Block a user