Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions assets/images/icons/add.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/images/icons/cart.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/images/icons/home.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions assets/images/icons/preview.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/images/icons/reviews.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/images/icons/search.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions lib/bindings/dashboard.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import 'package:book_store_app/controllers/add_controller.dart';
import 'package:book_store_app/controllers/dashboard.dart';
import 'package:book_store_app/controllers/home_controller.dart';
import 'package:get/get.dart';

class DashboardBinding extends Bindings {
@override
void dependencies() {
Get.lazyPut<DashboardController>(() => DashboardController());
Get.lazyPut<HomeController>(() => HomeController());
Get.lazyPut<AddController>(() => AddController());
}
}
49 changes: 49 additions & 0 deletions lib/controllers/add_controller.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import 'package:book_store_app/data/data_source.dart';
import 'package:book_store_app/data/models/book.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class AddController extends GetxController {
late final GlobalKey<FormState> formKey;
late final TextEditingController nameController;
late final TextEditingController authorController;
late final TextEditingController priceController;
late final TextEditingController imageLinkController;
late final TextEditingController descriptionController;

@override
void onInit() {
super.onInit();
formKey = GlobalKey<FormState>();
nameController = TextEditingController();
authorController = TextEditingController();
priceController = TextEditingController();
imageLinkController = TextEditingController();
descriptionController = TextEditingController();
}

@override
void onClose() {
nameController.dispose();
authorController.dispose();
priceController.dispose();
imageLinkController.dispose();
descriptionController.dispose();
}

addBook() {
if (formKey.currentState!.validate()) {
DataSource.localBooks.add(
Book(
title: nameController.text,
author: authorController.text,
price: double.parse(priceController.text),
cover: imageLinkController.text,
description: descriptionController.text,
),
);
Get.closeCurrentSnackbar();
Get.snackbar('Book has been added successfully', '');
}
}
}
33 changes: 33 additions & 0 deletions lib/controllers/dashboard.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import 'package:book_store_app/views/addition/add_view.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class DashboardController extends GetxController {
var tabIndex = 0.obs;
late PageController pageController;

@override
void onInit() {
super.onInit();
pageController = PageController();
}

@override
void onClose() {
super.onClose();
pageController.dispose();
}

void changeTabIndex(int index) {
if (index != 2) {
tabIndex.value = index;
pageController.animateToPage(
index,
duration: const Duration(milliseconds: 300),
curve: Curves.linear,
);
} else {
Get.to(const AddView());
}
}
}
18 changes: 18 additions & 0 deletions lib/controllers/home_controller.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import 'package:get/get.dart';

class HomeController extends GetxController {
@override
void onInit() {
super.onInit();
}

@override
void onReady() {
super.onReady();
}

@override
void onClose() {
super.onClose();
}
}
29 changes: 29 additions & 0 deletions lib/core/theme.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import 'package:flutter/material.dart';

class AppTheme {
const AppTheme._();

// Light Theme Colors.
static Color lightBackgroundColor = const Color(0xffFDFDFD);
static Color lightPrimaryColor = const Color(0xff06070D);
static Color lightSecondaryColor = lightPrimaryColor.withOpacity(0.5);
static Color lightTertiaryColor = const Color(0xff9C9EA8);
static Color lightErrorColor = const Color(0xffe63946);

static final lightTheme = ThemeData(
brightness: Brightness.light,
backgroundColor: lightBackgroundColor,
errorColor: lightErrorColor,
primaryColor: lightPrimaryColor,
textTheme: _textTheme,
colorScheme: _colorScheme,
visualDensity: VisualDensity.adaptivePlatformDensity,
);

static final _textTheme = const TextTheme().copyWith();

static final _colorScheme = ColorScheme.light(
secondary: lightSecondaryColor,
tertiary: lightTertiaryColor,
);
}
83 changes: 83 additions & 0 deletions lib/data/data_source.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import 'package:get/get.dart';

import 'models/book.dart';

