Skip to content

Commit

Permalink
done
Browse files Browse the repository at this point in the history
  • Loading branch information
aslight0013 committed May 4, 2021
1 parent 55d3a8b commit ab5de33
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 32 deletions.
11 changes: 10 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import 'package:admin/constants.dart';
import 'package:admin/controllers/MenuController.dart';
import 'package:admin/screens/main/main_screen.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:provider/provider.dart';

void main() {
runApp(MyApp());
Expand All @@ -20,7 +22,14 @@ class MyApp extends StatelessWidget {
.apply(bodyColor: Colors.white),
canvasColor: secondaryColor,
),
home: MainScreen(),
home: MultiProvider(
providers: [
ChangeNotifierProvider(
create: (context) => MenuController(),
),
],
child: MainScreen(),
),
);
}
}
30 changes: 21 additions & 9 deletions lib/screens/dashboard/components/header.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import 'package:admin/controllers/MenuController.dart';
import 'package:admin/responsive.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:provider/provider.dart';

import '../../../constants.dart';

Expand All @@ -12,11 +15,18 @@ class Header extends StatelessWidget {
Widget build(BuildContext context) {
return Row(
children: [
Text(
"Dashboard",
style: Theme.of(context).textTheme.headline6,
),
Spacer(flex: 2),
if (!Responsive.isDesktop(context))
IconButton(
icon: Icon(Icons.menu),
onPressed: context.read<MenuController>().controlMenu,
),
if (!Responsive.isMobile(context))
Text(
"Dashboard",
style: Theme.of(context).textTheme.headline6,
),
if (!Responsive.isMobile(context))
Spacer(flex: Responsive.isDesktop(context) ? 2 : 1),
Expanded(child: SearchField()),
ProfileCard()
],
Expand Down Expand Up @@ -48,10 +58,12 @@ class ProfileCard extends StatelessWidget {
"assets/images/profile_pic.png",
height: 38,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: defaultPadding / 2),
child: Text("Angelina Joli"),
),
if (!Responsive.isMobile(context))
Padding(
padding:
const EdgeInsets.symmetric(horizontal: defaultPadding / 2),
child: Text("Angelina Joli"),
),
Icon(Icons.keyboard_arrow_down),
],
),
Expand Down
49 changes: 39 additions & 10 deletions lib/screens/dashboard/components/my_fiels.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:admin/models/MyFiles.dart';
import 'package:admin/responsive.dart';
import 'package:flutter/material.dart';

import '../../../constants.dart';
Expand All @@ -11,6 +12,7 @@ class MyFiels extends StatelessWidget {

@override
Widget build(BuildContext context) {
final Size _size = MediaQuery.of(context).size;
return Column(
children: [
Row(
Expand All @@ -24,7 +26,8 @@ class MyFiels extends StatelessWidget {
style: TextButton.styleFrom(
padding: EdgeInsets.symmetric(
horizontal: defaultPadding * 1.5,
vertical: defaultPadding,
vertical:
defaultPadding / (Responsive.isMobile(context) ? 2 : 1),
),
),
onPressed: () {},
Expand All @@ -34,18 +37,44 @@ class MyFiels extends StatelessWidget {
],
),
SizedBox(height: defaultPadding),
GridView.builder(
shrinkWrap: true,
itemCount: demoMyFiels.length,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 4,
crossAxisSpacing: defaultPadding,
childAspectRatio: 1.4,
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,
),
itemBuilder: (context, index) =>
FileInfoCard(info: demoMyFiels[index]),
),
],
);
}
}

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: demoMyFiels.length,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: crossAxisCount,
crossAxisSpacing: defaultPadding,
mainAxisSpacing: defaultPadding,
childAspectRatio: childAspectRatio,
),
itemBuilder: (context, index) => FileInfoCard(info: demoMyFiels[index]),
);
}
}
19 changes: 13 additions & 6 deletions lib/screens/dashboard/dashboard_screen.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:admin/responsive.dart';
import 'package:flutter/material.dart';

import '../../constants.dart';
Expand Down Expand Up @@ -25,15 +26,21 @@ class DashboardScreen extends StatelessWidget {
children: [
MyFiels(),
SizedBox(height: defaultPadding),
RecentFiles()
RecentFiles(),
if (Responsive.isMobile(context))
SizedBox(height: defaultPadding),
if (Responsive.isMobile(context)) StarageDetails(),
],
),
),
SizedBox(width: defaultPadding),
Expanded(
flex: 2,
child: StarageDetails(),
),
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: StarageDetails(),
),
],
)
],
Expand Down
18 changes: 12 additions & 6 deletions lib/screens/main/main_screen.dart
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
import 'package:admin/controllers/MenuController.dart';
import 'package:admin/responsive.dart';
import 'package:admin/screens/dashboard/dashboard_screen.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:provider/provider.dart';

import 'components/side_menu.dart';

class MainScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
key: context.read<MenuController>().scaffoldKey,
drawer: SideMenu(),
body: SafeArea(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
// default flex = 1
// and it takes 1/6 part of the screen
child: SideMenu(),
),
// We want this side menu only for large screen
if (Responsive.isDesktop(context))
Expanded(
// default flex = 1
// and it takes 1/6 part of the screen
child: SideMenu(),
),
Expanded(
// It takes 5/6 part of the screen
flex: 5,
Expand Down

0 comments on commit ab5de33

Please sign in to comment.