diff --git a/lib/constants.dart b/lib/constants.dart index d38f7a3f..ad92baa3 100644 --- a/lib/constants.dart +++ b/lib/constants.dart @@ -4,4 +4,8 @@ const primaryColor = Color(0xFF2697FF); const secondaryColor = Color(0xFF2A2D3E); const bgColor = Color(0xFF212332); +const creamColor = Color(0xFFFFFFFF); +const snowColor = Color(0xFFFFFAFA); + + const defaultPadding = 16.0; diff --git a/lib/main.dart b/lib/main.dart index bbd8dccf..f9976f6b 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,3 +1,4 @@ +import 'package:adaptive_theme/adaptive_theme.dart'; import 'package:admin/constants.dart'; import 'package:admin/controllers/MenuController.dart'; import 'package:admin/screens/main/main_screen.dart'; @@ -13,6 +14,35 @@ class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { + return AdaptiveTheme( + light: ThemeData.light().copyWith( + scaffoldBackgroundColor: creamColor, + textTheme: GoogleFonts.poppinsTextTheme(Theme.of(context).textTheme) + .apply(bodyColor: Colors.black), + canvasColor: snowColor, + ), + dark: ThemeData.dark().copyWith( + scaffoldBackgroundColor: bgColor, + textTheme: GoogleFonts.poppinsTextTheme(Theme.of(context).textTheme) + .apply(bodyColor: Colors.white), + canvasColor: secondaryColor, + ), + initial: AdaptiveThemeMode.light, + builder: (theme, darkTheme) => MaterialApp( + title: 'Adaptive Theme Demo', + theme: theme, + darkTheme: darkTheme, + debugShowCheckedModeBanner: false, + home: MultiProvider( + providers: [ + ChangeNotifierProvider( + create: (context) => MenuController(), + ), + ], + child: MainScreen(), + ), + ), + ); return MaterialApp( debugShowCheckedModeBanner: false, title: 'Flutter Admin Panel', diff --git a/lib/screens/dashboard/components/chart.dart b/lib/screens/dashboard/components/chart.dart index bbc11090..a655669e 100644 --- a/lib/screens/dashboard/components/chart.dart +++ b/lib/screens/dashboard/components/chart.dart @@ -29,11 +29,10 @@ class Chart extends StatelessWidget { SizedBox(height: defaultPadding), Text( "29.1", - style: Theme.of(context).textTheme.headline4!.copyWith( - color: Colors.white, - fontWeight: FontWeight.w600, - height: 0.5, - ), + style: Theme.of(context).textTheme.bodyText1!.copyWith( + fontWeight: FontWeight.bold, + fontSize: 30 + ), ), Text("of 128GB") ], diff --git a/lib/screens/dashboard/components/file_info_card.dart b/lib/screens/dashboard/components/file_info_card.dart index 912a5973..db84b1e8 100644 --- a/lib/screens/dashboard/components/file_info_card.dart +++ b/lib/screens/dashboard/components/file_info_card.dart @@ -17,7 +17,7 @@ class FileInfoCard extends StatelessWidget { return Container( padding: EdgeInsets.all(defaultPadding), decoration: BoxDecoration( - color: secondaryColor, + color: Theme.of(context).canvasColor, borderRadius: const BorderRadius.all(Radius.circular(10)), ), child: Column( @@ -40,7 +40,7 @@ class FileInfoCard extends StatelessWidget { color: info.color, ), ), - Icon(Icons.more_vert, color: Colors.white54) + Icon(Icons.more_vert, color: Theme.of(context).backgroundColor) ], ), Text( @@ -59,15 +59,13 @@ class FileInfoCard extends StatelessWidget { "${info.numOfFiles} Files", style: Theme.of(context) .textTheme - .caption! - .copyWith(color: Colors.white70), + .caption, ), Text( info.totalStorage!, style: Theme.of(context) .textTheme - .caption! - .copyWith(color: Colors.white), + .caption, ), ], ) diff --git a/lib/screens/dashboard/components/header.dart b/lib/screens/dashboard/components/header.dart index 58ee66fc..3f0d2a49 100644 --- a/lib/screens/dashboard/components/header.dart +++ b/lib/screens/dashboard/components/header.dart @@ -48,7 +48,7 @@ class ProfileCard extends StatelessWidget { vertical: defaultPadding / 2, ), decoration: BoxDecoration( - color: secondaryColor, + color: Theme.of(context).canvasColor, borderRadius: const BorderRadius.all(Radius.circular(10)), border: Border.all(color: Colors.white10), ), @@ -81,7 +81,7 @@ class SearchField extends StatelessWidget { return TextField( decoration: InputDecoration( hintText: "Search", - fillColor: secondaryColor, + fillColor: Theme.of(context).canvasColor, filled: true, border: OutlineInputBorder( borderSide: BorderSide.none, diff --git a/lib/screens/dashboard/components/my_fields.dart b/lib/screens/dashboard/components/my_fields.dart index c4c7ca39..d76f5563 100644 --- a/lib/screens/dashboard/components/my_fields.dart +++ b/lib/screens/dashboard/components/my_fields.dart @@ -1,3 +1,4 @@ +import 'package:adaptive_theme/adaptive_theme.dart'; import 'package:admin/models/MyFiles.dart'; import 'package:admin/responsive.dart'; import 'package:flutter/material.dart'; @@ -22,17 +23,38 @@ class MyFiles extends StatelessWidget { "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), + Row( + children: [ + ElevatedButton.icon( + style: TextButton.styleFrom( + padding: EdgeInsets.symmetric( + horizontal: defaultPadding * 1.5, + vertical: defaultPadding / + (Responsive.isMobile(context) ? 2 : 1), + ), + ), + onPressed: () { + AdaptiveTheme.of(context).toggleThemeMode(); + }, + icon: Icon(Icons.ac_unit_sharp), + label: Text("Change Theme"), ), - ), - onPressed: () {}, - icon: Icon(Icons.add), - label: Text("Add New"), + SizedBox( + width: 20, + ), + 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"), + ), + ], ), ], ), diff --git a/lib/screens/dashboard/components/recent_files.dart b/lib/screens/dashboard/components/recent_files.dart index 3a50295f..d362e32c 100644 --- a/lib/screens/dashboard/components/recent_files.dart +++ b/lib/screens/dashboard/components/recent_files.dart @@ -15,7 +15,7 @@ class RecentFiles extends StatelessWidget { return Container( padding: EdgeInsets.all(defaultPadding), decoration: BoxDecoration( - color: secondaryColor, + color: Theme.of(context).canvasColor, borderRadius: const BorderRadius.all(Radius.circular(10)), ), child: Column( diff --git a/lib/screens/dashboard/components/storage_details.dart b/lib/screens/dashboard/components/storage_details.dart index e8205c51..f1b9c1ef 100644 --- a/lib/screens/dashboard/components/storage_details.dart +++ b/lib/screens/dashboard/components/storage_details.dart @@ -14,7 +14,7 @@ class StarageDetails extends StatelessWidget { return Container( padding: EdgeInsets.all(defaultPadding), decoration: BoxDecoration( - color: secondaryColor, + color: Theme.of(context).canvasColor, borderRadius: const BorderRadius.all(Radius.circular(10)), ), child: Column( diff --git a/lib/screens/dashboard/components/storage_info_card.dart b/lib/screens/dashboard/components/storage_info_card.dart index d1c8f38b..146b7dd4 100644 --- a/lib/screens/dashboard/components/storage_info_card.dart +++ b/lib/screens/dashboard/components/storage_info_card.dart @@ -48,14 +48,13 @@ class StorageInfoCard extends StatelessWidget { "$numOfFiles Files", style: Theme.of(context) .textTheme - .caption! - .copyWith(color: Colors.white70), + .caption, ), ], ), ), ), - Text(amountOfFiles) + Text(amountOfFiles,style: Theme.of(context).textTheme.bodyText1,) ], ), ); diff --git a/lib/screens/main/components/side_menu.dart b/lib/screens/main/components/side_menu.dart index a21065cd..1f2470a1 100644 --- a/lib/screens/main/components/side_menu.dart +++ b/lib/screens/main/components/side_menu.dart @@ -84,7 +84,7 @@ class DrawerListTile extends StatelessWidget { ), title: Text( title, - style: TextStyle(color: Colors.white54), + style: Theme.of(context).textTheme.bodyText1, ), ); } diff --git a/pubspec.yaml b/pubspec.yaml index a00bff1d..94da9958 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -29,10 +29,11 @@ dependencies: cupertino_icons: ^1.0.3 google_fonts: ^2.1.0 - flutter_svg: ^0.22.0 - fl_chart: ^0.36.1 - provider: ^5.0.0 + flutter_svg: ^1.0.0 + fl_chart: ^0.40.5 + provider: ^6.0.1 data_table_2: ^2.0.3 + adaptive_theme: ^2.3.0 dev_dependencies: flutter_test: