Skip to content

Commit

Permalink
Code Refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
aslight0013 committed May 31, 2021
1 parent 1dd401b commit 106e5b4
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 69 deletions.
27 changes: 14 additions & 13 deletions lib/models/MyFiles.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,47 @@ import 'package:flutter/material.dart';

class CloudStorageInfo {
final String? svgSrc, title, totalStorage;
final int? numOfFiels, percentage;
final int? numOfFiles, percentage;
final Color? color;

CloudStorageInfo(
{this.svgSrc,
this.title,
this.totalStorage,
this.numOfFiels,
this.percentage,
this.color});
CloudStorageInfo({
this.svgSrc,
this.title,
this.totalStorage,
this.numOfFiles,
this.percentage,
this.color,
});
}

List demoMyFiels = [
List demoMyFiles = [
CloudStorageInfo(
title: "Documents",
numOfFiels: 1328,
numOfFiles: 1328,
svgSrc: "assets/icons/Documents.svg",
totalStorage: "1.9GB",
color: primaryColor,
percentage: 35,
),
CloudStorageInfo(
title: "Google Drive",
numOfFiels: 1328,
numOfFiles: 1328,
svgSrc: "assets/icons/google_drive.svg",
totalStorage: "2.9GB",
color: Color(0xFFFFA113),
percentage: 35,
),
CloudStorageInfo(
title: "One Drive",
numOfFiels: 1328,
numOfFiles: 1328,
svgSrc: "assets/icons/one_drive.svg",
totalStorage: "1GB",
color: Color(0xFFA4CDFF),
percentage: 10,
),
CloudStorageInfo(
title: "Documents",
numOfFiels: 5328,
numOfFiles: 5328,
svgSrc: "assets/icons/drop_box.svg",
totalStorage: "7.3GB",
color: Color(0xFF007EE5),
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/dashboard/components/file_info_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class FileInfoCard extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"${info.numOfFiels} Files",
"${info.numOfFiles} Files",
style: Theme.of(context)
.textTheme
.caption!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import 'package:flutter/material.dart';
import '../../../constants.dart';
import 'file_info_card.dart';

class MyFiels extends StatelessWidget {
const MyFiels({
class MyFiles extends StatelessWidget {
const MyFiles({
Key? key,
}) : super(key: key);

Expand Down Expand Up @@ -67,14 +67,14 @@ class FileInfoCardGridView extends StatelessWidget {
return GridView.builder(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: demoMyFiels.length,
itemCount: demoMyFiles.length,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: crossAxisCount,
crossAxisSpacing: defaultPadding,
mainAxisSpacing: defaultPadding,
childAspectRatio: childAspectRatio,
),
itemBuilder: (context, index) => FileInfoCard(info: demoMyFiels[index]),
itemBuilder: (context, index) => FileInfoCard(info: demoMyFiles[index]),
);
}
}
80 changes: 80 additions & 0 deletions lib/screens/dashboard/components/my_files.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@

import 'package:admin/responsive.dart';
import 'package:flutter/material.dart';
import 'package:admin/models/MyFiles.dart';
import '../../../constants.dart';
import 'file_info_card.dart';

class MyFiles extends StatelessWidget {
const MyFiles({
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: [
Text(
"My Files",
style: Theme.of(context).textTheme.subtitle1,
),
ElevatedButton.icon(
style: TextButton.styleFrom(
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: FileInfoCardGridView(
crossAxisCount: _size.width < 650 ? 2 : 4,
childAspectRatio: _size.width < 650 ? 1.3 : 1,
),
tablet: FileInfoCardGridView(),
desktop: FileInfoCardGridView(
childAspectRatio: _size.width < 1400 ? 1.1 : 1.4,
),
),
],
);
}
}

class FileInfoCardGridView extends StatelessWidget {
const FileInfoCardGridView({
Key? key,
this.crossAxisCount = 4,
this.childAspectRatio = 1,
}) : super(key: key);

final int crossAxisCount;
final double childAspectRatio;

@override
Widget build(BuildContext context) {
return GridView.builder(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: demoMyFiles.length,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: crossAxisCount,
crossAxisSpacing: defaultPadding,
mainAxisSpacing: defaultPadding,
childAspectRatio: childAspectRatio,
),
itemBuilder: (context, index) => FileInfoCard(info: demoMyFiles[index]),
);
}
}
5 changes: 3 additions & 2 deletions lib/screens/dashboard/dashboard_screen.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import 'package:admin/responsive.dart';
import 'package:admin/screens/dashboard/components/my_fields.dart';
import 'package:flutter/material.dart';

import '../../constants.dart';
import 'components/header.dart';
import 'components/my_fiels.dart';

import 'components/recent_files.dart';
import 'components/storage_details.dart';

Expand All @@ -24,7 +25,7 @@ class DashboardScreen extends StatelessWidget {
flex: 5,
child: Column(
children: [
MyFiels(),
MyFiles(),
SizedBox(height: defaultPadding),
RecentFiles(),
if (Responsive.isMobile(context))
Expand Down
95 changes: 46 additions & 49 deletions lib/screens/main/components/side_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,55 +9,52 @@ class SideMenu extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Drawer(
child: SingleChildScrollView(
// it enables scrolling
child: Column(
children: [
DrawerHeader(
child: Image.asset("assets/images/logo.png"),
),
DrawerListTile(
title: "Dashbord",
svgSrc: "assets/icons/menu_dashbord.svg",
press: () {},
),
DrawerListTile(
title: "Transaction",
svgSrc: "assets/icons/menu_tran.svg",
press: () {},
),
DrawerListTile(
title: "Task",
svgSrc: "assets/icons/menu_task.svg",
press: () {},
),
DrawerListTile(
title: "Documents",
svgSrc: "assets/icons/menu_doc.svg",
press: () {},
),
DrawerListTile(
title: "Store",
svgSrc: "assets/icons/menu_store.svg",
press: () {},
),
DrawerListTile(
title: "Notification",
svgSrc: "assets/icons/menu_notification.svg",
press: () {},
),
DrawerListTile(
title: "Profile",
svgSrc: "assets/icons/menu_profile.svg",
press: () {},
),
DrawerListTile(
title: "Settings",
svgSrc: "assets/icons/menu_setting.svg",
press: () {},
),
],
),
child: ListView(
children: [
DrawerHeader(
child: Image.asset("assets/images/logo.png"),
),
DrawerListTile(
title: "Dashbord",
svgSrc: "assets/icons/menu_dashbord.svg",
press: () {},
),
DrawerListTile(
title: "Transaction",
svgSrc: "assets/icons/menu_tran.svg",
press: () {},
),
DrawerListTile(
title: "Task",
svgSrc: "assets/icons/menu_task.svg",
press: () {},
),
DrawerListTile(
title: "Documents",
svgSrc: "assets/icons/menu_doc.svg",
press: () {},
),
DrawerListTile(
title: "Store",
svgSrc: "assets/icons/menu_store.svg",
press: () {},
),
DrawerListTile(
title: "Notification",
svgSrc: "assets/icons/menu_notification.svg",
press: () {},
),
DrawerListTile(
title: "Profile",
svgSrc: "assets/icons/menu_profile.svg",
press: () {},
),
DrawerListTile(
title: "Settings",
svgSrc: "assets/icons/menu_setting.svg",
press: () {},
),
],
),
);
}
Expand Down

0 comments on commit 106e5b4

Please sign in to comment.