Skip to content

Commit

Permalink
Added dimentions constant
Browse files Browse the repository at this point in the history
Moved all constant dimensions to a separate file VaibhavCodeClub#91
  • Loading branch information
sapatevaibhav authored May 25, 2024
2 parents e5bd3e3 + 2225346 commit d85b116
Show file tree
Hide file tree
Showing 17 changed files with 170 additions and 108 deletions.
40 changes: 21 additions & 19 deletions lib/pages/about.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import 'package:flutter_svg/flutter_svg.dart';
import 'package:learn/utils/constants.dart';
import 'package:url_launcher/url_launcher.dart';

import '../utils/const_dimensions.dart';

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

Expand All @@ -29,30 +31,30 @@ class AboutPage extends StatelessWidget {
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 16.0),
const SizedBox(height: ConstantDimensions.heightSmall_Medium),
const Text(
'Version: 1.1.0',
style: TextStyle(fontSize: 18.0),
),
const SizedBox(height: 8.0),
const SizedBox(height: ConstantDimensions.heightSmall_Medium / 2),
const Text(
'Developed by: sapatevaibhav',
style: TextStyle(fontSize: 18.0),
),
const SizedBox(height: 16.0),
const SizedBox(height: ConstantDimensions.heightSmall_Medium),
const Text(
'Description:',
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 8.0),
const SizedBox(height: ConstantDimensions.heightSmall_Medium / 2),
const Text(
AppConstants.description,
style: TextStyle(fontSize: 18.0),
),
const SizedBox(height: 6.0),
const SizedBox(height: ConstantDimensions.heightExtraSmall),
const Text(
'Source code:',
style: TextStyle(
Expand All @@ -66,14 +68,14 @@ class AboutPage extends StatelessWidget {
},
child: SvgPicture.asset(
'assets/images/git.svg',
width: 32.0,
height: 32.0,
width: ConstantDimensions.widthSmall_Medium * 2,
height: ConstantDimensions.heightSmall_Medium * 2,
color: Theme.of(context).brightness == Brightness.dark
? Colors.white
: Colors.black,
),
),
const SizedBox(height: 16.0),
const SizedBox(height: ConstantDimensions.heightSmall_Medium),
const Text(
'Connect:',
style: TextStyle(
Expand All @@ -89,48 +91,48 @@ class AboutPage extends StatelessWidget {
},
child: SvgPicture.asset(
'assets/images/github.svg',
width: 32.0,
height: 32.0,
width: ConstantDimensions.widthSmall_Medium * 2,
height: ConstantDimensions.heightSmall_Medium * 2,
color: Theme.of(context).brightness == Brightness.dark
? Colors.white
: Colors.black,
),
),
const SizedBox(width: 16.0),
const SizedBox(width: ConstantDimensions.widthSmall_Medium),
GestureDetector(
onTap: () {
_launchURL(context, "mailto:[email protected]");
},
child: SvgPicture.asset(
'assets/images/email.svg',
width: 32.0,
height: 32.0,
width: ConstantDimensions.widthSmall_Medium * 2,
height: ConstantDimensions.heightSmall_Medium * 2,
color: Theme.of(context).brightness == Brightness.dark
? Colors.white
: Colors.black ,
),
),
const SizedBox(width: 16.0),
const SizedBox(width: ConstantDimensions.widthSmall_Medium),
GestureDetector(
onTap: () {
_launchURL(
context, "https://linkedin.com/in/sapatevaibhav");
},
child: SvgPicture.asset(
'assets/images/linkedin.svg',
width: 32.0,
height: 32.0,
width: ConstantDimensions.widthSmall_Medium * 2,
height: ConstantDimensions.heightSmall_Medium * 2,
),
),
const SizedBox(width: 16.0),
const SizedBox(width: ConstantDimensions.widthSmall_Medium),
GestureDetector(
onTap: () {
_launchURL(context, "https://instagram.com/v.d.r.sapate");
},
child: SvgPicture.asset(
'assets/images/instagram.svg',
width: 32.0,
height: 32.0,
width: ConstantDimensions.widthSmall_Medium * 2,
height: ConstantDimensions.heightSmall_Medium * 2,
color: Theme.of(context).brightness == Brightness.dark
? Colors.white
: Colors.black,
Expand Down
5 changes: 4 additions & 1 deletion lib/pages/explore.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:learn/utils/constants.dart';

import '../utils/const_dimensions.dart';

// Explore Page
class ExplorePage extends StatelessWidget {
const ExplorePage({super.key});
Expand Down Expand Up @@ -34,7 +36,7 @@ class ExplorePage extends StatelessWidget {
child: Container(
margin: const EdgeInsets.symmetric(
horizontal: 24, vertical: 12),
height: 200,
height: ConstantDimensions.heightExtraLarge * 4,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16),
boxShadow: [
Expand Down Expand Up @@ -110,6 +112,7 @@ class ExplorePage extends StatelessWidget {
childCount: AppConstants.modules.length,
),
),

// GestureDetector(
// onTap: () {
// Navigator.pushNamed(context, '/quiz');
Expand Down
10 changes: 6 additions & 4 deletions lib/pages/explore/explore.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:learn/utils/constants.dart';

import '../../utils/const_dimensions.dart';

// Explore Page
class ExplorePage extends StatelessWidget {
const ExplorePage({super.key});
Expand Down Expand Up @@ -43,12 +45,12 @@ class ExplorePage extends StatelessWidget {
child: Row(
children: [
SizedBox(
width: 50,
height: 50,
width: ConstantDimensions.widthExtraLarge,
height: ConstantDimensions.heightExtraLarge,
child:
SvgPicture.asset('assets/explore/notebook.svg'),
),
const SizedBox(width: 28.0),
const SizedBox(width: ConstantDimensions.widthMedium_Large),
const Text(
'Quiz',
style: TextStyle(
Expand Down Expand Up @@ -76,7 +78,7 @@ class ExplorePage extends StatelessWidget {
child: Container(
margin: const EdgeInsets.symmetric(
horizontal: 24, vertical: 12),
height: 200,
height: ConstantDimensions.heightExtraLarge * 4,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16),
boxShadow: [
Expand Down
18 changes: 10 additions & 8 deletions lib/pages/explore/quiz.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:learn/utils/constants.dart';

import '../../utils/const_dimensions.dart';

class QuizQuestion {
final String question;
final List<String> options;
Expand Down Expand Up @@ -92,7 +94,7 @@ class _QuizPageState extends State<QuizPage> {
fontSize: 24, fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
),
const SizedBox(height: 20),
const SizedBox(height: ConstantDimensions.heightMedium),
ElevatedButton(
onPressed: () {
Navigator.of(context).pop();
Expand All @@ -109,12 +111,12 @@ class _QuizPageState extends State<QuizPage> {
style: const TextStyle(
fontSize: 22, fontWeight: FontWeight.bold),
),
const SizedBox(height: 20),
const SizedBox(height: ConstantDimensions.heightMedium),
Text(
_questions[_currentQuestionIndex].question,
style: const TextStyle(fontSize: 18),
),
const SizedBox(height: 20),
const SizedBox(height: ConstantDimensions.heightMedium),
Column(
children: List.generate(
_questions[_currentQuestionIndex].options.length,
Expand All @@ -131,12 +133,12 @@ class _QuizPageState extends State<QuizPage> {
child: Row(
children: [
SizedBox(
width: 30,
height: 30,
width: ConstantDimensions.widthLarge,
height: ConstantDimensions.heightLarge,
child:
SvgPicture.asset('assets/explore/dot.svg'),
),
const SizedBox(width: 12.0),
const SizedBox(width: ConstantDimensions.heightExtraSmall * 2),
Expanded(
child: Text(
_questions[_currentQuestionIndex]
Expand All @@ -150,7 +152,7 @@ class _QuizPageState extends State<QuizPage> {
),
),
),
const SizedBox(height: 20),
const SizedBox(height: ConstantDimensions.heightMedium),
if (_feedbackMessage.isNotEmpty)
Container(
padding: const EdgeInsets.all(12.0),
Expand All @@ -168,7 +170,7 @@ class _QuizPageState extends State<QuizPage> {
),
),
),
const SizedBox(height: 20),
const SizedBox(height: ConstantDimensions.heightMedium),
if (_answered && !_quizCompleted)
ElevatedButton(
onPressed: _nextQuestion,
Expand Down
14 changes: 8 additions & 6 deletions lib/pages/fruits.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import 'package:flutter_tts/flutter_tts.dart';
import 'package:just_audio/just_audio.dart';
import 'package:learn/utils/constants.dart';

import '../utils/const_dimensions.dart';

class Fruit {
final String name;
final String svgAsset;
Expand Down Expand Up @@ -66,8 +68,8 @@ class _FruitsPageState extends State<FruitsPage> {
GestureDetector(
onTap: _navigateToNextBird,
child: Container(
width: 375,
height: 375,
width: ConstantDimensions.exceptions[1],
height: ConstantDimensions.exceptions[1],
decoration: BoxDecoration(
border: Border.all(color: Colors.black),
borderRadius: BorderRadius.circular(8.0),
Expand All @@ -77,16 +79,16 @@ class _FruitsPageState extends State<FruitsPage> {
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width: 350,
height: 350,
width: ConstantDimensions.widthExtraLarge * 7,
height: ConstantDimensions.heightExtraLarge * 7,
child: SvgPicture.asset(
AppConstants.Fruits[_currentIndex].svgAsset),
),
],
),
),
),
const SizedBox(height: 20),
const SizedBox(height: ConstantDimensions.heightMedium),
IconButton.outlined(
onPressed: () {
readName(
Expand All @@ -103,7 +105,7 @@ class _FruitsPageState extends State<FruitsPage> {
fontFamily: 'Comic',
),
),
const SizedBox(height: 20),
const SizedBox(height: ConstantDimensions.heightMedium),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Expand Down
27 changes: 19 additions & 8 deletions lib/pages/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:learn/main.dart';
import 'package:learn/utils/assets_path.dart';
import 'package:learn/utils/const_dimensions.dart';

import '../utils/routes.dart';
import '../widgets/drawer.dart';
Expand Down Expand Up @@ -79,7 +80,7 @@ class _MyHomePageState extends State<MyHomePage> {
index: 0,
),
const SizedBox(
height: 20,
height: ConstantDimensions.heightMedium,
),
categoryCard(
context: context,
Expand All @@ -90,7 +91,7 @@ class _MyHomePageState extends State<MyHomePage> {
index: 1,
),
const SizedBox(
height: 20,
height: ConstantDimensions.heightMedium,
),
categoryCard(
context: context,
Expand All @@ -101,7 +102,9 @@ class _MyHomePageState extends State<MyHomePage> {
route: AllRoutes.partsRoute,
index: 2,
),
const SizedBox(height: 20),
const SizedBox(
height: ConstantDimensions.heightMedium,
),
categoryCard(
context: context,
title: "BIRDS",
Expand All @@ -110,7 +113,9 @@ class _MyHomePageState extends State<MyHomePage> {
route: AllRoutes.birdsRoute,
index: 3,
),
const SizedBox(height: 20),
const SizedBox(
height: ConstantDimensions.heightMedium,
),
categoryCard(
context: context,
title: "COLOURS",
Expand All @@ -119,7 +124,9 @@ class _MyHomePageState extends State<MyHomePage> {
route: AllRoutes.colourRoute,
index: 4,
),
const SizedBox(height: 20),
const SizedBox(
height: ConstantDimensions.heightMedium,
),
categoryCard(
context: context,
title: "FLOWERS",
Expand All @@ -128,7 +135,9 @@ class _MyHomePageState extends State<MyHomePage> {
route: AllRoutes.flowerRoute,
index: 5,
),
const SizedBox(height: 20),
const SizedBox(
height: ConstantDimensions.heightMedium,
),
categoryCard(
context: context,
title: "FRUITS & VEGETABLES",
Expand Down Expand Up @@ -169,7 +178,9 @@ class _MyHomePageState extends State<MyHomePage> {
child: AnimatedContainer(
duration: const Duration(milliseconds: 300),
curve: Curves.easeInOut,
height: _isImageClicked[index] ? 325 : 350,
height: _isImageClicked[index]
? ConstantDimensions.heightSmallImage
: ConstantDimensions.heightBigImage,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
border: Border.all(color: Colors.black, width: 2),
Expand All @@ -188,7 +199,7 @@ class _MyHomePageState extends State<MyHomePage> {
),
),
),
const SizedBox(height: 20),
const SizedBox(height: ConstantDimensions.heightMedium),
Text(
title,
style: const TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
Expand Down
Loading

0 comments on commit d85b116

Please sign in to comment.