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
113 changes: 113 additions & 0 deletions lib/add_book_page/add_book_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
//import 'package:book_store_app/bookmodel.dart';
import 'package:book_store_app/add_book_page/mytextfield2.dart';
import 'package:book_store_app/bookmodel.dart';
import 'package:flutter/material.dart';

import 'app_bar2.dart';

class AddBook extends StatefulWidget {
const AddBook({
Key? key,
}) : super(key: key);

@override
State<AddBook> createState() => _AddBookState();
}

class _AddBookState extends State<AddBook> {
final book_name = TextEditingController();
final author_name = TextEditingController();
final price = TextEditingController();
final description = TextEditingController();
final image_link = TextEditingController();

@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
backgroundColor: Color.fromARGB(255, 245, 245, 245),
body: Padding(
padding: const EdgeInsets.all(20),
child: Column(
children: [
MyAppBar2(),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 15),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Padding(
padding: EdgeInsets.only(bottom: 20),
child: Text(
'Add Book',
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
),
MyTextField2(
hint: 'Book Name..',
maxlines: 1,
mycontroller: book_name,
),
MyTextField2(
hint: 'Author Name..',
maxlines: 1,
mycontroller: author_name,
),
MyTextField2(
hint: 'Book Price..',
maxlines: 1,
mycontroller: price,
),
MyTextField2(
hint: 'Image Link..',
maxlines: 1,
mycontroller: image_link,
),
MyTextField2(
hint: 'Book Description..',
maxlines: 5,
mycontroller: description,
),
TextButton(
onPressed: () {
Book book = Book(
book_name.text,
author_name.text,
description.text,
price.text,
image_link.text,
);
Book.books.add(book);
},
child: Container(
width: 335,
height: 60,
margin: EdgeInsets.symmetric(vertical: 20),
padding: EdgeInsets.all(15),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: Colors.black),
child: const Text(
'Add',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 18,
color: Colors.white,
fontWeight: FontWeight.bold),
),
),
)
],
),
)
],
),
)),
);
}
}
30 changes: 30 additions & 0 deletions lib/add_book_page/app_bar2.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import 'package:flutter/material.dart';

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

@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: Icon(Icons.arrow_back_ios, size: 24, color: Colors.black),
),
//Expanded(child: SizedBox()),
TextButton(
onPressed: () {},
child: Icon(Icons.more_vert, size: 26, color: Colors.black))
],
),
);
}
}
48 changes: 48 additions & 0 deletions lib/add_book_page/mytextfield2.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class MyTextField2 extends StatefulWidget {
const MyTextField2({
Key? key,
required this.hint,
required this.maxlines,
required this.mycontroller,
}) : super(key: key);
final String hint;
final int maxlines;
final TextEditingController mycontroller;

@override
State<MyTextField2> createState() => _MyTextField2State();
}

class _MyTextField2State extends State<MyTextField2> {
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 15),
child: TextField(
controller: widget.mycontroller,
onSubmitted: (x) {
widget.mycontroller.text = x;
setState(() {});
},
style: const TextStyle(fontSize: 20),
maxLines: widget.maxlines,
decoration: InputDecoration(
filled: true,
fillColor: Colors.white,
hintText: widget.hint,
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(20),
borderSide: BorderSide.none,
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(20),
borderSide: BorderSide.none,
),
),
),
);
}
}
45 changes: 45 additions & 0 deletions lib/book_details/MyButtons.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import 'package:flutter/material.dart';

class MyButton extends StatelessWidget {
const MyButton({
Key? key,
required this.icon,
required this.text,
}) : super(key: key);
final IconData icon;
final String text;
@override
Widget build(BuildContext context) {
return Container(
width: 154,
height: 40,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15), color: Colors.white),
child: Align(
alignment: Alignment.center,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
icon,
size: 24,
color: Colors.black,
),
SizedBox(
width: 8,
),
Text(
text,
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.black),
)
],
),
),
);
}
}
/*
*/
79 changes: 79 additions & 0 deletions lib/book_details/book_details.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import 'package:book_store_app/bookmodel.dart';
import 'package:flutter/material.dart';

class MyBookDetails extends StatelessWidget {
const MyBookDetails({
Key? key,
required this.book,
}) : super(key: key);

final Book book;

@override
Widget build(BuildContext context) {
return Expanded(
flex: 3,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.only(bottom: 10),
child: Text(
book.book_name,
style: const TextStyle(
fontSize: 26,
color: Colors.black,
fontWeight: FontWeight.bold,
),
),
),
Padding(
padding: const EdgeInsets.only(bottom: 10),
child: Text(
book.author,
style: const TextStyle(
fontSize: 16,
color: Colors.grey,
fontWeight: FontWeight.normal,
),
),
),
Padding(
padding: const EdgeInsets.only(bottom: 10),
child: Row(mainAxisAlignment: MainAxisAlignment.center, children: [
for (var i = 0; i < 4; i++)
const Padding(
padding: EdgeInsets.only(right: 2),
child: Icon(Icons.star, size: 16, color: Colors.orange),
),
const Icon(Icons.star, size: 16, color: Colors.grey),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 5),
child: Text(
'4.0/5.0',
style: TextStyle(
fontSize: 16,
color: Colors.black,
fontWeight: FontWeight.bold,
),
),
)
]),
),
Padding(
padding: const EdgeInsets.only(bottom: 10),
child: Text(
book.description,
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 16,
color: Colors.grey,
fontWeight: FontWeight.normal,
),
),
),
],
),
);
}
}
69 changes: 69 additions & 0 deletions lib/book_details/book_details_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import 'package:book_store_app/book_details/MyButtons.dart';
import 'package:book_store_app/book_details/book_details.dart';
import 'package:book_store_app/book_details/book_image.dart';
import 'package:book_store_app/bookmodel.dart';
import 'package:flutter/material.dart';

import '../add_book_page/app_bar2.dart';

class BookDetails extends StatelessWidget {
const BookDetails({Key? key, required this.book}) : super(key: key);

final Book book;

@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
backgroundColor: Color.fromARGB(255, 245, 245, 245),
body: Padding(
padding: const EdgeInsets.all(20),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
MyAppBar2(),
MyBookImage(book: book),
MyBookDetails(book: book),
Stack(children: [
Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center,
children: const [
MyButton(icon: Icons.menu_outlined, text: 'Preview'),
MyButton(icon: Icons.comment_outlined, text: 'Reviews')
],
),
TextButton(
onPressed: () {
Book.cart_books.add(book);
},
child: Container(
width: 335,
height: 60,
margin: EdgeInsets.symmetric(vertical: 20),
padding: EdgeInsets.all(15),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: Colors.black),
child: Text(
'Buy Now for ${book.price}',
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 18,
color: Colors.white,
fontWeight: FontWeight.bold),
),
),
)
],
)
])
],
),
),
),
);
}
}
Loading