Skip to content

Commit

Permalink
Merge pull request #11 from RounakTadvi/master
Browse files Browse the repository at this point in the history
Added Support For Null-Safety and made some minor changes
  • Loading branch information
aslight0013 committed Jun 1, 2021
2 parents 9621aaa + 106e5b4 commit 0bcc761
Show file tree
Hide file tree
Showing 17 changed files with 217 additions and 138 deletions.
4 changes: 2 additions & 2 deletions lib/controllers/MenuController.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class MenuController extends ChangeNotifier {
GlobalKey<ScaffoldState> get scaffoldKey => _scaffoldKey;

void controlMenu() {
if (!_scaffoldKey.currentState.isDrawerOpen) {
_scaffoldKey.currentState.openDrawer();
if (!_scaffoldKey.currentState!.isDrawerOpen) {
_scaffoldKey.currentState!.openDrawer();
}
}
}
31 changes: 16 additions & 15 deletions lib/models/MyFiles.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,48 @@ import 'package:admin/constants.dart';
import 'package:flutter/material.dart';

class CloudStorageInfo {
final String svgSrc, title, totalStorage;
final int numOfFiels, percentage;
final Color color;
final String? svgSrc, title, totalStorage;
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/models/RecentFile.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class RecentFile {
final String icon, title, date, size;
final String? icon, title, date, size;

RecentFile({this.icon, this.title, this.date, this.size});
}
Expand Down
10 changes: 5 additions & 5 deletions lib/responsive.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import 'package:flutter/material.dart';

class Responsive extends StatelessWidget {
final Widget mobile;
final Widget tablet;
final Widget? tablet;
final Widget desktop;

const Responsive({
Key key,
@required this.mobile,
Key? key,
required this.mobile,
this.tablet,
@required this.desktop,
required this.desktop,
}) : super(key: key);

// This size work fine on my design, maybe you need some customization depends on your design
Expand All @@ -34,7 +34,7 @@ class Responsive extends StatelessWidget {
}
// If width it less then 1100 and more then 850 we consider it as tablet
else if (_size.width >= 850 && tablet != null) {
return tablet;
return tablet!;
}
// Or less then that we called it mobile
else {
Expand Down
4 changes: 2 additions & 2 deletions lib/screens/dashboard/components/chart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import '../../../constants.dart';

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

@override
Expand All @@ -29,7 +29,7 @@ class Chart extends StatelessWidget {
SizedBox(height: defaultPadding),
Text(
"29.1",
style: Theme.of(context).textTheme.headline4.copyWith(
style: Theme.of(context).textTheme.headline4!.copyWith(
color: Colors.white,
fontWeight: FontWeight.w600,
height: 0.5,
Expand Down
30 changes: 15 additions & 15 deletions lib/screens/dashboard/components/file_info_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import '../../../constants.dart';

class FileInfoCard extends StatelessWidget {
const FileInfoCard({
Key key,
@required this.info,
Key? key,
required this.info,
}) : super(key: key);

final CloudStorageInfo info;
Expand All @@ -32,19 +32,19 @@ class FileInfoCard extends StatelessWidget {
height: 40,
width: 40,
decoration: BoxDecoration(
color: info.color.withOpacity(0.1),
color: info.color!.withOpacity(0.1),
borderRadius: const BorderRadius.all(Radius.circular(10)),
),
child: SvgPicture.asset(
info.svgSrc,
info.svgSrc!,
color: info.color,
),
),
Icon(Icons.more_vert, color: Colors.white54)
],
),
Text(
info.title,
info.title!,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Expand All @@ -56,17 +56,17 @@ class FileInfoCard extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"${info.numOfFiels} Files",
"${info.numOfFiles} Files",
style: Theme.of(context)
.textTheme
.caption
.caption!
.copyWith(color: Colors.white70),
),
Text(
info.totalStorage,
info.totalStorage!,
style: Theme.of(context)
.textTheme
.caption
.caption!
.copyWith(color: Colors.white),
),
],
Expand All @@ -79,13 +79,13 @@ class FileInfoCard extends StatelessWidget {

class ProgressLine extends StatelessWidget {
const ProgressLine({
Key key,
Key? key,
this.color = primaryColor,
@required this.percentage,
required this.percentage,
}) : super(key: key);

final Color color;
final int percentage;
final Color? color;
final int? percentage;

@override
Widget build(BuildContext context) {
Expand All @@ -95,13 +95,13 @@ class ProgressLine extends StatelessWidget {
width: double.infinity,
height: 5,
decoration: BoxDecoration(
color: color.withOpacity(0.1),
color: color!.withOpacity(0.1),
borderRadius: BorderRadius.all(Radius.circular(10)),
),
),
LayoutBuilder(
builder: (context, constraints) => Container(
width: constraints.maxWidth * (percentage / 100),
width: constraints.maxWidth * (percentage! / 100),
height: 5,
decoration: BoxDecoration(
color: color,
Expand Down
6 changes: 3 additions & 3 deletions lib/screens/dashboard/components/header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import '../../../constants.dart';

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

@override
Expand Down Expand Up @@ -36,7 +36,7 @@ class Header extends StatelessWidget {

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

@override
Expand Down Expand Up @@ -73,7 +73,7 @@ class ProfileCard extends StatelessWidget {

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

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import 'package:flutter/material.dart';
import '../../../constants.dart';
import 'file_info_card.dart';

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

@override
Expand Down Expand Up @@ -54,7 +54,7 @@ class MyFiels extends StatelessWidget {

class FileInfoCardGridView extends StatelessWidget {
const FileInfoCardGridView({
Key key,
Key? key,
this.crossAxisCount = 4,
this.childAspectRatio = 1,
}) : super(key: key);
Expand All @@ -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]),
);
}
}
10 changes: 5 additions & 5 deletions lib/screens/dashboard/components/recent_files.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import '../../../constants.dart';

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

@override
Expand Down Expand Up @@ -59,19 +59,19 @@ DataRow recentFileDataRow(RecentFile fileInfo) {
Row(
children: [
SvgPicture.asset(
fileInfo.icon,
fileInfo.icon!,
height: 30,
width: 30,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: defaultPadding),
child: Text(fileInfo.title),
child: Text(fileInfo.title!),
),
],
),
),
DataCell(Text(fileInfo.date)),
DataCell(Text(fileInfo.size)),
DataCell(Text(fileInfo.date!)),
DataCell(Text(fileInfo.size!)),
],
);
}
Loading

0 comments on commit 0bcc761

Please sign in to comment.