class DataSource {
static RxList<Book> localBooks = <Book>[
Book(
title: "A Tale of Two Cities",
author: "Charles Dickens",
cover: "https://api.lorem.space/image/book?w=150&h=220&hash=8B7BCDC1",
rate: 5.0,
price: 99.99,
description:
"Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero, written in 45 BC.",
),
Book(
title: "The Little Prince",
author: "Antoine de Saint-Exupéry",
cover: "https://api.lorem.space/image/book?w=150&h=220&hash=8B7BCDC2",
rate: 4.3,
price: 46.99,
description:
"Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero, written in 45 BC.",
),
Book(
title: "Harry Potter and the Philosopher's Stone",
author: "J.K.Rowling",
cover: "https://api.lorem.space/image/book?w=150&h=220&hash=8B7BCDC3",
rate: 3.0,
price: 64.99,
description:
"Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero, written in 45 BC.",
),
Book(
title: "Mockingjay",
author: "Suzanne Collins",
cover: "https://api.lorem.space/image/book?w=150&h=220&hash=8B7BCDC4",
rate: 4.0,
price: 52.99,
description:
"Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero, written in 45 BC.",
),
Book(
title: "Me Before You",
author: "Jojo Moyes",
cover: "https://api.lorem.space/image/book?w=150&h=220&hash=8B7BCDC5",
rate: 4.9,
price: 30.99,
description:
"Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero, written in 45 BC.",
),
Book(
title: "Harry Potter and the Philosopher's Stone",
author: "J.K.Rowling",
cover: "https://api.lorem.space/image/book?w=150&h=220&hash=8B7BCDC6",
rate: 3.0,
price: 64.99,
description:
"Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero, written in 45 BC.",
),
].obs;

static RxList<Book> cartItems = <Book>[
Book(
title: "Me Before You",
author: "Jojo Moyes",
cover: "https://api.lorem.space/image/book?w=150&h=220&hash=8B7BCDC5",
rate: 4.9,
price: 30.99,
description:
"Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero, written in 45 BC.",
),
Book(
title: "Harry Potter and the Philosopher's Stone",
author: "J.K.Rowling",
cover: "https://api.lorem.space/image/book?w=150&h=220&hash=8B7BCDC6",
rate: 3.0,
price: 64.99,
description:
"Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero, written in 45 BC.",
),
].obs;
}
17 changes: 17 additions & 0 deletions lib/data/models/book.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class Book {
String? title;
String? author;
String? cover;
String? description;
double? price;
double rate;

Book({
this.title,
this.author,
this.cover,
this.description,
this.price,
this.rate = 0.0,
});
}
15 changes: 9 additions & 6 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import 'package:book_store_app/core/theme.dart';
import 'package:book_store_app/routes/app_pages.dart';
import 'package:book_store_app/routes/app_routes.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

void main() {
runApp(const MyApp());
Expand All @@ -9,12 +13,11 @@ class MyApp extends StatelessWidget {

@override
Widget build(BuildContext context) {
return const MaterialApp(
home: Scaffold(
body: Center(
child: Text("Book Store App"),
),
),
return GetMaterialApp(
debugShowCheckedModeBanner: false,
theme: AppTheme.lightTheme,
initialRoute: AppRoutes.DASHBOARD,
getPages: AppPages.list,
);
}
}
14 changes: 14 additions & 0 deletions lib/routes/app_pages.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import 'package:book_store_app/bindings/dashboard.dart';
import 'package:book_store_app/routes/app_routes.dart';
import 'package:book_store_app/views/dashboard/dashboard_view.dart';
import 'package:get/get.dart';

class AppPages {
static var list = [
GetPage(
name: AppRoutes.DASHBOARD,
page: () => DashboardView(),
binding: DashboardBinding(),
),
];
}
3 changes: 3 additions & 0 deletions lib/routes/app_routes.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class AppRoutes {
static const String DASHBOARD = '/';
}
16 changes: 16 additions & 0 deletions lib/views/addition/add_view.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'widgets/body.dart';
import 'package:flutter/material.dart';

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

@override
Widget build(BuildContext context) {
return const SafeArea(
child: Scaffold(
resizeToAvoidBottomInset: true,
body: Body(),
),
);
}
}
Loading